Jump to content

control a vi from another vi with event


Recommended Posts

Hi Nicola, just to make sure I understand this correctly, you want two VIs with the following functions:

VI1: Is (part of) the UI.

VI2: Is a keylogger. It gets some reference to VI1 and then log any keystrokes that VI1 receives.

 

Please see the attached files. Run KeyLogger.VI, which will launch VI1.vi and register for its keystrokes.

KeyLogger.vi

VI1.vi

Link to comment

Here are the VIs saved for 2009.

Please note that this is just a quick example to show the functionality, which is why the KeyLogger is launching VI1 (and is only displaying the keystrokes and not logging them). For your real KeyLogger, you will need to use some methods to find out which VIs are in memory and open references to them (may be register for events if the FP is open). You could use "Application:All VIs in Memory" property every now and then to see if new VIs have been launched.

KeyLogger.vi

VI1.vi

Link to comment

Thank you.

The example is ok. I have another question related: is it possible to have a vi running always on top, type on that and that vi send the events to the desired vi. Something like on-screen-keyboard with the keyboard focused that send the button pressure (corresponding to a keyboard keystroke) to a desired vi running?

I'm not sure I said it in the right way.

Link to comment

Sure.

One way to do this is by using user events. So the VI with the on screen keyboard creates a user event that any other VI can register for. The keyboard VI will get the user input by looking for value change on the keyboard buttons. If the user uses the physical keyboard, you could use the key down event to read the key stroke (and briefly depress the corresponding key on your virtual keyboard). In either case, since you know which key the user intended to press, you can fire the user event with the details. Any other VI can register for and get this user event.

Link to comment
  • 2 weeks later...
  • 1 month later...

1) "Create User Event"

2) Make that event (the wire) available to all the VIs that will generate it or respond to it.

3) For each VI that should respond to it, "Register for Events". Only wire that event ref to one event structure (ES). Other ES can register for the event, too.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.