GetCursorType>resultvar

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

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

GetCursorType>resultvar

Post by Snickers » Mon Aug 20, 2007 3:25 pm

It would be very useful if we were able to GetCursorType>resultvar

This would allow user to get the Cursors current state and then move the mouse and again get the mouse cursors state for the purpose of comparing the two.

This would allow the user to compare the cursor at two different locations.
For example:

Code: Select all

Label>Start
Mousemove,%X1%,%Y1%
GetCursorState>var_1
wait>.25

Mousemove,%X2%,%Y2%
GetCursorState>var_2
wait>.25

If>var_1=var_2,Start,End

Label>End
This feature would allow users to do a number of things:

Search for graphical buttons on webpages that might only be identified by a cursor change in a general area

Search for Flash multimedia buttons on webpages that might only be identified by a cursor change in a general area

Search areas within applications that are only identifiable by a cursor change

Using a random search of a pixel box area, the user could simply put in start and finish coordinates and search for a cursor change either pixel by pixel (which is not the best idea) or search using a more efficient search pattern.
Last edited by Snickers on Mon Aug 20, 2007 7:07 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 3:27 pm

What is meant by "cursor state"?
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 3:42 pm

mtettmar wrote:What is meant by "cursor state"?
By "cursor state" I am, probably incorrectly, referring to the icon that shows the position of the mouse. In any normal instance, the cursor looks similar to this: http://www.powerpointpanic.co.uk/Cursor.jpg
but when you mouse over certain objects that require a user's action, the cursor changes to icons that look similar to this: http://www1.istockphoto.com/file_thumbv ... r_hand.jpg
WaitCursorChanged> is more of a passive command. The entire script is forced to freeze while it waits for the cursor to change.

GetCursorIcon> or GetCursorState> would be an aggressive method to actively search for an area that causes the cursor to change.

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 3:46 pm

There's no such thing as cursor "state" - just different cursors. The cursor can change type. Just wanted to clarify your intentions.
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 3:53 pm

mtettmar wrote:There's no such thing as cursor "state" - just different cursors. The cursor can change type. Just wanted to clarify your intentions.
Yes absolutely! that would be exactly what I'm looking for.

I was hoping to compare a cursor type at one location, move the mouse, and compare it to the cursors type at the last location.


Just like you would compare the pixelcolors at two different locations, I would like to move the mouse and see if the cursor changed because of my mouse's new location.

If I go to Control Panel/Mouse/Mouse Properites/Pointers, it shows a list of possible mouse cursors: Normal Select, Help Select, Working in Background, Busy, Precision Select, Text Select, Handwriting, Unavailable, etc.

WaitCursorchanged> will continue the script when one of these cursors change to a different one.

I was hoping for a way to create a variable that stores the pointer type at the mouse's current location .


I can later use that variable to compare it to the mouse pointer type at a different location.
Last edited by Snickers on Mon Aug 20, 2007 4:06 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 4:05 pm

You can already do this with the command I showed you earlier:

Code: Select all

MouseMove>232,540
LibFunc>user32,GetCursor,Cursor1
MouseMove>38,500
LibFunc>user32,GetCursor,Cursor2
If>Cursor1<>Cursor2
  MessageModal>Cursor changes on mouse move
Else
  MessageModal>No Change to Cursor
Endif
Try it.

If the two positions have different cursors then the cursor handles will differ.
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 4:19 pm

I tried this earlier. I tried it again now with the exact code you provided. I have also added waits so that I am certain there is no processing error.

This is not working. It displays "No Change to Cursor" everytime. I have removed the waits, and I even made them longer waits (3 seconds each) with no positive cursor change result.

Code: Select all

wait>3
SetFocus>Firefox*
//within firefox window, move mouse to blank area that displays a normal cursor (Normal Select cursor)
MouseMove>10,413
wait>1
LibFunc>user32,GetCursor,Cursor1
wait>1
//within firefox window, move mouse over a button that causes my cursor to change to a (Link Select cursor)
MouseMove>301,278
wait>1
LibFunc>user32,GetCursor,Cursor2
wait>1

