Send message to window
-
I want to send a key to a window. I used Global Hook and my code is like this : //In hook proc : if(nCode <0) CallNextHookEx(MyHook,nCode,wParam,lParam); hWndApp = CWnd::FindWindow(0,_T("Test")); if (hWndApp == NULL) MessageBox(NULL,L" Can't find the window", L"",0); hWndApp->SendMessage(WM_CHAR, 8, 0); //Backspace It can find the window but it can't send the message. Some one plz help me :rose:
-
I want to send a key to a window. I used Global Hook and my code is like this : //In hook proc : if(nCode <0) CallNextHookEx(MyHook,nCode,wParam,lParam); hWndApp = CWnd::FindWindow(0,_T("Test")); if (hWndApp == NULL) MessageBox(NULL,L" Can't find the window", L"",0); hWndApp->SendMessage(WM_CHAR, 8, 0); //Backspace It can find the window but it can't send the message. Some one plz help me :rose:
Why it cant send?
-
I want to send a key to a window. I used Global Hook and my code is like this : //In hook proc : if(nCode <0) CallNextHookEx(MyHook,nCode,wParam,lParam); hWndApp = CWnd::FindWindow(0,_T("Test")); if (hWndApp == NULL) MessageBox(NULL,L" Can't find the window", L"",0); hWndApp->SendMessage(WM_CHAR, 8, 0); //Backspace It can find the window but it can't send the message. Some one plz help me :rose:
I think you should should send: WM_KEYDOWN WM_CHAR WM_KEYUP
-@SuDhIrKuMaR@-
-
I want to send a key to a window. I used Global Hook and my code is like this : //In hook proc : if(nCode <0) CallNextHookEx(MyHook,nCode,wParam,lParam); hWndApp = CWnd::FindWindow(0,_T("Test")); if (hWndApp == NULL) MessageBox(NULL,L" Can't find the window", L"",0); hWndApp->SendMessage(WM_CHAR, 8, 0); //Backspace It can find the window but it can't send the message. Some one plz help me :rose:
see SendInput api of any use??
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
-
I want to send a key to a window. I used Global Hook and my code is like this : //In hook proc : if(nCode <0) CallNextHookEx(MyHook,nCode,wParam,lParam); hWndApp = CWnd::FindWindow(0,_T("Test")); if (hWndApp == NULL) MessageBox(NULL,L" Can't find the window", L"",0); hWndApp->SendMessage(WM_CHAR, 8, 0); //Backspace It can find the window but it can't send the message. Some one plz help me :rose:
If the target window is active, you can use
SendInput()
."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I think you should should send: WM_KEYDOWN WM_CHAR WM_KEYUP
-@SuDhIrKuMaR@-
-
If the target window is active, you can use
SendInput()
."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Could you show me an example of using SendInput to send a key to an active window plz ? I find it difficult to find a specific example :(
I found this using Google.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I found this using Google.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I found this using Google.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
If the target window is active, you can use
SendInput()
."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Plz help me one more time. I would like to know how to send WM_KEYUP by SendInput. When I send a key, it seems to be pressed forever ...
See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I've read many pages from the pages you gave me but I still can't find the answer :( They recommend to use SendMessage but it doesn't work with SendMessage...
Is the problem with sending or receiving? What does your code look like?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Is the problem with sending or receiving? What does your code look like?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
This is my code :
HWND windowHandle = ::FindWindow(0, _T("Test"));
INPUT *key;
::SetForegroundWindow(windowHandle);
key = new INPUT;
key->type = INPUT_KEYBOARD;
key->ki.wVk = VK_CONTROL;
key->ki.dwFlags = 0;
key->ki.time = 0;
key->ki.wScan = 0;
key->ki.dwExtraInfo = 0;
SendInput(1,key,sizeof(INPUT));
key->ki.dwExtraInfo = KEYEVENTF_KEYUP;
SendInput(1,key,sizeof(INPUT));::SendMessage(windowHandle,WM_KEYUP,0,0); //==> No effect ?
-
This is my code :
HWND windowHandle = ::FindWindow(0, _T("Test"));
INPUT *key;
::SetForegroundWindow(windowHandle);
key = new INPUT;
key->type = INPUT_KEYBOARD;
key->ki.wVk = VK_CONTROL;
key->ki.dwFlags = 0;
key->ki.time = 0;
key->ki.wScan = 0;
key->ki.dwExtraInfo = 0;
SendInput(1,key,sizeof(INPUT));
key->ki.dwExtraInfo = KEYEVENTF_KEYUP;
SendInput(1,key,sizeof(INPUT));::SendMessage(windowHandle,WM_KEYUP,0,0); //==> No effect ?
capint wrote:
::SendMessage(windowHandle,WM_KEYUP,0,0); //==> No effect ?
What does
SendMessage()
return?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne