public static void SendAltKey(IntPtr mainWindowHandle) { int result = NativeAPI.PostMessage(mainWindowHandle, NativeAPI.WM_SYSKEYDOWN, 0x12, (IntPtr)0x20380001); Thread.Sleep(200); result = NativeAPI.PostMessage(mainWindowHandle, NativeAPI.WM_SYSKEYUP, 0x12, (IntPtr)0xC0380001); }
public static void SendF10Key(IntPtr mainWindowHandle) { int result = NativeAPI.PostMessage(mainWindowHandle, NativeAPI.WM_SYSKEYDOWN, NativeAPI.VK_F10, IntPtr.Zero); Thread.Sleep(200); result = NativeAPI.PostMessage(mainWindowHandle, NativeAPI.WM_SYSKEYUP, NativeAPI.VK_F10, IntPtr.Zero); }
public static void FileSave(IntPtr appHwnd, string fileName) { NativeAPI.PostMessage(appHwnd, NativeAPI.WM_COMMAND, 4, IntPtr.Zero); Thread.Sleep(1000); var tmpWndClass = "#32770"; var tmpHwnd = NativeAPI.FindWindowEx(IntPtr.Zero, IntPtr.Zero, tmpWndClass, null); var dlgOpenHwnd = tmpHwnd; tmpWndClass = "ComboBoxEx32"; tmpHwnd = NativeAPI.FindWindowEx(tmpHwnd, IntPtr.Zero, tmpWndClass, null); tmpWndClass = "ComboBox"; var fileNameEditHwnd = NativeAPI.FindWindowEx(tmpHwnd, IntPtr.Zero, tmpWndClass, null); tmpWndClass = "Edit"; fileNameEditHwnd = NativeAPI.FindWindowEx(fileNameEditHwnd, IntPtr.Zero, tmpWndClass, null); AppAutomationHelper.SendText(fileNameEditHwnd, fileName); Thread.Sleep(100); NativeAPI.SendMessage(dlgOpenHwnd, NativeAPI.WM_COMMAND, 1, IntPtr.Zero); }