Page 1 of 1

Potential bug AHK 1.1.33.10 script runs twice despite only being initiated once

Posted: 17 Oct 2021, 13:16
by penalvch
Hi all,

I'm coming into a weird scenario using AHK 1.1.33.10. What is expected to happen is when I "Run As Administrator" the attached text.ahk script it runs one instance of the script.

What happens instead is it somehow runs two instances simultaneously. I'm not accidentally clicking it open twice. Please see following youtube video:
https://www.youtube.com/watch?v=Hn5Eizh6byk

Got any idea on wth is going on here?

Re: Potential bug AHK 1.1.33.10 script runs twice despite only being initiated once

Posted: 17 Oct 2021, 14:52
by mikeyww
This is a test script that runs as admin.

Code: Select all

If !A_IsAdmin && !RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)") {
 Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
 ExitApp
} Else CoordMode, Mouse

#IfWinActive ahk_exe test.exe
F3::Send x

#IfWinActive ahk_exe test2.exe
F3::Send y
#IfWinActive
If it works, expand it iteratively, testing carefully along the way.

Line 30 in your script will yield unexpected results. To prove it, you can run the following demo.

Code: Select all

If GetKeyState("LAlt", "P")
 F2::Send z
Read about #If in the documentation.

Re: Potential bug AHK 1.1.33.10 script runs twice despite only being initiated once

Posted: 20 Oct 2021, 00:55
by penalvch
mikeyww, thanks for the quick response and suggestions! I'll tweak around with it and report back if it doesn't work out. Thanks!