WaitCursorChanged> similar function question

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

WaitCursorChanged> similar function question

Post by Snickers » Mon Aug 20, 2007 11:48 am

WaitCursorChanged> detects when the cursor has changed. Is there a function that storesthe cursor's current state in a variable?

GetCursorState> would store the cursors current state.

For example:

Code: Select all

GetCursorState>result
Mousemove>%X%,%Y%
wait>.25
GetCursorState>result2
//detect if the cursor has changed as a result of the mouse movement
If>result=result2
MDL>Your cursor has NOT changed
else
MDL>Your cursor has changed
endif
I managed to get something that works only when the mousemove guarantees the cursor to change:

I tested it out using the Macro Scheduler website's POST REPLY BUTTON.

Code: Select all

Mousemove>389,421
WaitCursorChanged>.025
if>WCC_RESULT=TRUE
mdl>It detected the cursor change %WCC_RESULT%
endif
The only problem with the code is that the minimum wait limit that works with WaitCursorChanged> seems to be 1 second. I could use this method if I could set the wait time to .025 or .5

Is there a way noway to do this 100% using the commands of Macro Scheduler, is it possible to perform this check using VB within Macro scheduler? If so, and I hate asking for someone to provide the actual code for it, could you please provide the VB code that would getcursor state and assign it to a macro scheduler variable, and then a second vb code that would getcursor state and assign it to a second macro scheduler variable.

Thank you very much for your assistance!

EDIT: Also, if it was done in VB, would it be as fast as though it were done within Macro Scheduler?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Aug 20, 2007 12:31 pm

The following code uses Win32 functions. But it might not always work.

//Get a handle to the current cursor:
LibFunc>user32,GetCursor,savCursor

..
.. do something
..

//Restore cursor
LibFunc>user32,SetCursor,r,savCursor

That any help?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Aug 20, 2007 1:18 pm

//Get a handle to the current cursor:
LibFunc>user32,GetCursor,savCursor

does this store the current cursor's state into a variable?
If so, which variable does it store it into?

How can I use this to:

Code: Select all

getcursorstate>var_1
mousemove>X,Y
getCursorState>var_2
If>var_1=var_2
do something
else
do something else
endif
I tried the following code in different variants as a test, but it did not detect the cursor change:

Code: Select all

wait>3
Label>start
Label>check1
//Get a handle to the current cursor:
LibFunc>user32,GetCursor,savCursor
wait>.025
Mousemove>10,413
wait>.025
LibFunc>user32,GetCursor,savCursor2
if>%savCursor%=%savCursor2%
goto>check2
else
mdl>It detected the cursor change %savCursor% and %savCursor2%
endif

[...]

//Get a handle to the current cursor:
LibFunc>user32,GetCursor,savCursor
wait>.025
Mousemove>390,413
wait>.025
LibFunc>user32,GetCursor,savCursor2
if>%savCursor%=%savCursor2%
goto>check10
else
mdl>It detected the cursor change %savCursor% and %savCursor2%
endif
Label>end
...But it might not always work.
Why will it not always work?


Why is the WaitCursorChanged> wait minimum only 1 second. Why is it not allowed to wait only a fraction of a second?
Last edited by Snickers on Mon Aug 20, 2007 1:30 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Aug 20, 2007 1:29 pm

>LibFunc>user32,GetCursor,savCursor does this store the
>current cursor's state into a variable?

It stores a handle to the current cursor in the savCursor variable.

>Why is the WaitCursorChanged> wait minimum only 1 second.
>Why is it not allowed to wait only a fraction of a second?

I don't know what you mean. There is no wait time coded into WaitCursorChanged. It waits until there is a change in cursor. No delay is included in the code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Aug 20, 2007 1:42 pm

mtettmar wrote:I don't know what you mean. There is no wait time coded into WaitCursorChanged. It waits until there is a change in cursor. No delay is included in the code.
I apologize for not making myself clear. I mean to ask why is the timeout for WaitCursorChanged limited to a minimum of 1 second?

If the timeout was able to be set at a fraction of a second, then waitcursorchanged could be used in the following way:

Code: Select all

//Set 1st row to check for cursor change
Let>X1=10
[...]
//my test detected a cursor change here
Let>X20=346
//set 1st colomn to check for cursor change
Let>Y1=413
[...]
//my test detected a cursor change here
Let>Y20=275

Mousemove>%X1%,%Y1%
WaitCursorChanged>1 //i want to set this timeout for shorter timeout
if>WCC_RESULT=TRUE
mdl>cursor change was detected.
endif

Mousemove>%X20%,%Y20%
WaitCursorChanged>1 //i want to set this timeout for shorter timeout
if>WCC_RESULT=TRUE
mdl>cursor change was detected.
endif
The above code does in fact work, however, it is too slow for what I need. If the timedelay was only a fraction of a second, I could use waitCursorchanged as a way to compare one cursor to the next.

run this script using your internet browser and put x20 and Y 20 as the coordinates for any button on your screen that makes the cursor change.
Last edited by Snickers on Mon Aug 20, 2007 1:44 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Aug 20, 2007 1:44 pm

Still not sure what you mean. You can set the timeout to be as long as you like. From the help file:

"WaitCursorChanged>Timeout

This command causes Macro Scheduler to wait until the cursor of the foreground window changes. If it doesn't change within the number of seconds specified in Timout, the command stops waiting and the variable WCC_RESULT is set to FALSE. WCC_RESULT is TRUE if the command terminated because the foreground window cursor changed within the specified time. if Timeout is set to 0, the command will wait indefinitely."

The timeout is not limited to one second. Where are you getting that from?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Snickers
Macro Veteran
Posts: 151
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Mon Aug 20, 2007 1:48 pm

If you set the WaitCursorChanged's timeout to something less than one second, it will timeout indefinitely. WaitCursorChanged's timeout minimum is set at 1 second for some reason.


Run the code I have pasted above and you will see. Change the timeout to something below 1 second; change the timeout to anything between 0 seconds and .99 seconds.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts