Hi Rick,
The location to get what you are looking for is under the key tree
inside the object model. You want to monitor one key event, or combination
of shift and Escape which is the key for escape and the modifier of a value
of 1.
Only during the OnKeyProcessedDown or OnKeyProcessedUp events do you
really want to do anything.
You can place a Queue inside a KeyDown event but why?
If you want to see if the window has changed, wait until the
OnKeyProcessedUp event just to make sure of 2 things, the screen has changed
and you have both the keys pressed you are looking for, and they are only
available after the key has been processed.
So just take out the treeview word in my example and do your thing.
Bruce
Sent: Friday, May 25, 2012 3:21 PM
Subject: Re: KeyProcessedUp and KeyProcessedDown Events
Hi Rick,
This is for the key processed up event and there is one for the key
processed down event.
Note, the warning inside the description of the key up process event or
the key up event, for the thing I told you about exists and mentioned there.
The key down and key up you should do nothing there but flag them if you
want but do nothing there!
Only do something during the process event for key down and up. The best
result is when the key is up, processed and you are away from any other
things going on by the shift escape actions you are monitoring.
My Example including declarations of variables/objects:
Dim myTV_KeyConnection, myTV_MouseConnection: myTV_KeyConnection = 0:
myTV_MouseConnection = 0
Function MainDialogProc(dObj, dEvent, dId, dControl)
' The main menu for the Trek program which does all setting changes.
' Below are all the events to watch to make any changes.
' First we must notify the event queue that no event processing has taken
place.
MainDialogProc = False
'Rick you can monitor just a key event and does not have to be a tree view
event:
' So a key down event:
If dEvent = treeviewKeyDown Then
TV_KeyDown = True
myTV_KeyConnection = ConnectEvent( Keyboard, "OnKeyProcessedUp",
"OnKeyProcessedUp")
End If
' A mouse click or button down:
If dEvent = treeviewClicked Then
TV_MouseDown = True
myTV_MouseConnection = ConnectEvent( Mouse, "OnButtonUp", "OnButtonUp")
End If
...
End Function
' Rick, this is the only time you can even tell if the key you are looking
for has been done:
' In other words the key data is not even ready until the process event:
Sub OnKeyProcessedUp( ky, md)
' Rick this is how you get rid of the event monitoring:
Disconnect myTV_KeyConnection
myTV_KeyConnection = 0
' Rick, this is now how you test if it was your escape key and not until
this event:
' Note that not until here do I do any Queue work:
If TV_KeyDown and ky = vk_Space and md = 0 Then
Silence
' Speak " Name Is: " & TV_Name & " Item " & TV_Data & " Whose Item Was
Space Barred "
If treeNamesDict.Exists( TV_Name) Then Speak treeNamesDict( TV_Name)
Queue "LaunchURLEmail"
End If
TV_KeyDown = False
End Sub
Sub OnButtonUp( button)
Disconnect myTV_MouseConnection
myTV_MouseConnection = 0
If TV_MouseDown and button = 0 Then
' Speak " Name Is: " & TV_Name & " Item " & TV_Data & " Whose Item Was
Mouse Clicked "
If treeNamesDict.Exists( TV_Name) Then Speak treeNamesDict( TV_Name), 2
Queue "LaunchURLEmail"
End If
TV_MouseDown = False
End Sub
Sent: Friday, May 25, 2012 2:40 PM
Subject: Re: KeyProcessedUp and KeyProcessedDown Events
Hi Steve:
I just want the normal things to happen when I click Shift-Escape to hide
the Solution Explorer Window.
WE does not recognize it has been hidden.
When I use Event Handlers to watch for the KeyProcessedDown and
keyProcessedUp events 2 things happen:
1) The normal processing does not take place, in other words, the screen
does not go dark and Solution Explorer seems to still have focus.
2) The KeyProcessedDown key handler fires but the following
KeyProcessedKeyUp does not fire.
Actually it fired in a test where I had acoding error and created multiple
copies of the handler but when coded correctly it does not appear to fire
and the normal processing of hiding Solution Explorer does not take place.
This is sounding more and more like a WE Problem Bruce had described in a
previous post.
so I will have to dig into his VBS solution to see if I can adapt it to my
external script for another test tomorrow or this weekend.
By the way, the ActiveWindow and FocusedWindow elements do not change after
the KeyDown event fires as I would expect from some testing in the WE
Immediate Window so something appears to be not allowing the normal
processing to take place when I use the KeyProcessedDown event handler which
does fire correctly on the Shift-Escape key press.
Anyway, I will have to download Bruces code base and go through it to see
what he did to get around this problem if I can.
Rick USA