Portwolf wrote: ↑26 Nov 2018, 06:42
Hello.
So, i've built a website checking tool, and it works nicelly.. Thing is, it just dies after some hours.
That just doesn't work as you might imagine, if the objective is to keep an eye on things.
And by "dies" i mean i've seen it go down, it just disapears while it is working and closes itself.
Can someone please take a look and see what might be causing this?
I've been banging my head for days now..
Taking a quick look, I noticed that a number of your subroutines/labels don't have a "return" after them. This can cause unexpected results, because AutoHotkey will keep going down to the next label, after the next, and processing commands until it hits a "return", unless you have it in a loop or waiting for input or a result.
https://autohotkey.com/docs/commands/Return.htm
In this pseudo code example, such a script design can have all kinds of problems. You are telling AutoHotkey to jump to a label 3, but it will keep executing until it hits the "return" at label 4. To make it worse, your gosubs or goto can have the code jumping all over, but the program will execute other unwanted labels or subroutines because there is no "return" or code logic to stop it.
Code: Select all
code
Label 1:
code
gosub, Label 3
Label 2:
code
Label 3:
code
Label 4:
code
return
You might want to organize your code where every label has a return, unless you want it to keep running downwards or exit the program (like GuiClose and ExitApp). If you want sections of code to execute in sequence, one after the other, then you might want to organize them under the same subroutine.
When Label 1 one jumps to Label 3, after Label 3 is done, it will then "jump back" and return to Label 1 or from the point where it started the jump from. Unless of course, you specifically want the program to
blend labels together by letting it execute downwards to the next label or group of labels. Making sure subroutines are separate from each other, is what makes gosub much safer to use. And it stops unexpected results.
Code: Select all
code
Label 1:
code
gosub, Label 3
return
Label 2:
code
return
Label 3:
code
return
Label 4:
code
return
GuiClose:
ExitApp