//compare the two cursor variables
If>Cursor1<>Cursor2
  MessageModal>Cursor changes on mouse move
Else
  MessageModal>No Change to Cursor
Endif
Last edited by Snickers on Mon Aug 20, 2007 4:27 pm, edited 2 times 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 4:25 pm

Strange. It works for me. Make sure if you test it that you change the coordinates to ones where you will see a cursor change!

When pasting code disable smilies and html - some of the code is being seen as a smilie or html and altered.
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 4:33 pm

mtettmar wrote:When pasting code disable smilies and html - some of the code is being seen as a smilie or html and altered.
I am so glad you told me this. This has been a pain for quite a while.

You had told me earlier in the other post that the LibFunc> doesn't work all the time.

I must be one of those cases. :-)

It would be amazingly great if Macro Scheduler could add a feature that is as reliable as WaitCursorChanged but not as passive (aka: freeze your script till the cursor changes).

The script I pasted above has coordinates specific to my screen. The first coord, 10,413 , moves the cursor to a grey area on the left side of my screen. The second coords moves it over the "Products" link on the MJTNET forums website. At these coords, 301,278, my mouse pointer changes into a Hand.



If i change the else message modal to the following:

Code: Select all

  MessageModal>No Change to Cursor %Cursor1% %Cursor2%
The message that appears is "No Change to Cursor 65557 65557"

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

Post by Snickers » Mon Aug 20, 2007 4:47 pm

When using the following code, i simply wait 3 seconds and manually move my mouse around the screen. As my cursor changes numerous times, the message modal never displays.

The following code does not work:

Code: Select all

wait>3
SetFocus>Firefox*
wait>
Label>start
LibFunc>user32,GetCursor,Cursor1
wait>.25

If>Cursor1<>65557
  MessageModal>Cursor changes on mouse move
  goto>end
Endif
Goto>start
Label>end
When using the following code, i simply wait 3 seconds and manually move my mouse around the screen. The very second my cursor changes, the message modal displays.
The following code works.

Code: Select all

wait>3
SetFocus>Firefox*
Label>start
WaitCursorChanged>0
MDL>Cursor has changed
Label>end
I was hoping that macro scheduler could move my cursor for me and trigger events when the cursor changes. Currently, i cant have macro scheduler move my mouse and trigger events using WaitCursorChanged>

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 5:43 pm

A macro can't wait and do something at the same time.

But one process can wait while another does something. So perhaps you need two compiled macros.
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 6:20 pm

The libfunc does not function correctly with my system.

This is the Enhancement Suggestion section. I am trying to suggest a needed enhancement that would hopefully be included in one of the next versions of Macro Scheduler.

I am trying to be as clear as possible as to what enhancement I am suggesting. The feature I am suggesting is very feasible using probably nearly identical program coding as waitcursorchange.

In my mind, the logical process of a waitcursorchange> command is as follows:

Code: Select all

get cursor type
wait until cursor type is different
continue script if it is different
I am suggesting that Macro Scheduler invent a new command for one of their next versions. In my mind, the logical process that I need is as follows:

Code: Select all

get cursor type and store its value in a variable
You have suggested the following code for me to use and you have also stated that it doesn't always work. The following code does not detect cursor type changes in my firefox browser (when set as the foreground window) nor in my IE browser (when set as the foreground window):
wait>3
SetFocus>Firefox*
//within firefox window, move mouse to blank area that displays a normal cursor (Normal Select cursor)
MouseMove>10,413
wait>1
LibFunc>user32,GetCursor,Cursor1
wait>1
//within firefox window, move mouse over a button that causes my cursor to change to a (Link Select cursor)
MouseMove>301,278
wait>1
LibFunc>user32,GetCursor,Cursor2
wait>1

