Jump to content

Recommended Posts

Posted

I need a safe way to trap the mouse cursor with ID 1 (appstarting)

I need to fill a form, with {TAB}{SPACE}. This form has between 200 and 250 radiobuttons, I'm never sure of the exact number of radiofields. At the end of the form I need to stop. The only way to see if i'm at the end of the form is that the last control of the form is a button, when I tab to it and give a space the mousecursor changes from an arrow (ID 2) to an appstarting arrow (ID 1). That's when I need to stop. The controls on the form have no name's or handles (AutoInfo is blank!). So I decided to focus on trying to trap the change from arrow to appstarting arrow.

here is the snipped:

While 1

Send("{TAB}{SPACE}")

MouseMove(5, 10)

$MouseCursor = MouseGetCursor()

If $MouseCursor = "1" Then ExitLoop

WEnd

It works, except that about every 1 out of 4 times the appsstarting arrow does not end the loop, even if the wanted cursor is clearly visible there for 1 or 2 seconds. I have thrown in some sleeps, even sleep(1000) but apart from slowing down the whole process, it still doesn't allways trap the appstarting arrow. Any suggestion for a more foolproof method?

Thank you in advance

Peter

Posted

You didn't mention what speed you're moving the mouse at. I would make the moves instantaneous, and then run a tight while loop - you're not going to have long to detect the change, your message implies that you get just a blink of the cursor change. The (untested) code below demonstrates the idea - if you ever have the cursor type change, you're done - you get to decide how long to wait w/ $max_wait

There is (obviously) a way of doing this through the API as well, or the function wouldn't be in au3 B) - A check through the source for MouseGetCursor() would let you figure out how they'rre doing it and provide a way to see if you can find the right syntax for a dllcall().

;wade through mouse moves

mousemove(x,y,0)

$iCursorType = _GetMouseCursorType()

if $iCursorType Then exit

;not done yet

Func _GetMouseCursorType()

$timer = TimerInit()

$max_wait = 5000

While 1

If TimerDiff($timer) > $max_wait Then Return 0

if MouseGetCursor() <> 2 Then Return 1

sleep(1)

Wend

EndFunc

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Posted (edited)

I move the mouse to the same position all the time (so actually it does not move!) because without a mousemove no cursorid is reported. I'm suspecting that my gui which uses messageloop could be the culprid, so I'm rewriting it to use on-event mode. If that doesn't help I'll try your suggestion. Thx anyway for your response

Peter

Edited by PJThys

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
×
×
  • Create New...