Windows-Snipping-Tool kann nicht automatisch mit AutoHotKey ausgeführt werden

6123
JasonDavis

Ich versuche, das Windows 7-Sniping-Tool zum Laufen zu bringen, wenn ich PRINTSCREENmit AUTOHOTKEY meine Tastaturtaste drücke.

Ich war bisher jedoch nicht erfolgreich. Folgendes habe ich für das AutoHotKey-Skript.

Ich habe es versucht

PRINTSCREEN::Run, c:\windows\system32\SnippingTool.exe 

und das

PRINTSCREEN::Run, SnippingTool.exe 

und das

PRINTSCREEN::Run, SnippingTool 

Und alle diese geben mir einen Fehler, der besagt, dass die Datei nicht gefunden werden kann. Der Dateipfad scheint jedoch korrekt zu sein. Ich kann ihn kopieren und in ein Fenster einfügen. Das Snipping-Tool wird geöffnet.


Hier ist der vollständige Code zu meiner AHK-Datei ...

; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win7 ; Author: Jason Davis <friendproject@> ; ; Script Function: ; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder) ;  #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.   /* PRINTSCREEN = Will run Windows 7 snipping tool */ PRINTSCREEN::Run, c:\windows\system32\SnippingTool.exe return 
13

3 Antworten auf die Frage

17
John T

Führen Sie zufällig eine 64-Bit-Version von Windows 7 aus?

Windows 7 (wie auch Vista glaube ich) implementiert die so genannte WoW64 Filesystem Redirection. In diesem Fall sollten Sie AHK auf das Sysnative-Verzeichnis verweisen:

PrintScreen :: Ausführen "C: \ Windows \ Sysnative \ SnippingTool.exe"
4
Steve

Benutzen

PrintScreen :: Führen Sie C: \ Windows \ explorer.exe C: \ Windows \ system32 \ SnippingTool.exe aus

Dadurch wird die ausführbare Datei korrekt innerhalb der Grenzen der WoW64-Dateisystemumleitung aufgerufen

4
jsbannis

You can determine if you need to call SnippingTool.exe from the Sysnative or the windows32 based on whether autohotkey is running as a Wow64 process or not.

PrintScreen::LaunchSnippingTool() ; Determines if we are running a 32 bit program (autohotkey) on 64 bit Windows IsWow64Process() { hProcess := DllCall("kernel32\GetCurrentProcess") ret := DllCall("kernel32\IsWow64Process", "UInt", hProcess, "UInt *", bIsWOW64) return ret & bIsWOW64 } ; Launch snipping tool using correct path based on 64 bit or 32 bit Windows LaunchSnippingTool() { if(IsWow64Process()) { Run, %windir%\Sysnative\SnippingTool.exe } else { Run, %windir%\system32\SnippingTool.exe } } 

More info and source for IsWow64Process here: http://www.autohotkey.com/community/viewtopic.php?t=22277

Ich habe "% A_WinDir%" anstelle von "% windir%" verwendet, wobei die Einstellung "# noEnv" deaktiviert war. jiggunjer vor 8 Jahren 0