|
Yes it's not possible to specify a window as it's simulating keys at the lowest level. You would have to set the window as the foreground window.
Raymond talks about this. You can also read the comments for more good info.
http://blogs.msdn.com/oldnewthing/archive/2005/05/30/423202.aspx[^]
Using PostMessage with WM_KEYDOWN / WM_KEYUP / WM_SYSKEYDOWN / WM_SYSKEYUP (WM_CHAR is generated by the TranslateMessage function) might work with a number of applications though (there's that problem with key states though). You would have to test with all the applications you wish to send input to if you would like to still continue with this route.
-- modified at 6:49 Thursday 6th July, 2006
|
|
|
|
|
Meat Loaf wrote: endInput doesn't take Hwnd as a param so is it not possible to specify the window? and hence you said "The window must have focus" ?
then First SetFocus on window and then send Keyinput to that window. Is setting focus on That window incurred any problem?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I haven't tried that yet. There must be no problem in setting the focus. But still I'd try to do it with a sendMessage.
NULL
|
|
|
|
|
Meat Loaf wrote: I haven't tried that yet. There must be no problem in setting the focus. But still I'd try to do it with a sendMessage.
then Simulate KeyPress by sending WM_KEYDOWN and WM_KEYUP message one after another!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Re
|
|
|
|
|
hi,
Assuming m_pWnd is pointer to the window you want to send keys then use,
m_pWnd->SendMessage(WM_KEYDOWN,WPARAM(VK_DELETE),LPARAM(0x01530001));<br />
m_pWnd->SendMessage(WM_KEYUP,WPARAM(VK_DELETE),LPARAM(0xC1530001));
or
::SendMessage(hwnd,WM_KEYDOWN,WPARAM(VK_DELETE),LPARAM(0x01530001));<br />
::SendMessage(hwnd,WM_KEYUP,WPARAM(VK_DELETE),LPARAM(0xC1530001));
if this answers you then, vote for 5
|
|
|
|
|
Muhammad Azam wrote: ::SendMessage(hwnd,WM_KEYDOWN,WPARAM(VK_DELETE),LPARAM(0x01530001));
::SendMessage(hwnd,WM_KEYUP,WPARAM(VK_DELETE),LPARAM(0xC1530001));
What's being stored in LPARAM here? Can you explain a bit?
NULL
|
|
|
|
|
what If I'd do the try the same with VK_F1 ? should I change the LPARAM accordingly?
NULL
|
|
|
|
|
No I guess not, is it working with VK_F1?
|
|
|
|
|
ok here is your explaination
1. Run your Application,
2. run spy++ and set it to capture KeyBorad messages (using Finder tool).
3. Press F1 key (or what ever key you want to send).
4. analyze the Messages log window and double click on the message having WM_KEYDOWN and nVirtualKey:VK_F1 or WM_KEYUP and nVirtualKey:VK_F1 . Get LPARAM value from there.
you are done.
The LPARAM valur for F1 remains constant. no matter where you run your application and when you run it.
This way u can get LPARAM values for all your virtual key simulations,
infact LPARAM contains bit combinations for ScanCode,RepeatCout,AltDown, Extended Value for the WM_KeyDown event.
Thanks
Azam
|
|
|
|
|
Hey Still not working . SendInput is the way to go I guess
NULL
|
|
|
|
|
See my example here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks david. It looks good I'll try that.
NULL
|
|
|
|
|
i want to mage to make boarder as in dialog box in upper side
but i want to make this in lower side as in the windows xp and to put button on that.
plz tell me with example and detail as possible
Ashish Dogra
MCA
Noida
|
|
|
|
|
plz solve my problem
plz...................... nobody there to ans wer my question
virol can u
Ashish Dogra
MCA
Noida
-- modified at 6:38 Thursday 6th July, 2006
|
|
|
|
|
|
yar i simply ask question
that how can i put button on border of dialog box
and i want ti insert a border in the bottom of dialog box
this vc++ question
if there is any problem then i am sorry yar
but plz yar tell me some example .......
its important..............
Ashish Dogra
MCA
Noida
|
|
|
|
|
I think you asked this question yesterday,right?and i answered to you
whitesky
|
|
|
|
|
no answer yar
that was simply with yes option that you can do that
but i want some example or code for this plz ... solve the problem
Ashish Dogra
MCA
Noida
|
|
|
|
|
no body want to tell me
yar plz do answer my qeuestion
Ashish Dogra
MCA
Noida
-- modified at 7:42 Thursday 6th July, 2006
|
|
|
|
|
well, i think my post wasn't understood at its correct sense. here are the points i want to show :
1. Speak a proper english. Codeproject is an international forum where people from many coutries meet there, and most of them don't speak english as their mother tongue (so do i).
2. stop your SMS-ed post.
3. ask for a specific point ; don't expect anyone to do the job you cannot do yourself, just because you're too lazy to google a bit
4. have respect for the ones who are to answer you. no one owe you anything, ,simply because no one here is paid for helping. we do it at free time, for pleasure.
5. be patient. forums are cross by hundreds of valuable developers, but if no one understand the question, or if no one know the answer, it is commonly bad seen to spam the boards.
6. as i'm talking about spam, stop asking the same thing again and again. ask it once, clearly, and wait ! if you have to answer to a reply, the do it on the same thread. no need to start a new one, especially if it deal with the same topic.
now, at least, i hope you understand better what i meant.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
ok iam sorry ..................
Ashish Dogra
MCA
Noida
|
|
|
|
|
Could you pls stop these "plzzzz" or can you reduce the amount of "Plzzz" in your question. seems very awkward. I tried to mail you personally but your mail iD is not verified yet.
Please take this positively.
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
MAIL ME AT JUST_CHILL456@YAHOO.COM
Ashish Dogra
MCA
Noida
|
|
|
|
|
i'm having a problem linking my program to the library using Visual C++ 6.0/MFC an someone help me?
i went to Project-> Settings, selected "Link" pane, entered the path of where the Library is (Settings For : All Configurations)... but i still cannot link them together why is tat so? pls help me
Thanks
Best Regards
|
|
|
|
|
Maybe you have to specify the name of the library file in the Object/Library modules field too?
|
|
|
|