PDA

View Full Version : How to get shift key state (up/down) in Lua?



NaTeDoGG
February 25th, 2004, 04:38 PM
Can anyone tell me how I can tell if the shift key is down?

Basically, I have a bunch of macros I want to run when I press CTRL + ALT + [some key]. The problem is that the macro runs as soon as I press the keys that trigger it, so the CTRL + ALT keys are still down and the macro malfunctions. I need to have the macro wait to execute until the keys that triggered it are released.

Thanks!

Promixis
February 25th, 2004, 09:31 PM
Interesting problem....

You might be able to find an ActiveX object to use to query the keyboard status.

You could also just wait a second or so before running the macro...

NaTeDoGG
February 26th, 2004, 03:13 PM
Yeah, but these macros are to perform quick actions. For example, I have to log in to a product I'm developing ALL the time and I get sick of typing:

Administrator[tab]password[enter]

So I have a macro to do that. I'm a big fan of using Windows shortcut keys to start my applications, so if I am still holding ctrl+alt by the time the macro starts, about 10 different applications open (ctrl+alt+A opens one, ctrl+alt+d opens another, etc). Having a delay still leaves this risk, and I'd want a small delay since most of these macros are meant to be quick and helpful.

Really I'm just starting to use Girder and want it to replace Perfect Keyboard (which has the wait-for-trigger-keys-to-be-released feature). I'd like to get the shortcut keys working exactly how I want, if only as an excerise to do more complicated tasks with Girder. Soon I'll integrate my PC with my HT.

Can you point me to a few links about using ActiveX controls with Girder, etc?

miked
February 27th, 2004, 12:14 PM
Natedogg, why does the macro malfunction? Is it because it tries to be started again and hasn't completed processing? If so, the anti-repeat setting in Girder may do the trick for you.

I also have to say that I don't think Girder is your best tool for simple keyboard macros . . . it's power really lies in remote control of applications and devices. You may want to check out www.hot-keyboard.com as an alternative for PK (and I guess this begs the question as to why you're ditching PK in the first place . . . . ).

NaTeDoGG
February 27th, 2004, 02:29 PM
PK starts a bunch of processes and has a larger footprint than Girder. But mostly I just want to use a single program for macro needs. Girder is going to control my HT through a UIRT, so I figure I'd like to use it for all my other needs as well. At first glance it seemed like it's Lua integration would allow me to write scripts to do everything I need. However, it seems more targetted at HT than I had hoped. It does seem close though, I wonder if more all purpose usage is a consideration with future developement? I saw a Girder 4.0 forum I guess I should take a look at. I don't see why Girder needs to be limited in any way for only remote control. I suppose it isn't considering that you can use C modules and ActiveX. I haven't dug into that yet, but it seems some of the functionality I need is pretty simple and could be built in. Ideally what I want is a scripting language for Windows automation, from interacting with UIRT to all my other automation needs. A GUI isn't really necessary.

Sorry if I went off on a rant just now. :wink:

Another reason I dislike PK is that it uses some quasi-XML as it's scripts. The scripts have a loosely defined structure that I find unintuitive. Why they didn't use XML is beyond me. The kicker is that you have to worry about where you place whitespace to keep it from being sent as key commands! I would much rather use a scripting language such as Lua.

The macro malfunctions because the CTRL + ALT keys are still down when it executes. This means that when the macro sends an A key, Windows sees CTRL + ALT + A, which is a hotkey I have assigned as a Windows shortcut to open Adobe Photoshop. I have Windows shortcuts for nearly all my programs, so when a macro types something like "Administrator" and the CTRL + ALT keys are still down, about 13 programs start up!

I'll check out HotKeyboard. Another program I've heard good things about is WinBatch. http://www.winbatch.com Though it is expensive. What I want is a Windows automation scripting language that interfaces with UIRT...

miked
February 27th, 2004, 08:10 PM
Interesting . . . I wouldn't really say that Girder is necessarily geared to HT . . . . although it's a great application for it. It's geared most to manipulating Windows applications in response to events.

That said, I think for what you want to do, that WinBatch is probably a good alternative to look at.

NaTeDoGG
March 3rd, 2004, 03:24 PM
The event is a keypress. The manipulation of a Windows application is sending keystrokes. What is so different here that you would recommend another program? That's why I said I felt it is more targetted at HT than I had hoped. I'd really like to use just one program for all my macro needs. I'd really like to be able to do everything (and more) that the Girder UI does, but through Lua script.

miked
March 3rd, 2004, 03:52 PM
Yeah, unfortunately, I do not know of any way within Girder to detect when a key is released, as opposed to first being pressed. Sorry. :(

NaTeDoGG
March 8th, 2004, 03:36 PM
Haven't had time to play with Girder proper yet but my UIRT came today so I will be doing that soon! :) You know, if I can put the keys I want to send on the clipboard and then send a paste message or emulate SHIFT + INSERT then I don't think that the CTRL + ALT keys still being down will matter. I would want to save what was on the clipboard and restore it after the macro is run. Any ideas on how to go about this? :)

miked
March 8th, 2004, 09:50 PM
Under the Girder tab there are "variable to clipboard" and "clipboard to variable" commands.

So, before you spill something to the clipboard, you can copy the clipboard to a variable (specified in the icon box), then copy a different variable to the clipboard, which contains the stuff you want to force, and then when you're all done, copy the first variable back to the clipboard to revert its contents.