public static void CommandWithClick(string wndClass, int width, int height, double xFactor, double yFactor) { WndFinder wf = new WndFinder(); IntPtr hWnd = wf.GetWindow(wndClass); if (hWnd != IntPtr.Zero) { SetWindowPos(hWnd, /*HWND_TOPMOST*/(IntPtr)(-1), 0, 0, width, height, SetWindowPosFlags.ShowWindow); int x = (int)(width * xFactor); int y = (int)(height * yFactor); MouseLeftClick(x, y); } }
public static void ActivateMenuItem(string mainWndClass, int menuItemNum, int menuSubItemNum) { IntPtr hWnd = new WndFinder().GetWindow(mainWndClass); IntPtr hMenu = GetSubMenu(GetMenu(hWnd), menuItemNum); SendMessage(hWnd, WM_INITMENU, (int)hMenu, 0); SendMessage(hWnd, WM_INITMENUPOPUP, (int)hMenu, 0); SendMessage(hWnd, WM_COMMAND, GetMenuItemID(hMenu, menuSubItemNum), 0); }