Cue Posted November 12, 2006 Posted November 12, 2006 I have a problem which keeps reoccurring (no pun intended). I Need to figure out a way to exit a previous function call and start it again. Ive searched the forums far and wide and though the question has come up alot i cannot find a definite answer.code for an accelerating mouseDim $MouseStep=0 $Keys2Set=StringSplit('{UP},{RIGHT},{DOWN},{LEFT}',',') for $i=1 to 4 HotKeySet($Keys2Set[$i],"Control_Mouse") Next while 1 WEnd Func Control_Mouse() $MouseStep+=1 Switch @HotKeyPressed Case $Keys2Set[1] MouseMove(MouseGetPos(0),MouseGetPos(1)-$MouseStep,0);up Case $Keys2Set[2] MouseMove(MouseGetPos(0)+$MouseStep,MouseGetPos(1),0);right Case $Keys2Set[3] MouseMove(MouseGetPos(0),MouseGetPos(1)+$MouseStep,0);down Case $Keys2Set[4] MouseMove(MouseGetPos(0)-$MouseStep,MouseGetPos(1),0);left EndSwitch Do $g = $MouseStep Sleep(100) until $g == $MouseStep $MouseStep=0 Return 0 EndFuncThe problem with this code and many of my previous codes is that it is recurrsive which is a big problem. My previous post which is related:http://www.autoitscript.com/forum/index.ph...mp;#entry253581even though the recurrsion limit of Autoit is fairly highMAXEXECUTERECURSE 384 I need to figure out a way to avoid it. So if there is anyone with good programming practice please can you give me some advice for this kind of senarioOther postshttp://www.autoitscript.com/forum/index.ph...mp;hl=Recursionhttp://www.autoitscript.com/forum/index.ph...mp;hl=Recursion
Paulie Posted November 12, 2006 Posted November 12, 2006 I have a problem which keeps reoccurring (no pun intended).Good thing you said "no pun intended" there, otherwise people might get the impression that... that... wait, where was the pun again? Anyway, try this maybe? expandcollapse popupHotKeySet("{UP}", "MoveUp") HotKeySet("{Down}", "MoveDwn") HotKeySet("{Left}", "MoveLft") HotKeySet("{Right}", "MoveRt") HotKeySet("{End}", "LClick") HotKeySet("{PgDn}", "RClick") Global $Speed = 10 While 1 Sleep(10000) WEnd Func MoveUp() $Pos = MouseGetPos() MouseMove($Pos[0], $Pos[1]-$Speed, 1) EndFunc Func MoveDwn() $Pos = MouseGetPos() MouseMove($Pos[0], $Pos[1]+$Speed, 1) EndFunc Func MoveLft() $Pos = MouseGetPos() MouseMove($Pos[0]-$Speed, $Pos[1], 1) EndFunc Func MoveRt() $Pos = MouseGetPos() MouseMove($Pos[0]+$Speed, $Pos[1], 1) EndFunc Func LClick() MouseClick("Left") EndFunc Func RClick() MouseClick("Right") EndFunc one of the first scripts I made...
Cue Posted November 12, 2006 Author Posted November 12, 2006 Thanks Paulie I was begginig to think this was going to be another post that will get buried without a reply. Is there a way to make the mouse accelerate using your code like the one i posted without getting a stack overflow problem.
Cue Posted November 12, 2006 Author Posted November 12, 2006 lol, I dont even know anymore. it was 4 am when i posted that and for some reason I thought reoccurring and recursion were similiar things. Lame i know
Valuater Posted November 12, 2006 Posted November 12, 2006 maybe... expandcollapse popupDim $MouseStep = 0 $Keys2Set = StringSplit('{UP},{RIGHT},{DOWN},{LEFT},{F9},{ESC}', ',') For $i = 1 To $Keys2Set[0] HotKeySet($Keys2Set[$i], "Control_Mouse") Next While 1 Sleep(10) WEnd Func Control_Mouse() $MouseStep += 1 $Mpos = MouseGetPos() $XMove = 0 $YMove = 0 Switch @HotKeyPressed Case $Keys2Set[1] $YMove = -1 Case $Keys2Set[2] $XMove = 1 Case $Keys2Set[3] $YMove = 1 Case $Keys2Set[4] $XMove = -1 Case $Keys2Set[5] $MouseStep = 0 Return Case $Keys2Set[6] Exit EndSwitch For $x = 1 To $MouseStep MouseMove($Mpos[0] + $XMove, $Mpos[1] + $YMove, 0) $XMove += $XMove $YMove += $YMove Sleep(100) Next EndFunc ;==>Control_Mouse 8)
Cue Posted November 12, 2006 Author Posted November 12, 2006 Hi Valuator, that code also suffurs from recursion and it seems to make the cursor behave very odd.
Cue Posted November 14, 2006 Author Posted November 14, 2006 (edited) Dim $MouseStep=0 $Keys2Set=StringSplit('{UP},{RIGHT},{DOWN},{LEFT}',',') for $i=1 to 4 HotKeySet($Keys2Set[$i],"Control_Mouse") Next while 1 WEnd Func Control_Mouse() $MouseStep+=1 Switch @HotKeyPressed Case $Keys2Set[1] MouseMove(MouseGetPos(0),MouseGetPos(1)-$MouseStep,0);up Case $Keys2Set[2] MouseMove(MouseGetPos(0)+$MouseStep,MouseGetPos(1),0);right Case $Keys2Set[3] MouseMove(MouseGetPos(0),MouseGetPos(1)+$MouseStep,0);down Case $Keys2Set[4] MouseMove(MouseGetPos(0)-$MouseStep,MouseGetPos(1),0);left EndSwitch Sleep(100) $MouseStep=0 Return 0 EndFunc right I simple got rid of the do...until. to be honest i dont even know why i added it in the first place. i think the time i write it was an importatnt factor again Edited October 20, 2008 by Cue
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now