 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
me10c
Joined: 22 Nov 2008 Posts: 44
|
Posted: Mon Jun 22, 2009 5:39 am Post subject: The Script Crashes - I THINK ITS FIXED |
|
|
| Code: |
Random(min,max) {
Random, res, % min, % max
Return res
}
#4::
SetMouseDelay, % Random(50,65) ;#4, loop4, F4, FishBCheck, F7, repeat loop4 >
WinGetPos,,, x, y, A
GoSub, loop4
Return
Loop4:
Sleep, % Random(50,100)
SetMouseDelay, % Random(50,65)
GoSub, prelogout
GoSub, Huml
GoSub, F4
Return
F4:
Sleep, % Random(200,400)
SetKeyDelay, 4, 6,
Send {F4}
GoSub, prelogout
PixelSearch, Px, Py, 895, 320, 920, 345, 0x202876, 3, Fast
if ErrorLevel
GoSub, F4
else
Sleep, % Random(1500,1700)
GoSub FishBCheck
Return
FishBCheck:
Sleep, % Random(200,300)
GoSub, prelogout
PixelSearch, Px, Py, 836, 400, 852, 412, 0x7F6663, 3, Fast
if ErrorLevel
GoSub, FishBCheck
else
GoSub, I21L2
GoSub, F7
Return
F7:
Sleep, % Random(200,400)
GoSub, prelogout
SetKeyDelay, 4, 6,
Send {F7}
PixelSearch, Px, Py, 995, 320, 1020, 345, 0x1E2875, 3, Fast
if ErrorLevel
GoSub, F7
else
GoSub, loop4
Return
PreLogout:
PixelSearch, Px, Py, 995, 320, 1020, 345, 0x337095, 3, Fast
if ErrorLevel
GoSub, logout
else
sleep, 1
Return
Logout:
MouseClick, Left , % Random(1010,1020), % Random(150,165)
Sleep, % Random(500,2000)
MouseClick, Left , % Random(840,970), % Random(510,535)
Sleep, % Random(60000,120000)
Return
HumL:
MouseClick, Left , % Random(826,841), % Random(396,414)
Return
I21L2:
Sleep, % Random(150,250)
MouseClick, Left , % Random(836,852), % Random(400,412)
Return
|
Explanation what the script does.
Its a runescape humidify script. In short - it clicks on the 1st spot, after which it clicks F4 until the colour1 changes. It waits until the colour2 changes again and it clicks on the 2nd spot. It clicks F7 until the colour3 changes. During the script if colour4 changes it logs off the acc. and shuts down the pc.
Now the strange thing is - it runs for ~1000 casts of humidify (~ 1 hour and 10 minutes) after which the script/autohotkey crashes ... any idea why does this happen ?
Last edited by me10c on Mon Jun 22, 2009 8:19 pm; edited 3 times in total |
|
| Back to top |
|
 |
BF2 Player
Joined: 27 Mar 2009 Posts: 71
|
Posted: Mon Jun 22, 2009 6:57 am Post subject: |
|
|
Are you shure it crashes? or just ends.
Try putting #Persistent at the top of you script. |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Jun 22, 2009 7:49 am Post subject: |
|
|
| BF2 Player wrote: | Are you shure it crashes? or just ends.
Try putting #Persistent at the top of you script. |
Incorrect! The script is already persistent due to the presence of a hotkey.
| Quote: | | A script that is not persistent and that lacks hotkeys, hotstrings, OnMessage, and GUI will terminate after the auto-execute section has completed. Otherwise, it will stay running in an idle state, responding to events such as hotkeys, hotstrings, GUI events, custom menu items, and timers. |
|
|
| Back to top |
|
 |
me10c
Joined: 22 Nov 2008 Posts: 44
|
Posted: Mon Jun 22, 2009 9:33 am Post subject: |
|
|
it doesnt finishes for sure .. its kind of a loop as you can see.
it crashes and I am sure about it "windows have found a problem and the program needs to be closed" or something like that (I am too lazy to check the acutal message but you get the idea). |
|
| Back to top |
|
 |
What? Guest
|
Posted: Mon Jun 22, 2009 1:57 pm Post subject: |
|
|
| Quote: | | I am too lazy to check the acutal message |
i am to lazy to actually help you. |
|
| Back to top |
|
 |
