Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 this error when I hit the PRINTSCREEN button... alt text

It basicly 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
share|improve this question
add comment

3 Answers

up vote 10 down vote accepted

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"
share|improve this answer
add comment

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

share|improve this answer
add comment

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

share|improve this answer
    
thanks mate.... –  tumchaaditya Sep 12 '12 at 3:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.