Do X if Enter is pressed in a specific window
Posted: 10 Jun 2023, 14:40
Among several other hotkeys, I want to MouseMove if the Enter key is pressed within a specific window (so I used #HotIf already to check if the window is active, and AFAIK we can't nest #HotIf blocks). So, how do I do this?
I already tried, for example:
It didn't work. And I've already been told that we can't use if contextually and we have to use #HotIf instead, despite me seeing examples on the GetKeyState help page that suggest otherwise, after having added the braces to the if statement as per the v2 If help page.
Also, what is a correct example of using if in v2 currently?
By the way, I also tried:
That also didn't work. In fact, the mouse cursor just moved downward immediately upon running the script, despite me not being in Notepad and Enter having not been pressed.
I already tried, for example:
Code: Select all
#HotIf WinActive("ahk_exe Notepad.exe")
if GetKeyState("Enter", "P")
{
MouseMove 0, 100, 50, "R"
}
#HotIf
Also, what is a correct example of using if in v2 currently?
By the way, I also tried:
Code: Select all
#HotIf WinActive("ahk_exe Notepad.exe") && GetKeyState("Enter", "P")
MouseMove 0, 100, 50, "R"
#HotIf