aprisma Posted January 29, 2006 Share Posted January 29, 2006 Hello! Sorry to the admin that I post the same thing twice. But my main thread goes into the wrong direction. So please delete the other thread. My problem is this programm here: dim $pos = 0 While 1 $neupos = 0 $pos = MouseGetPos() MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]) $neupos = $pos [0] $pos = MouseGetPos() if $neupos = $pos then ExitLoop WEnd I did this also with all $neupos as dim ........... no error but the programm should do the following. As long as i move the mouse it stays in the loop. When I stop the loop should stop too. The MessageBox is only here for control, so I dont need it really. But what really happens is - the loop is forever. Dont matter what I do with my mouse - why???? Please help me cause I am really getting mad. I watch now about 5 hours on the same 10 lines ...... thanx so far, cheers, Juergen Link to comment Share on other sites More sharing options...
greenmachine Posted January 29, 2006 Share Posted January 29, 2006 It was covered correctly in the other post. I don't know what's wrong with that one. Your problem is simple: $pos changes from array to standard variable halfway though, so it can't be caught. Your code: dim $pos = 0 While 1 $neupos = 0 $pos = MouseGetPos() MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]) $neupos = $pos [0] $pos = MouseGetPos() if $neupos = $pos then ExitLoop WEnd Notice: $pos = 0 ... $pos = MouseGetPos() ... $pos[0] & "," & $pos[1] ... $neupos = $pos [0] ... $pos = MouseGetPos() ... if $neupos = $pos You did it right the first time, using an array after the MouseGetPos() call. Then all of a sudden you call it again and don't use an array? Why? All you have to do is change it to this: dim $pos = 0 While 1 $neupos = 0 $pos = MouseGetPos() MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]) $neupos = $pos [0] $pos = MouseGetPos() if $neupos = $pos[0] then ExitLoop WEnd Link to comment Share on other sites More sharing options...
herewasplato Posted January 29, 2006 Share Posted January 29, 2006 (edited) Do $pos1 = MouseGetPos() ToolTip("$pos1 " & $pos1[0] & ", " & $pos1[1]) Sleep(2500) $pos2 = MouseGetPos() ToolTip("$pos1 " & $pos1[0] & ", " & $pos1[1] & @CR & _ "$pos2 " & $pos2[0] & ", " & $pos2[1]) Sleep(2500) Until $pos1[0] = $pos2[0] And $pos1[1] = $pos2[1]orWhile 1 $pos1 = MouseGetPos() MsgBox(0, "1", "1") $pos2 = MouseGetPos() If $pos1[0] = $pos2[0] And $pos1[1] = $pos2[1] Then MsgBox(0, "2", "did not move") ExitLoop Endif WEndTest these little scripts without adding them to your script. Make a new au3 file for each test.Edit1:Your code's error shown in red:While 1$neupos = 0$pos = MouseGetPos()MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])$neupos = $pos [0]$pos = MouseGetPos()if $neupos = $pos [0] then ExitLoopWEndI've tested that corrected code - it seems to work for me.Edit2:I know that several others have pointed this same error out to you, but perhaps you did not see the difference between your code and the corrected code that they posted. Edited January 29, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
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