0

我创建了在 Windows VM 上运行的应用程序(KeySimulator)。此应用程序正在向另一个应用程序 (DraftSight) 发送一个“ENTER”键。DraftSight 在同一个 VM 上运行。我的应用程序的缅因州目的是选择 DraftSight 并单击“ENTER”,以防万一在 DraftSight 上弹出任何消息。一切正常,除了我的应用程序有时无法识别 DS 应用程序。我的应用程序 24/7 全天候运行,我有一个任务可以在登录时启动我的应用程序,或者如果我的应用程序没有运行。这是我的该功能的代码:

[DllImport("USER32.DLL", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hWnd);

IntPtr draftSightHandle = FindWindow("Qt5QWindowIcon", null);

SetForegroundWindow(draftSightHandle);

常量 UInt32 WM_KEYDOWN = 0x0100; PostMessage(draftSightHandle, WM_KEYDOWN, (int)Keys.Enter, 0);

4

0 回答 0