Jump to content

Mouse query - problems with loops and conditions


aprisma
 Share

Recommended Posts

Hello!

I am new to autoit. Till now I only did it with clickn play :-) But I found that great tool and beginn to like it. Of course there are a lot of questions and I DID look into the help files.

I want to make a mouse query that tells me the x and the y coordinate and if i stop mouse mooving longer than 10 seconds it should write the x and y cordinate down and put it into 2 different varables.

The more I try the more disappointed I am:

So here is a part of my idea. But the loop NEVER stops. Where is the error or is it totally crap?

dim $pos = 0

While 1

$neupos = 0

$pos = MouseGetPos()

MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])

$neupos = $pos [0]

$pos = MouseGetPos()

Sleep (5000)

if $neupos = $pos then ExitLoop

WEnd

thanx a lot for your help!

cheers,

Link to comment
Share on other sites

Hallo!

Ok das stimmt, das habe ich beim umhereditieren vergessen. Aber dennoch stoppt das Programm nicht. Das heisst er hängt für immer in der Schleife fest. Es müßte doch wenn ich die Maus nicht mehr anrühre von selber aufhören.

Gibt es einen Source von Auto-It-Windows-Info?

Programm nochmal:

; Script Start - Add your code below here

dim $pos = 0

While 1

$neupos = 0

$pos = MouseGetPos()

MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])

$neupos = $pos [0]

$pos = MouseGetPos()

Sleep (5000)

if $neupos = $pos[0] then ExitLoop

WEnd

DANKE,

Link to comment
Share on other sites

  • Developers

Is it me or am i reading a different languages ... :lmao:

try this:

Dim $neupos = 0
While 1
    $pos = MouseGetPos()
    If $neupos = $pos[0] Then ExitLoop
    $neupos = $pos[0]
    sleep(5000)
WEnd
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hello!

Maybe its my fault and this why I say again what I need.

I want to moove the mouse in the screen. When I stand still for a total of 5 sekunds the loop should end that the programm can go to the next part of the programm - printing the mouse coordinates and put them each into own variabel.

Even with your programm propasal the loop never ends when i hold still the mouse pointer.

any ideas whats wrong?

cheers, Juergen

Link to comment
Share on other sites

  • Developers

Hello!

Maybe its my fault and this why I say again what I need.

I want to moove the mouse in the screen. When I stand still for a total of 5 sekunds the loop should end that the programm can go to the next part of the programm - printing the mouse coordinates and put them each into own variabel.

Even with your programm propasal the loop never ends when i hold still the mouse pointer.

any ideas whats wrong?

cheers, Juergen

The script I posted will stop the While..End loop when the mouse didn't move for 5-10 seconds..

This one will end after exact 5 second :

$neupos = 0
$time = TimerInit()
While 1
    $pos = MouseGetPos()
    If $neupos = $pos[0] Then
        if TimerDiff ($time) > 5000 Then ExitLoop
    Else
        $time = TimerInit() 
        $neupos = $pos[0]
    EndIf       
    sleep(10)
WEnd

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

WOOOOOOOOOOOOOOT !!!!

Thanx a lot you are great! I dont know why but the other script didnt end even after 10 minutes :-))) But this exact after 5 Sekunds. Now I can ask for the mouse pointes and put them in a file.

GREAT!!!!

thanx a lot!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...