简体   繁体   中英

How do I determine if a button is held before an AutoHotkey script is launched?

I have a script with two subroutines: A and B . I want A to run if I launch the .ahk script regularly (by double clicking its icon). and I want B to run if I launch the .ahk script while a button (say, Ctrl) is held down (while double clicking the icon). Is this possible?

It's not possible to detect if a key was pressed before the script started, but you can use GetKeyState to check if a key is in the "pressed" state when the script starts:

if GetKeyState("Ctrl")
    MsgBox Holding Ctrl
else
    MsgBox Not holding Ctrl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM