Jump to content
Xtreme .Net Talk

SendMessage for keystroke is not working


Recommended Posts

Guest poirepoisson
Posted

Hi all

 

 

 

could you please tell me why this code does not work? It should simulate the pression of TAB and then arrow DOWN, but nothing happens. I´m sure I have the right handle to the window, because I can click with the mouse on some of its buttons.

 

 

 

SetForegroundWindow(hwndWindow);

 

SetActiveWindow(hwndWindow);

 

SetFocus(hwndWindow);

 

 

SendMessage(hwndWindow, WM_SETFOCUS, VK_TAB, 0); //tried also without

 

SendMessage(hwndWindow, WM_SETFOCUS, VK_TAB, 0); //these 2 messages

 

Sleep(500);

 

SendMessage(hwndWindow, WM_KEYDOWN, VK_TAB, 0);

 

SendMessage(hwndWindow, WM_KEYUP, VK_TAB, 0);

 

Sleep(1000);

 

SendMessage(hwndWindow, WM_KEYDOWN, VK_DOWN, 0);

 

SendMessage(hwndWindow, WM_KEYUP, VK_DOWN, 0);

 

 

 

 

Many thanks in advance

 

 

 

Fede

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...