Hi Rick,

    As I had sent you a threading issue, what you are seeing is all about 
timing and who is getting in first. Also as Chip had pointed out, by the time 
the second event has happened, are we out of scope? Has everything changed? All 
when the second event comes along in the Queue, for you are looking at 2 events 
coming back, not one and the second one never gets time to show up.

    It could all be a scope issue, or you need to find a way to monitor the 
event queue beyond the time it takes to process the synchronous keyboard events 
since those events are not asynchronous; at least when not using the WMI 
ascronous that is blocked in UI systems, at least in the WE Object model.
    As pointed out in my reading, you may have to use 2 different threads to 
see both events and that may fix the problem, for it warns you of using the 
same thread for 2 different events...
    So, if you can make 2 different models, monitor each from a separate 
process and I bet you have solved your problem.

        Bruce

  Sent: Friday, June 22, 2012 7:35 AM
  Subject: OnKeyUp OnKeyDown problem clue perhaps


  Hi again Guys:
  I went back to Aaron's original sample to start from a solid base.
  I just flipped the AddHandlers and found that makes a diference in which 
handler function in my script gets executed and which is not executed.
  I define a keyboard object as follows in the global module:
  Public WithEvents myKeyboard As WindowEyes.Keyboard
  myKeyBoard = weApplication.KeyBoard
  Then if I add the handlers in the following order:
  AddHandler myKeyboard.OnKeyUp, AddressOf OnKeyUpHandler
  AddHandler myKeyboard.OnKeyDown, AddressOf OnKeyDownHandler
  Only The OnKeyUpHandler function in my script gets executed every time I hit 
a key.
  But, if in the following order:
  AddHandler myKeyboard.OnKeyDown, AddressOf OnKeyDownHandler
  AddHandler myKeyboard.OnKeyUp, AddressOf OnKeyUpHandler
  only the OnKeyDownHandler function in my script gets executed.
  note that both the OnKeyUp and OnKeyDown events fire when viewing WEEvent but 
no MSAA or other Window events seem to be getting through which would affect 
the OnKeyUp and OnKeyDown events in the underlying vb.net 2010 express 
application.
  The fact that only the first added handler fires in my script tells me 
something, not sure what exactly.
  If there was an error at compile time I should get a message but no messages, 
if an error at runtime there should be an error or the error handling within 
the Try Catch block should get executed but it is not recording an error either.
  So the first AddHandler statement is ok, at least for making my script 
receive the event but the second AddHandler just doesnt work.
  I'll have to think on this and let me know if you have run into anything like 
this in the past - this is a new one to me.
  Rick USA

Reply via email to