Identifying Custom Cursor

Ask general questions here.
cosmicluna
Posts: 5
Joined: Tue May 16, 2017 4:46 pm

Identifying Custom Cursor

Post by cosmicluna » Tue Jun 06, 2017 3:36 pm

Is there any way to identify custom cursors in Ranorex testing? I want the program to do something when it is a specific cursor, which happens to be custom. Thanks in advance.

User avatar
Stub
Posts: 173
Joined: Fri Jul 15, 2016 1:35 pm

Re: Identifying Custom Cursor

Post by Stub » Wed Jun 07, 2017 7:55 am

I save the cursor image when I first encounter it:

Code: Select all

Bitmap mouse_cursor_bitmap = Mouse.GetCursorImage();
CompressedImage mouse_cursor_image = new CompressedImage(mouse_cursor_bitmap);
mouse_cursor_image.Store(mouse_cursor_file);
And then subsequently compare the current cursor image to this saved image. This works for both system and custom cursors, though system cursors can change between OS'.

Code: Select all

Bitmap expected_cursor_image = Imaging.Load(cursor_image_filename);
Bitmap actual_cursor_image = Mouse.GetCursorImage();
:
Validate.IsTrue(Imaging.Compare(actual_cursor_image, expected_cursor_image, find_options), ...
I log the cursor images too, which helps clarify issues in the report.