Jump to content

Diagram shortcuts


Recommended Posts

In the meanwhile I wrote a simple tool for speeding up coding in LabVIEW.

I was little bit frustrated by searching for frequently used blocks again and again in palletes. Some time ago I worked with application with console input (like AutoCAD) where I was able to create macros for any command sequence. I created a set of macros giving them very short names and then I was able to call them just typing 2-, 3-keystrokes commands (I had to press enter each time). So here is my try to reproduce such functionality in LV.

This VI is running in background monitoring all key presses. It looks only for commands preceded with "~" key (without shift) - to distinguish from normal typing. Commands may consist of alphanumeric characters only and may not be longer than 10 characters (not case sensitive). Commands are defined in _definitions.vi file. The only item in this file should be a case structure with separate frame for each command (name of the frame is the command itself). Frames may conatin whatever you want - it will be put into block diagram after typing a command. I predefined four commands: ADD, MIN, MUL and DIV (I guess that these shortcuts are descriptive enough :) )

So run VI, bring up the block diagram you work on and type "`add" ("`" is same key as "~", or at least should be - don't use shift while typing) and appropriate block will appear in the diagram at the cursor position.

I used Windows DLL for catching the keys, so it will not work on Linux - I don't know whether sth similar is possible on Linux

Known issues:

  • error handling is not perfect - partially because I wanted to keep the code clear, at least in this stage. Strange things may happen if you type the correct command when the topmost window is not block diagram in edit mode.
  • when cursor is outside the window during typing, block will appear in hidden area
  • when cursor points inside any structure (i.e. For Loop) block will appear "over" it (with a shadow) - so you have to drag it a little to drop it into the structure
  • blocks are put using ordinary copy and paste, so the clipboard may be overwritten (I did not found any better and working method)
  • very, very fast typing may not work - it is because I didn't want to scan keybord too frequent
  • if you will type sth very, very quickly after a command (or click a mouse), additional block copy appears

So please test it and let me know whether is is useful for you.

Link to comment

I see that you are determined to make different versions of all the tools I'm creating :laugh: . Here's my version, although I haven't been working on it very intensively. If you want, I could use some help with that one. It works well, but I need to work on the part of easily creating and transferring the names between computers and versions. I would suggest you read at least the end of the thread to get an idea of its current status.

As mentioned in that thread, the original idea came from a prototype demonstrated by an NI employee, so NI are also working on their own version of this.

By the way, I didn't manage to use it. The DLL call simply returns 0 all the time. It might be because I'm using a bilingual keyboard, but I doubt it, since I could type the char. Explicitly pointing it to user32.dll didn't help either.

Link to comment

QUOTE(Yen @ Feb 25 2008, 09:32 PM)

In fact, interesting coincidece... What else do you work on? ;)

QUOTE(Yen @ Feb 25 2008, 09:32 PM)

By the way, I didn't manage to use it. The DLL call simply returns 0 all the time. It might be because I'm using a bilingual keyboard, but I doubt it, since I could type the char. Explicitly pointing it to user32.dll didn't help either.

Using attached VI You can test how this function in user32.dll works with your keybord. Or even better press the key you want to use as a prefix, notice number that appears and enter it to a constant on the left side of top loop (marked with arrow).

Link to comment

By the way, you can use the input device VIs to monitor for keystrokes in a platform indepedent way. They even recognize the grave key in my keyboard. :)

You might also want to use a popup dialog which is ended with an Enter keystroke, since it's a bit more user-friendly.

Link to comment

QUOTE(Yen @ Feb 28 2008, 08:00 PM)

By the way, you can use the input device VIs to monitor for keystrokes in a platform indepedent way. They even recognize the grave key in my keyboard. :)

I verified this method, but it captures key presses, not releases. When I implemented key release using this VI, the tool takes 90% of processor time while typing... On the other hand it's multiplatform...

QUOTE

You might also want to use a popup dialog which is ended with an Enter keystroke, since it's a bit more user-friendly.

It would be too similar to your solution then... :unsure:

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
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.