Page 1 of 1

Validation of the mouse

Posted: Fri Jan 25, 2019 9:53 am
by Anett
Hello all,

I need to validate in my scipts that the mouse pointer changes to a doubled arrow by moving over a special point.
Is there a possibility for that?

Best Regards,

Anett

Re: Validation of the mouse

Posted: Fri Jan 25, 2019 1:51 pm
by odklizec
Hi Anett,

There is no built-in way to achieve what you want, so you will most probably have to create some code for this. For evaluating mouse pointer, you can use Mouse.CursorName, which should return name of actually used cursor.

Re: Validation of the mouse

Posted: Fri Jan 25, 2019 3:32 pm
by Andymann
I did that once and my code (which works surprisingly well) looks like this (pSeconds is the amount of seconds that I am willing to wait.):
string currentState = Mouse.Cursor.ToString();			
        	System.Diagnostics.Stopwatch newWatch = System.Diagnostics.Stopwatch.StartNew();
        	
        	while (currentState.ToLower().Contains("waitcursor") && newWatch.Elapsed.Seconds <= pSeconds){
        		Thread.Sleep(1000);
        		currentState = Mouse.Cursor.ToString();
        		//Ranorex.Report.Debug("waitForSavingDone(): currentState=" + currentState + ". newWatch.Elapsed.Seconds:" + newWatch.Elapsed.Seconds + "; pSeconds:" + pSeconds);
        		
        	}
        	        	
        	if(newWatch.Elapsed.Seconds > pSeconds){
        		//Ranorex.Report.Error("Mauszeiger zeigt nach Ablauf von " + pSeconds.ToString() + " Sekunden immer noch 'Speichern'.");
        		throw new TimeoutException("Mauszeiger zeigt nach Ablauf von " + pSeconds.ToString() + " Sekunden immer noch 'Speichern' - Timeout.");
        	}else{
        		Ranorex.Report.Info("Mauszeiger gibt keinen Hinweis (mehr) auf 'Speichern'-Vorgang.");
        	}			


Re: Validation of the mouse

Posted: Mon Jan 28, 2019 11:44 am
by Stub
I wrote some code to validate the mouse cursor. It was useful in verifying that I'd calculated the correct position for the mouse in our AUT.

I look at Mouse.CursorName first. This works great with system cursors.

But in our case it might be something like "Custom123456" if it's a mouse cursor image of our own. If that's the case then I Ranorex.Imaging.Load() an image of the mouse cursor that I previously saved via Mouse.GetCursorImage(). And then I Ranorex.Imaging.Compare() that loaded image with the current cursor image, via Mouse.GetCursorImage() again.

Re: Validation of the mouse

Posted: Tue Feb 05, 2019 8:48 am
by Anett
Thank you very much!!!!

Validating the CursorName is the way we will do it.

Thank you everybody!