I am heavy user of AHK with 2000+ lines of personal scripts/hotkeys along with around a dozen of library. My problem is AHK crash every few days/weeks. Sometime not from weeks, sometime twice in a day.
Since it happens very rarely, it's very hard for me to determine what cause it and fix the relevant code in my script. How can I determine what causes it?
Also is there any way to auto restart it whenever it crash? It happens very rarely so I won't mind if restart automatically itself.
How to find reason for crash every few weeks
Re: How to find reason for crash every few weeks
You can do second script which check for example every 1min if win exist, if not then run script.
Without any code we can only guess why it's crashing. Maybe lost connection to network drive which is required for your script, missing required file, maybe bad var. Who knows
Without any code we can only guess why it's crashing. Maybe lost connection to network drive which is required for your script, missing required file, maybe bad var. Who knows
Re: How to find reason for crash every few weeks
- In what way is it crashing? Does it show an error message? Does it 'forget' the hotkeys?
- You could set DetectHiddenWindows to On, and use a Loop, with WinWaitActive, and ahk_class AutoHotkey to identify which scripts are open. You could use PostMessage/WinClose to close or Process Close to force close a script.
- You could set DetectHiddenWindows to On, and use a Loop, with WinWaitActive, and ahk_class AutoHotkey to identify which scripts are open. You could use PostMessage/WinClose to close or Process Close to force close a script.
Code: Select all
q:: ;list AutoHotkey scripts
DetectHiddenWindows, On
WinGet, vWinList, List, ahk_class AutoHotkey
vOutput := ""
Loop, % vWinList
{
hWnd := vWinList%A_Index%
WinGetTitle, vWinTitle, % "ahk_id " hWnd
;WinGetClass, vWinClass, % "ahk_id " hWnd
;WinGet, vPID, PID, % "ahk_id " hWnd
vOutput .= hWnd " " vWinTitle "`r`n"
}
MsgBox, % vOutput
return
;link:
;list of AutoHotkey WM_COMMAND IDs (e.g. Reload/Edit/Suspend/ListVars on another script) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=7&t=27824
w:: ;close an AutoHotkey script
DetectHiddenWindows, On
SetTitleMatchMode, 2 ;Contains
vScriptName := "MyScript.ahk"
WinGet, hWnd, ID, % "\" vScriptName " - AutoHotkey v ahk_class AutoHotkey"
WinGet, vPID, PID, % "ahk_id " hWnd
;close
;ID_FILE_EXIT := 65405
PostMessage, 0x111, 65405,,, % "ahk_id " hWnd
;close (alternative)
;WinClose, % "ahk_id " hWnd
;force close
;Process, Close, % vPID
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How to find reason for crash every few weeks
and maybe helps to write to a logfile.
so you could later look at the last actions.
so you could later look at the last actions.
github>g_IntelliSense + next improvements + forum
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How to find reason for crash every few weeks
It's more than 2000 lines. I don't know what to even share. It happens very rarely so it's very hard to separete the code causing the issue.Ravenlord wrote:You can do second script which check for example every 1min if win exist, if not then run script.
Without any code we can only guess why it's crashing. Maybe lost connection to network drive which is required for your script, missing required file, maybe bad var. Who knows
Re: How to find reason for crash every few weeks
Is there some automated way to do it?SL5 wrote:and maybe helps to write to a logfile.
so you could later look at the last actions.
Re: How to find reason for crash every few weeks
jeeswg wrote:- In what way is it crashing? Does it show an error message? Does it 'forget' the hotkeys?
- You could set DetectHiddenWindows to On, and use a Loop, with WinWaitActive, and ahk_class AutoHotkey to identify which scripts are open. You could use PostMessage/WinClose to close or Process Close to force close a script.Code: Select all
q:: ;list AutoHotkey scripts DetectHiddenWindows, On WinGet, vWinList, List, ahk_class AutoHotkey vOutput := "" Loop, % vWinList { hWnd := vWinList%A_Index% WinGetTitle, vWinTitle, % "ahk_id " hWnd ;WinGetClass, vWinClass, % "ahk_id " hWnd ;WinGet, vPID, PID, % "ahk_id " hWnd vOutput .= hWnd " " vWinTitle "`r`n" } MsgBox, % vOutput return ;link: ;list of AutoHotkey WM_COMMAND IDs (e.g. Reload/Edit/Suspend/ListVars on another script) - AutoHotkey Community ;https://autohotkey.com/boards/viewtopic.php?f=7&t=27824 w:: ;close an AutoHotkey script DetectHiddenWindows, On SetTitleMatchMode, 2 ;Contains vScriptName := "MyScript.ahk" WinGet, hWnd, ID, % "\" vScriptName " - AutoHotkey v ahk_class AutoHotkey" WinGet, vPID, PID, % "ahk_id " hWnd ;close ;ID_FILE_EXIT := 65405 PostMessage, 0x111, 65405,,, % "ahk_id " hWnd ;close (alternative) ;WinClose, % "ahk_id " hWnd ;force close ;Process, Close, % vPID return
No! It just terminate itself without any message/warning whatsoever. Does it log crash somewhere?
Re: How to find reason for crash every few weeks
https://autohotkey.com/boards/viewtopic ... 22#p202322VarunAgw wrote:Is there some automated way to do it?SL5 wrote:and maybe helps to write to a logfile.
so you could later look at the last actions.
Last edited by SL5 on 24 Feb 2018, 03:23, edited 1 time in total.
github>g_IntelliSense + next improvements + forum
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How to find reason for crash every few weeks
Then it doesn't look like a crash. Imo it look's like error in your code and instead exiting your function, it's exiting a whole script sometimes.VarunAgw wrote:No! It just terminate itself without any message/warning whatsoever. Does it log crash somewhere?
If it's AHK program crash then it should be listed in system event log.
https://www.digitalmastersmag.com/magaz ... windows-8/ Example how to find it, If You don't know.
Re: How to find reason for crash every few weeks
- How do you know that it's crashing? Does the systray icon disappear? Does it no longer appear in Task Manager.
Taken from:
jeeswg's Explorer tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31755
To show the Command Line column in Task Manager:
if the Command Line column is not visible in the 'Processes' tab,
go to 'View, Select Columns...' and tick 'Command Line'.
- Some possibilities include: the use of Exit/ExitApp, a script with no hotkeys reaching the end, a Windows update causing a restart, the systray icon being hidden via the Menu command or for some unknown reason.
- You could try running the script in admin mode, maybe another window is closing it, and putting the script in admin mode might protect it. Someone mentioned such a problem once, although it hasn't happened to me personally.
Do Autohotkey scripts require running as administrator? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=41365
- To check that a script is working, you can add FileAppend in various places, and use A_Now or FormatTime to generate a datestamp.
- You could use a variation of my script to periodically list all windows on the system, in case there is a correlation between some window opening and your script closing.
Taken from:
jeeswg's Explorer tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31755
To show the Command Line column in Task Manager:
if the Command Line column is not visible in the 'Processes' tab,
go to 'View, Select Columns...' and tick 'Command Line'.
- Some possibilities include: the use of Exit/ExitApp, a script with no hotkeys reaching the end, a Windows update causing a restart, the systray icon being hidden via the Menu command or for some unknown reason.
- You could try running the script in admin mode, maybe another window is closing it, and putting the script in admin mode might protect it. Someone mentioned such a problem once, although it hasn't happened to me personally.
Do Autohotkey scripts require running as administrator? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=41365
- To check that a script is working, you can add FileAppend in various places, and use A_Now or FormatTime to generate a datestamp.
- You could use a variation of my script to periodically list all windows on the system, in case there is a correlation between some window opening and your script closing.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: No registered users and 11 guests