Can't seem to send Function key in my script.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ethanross1a
Posts: 16
Joined: 18 Sep 2019, 18:36

Can't seem to send Function key in my script.

21 Sep 2019, 00:44

Code: Select all

setTitleMatchMode,2

F1::
if(WinActive("ahk_exe SLDWORKS.exe"))
        Send {f1}
else
    SendInput ^+{tab}
return

F2::
if(WinActive("ahk_exe SLDWORKS.exe") or WinActive("ahk_exe explorer.exe"))
        Send {f2}
else
    SendInput ^{tab}
return
If I don't used the {}, it seems to send the literal F1 and F2 properly
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: Can't seem to send Function key in my script.

21 Sep 2019, 01:34

Use the $ modifier - otherwise F1 (and F2) will trigger itself.

Code: Select all

$F1::
; [...]
$F2::
; [...]
ethanross1a
Posts: 16
Joined: 18 Sep 2019, 18:36

Re: Can't seem to send Function key in my script.

21 Sep 2019, 02:24

Thanks so much! The code is now: for anyone else who stumbles on this.

Code: Select all

setTitleMatchMode,2

$F1::
if(WinActive("ahk_exe SLDWORKS.exe"))
        Sendinput {f1}
else
    SendInput ^+{tab}
return

$F2::
if(WinActive("ahk_exe SLDWORKS.exe") or WinActive("ahk_exe explorer.exe"))
        Sendinput {f2}
else
    SendInput ^{tab}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: wpulford and 420 guests