|
-
Oct 11th, 2004, 06:56 AM
#1
Thread Starter
Fanatic Member
Keep focus while sending keys
What are some ways to retain focus on an application, while using the sendkeys statement?
The application has been started with an appactivate (appid).
-
Oct 11th, 2004, 07:32 AM
#2
Fanatic Member
Don't use sendkeys use sendmessage like this:
Private Const WM_IME_CHAR = &H286
mTargetHwnd = text1.hwnd
SendMessage mTargetHwnd, WM_IME_CHAR, Asc(sCharacter), 0
If you want to send Alts and Ctrl just use spy++ to monitor what is been sent to a test app.
Rob
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
-
Oct 12th, 2004, 05:07 PM
#3
Thread Starter
Fanatic Member
?
Yes, I am using Alt ie, %(f+x){Tab} etc.
Do I send the same string?
How will spy++ help me, or would I have to add alot of code?
-
Oct 13th, 2004, 03:24 AM
#4
Fanatic Member
If you need to send teh following:
CTRL + A
SendMessage mTargetHwnd, WM_CHAR, Asc(LCase$("A")) - 96, 0
A:
SendMessage mTargetHwnd, WM_IME_CHAR, Asc("A"), 0
Enter:
SendMessage mTargetHwnd, WM_CHAR, VK_RETURN, 0
Tab:
SendMessage mFormHwnd, WM_IME_KEYDOWN, VK_TAB, 0
Shift + Tab is a little more tricky:
SetForegroundWindow mFormHwnd
keybd_event VK_SHIFT, 0, 0, 0 'press shift
keybd_event VK_TAB, 0, 0, 0 'press tab
keybd_event VK_SHIFT, 0, 2, 0 'release shift
Spy ++ looks at what messages are sent to a window - almost everything you do can be done in either a sendmessage or a postmessage - with spy ++ you can see these messages and use the functions to send them yourself.
If the code needs too much changing you might aswell stay with sendkeys. Before each sendkeys statement do a SetForegroundWindow me.hwnd to stay focused.
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
-
Oct 13th, 2004, 04:59 AM
#5
Fanatic Member
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|