13

I am trying to get Windows 7 sniping tool to run when I hit my PRINTSCREEN keyboard button with AUTOHOTKEY.

I have been unsuccessful so far though. Here is what I have for the AutoHotKey script.

I have tried this

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

and this

PRINTSCREEN::Run, SnippingTool.exe

and this

PRINTSCREEN::Run, SnippingTool

And all those give me an error that basically says it cannot find the file, however the file path seems to be correct, I can copy paste it into a window and it opens the snipping tool, any ideas why it will not work?


Here is the full code to my AHK file...

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

4 Answers 4

17

Are you running a 64-bit version of Windows 7 by any chance?

Windows 7 (as well as Vista I believe) implements what is called WoW64 Filesystem Redirection. If this is the case, you'll want to point AHK to the Sysnative directory:

PrintScreen::Run, "C:\Windows\Sysnative\SnippingTool.exe"
5

Use

PrintScreen::Run C:\Windows\explorer.exe C:\Windows\system32\SnippingTool.exe

This will correctly call the executable withing the boundaries of the WoW64 Filesystem Redirection

0
4

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

1
  • I used %A_WinDir% instead of %windir% ,with the #noEnv setting disabled.
    – jiggunjer
    Jan 15, 2016 at 6:00
1

Use

PrintScreen::Send #+s

Windows + Shift + S is the default short key on Windows

You can also alter your Windows configurations to get the same effect:
Go to "Ease of Access keyboard settings" and scroll down to "Print Screen shortcut" and toggle "Use PrtScn button to open screen snipping" setting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .