6 Replies - 419 Views - Last Post: 26 September 2019 - 06:46 PM Rate Topic: -----

#1 ginocapo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-September 19

Help with TranslateMessage

Posted 26 September 2019 - 05:12 AM

Hi, can you help me to simulate a key press with TranslateMessage please?

I need to send a ENTER or any key to a external application but only with TranslateMessage api, any other doesnt work in that application.

thanks in advance
Is This A Good Question/Topic? 0
  • +

Replies To: Help with TranslateMessage

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15315
  • View blog
  • Posts: 61,414
  • Joined: 12-June 08

Re: Help with TranslateMessage

Posted 26 September 2019 - 05:48 AM

What have you tried, thought about, or considered?

Why TranslateMessage?
Was This Post Helpful? 0
  • +
  • -

#3 ginocapo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-September 19

Re: Help with TranslateMessage

Posted 26 September 2019 - 06:13 AM

I have tried with SendKeys.SendWait, SendKeys.Send, keybd_event, PostMessage, SendMessage, SendInput, and none worked. I read in a forum that TranslateMessage could work, but I dont know how to properly use to send a key.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15315
  • View blog
  • Posts: 61,414
  • Joined: 12-June 08

Re: Help with TranslateMessage

Posted 26 September 2019 - 06:20 AM

What's that link? This is lacking context.
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2956
  • View blog
  • Posts: 11,476
  • Joined: 03-December 12

Re: Help with TranslateMessage

Posted 26 September 2019 - 09:30 AM

Why do you need to send key presses to an external application to begin with?
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7105
  • View blog
  • Posts: 24,124
  • Joined: 05-May 12

Re: Help with TranslateMessage

Posted 26 September 2019 - 01:07 PM

View Postginocapo, on 26 September 2019 - 09:13 AM, said:

I have tried with SendKeys.SendWait, SendKeys.Send, keybd_event, PostMessage, SendMessage, SendInput, and none worked. I read in a forum that TranslateMessage could work, but I dont know how to properly use to send a key.

If those messages don't work, it's likely because they are running at a higher security context than your code is running at.

I have no idea why someone would think that TranslateMessage() would be able to do anything, especially since TranslateMessage() needs to be called from the context of the running program. So calling TranslateMessage() from your code is not going to (pardon the pun) translate to an action on the other program.

See documentation for TranslateMessage().

Also as a thought: If the other program you are trying to send keystrokes to is a game written for DirectX, then sending Windows messages won't do you any good. Some (if not most) DirectX games sample the keyboard directly for key state rather than depend on Windows messages.
Was This Post Helpful? 1
  • +
  • -

#7 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7105
  • View blog
  • Posts: 24,124
  • Joined: 05-May 12

Re: Help with TranslateMessage

Posted 26 September 2019 - 06:46 PM

Crossposted over in C# Forums.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1