无法使Windows截图工具与AutoHotKey自动运行


13

我试图PRINTSCREEN用AUTOHOTKEY 击键盘按钮时运行Windows 7狙击工具。

到目前为止,我一直没有成功。这是我拥有的AutoHotKey脚本。

我已经试过了

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

还有这个

PRINTSCREEN::Run, SnippingTool.exe

还有这个

PRINTSCREEN::Run, SnippingTool

所有这些给了我一个错误,基本上说它找不到文件,但是文件路径似乎是正确的,我可以将其复制粘贴到窗口中并打开截图工具,为什么它不起作用?


这是我的AHK文件的完整代码...

;
; 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

Answers:


17

您是否正在运行Windows 7的64位版本?

Windows 7(以及我相信的Vista)实现了所谓的WoW64文件系统重定向。在这种情况下,您需要将AHK指向Sysnative目录:

PrintScreen :: Run,“ C:\ Windows \ Sysnative \ SnippingTool.exe”

4

采用

PrintScreen ::运行C:\ Windows \ explorer.exe C:\ Windows \ system32 \ SnippingTool.exe

这将在WoW64文件系统重定向的边界范围内正确调用可执行文件


4

您可以根据autohotkey是否作为Wow64进程运行,来确定是否需要从Sysnative或Windows32调用SnippingTool.exe。

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
    }
}

IsWow64Process的更多信息和来源,请访问:http ://www.autohotkey.com/community/viewtopic.php?t=22277


我用%A_WinDir%代替%windir%#noEnv禁用了设置。
jiggunjer '16
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.