me10c
Joined: 22 Nov 2008 Posts: 44
|
Posted: Mon Jun 22, 2009 2:14 pm Post subject: |
|
|
Yeaaah I am sure most of the ppl actually got the idea which message I was talking about, but then again I will post the exact message tomarow (it will take some time to get it again)
I dont see where is the hard part about "Windows has found a problem with this file" and AHK has crushed ... but anyways ... yeah tnx |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Mon Jun 22, 2009 2:49 pm Post subject: |
|
|
| me10c wrote: | | Yeaaah I am sure most of the ppl actually got the idea which message I was talking about... |
No offense, but it doesn't matter if we've "got the idea," the error details supplied when the crash occurs are more important than anyone here's general idea about the error message. That aside, you also didn't post your entire code; even if those code portions don't appear to be relevant you should post them anyway since you may have a problem with those that someone here can identify.
FYI, instead of repeatedly using the Random command in your script you can wrap the command into a function and trim a bit of your code:
| Code: | Random(min,max) {
Random, res, % min, % max
return res
}
#4:: ;#4, loop4, F4, FishBCheck, F7, repeat loop4 >
SetMouseDelay, % Random(50,65) ; forces expression mode so the function can be processed
WinGetPos,,, x, y, A
GoSub, loop4
return
loop4:
Sleep, % Random(50,100)
SetMouseDelay, % Random(50,65)
PixelSearch, Px, Py, 995, 320, 1020, 345, 0x337095, 3, Fast
if ErrorLevel
GoSub, logout
else
GoSub, Huml
GoSub, F4
return
F4:
SetKeyDelay, 2, 8
Sleep, % Random(200,400)
Send {F4}
PixelSearch, Px, Py, 995, 320, 1020, 345, 0x337095, 3, Fast
if ErrorLevel
GoSub, logout
else
sleep, 1
PixelSearch, Px, Py, 895, 320, 920, 345, 0x202876, 3, Fast
if ErrorLevel
GoSub, F4
else
sleep, 1500
GoSub FishBCheck
return
FishBCheck:
Sleep, % Random(200,300)
PixelSearch, Px, Py, 995, 320, 1020, 345, 0x337095, 3, Fast
if ErrorLevel
GoSub, logout
else
sleep, 1
PixelSearch, Px, Py, 836, 400, 852, 412, 0x7F6663, 3, Fast
if ErrorLevel
GoSub, FishBCheck
else
GoSub, i21l2
GoSub, F7
return
F7:
Random, Rand, 200, 400
Sleep, %Rand%
SetKeyDelay, 2, 8,
Send {F7}
PixelSearch, Px, Py, 995, 320, 1020, 345, 0x1E2875, 3, Fast
if ErrorLevel
GoSub, F7
else
GoSub, loop4
return |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
me10c
Joined: 22 Nov 2008 Posts: 44
|
Posted: Mon Jun 22, 2009 3:13 pm Post subject: |
|
|
Now when you mention it ...
Those parts of the code are scattered around the file itself ...
Anyways they were just random clicks
As I said I thought that the message is standart .. I will try to "crash" it till tomarow (well 12 hours till then by my clock )
I am not sure but it might be all those colour checks .. I think it crashes from them (overloaded or something ?).
EDIT:
I assume I can use
| Code: |
Random(min,max) {
Random, res, % min, % max
return res
}
|
for multiple scripts in the same file ? (I mean :
| Code: |
Random(min,max) {
Random, res, % min, % max
return res
}
#1::
Sleep, % Random(50,100)
return
#2::
Sleep, % Random(50,200)
#3::
Sleep, % Random(50,400)
etc etc
|
EDIT2:
is there something similiar for
Random, Xpos, x1, x2
Random, Ypos, y1, y2
MouseClick, Left , Xpos, Ypos
I have like 50 of those
In other words is there a way to make it 1 lined like the PixelSearch coordinates
and is there a way to make the IF 1 lined
| Code: | Random, Rand, 1, 4
IF(Rand = 1)
{
GoSub, 1
}
IF(Rand = 2)
{
GoSub, 2
}
IF(Rand = 3)
{
GoSub,3
}
|
In other words to make it something like this
| Code: | | IF(Rand =1), { GoSub, 1 } |
I have a lot of those 2 ... (while we are at it I can at least make my code ... smaller while trying to figure out while does it crash ) |
|
| Back to top |
|
 |
hd0202
Joined: 13 Aug 2006 Posts: 265 Location: Germany
|
Posted: Mon Jun 22, 2009 3:34 pm Post subject: |
|
|
You may get indefinite loops. You use
| Quote: | gosub F4 in F4:
gosub F7 in F7:
gosub FishBCheck in FishBCheck: |
I think, this may crash windows.
Hubert |
|
| Back to top |
|
 |
me10c
Joined: 22 Nov 2008 Posts: 44
|
Posted: Mon Jun 22, 2009 3:37 pm Post subject: |
|
|
Yeah I made those on purpose ...
I need it to click when the colour apears and I dont know another way
basicly when the sub starts and if it doesnt find the colour the sub starts again, and it does that until the colour is found ... (it usually does that 1 or 2 times , so there is no chance of a big loop) |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Mon Jun 22, 2009 3:51 pm Post subject: |
|
|
| me10c wrote: | I assume I can use
| Code: |
Random(min,max) {
Random, res, % min, % max
return res
}
|
for multiple scripts in the same file? |
Yes, as long as your working script has a reference to the function any hotkeys/applicable commands can access it. In your second example you would use the function like this to create a one-line command for MouseClick:
| Code: | | MouseClick, Left , % Random(x1,x2), % Random(y1,y2) |
You can also change the if/else format as well:
| Code: | If Random(1,4) = 1
GoSub, 1
else If Random(1,4) = 2
GoSub, 2
else If Random(1,4) = 3
GoSub,3 |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies.
Last edited by sinkfaze on Mon Jun 22, 2009 4:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
me10c
Joined: 22 Nov 2008 Posts: 44
|
Posted: Mon Jun 22, 2009 4:09 pm Post subject: |
|
|
the last thing that remains is
what is the code for "when this colour apears do that"
so I can remove the loops ... |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Mon Jun 22, 2009 4:38 pm Post subject: |
|
|
| me10c wrote: | what is the code for "when this colour appears do that"
so I can remove the loops ... |
Perhaps a PixelSearch function would suffice (untested):
| Code: | PixelSearch(x1,y1,x2,y2,cid,var="",mode="") { ; 'cid' is ColorID and 'var' is Variation
global Px
global Py
PixelSearch, Px, Py, % x1, % y1, % x2, % y2, % cid, % var, % mode
if ErrorLevel
return true
}
loop4:
Sleep, % Random(50,100)
SetMouseDelay, % Random(50,65)
if PixelSearch(995,320,1020,345,0x337095,3,"Fast") ; checks if the functions returns true for 'ErrorLevel' (literal text must be in quotation marks)
GoSub, logout
else
GoSub, Huml
GoSub, F4
return |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|