I think putting in a delay may make this more reliable:

Dim myHotkey : Set myHotkey = Keyboard.RegisterHotkey("f2","ListenForKey")

sub listenforkey()
speak " listening for key input"
dim mykey : set mykey = keyboard.Capture()
Sleep 500
speak "the key pressed was " & mykey.name
end sub

This seems to work better.  Even if notepad is active, you might hear some of 
the document text, but then you will hear the captured key information.
Hope this helps,
Jeff Weiss

  ----- Original Message ----- 
  From: jeff weiss 
  To: [email protected] 
  Sent: Thursday, January 08, 2009 2:35 PM
  Subject: Re: capture key


  Try this: I changed the first line.

  Dim myHotkey : Set myHotkey = Keyboard.RegisterHotkey("f2","ListenForKey")

  sub listenforkey()
  speak " listening for key input"
  dim mykey : set mykey = keyboard.Capture()

  speak "the key pressed was " & mykey.name
  end sub


    ----- Original Message ----- 
    From: Juan Hernandez 
    To: [email protected] 
    Sent: Thursday, January 08, 2009 11:51 AM
    Subject: capture key


    Hi guys,

    so I'm trying to setup a method when I hit a key, like f2, to put 
window-eyes in a small wait period. and allow me to hit a letter on my 
keyboard, and perform a certain task, below is some really basic code.

    dim myreghotkey = set myreghotkey = 
keyboard.registerhotkey("f2","listenforkey",clientinformation.applicationprocess)
    sub listenforkey()
    speak " listening for key input"

    dim mykey : set mykey = keyboard.Capture()
    speak "the key pressed was " & mykey.name
    end sub


    when I hit f2 it says  listening for key input.  and I would assume that 
because I have the capture next, that it should take in my next key press?  
nothing happens, it doesn't speak the text that is in the sub.

    any ideas? I'm sure I'm doing something really stupid.

    Thanks.
      

    Juan Hernandez
    [email protected]
    858-699-2105

Reply via email to