I am trying to figure out how to send a WM_SYSKEYUP using sendmessage of the
winextensions. Here is my code:
cmd = '0105'x
wParam = reverse('00000012'x)
lParam = reverse('c0380001'x)
I have a monitor to trap keystokes and nothing appears when I do the above.
The sendkeyup function does work but I want to be able to use the sendmessage
Does anyone have an example of using sendmessage?
You're not going to be able to get that to work.
Keyboard event messages are handled differently by the OS than most other
window messages. For one thing, they have to be posted to a window, not sent.
The sendMessage() method will not post a message, as the name implies it uses
the SendMessage() API. So, it's just not going to work. <grin>
The sendKeyXXX methods in winsystm.cls are specially written to take into
account the differences between key event messages and other types of window
OK thanks Mark.
There also seems to be timing issue using the other sendkey functions. On some
very fast CPUs the messages seem to get out of order. I tried issuing a
SysSleep between the keystrokes which helps but not sure what value will work
for all CPUs. Have you had any luck doing this or know of someone who has come
up some code to do this?
(Hope I remembered your name correctly.)
As a matter of fact I had run into that problem when I was rewriting some of
the examples. Note sure what version of ooRexx your are on, but if it is at
least ooRexx 4.0.0 then in the samples directory for winsystm you will have
In there I have a routine: sendTextWithPause() along with some comment. I used
that to deal with text getting out of order in the examples when I ran them on
one of my fast systems.
It basically does what you are doing with SysSleep, maybe in a more structured
way. It works correctly on all the systems I tested on, which included a
couple of very fast systems. There is still no guarentee it will work on all
CPUs, but it probably will.
The whole thing comes down to what I mentioned above, key events need to be
posted to the message queue. When a message is posted, the function returns
immediately, so messages can end up arriving in the message queue in a
different order. Sleeping a small amount is enough, when you are using sendKey
from the same program, to synchronize things, I think.
Yes thanks I'm at 4.1.0 and had looked at that routine. What i'm having
trouble with is trying to send a CTRL+ALT+S to Google earth. I have another
program that sends keystrokes to a window and what it sends is:
Any idea how to do that with the oorexx functions?
BTW: you can get that other program here:
A interesting topic. I spent a little time this weekend looking into it.
From comment in the C implementation code, this should be the way to do
First get a WindowObject for the opened Google Earth. Then use the send key
methods in this fashion:
j = SysSleep(.1)
wnd = windowMgr~find("Google Earth")
if wnd~class == .WindowObject then leave
VK_CONTROL = 17
VK_MENU = 18
VK_S = 83
if wnd~class == .WindowObject then do
say 'Got Google Earth'
Unfortunately, the above doesn't work. A similar thing to send Ctrl-L, which
should be simplier and more likely to work is:
That doesn't work either.
The existing code in the winsystm.cls implementation uses an out-dated API
that Microsoft advises not to use. So I wrote some code using the modern API
just to see if it would work or not. And it does work.
I put that together in a small external libray package, which you could
download and use if you like. Go to this spot on SourceForge:
Well, SourceForge seems to be having trouble now. I post tomorrow on how to
get the package. But for now, I include a small test app and this is what its
code looks like:
VK_L = 76
-- Try to find an open Google Earth window.
googleWindow = .WindowRexx~findWindow("Google Earth")
if googleWindow~class == .WindowRexx then leave
-- If we found the window, send Ctrl-Alt-S to it, otherwise abort.
if googleWindow~class == .WindowRexx then do
say 'Got dialog window'
-- You can also try sending Ctrl-L by switching the two lines:
ret = googleWindow~sendKeyPress(VK_S, .array~of(VK_CONTROL, VK_MENU))
--ret = googleWindow~sendKeyPress(VK_L, .array~of(VK_CONTROL))
say 'Got ret:' ret
say "Failed to find Google Earth, aborting"
As you can see from the above the package name is windowRexx.frm.
My intent is to move the fixed code in .WindowRexx, into the .Window class of
ooDialog so that it will make it into a release.
Thanks for all the work Mark. Waiting for your package to try it out.
Log in to post a comment.