How to find reason for crash every few weeks

Report problems with documented functionality
VarunAgw
Posts: 19
Joined: 05 Jan 2016, 11:51
GitHub: VarunAgw

How to find reason for crash every few weeks

15 Feb 2018, 07:34

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.
Ravenlord
Posts: 10
Joined: 19 Jan 2018, 03:43

Re: How to find reason for crash every few weeks

15 Feb 2018, 08:22

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 :)
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to find reason for crash every few weeks

15 Feb 2018, 14:48

- 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] [Expand] [Download] GeSHi © Codebox Plus

User avatar
SL5
Posts: 269
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

Re: How to find reason for crash every few weeks

15 Feb 2018, 15:13

and maybe helps to write to a logfile.

so you could later look at the last actions.
VarunAgw
Posts: 19
Joined: 05 Jan 2016, 11:51
GitHub: VarunAgw

Re: How to find reason for crash every few weeks

17 Feb 2018, 20:06

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 :)


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.
VarunAgw
Posts: 19
Joined: 05 Jan 2016, 11:51
GitHub: VarunAgw

Re: How to find reason for crash every few weeks

17 Feb 2018, 20:06

SL5 wrote:and maybe helps to write to a logfile.

so you could later look at the last actions.


Is there some automated way to do it?
VarunAgw
Posts: 19
Joined: 05 Jan 2016, 11:51
GitHub: VarunAgw

Re: How to find reason for crash every few weeks

17 Feb 2018, 20:09

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] [Expand] [Download] GeSHi © Codebox Plus




No! It just terminate itself without any message/warning whatsoever. Does it log crash somewhere?
User avatar
SL5
Posts: 269
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

Re: How to find reason for crash every few weeks

17 Feb 2018, 23:08

VarunAgw wrote:
SL5 wrote:and maybe helps to write to a logfile.

so you could later look at the last actions.


Is there some automated way to do it?


https://autohotkey.com/boards/viewtopic ... 22#p202322
Last edited by SL5 on 24 Feb 2018, 03:23, edited 1 time in total.
Ravenlord
Posts: 10
Joined: 19 Jan 2018, 03:43

Re: How to find reason for crash every few weeks

18 Feb 2018, 04:47

VarunAgw wrote:No! It just terminate itself without any message/warning whatsoever. Does it log crash somewhere?


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.

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.
User avatar
jeeswg
Posts: 4509
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to find reason for crash every few weeks

19 Feb 2018, 01:35

- 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.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest