0

I am dumping characters one by one of a script file path onto powershell console using SendMessage API.

At the first execution of program, powershell skips the repeated character from a path which creates an issue.

For e.g. "C:\myFolder\abbc\test.ps1"

From above path when I dump a characters onto powershell window, it skips 1 b from "abbc" so the final path that gets dumped on console is "C:\myFolder\abc\test.ps1".

This happens only first execution of application, on subsequent executions it works fine and accepts repeat characters as well.

Gvs13
  • 126
  • 12
  • Perhaps it's a problem with your program (which you do not show us)? Have you tried *debugging* it? – Some programmer dude Aug 03 '17 at 07:20
  • @Someprogrammerdude If there is any issue with my program then why would it work for next executions of the application. And by the way why will I hide the code, I am here to get the answer for the issue I am facing. – Gvs13 Aug 03 '17 at 07:22
  • @Gvs13 Are you serious? You are here for answer but don't want to show the code in question? So you are sure that there is no problem in your code!? And what do you expect from us? What can we tell you without seeing any code? – Werner Henze Aug 03 '17 at 07:45
  • @WernerHenze I dont understand what more you guys expect when there is nothing much or something important that I havent mentioned. – Gvs13 Aug 03 '17 at 07:54
  • for(int i = 0;scriptPath[i] != '\0';i++) { ::SendMessage(g_hwndConsole,WM_CHAR,scriptPath[i],1L); Sleep(3*1000); } Here g_hwndConsole is the powershell console handle 1. Launching powershell using CreateProcess API. 2. Dumping characters on powershell console using SendMsssage API (which I have already mentioned in a question.) – Gvs13 Aug 03 '17 at 08:02
  • @Gvs13 Please don't hide relevant code in the comments, please add it to the question. – Werner Henze Aug 03 '17 at 08:44

1 Answers1

0

SendMessage is not the right way to do it. You should use SendInput. See also how to use sendinput function C++ for more information.

Werner Henze
  • 16,404
  • 12
  • 44
  • 69