Guest User

Untitled

a guest
Jun 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public void LaunchRPGApp(Application program)
  2. {
  3. var processInfo = new ProcessStartInfo("pcsws.exe")
  4. {
  5. WindowStyle = ProcessWindowStyle.Normal,
  6. Arguments = ""C:\Program Files (x86)\IBM\Client Access\Emulator\Private\veflast1.ws"",
  7. RedirectStandardInput = true,
  8. UseShellExecute = false,
  9. };
  10. var process = Process.Start(processInfo);
  11. if (process == null) throw new Exception("Error starting process.");
  12. using (var sr = process.StandardInput)
  13. {
  14. sr.Write("f");//does nothing
  15. sr.Close();
  16. }
  17. }
  18.  
  19. [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
  20. public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
  21. [DllImport("User32.dll")]
  22. public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
  23. private void SendTextToProcess(Process p, string text)
  24. {
  25. const int WM_SETTEXT = 0x000C;
  26. const int WM_KEYDOWN = 0x0100;
  27. const int F_KEY = 0x46;
  28. Thread.Sleep(500);
  29. var child = FindWindowEx(p.MainWindowHandle, new IntPtr(0), "Edit", null);
  30. SendMessage(child, WM_KEYDOWN, F_KEY, null);//does nothing
  31. SendMessage(child, WM_SETTEXT, 0, text);//does nothing
  32. }
  33.  
  34. ProcessStartInfo startInfo = new ProcessStartInfo("pcsws.exe");
  35. startInfo.WindowStyle = ProcessWindowStyle.Normal;
  36.  
  37. startInfo.Arguments = "C:\Program Files (x86)\IBM\Client Access\Emulator\Private\veflast1.ws";
  38. Process.Start(startInfo);
Add Comment
Please, Sign In to add comment