As of right now, for testing purposes the code is just doing a SendKeys("%^a"), then another call to handle the password (after verifying it is the active window). There is no need to make sure it is the active window initially because the purpose of the hot key is to pop-up a GUI window to type the password for toggling security. This initial GUI window is what I cannot get to happen. With previous program I was using (MagicFolders), I had no problem doing the same thing, but this one seems to handle hot keys differently.
My guess was that there is something inherently different at the bit level between SendKeys and someone physically typing the characters. | [reply] |
There is no need to make sure it is the active window initially because the purpose of the hot key is to pop-up a GUI window...
That's incorrect I'm afraid.
My guess was that there is something inherently different at the bit level between SendKeys and someone physically typing the characters.
Yes there is. When you type the characters at the keyboard, they are placed on the system input queue, when you use SendKeys(), they are placed directly into the queue of the application that currently has the keyboard focus (the active window).
Roughly, the way hot-keys work, is the application registers the hotkeys with the system through one of several mechanisms that establishes a "hook" onto the system input queue. When the registered key sequence is seen by the hook, the characters are removed from the system input key and the hook routine for the registered application is called. Thus bypassing the active window.
When you use SendKeys(), the sequence bypasses the system input queue (and any registered handlers).
You might try using the SendRawKey() function that Win32::GuiTest exports. Failing that, you could try setting the desktop to be the active window something like:
# Remember who has the focus
# Maybe unnecessary.
my $hwndActive = GetActiveWindow();
## Give focus to the desktop to force the key sequence through the sys
+tem input queue
SetFocus( GetDesktopWindow() );
## Send the sequence
SendKeys( ... );
## Set the focus back to where it was...
SetFocus( $hwndActive );
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?
| [reply] [d/l] [select] |