Sometimes A_ScriptHwnd will be less than 0?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
viv
Posts: 219
Joined: 09 Dec 2020, 17:48

Sometimes A_ScriptHwnd will be less than 0?

Post by viv » 24 Apr 2024, 21:26

Please keep the script editing status during testing
Avoid being unable to exit without errors
Delete ; to exit



Just tested 2.0.13, and it's still the same!

Code: Select all

#SingleInstance Force
#NoTrayIcon

; ExitApp()

index := 0
if A_Args.Length && IsInteger(A_Args[1])
    index := A_Args[1] + 1

if A_ScriptHwnd < 0
{
    DetectHiddenWindows(True)
    MsgBox(A_ScriptHwnd "@" WinExist(A_ScriptFullPath) "@" index "`n" A_AhkVersion)
    ExitApp()
}
else
    Run(A_ScriptFullPath " " index)
2024_04_25 @ 10_19_38 (642x338).JPEG
(30.88 KiB) Downloaded 52 times

User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: Sometimes A_ScriptHwnd will be less than 0?

Post by mikeyww » 24 Apr 2024, 22:29

Hello,

I ran this for a while and never saw a MsgBox.

viv
Posts: 219
Joined: 09 Dec 2020, 17:48

Re: Sometimes A_ScriptHwnd will be less than 0?

Post by viv » 25 Apr 2024, 05:38

I also cannot test out the error after restart the computer

But it does happen occasionally

I use to pass information in different scripts via WM_COPYDATA(need main hwnd)
Occasionally, when something goes wrong, it's like a screenshot,less than 0


Post Reply

Return to “Ask for Help (v2)”