LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

program left mouse click

Solved!
Go to solution
Highlighted

I have a Go button on the front panel of the VI. I can set the Key Focus Property Node to true.

Then I want to cause a left mouse click.

 

Apparently this can be done by calling user32.dll.

 

Is there a better way?

 

Can this be done using Generate User Event without having to resort to calling Windows API?

 

 

 

0 Kudos
Message 1 of 17
(999 Views)
Highlighted

Yes, you can use user events to accomplish this. You could have the event case in your event structure service both the value change (button actually pressed) and the user event associated with this button.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 17
(994 Views)
Highlighted

Generating a user event is certainly an option, and not too difficult, although I have to ask - why not use an event triggered by the button anyway?

0 Kudos
Message 3 of 17
(991 Views)
Highlighted

 


@KathrynB wrote:

Generating a user event is certainly an option, and not too difficult, although I have to ask - why not use an event triggered by the button anyway?


 

I already have a Event Structure in place.

Right now, the user would have to click on the button.

I want to do that programmatically so that the user doesn't need to click the button.

0 Kudos
Message 4 of 17
(989 Views)
Highlighted

 


@KathrynB wrote:

Generating a user event is certainly an option, and not too difficult, although I have to ask - why not use an event triggered by the button anyway?


Using the user event allows you to do things programmatically. For instance, I may have an Exit button on the FP. There is code that needs to be executed when exiting the program and I may have parallel loops to stop. I can write all of that code and tie it to the Exit button. However I may have cases when I need to exit because of some condition I encountered when executing the code; a fatal error for example. I can generate the user event at that point which will then execute the normal exit routine. I don't have to duplicate code to handle the same functionality.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 17
(978 Views)
Highlighted

Mark,

 

I have been looking at the example programs, but I am not sure which one is most appropriate for my case.

 

Is there a specific one that I should be looking at?

 

 

 

0 Kudos
Message 6 of 17
(976 Views)
Highlighted
Solution
Accepted by topic author nyc_(is_out_of_here)

This is a sample application architecture I created in the past. It may not address your specific question but it does use the various techniques I suggested. Take a look at this and then ask any questions you may have.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 17
(972 Views)
Highlighted

I am trying to add the <Event Message>: User Event to my event structure, but all I am able to get is <My User Event>: User Event.

 

What am I missing?  I am using LV2010.

 

 

0 Kudos
Message 8 of 17
(966 Views)
Highlighted

You can use the Property Node with Val(Signaling) property to not only change the value of a control but also to have it trigger an event structure the same as if the control's value was changed on the front panel. Then you can have an Exit button with an event case and execute everything in the case programmatically as well as in response to an actual front panel event. The only caveat is that you can't use the Val (Signaling) property with a Boolean that has latching mechanical action. That is not a big deal, though, and you can reset the button yourself in the event case. See attached simple example that uses the Esc key to mimic a Stop button push.

0 Kudos
Message 9 of 17
(963 Views)
Highlighted

Thanks for the VI, Richard.

 

But it isn't quite what I am trying to do. Taking your VI, I want to add another button which when clicked would cause the VI to act as if the Stop button was clicked.

 

 

Edit:

Nevermind, it does work for what I want to do.

 

I'll have to look into Val(Signaling).

 

Thanks again.

 

 

 

0 Kudos
Message 10 of 17
(956 Views)