Page 1 of 1

Identifying Custom Cursor

Posted: Tue Jun 06, 2017 3:36 pm
by cosmicluna
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.

Re: Identifying Custom Cursor

Posted: Wed Jun 07, 2017 7:55 am
by Stub
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.