Great, thanks. This made sense, and works nicely.

Now, let me just ask one more question, kind of in the same line, which I am 
not sure if it is possible, and in case, how to go about. Let's change the sub 
lines, a bit. Say that the script would count the numbers of Alt-Down arrows, 
that a user pressed, and replace them with Alt-Tab sequences. Guess I would 
have to do something like the following:

        Speak "You have pressed the hotkey "
  Keyboard.InsertKeyDown VK_Alt
  Keyboard.InsertKeyDown VK_Tab
  Keyboard.InsertKeyUp VK_Tab
        Count = Count +1
        Speak Count & ", "
  Keyboard.InsertKeyUp VK_Alt
        Speak " Times."

But, how do I know, if the user pressed the hotkey (Alt-Down arrow), 1, 2, or 
10 times. Is it possible to somehow hook on to the Alt-key, and 'keep 
counting', long as the hotkey is repeated? The speech output then would be like:

'You have pressed the hotkey 1, 2, 3, 4, times'

Thanks again!

  ----- Original Message -----
  From: Doug Geoffray
  To: [email protected]
  Sent: Tuesday, April 20, 2010 3:34 PM
  Subject: Re: Sending Alt-Tab in a script - doesn't work fully, why?


  David,

  Jared hit the nail on the head with this one.  But I just wanted to add that 
you could use the following method:

  Keyboard.InsertKeyDown vk_ALT
  Keyboard.InsertKeyDown vk_TAB
  Keyboard.InsertKeyUp vk_TAB
  Keyboard.InsertKeyDown vk_TAB
  Keyboard.InsertKeyUp vk_TAB
  Keyboard.InsertKeyUp vk_ALT

  This duplicates what you are really doing from the keyboard manually.  That 
being holding down the ALT and while keeping it down tapping the TAB twice and 
then letting go of ALT.

  Regards,
  Doug

  Jared Wright wrote:
    David, You are not pressing alt+Tab twice to get to document 3. You are 
holding alt and pressing tab twice. If you really pressed alt+tab, released it, 
you'd be in document 2. When you did it again, the first window it would take 
you to is the last one that previously had focus, which was document 1. Clear 
as mud?
    You might have more success iterating through the children of the desktop 
window for this rather than manually sending alt+tab keypresses.

    On 4/20/2010 8:18 AM, David wrote:
      One of my scripting projects, has to send a sequence of Alt-Tabs. To best 
reproduce my problem, here is what you can try.

      1. Use Script Framwork, and create a new script
      2. When asked to choose a hotkey, try setting it to Alt-Up arrow (this 
doesn't affect my probelm, but just to let you try it).
      3. After Framework ends, open the script in your editor, and go to the 
bottom of it, and make the last Sub read the following:

      Sub ForwardTab(myKeyId)
       'This routine is called when the hotkey Alt-Down is pressed.
       If Keyboard.KeyDescriberActive Then
        Speak myStrings(myKeyId & "_Description")
       Else
        'Main routine functionality goes here
        Speak "Forward. "
        Keyboard.InsertKey VK_Tab, KmAlt
        Keyboard.InsertKey VK_Tab, KmAlt
       End If
      End Sub


      4. Save your work, and load it in WE.
      5. Open three or four documents/windows on your system.
      5. Place yourself in Document1, and press the hotkey (alt-down arrow).
      6. The script is meant to send two Alt-Tab sequences, which would have 
put you into document3.

      But, here is my problem. What happens, is that the script switches to 
document2, then immediately throws you back to Document1. Sitting in Document1, 
and manually pressing Alt-Tab twice, I will pass by document2, and be left in 
document3. Why won't it work with the script? Due to a timing issue? Or, is 
there any other stuff going on? Would I have been better off, not using the 
Framework script, to initially create my script. That is, does the Framework 
insert any instructions, that could have been omitted here, and that would 
affect the behavior?

      Thanks alot, everyone!


--------------------------------------------------------------------------
      I am using the Free version of SPAMfighter.
      We are a community of 7 million users fighting spam.
      SPAMfighter has removed 1485 of my spam emails to date.
      The Professional version does not have this message.




--
I am using the free version of SPAMfighter.
We are a community of 7 million users fighting spam.
SPAMfighter has removed 1485 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

The Professional version does not have this message

Reply via email to