//compare the two cursor variables
If>Cursor1Cursor2
MessageModal>Cursor changes on mouse move
Else
MessageModal>No Change to Cursor
Endif
However, the above code works great at detecting the cursor change when I test it on the Macro Scheduler window in the foreground. For example: (setfocus>Macro Scheduler*)


WaitCursorChange> works perfectly as is however, I want to get cursor, just like waitcursorchange> apparently does, but without the wait.

I don't want macro scheduler to do two things at one time.

STEP 1:I want to get the cursor type and store the cursor type into var_1.

STEP2 :I then would like for macro scheduler to move my mouse

STEP 3:I want to get the cursor type and store the cursor type into var_2.

STEP 4:I want to compare the two cursor variables to see if they are the same or different.

The logical code would be as follows: (assume that this new feature would work such as this: GetCursorType>resultVariable)

Code: Select all

//get cursor type (the pixture of the mouse could be an hourglass, pointer, or whatever)
GetCursorType>var_1

//move the mouse somewhere else on the screen
MouseMove>%X%,%Y%

//get cursor type (the pixture of the mouse could be an hourglass, pointer, or whatever)
GetCursorType>var_2

//Compare the first cursor type with the second cursor type
If>var_1=var_2
//do something
else
//do something else
endif

When I use the firefox window or internet explore the LibFunc returns the exact same variable no matter what my cursor type is.

Code: Select all

LibFunc>user32,GetCursor,Cursor1
Cursor1 always equals 65553 no matter what my cursor type is at the time of checking it.


I don't want to wait until my cursor changes: (aka: WaitCursorChanged>Timeout)

I want to test and see if my cursor has changed with a feature that is not currently included in Macro Scheduler: (aka: GetCursorType>resultVar)


I shouldn't need two macros to do this simple function. I will test libfunc more and attempt to find out why it isn't functioning correctly. But at this present time, the LibFunc isn't functioning correctly with my system and I have tested it using a number of different applications.

Snickers76
Newbie
Posts: 12
Joined: Mon Mar 10, 2008 6:26 pm

ID the current Cursor

Post by Snickers76 » Mon Mar 17, 2008 4:38 pm

I love the new waitcursorchanged> timeout! Great addition.

However, waitcursorchanged is telling me when the cursor changes, and I use this feature quite often, but Is there a way to identify the current cursor or even Declare/define the current cursor so that next time the "cursor changes" I can say:

If>Cursor=%cursorvalue1%
Then do this
endif

If>Cursor=%cursorvalue2%
Then do something else
endif

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Mon Mar 17, 2008 5:22 pm

Snickers wrote:When I use the firefox window or internet explore the LibFunc returns the exact same variable no matter what my cursor type is.

Code: Select all

LibFunc>user32,GetCursor,Cursor1
Cursor1 always equals 65553 no matter what my cursor type is at the time of checking it.
I see what Snickers is saying. The following script...

Code: Select all

LibFunc>user32,GetCursor,Initial_Cursor_Type

Label>Loop
LibFunc>user32,GetCursor,Current_Cursor_Type

If>Current_Cursor_Type<>Initial_Cursor_Type
  MessageModal>Cursor Type changed from %Initial_Cursor_Type% to %Current_Cursor_Type%
Wait>1
EndIf

Goto>Loop
...will detect the cursor changing type in a Windows App like Macro Scheduler. But fire up IE, move the cursor around and you can watch it change from a pointer to a hand... but the script does not detect it.

Marcus, is this a known issue or is there a way to code this so we can detect when the cursor changes when IE has focus?

For instance, if the focused app is IE, would a different LinFunc> call be able to detect the actual cursor type?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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 Mar 17, 2008 5:38 pm

All I can do is link you to Microsoft's documentation on this function:

http://msdn2.microsoft.com/en-us/librar ... S.85).aspx

I'm not a Firefox or IE developer, so I can't comment on how they implement cursors or whether they affect the system cursor.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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