vugie Posted February 26, 2008 Report Share Posted February 26, 2008 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. Quote Link to comment
Yair Posted February 26, 2008 Report Share Posted February 26, 2008 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. Quote Link to comment
vugie Posted February 27, 2008 Author Report Share Posted February 27, 2008 QUOTE(Yen @ Feb 25 2008, 09:32 PM) I see that you are determined to make different versions of all the tools I'm creating :laugh: . 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). Quote Link to comment
LAVA 1.0 Content Posted February 27, 2008 Report Share Posted February 27, 2008 WOW ! That's really cool ! I've beeen dreaming of this and you made it. Even if I use it everyday, the IMAQ function palette is a maze for me, and the palette search tool doesn't really help me. I love this tool ! Nice coding style by the way Dziękuję bardzo ! Quote Link to comment
Yair Posted February 27, 2008 Report Share Posted February 27, 2008 QUOTE(vugie @ Feb 26 2008, 11:02 AM) In fact, interesting coincidece... What else do you work on? Nothing, why do you ask? :ninja: QUOTE Using attached VI You can test how this function in user32.dll works with your keybord. O.K., it just ignores that specific key. It seems to be happy with others. I guess I'll have to blame it on my OS language settings. By the way, for doing "macros", you can also use http://forums.ni.com/ni/board/message?board.id=170&message.id=237642' target="_blank">merge VIs. Quote Link to comment
Yair Posted February 29, 2008 Report Share Posted February 29, 2008 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. Quote Link to comment
vugie Posted March 1, 2008 Author Report Share Posted March 1, 2008 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... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.