Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Sending Keystroke To particular window of other application

Sending Keystroke To particular window of other application

Scheduled Pinned Locked Moved C#
csharpdata-structuresjsontutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sandeep Kalra
    wrote on last edited by
    #1

    Hi All I want to send a Keystroke to the window of other application. I have got the Handle of that window. Is there any API or Managed C# code which will directly send the Keystroke only to that window. setting the window to foreground and then sending the keystroke is working fine.But in the meantime if the user click on other window that window becomes active and the keystrokes are send to that window not to that window for which it was meant. I have also studied about SendMessage Api SendMessage Function Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message. To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function. Syntax LRESULT SendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); But i do not know how to put Keystrokes input into msg variable Does anybody know how to send only to particular window? Thanks in advance THE SK (Sandeep Kalra) I am the One

    S 1 Reply Last reply
    0
    • S Sandeep Kalra

      Hi All I want to send a Keystroke to the window of other application. I have got the Handle of that window. Is there any API or Managed C# code which will directly send the Keystroke only to that window. setting the window to foreground and then sending the keystroke is working fine.But in the meantime if the user click on other window that window becomes active and the keystrokes are send to that window not to that window for which it was meant. I have also studied about SendMessage Api SendMessage Function Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message. To send a message and return immediately, use the SendMessageCallback or SendNotifyMessage function. To post a message to a thread's message queue and return immediately, use the PostMessage or PostThreadMessage function. Syntax LRESULT SendMessage( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ); But i do not know how to put Keystrokes input into msg variable Does anybody know how to send only to particular window? Thanks in advance THE SK (Sandeep Kalra) I am the One

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      hWnd is the handle of the window that you want to receive the message. This is explained in the MSDN sendmessage [^] docs. The message you want to send is probably WM_KEYDOWN and then WM_KEYUP. (You can find a full list of the messages and their numbers here[^]) Look here[^] for an explanation of the WM_KEYDOWN message, and what to put in the wParam and lParam parameters. You can use google to find a similar doc page for the WM_KEYUP message.

      Simon

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups