LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regain mouse control after movement

Hello,

 

I'm trying to do something that seems simple. While executing my vi, I'm trying to move the mouse to another open window to specific coordinates, click on a button of another program that starts that program running (it's not a labview program) and then move my mouse to another location and perform another click. I'm trying to use the user32.dll to do the mouse movement and clicking as several people have suggested on earlier threads.

 

My problem is that while the first movement of the mouse works fine, when it clicks on the other application I seem to lose all control of the mouse and cannot get control back unless I physically move the mouse and click back on my labview vi. I've tried changing the active window to switch back to my vi window as well as making the vi window on top, but those don't seem to give me control of the mouse again.

 

Any thoughts on if there's another function I should be using instead of user32.dll to move the mouse or any other ways I can regain control after that first movement? Thanks!

0 Kudos
Message 1 of 4
(2,807 Views)

There's no reason in principle this shouldn't work, but just saying "user32.dll" isn't enough, because there are many functions there and we don't know which you're calling and how. Post the code you're actually using.


___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,775 Views)

This reminds me on an issue i have while manual using Windows XP and Windows 7.

When initiating the shut down of the system, i am used to end all applications before hand. I do either terminate each application as it is recommended (Quit button), using the X of the Titlebar or simply pressing Alt+F4.

 

The latest option initiates the shut down of the active application. If used properly, you can shut down all application one after another without interacting with the PC otherwise (no mouse move, no other keys pressed).

The issue i observe in more than 50% times when doing so is: After closing the last application, the desktop is "in focus". But pressing Alt+F4 doesn't bring up the system shut down dialog. In this case (remember: more than 50% of all times!) i have to CLICK on the desktop and THEN can press Alt+F4 in order to get the system shut down dialog.

 

I assume that this situation is created by the way how Windows shuts down applications and manages "Active Application". I am confident that there is some kind of race condition: An application, which is still in shut down gets the focus, but then is terminated. Which means, no application is in focus now....

 

It is the same as during starting up applications with windows. Starting e.g. Firefox, i enter some URL (e.g. "forums.ni.com") and press enter. During load of the page, i start another application (e.g. LV). The LV launcher appears and suddenly, the Firefox window pops in front and displays the forums. I hate this behavior, as with other applications, the swapping of the active window takes place even during typing (e.g. entering passwords).

 

So i would expect you to run into a bug of the OS which is present for years now but never being addressed by Microsoft.

 

Norbert

 

PS: Sorry, i have no solution for you except the recommendtion: Try to set the "active application" programmatically. Don't know if this is possible if the calling application is not already in focus. Meaning: I am not sure if this programmatic approach can only be used to pass the "active" flag from the active application to another.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 3 of 4
(2,770 Views)

You could try AutoHotkey (http://www.autohotkey.com/) to 'record' a script of mouse movements and clicks, then convert that to an exe (tool included in the download) and use sys exec.

 

 

0 Kudos
Message 4 of 4
(2,760 Views)