Pick up mouse position in virtual machines

3

I'm having a problem getting the mouse position on a virtual machine.

I have a macro program on a virtual machine that performs a series of looping actions, but it may happen that the action hangs and the only way to detect this is with the movement of the mouse. I made a small system in Delphi that captures the position of the mouse and if it stays more than 5 minutes in the same place I get an email, but when I disconnect from the virtual machine and leave the macro running in it, my system in Delphi for to capture the position.

Does anyone know a method to solve this? It can be in any language.

    
asked by anonymous 29.01.2014 / 17:13

1 answer

0

I imagine that you are using the windows API to recover the cursor position, but this function should stop working when you disconnect, so there is no "monitor" so you can tell the current position.

Without knowing the technology used in the macro, it's also tricky to make assertions, but I imagine it uses the windows APIs to click buttons, type text, etc.

Well, this macro should have a mechanism, in each event, to determine whether or not it can continue with the actions.

Finally, a solution in this case is to make every time the macro is waiting for the next step of the loop, it counts the time and, in case of failure, run the program that sends the email.

Another approach, if you are monitoring a specific program, would be to monitor something other than the mouse. If the macro goes through multiple screens, you could check the title of the current window with the windows API. Another possibility would be to capture the window image at regular intervals and check if anything has changed.

Ultimately, you can replicate to the same logic that the macro uses to wait for the system to check whether or not it is waiting indefinitely.

However, if the macro is "dumb" in the sense that it has no checks, it only works at defined time intervals, you can think of another solution.

There is a tool called Sikuli that allows you to do automation using images. For example, you capture the image of a button and then mount a script to click that button through the image. The sikuli will look for the image of the button on the screen and can wait a while until this button appears. If the expected button does not appear, then you can capture the error. Sikuli implementations can be done in java or python.

Update

I did a search on the APIs related to the position of the mouse cursor. The position of the mouse is usually given relative to the current monitor, since Windows supports multiple screens. So when you disconnect all the monitors the cursor can be disabled.

I assume you're currently using GetCursorPos . If this is the case, try checking GetCursorInfo because it returns useful information about the state of the cursor and also about its position.

However, it seems that this information is not accessible by the same design decision. See this link , which says more or less this :

  

You can not get this information with the desktop locked. While it is locked, the security subsystem between takes over and your desktop is off limits.

    
29.01.2014 / 17:40