public void SetCheckFlag(bool isChecked) { while (!WinAPI.IsWindowEnabled(_hWnd)) { Thread.Sleep(200); } Log.INFO(string.Format("Set Checkbox:[{0}], value{1}, hWnd[{2},{3}]", _Text, isChecked, _hWnd.ToString("X8"), _hWndWin.ToString("X8"))); WinAPI.SetActiveWindow(_hWndWin); WinAPI.SetFocus(_hWnd); IntPtr lparam = IntPtr.Zero; if (isChecked) { lparam = (IntPtr)0; } else { lparam = (IntPtr)1; } WinAPI.PostMessage(_hWnd, (int)WinAPI.ButtonMessages.BM_SETCHECK, lparam, (IntPtr)0); Thread.Sleep(1000); }
public void Click(int time = 1000) { while (!WinAPI.IsWindowEnabled(_hWnd)) { Thread.Sleep(200); } Log.INFO(string.Format("Click Button:[{0}], hWnd[{1},{2}]", _Text, _hWnd.ToString("X8"), _hWndWin.ToString("X8"))); WinAPI.SetActiveWindow(_hWndWin); WinAPI.SetFocus(_hWnd); //WinAPI.SendMessage(_hWnd, (int)WinAPI.ButtonMessages.BM_CLICK, (IntPtr)0, (IntPtr)0); WinAPI.PostMessage(_hWnd, (int)WinAPI.WMMessage.WM_LBUTTONDOWN, (IntPtr)1, (IntPtr)0); WinAPI.PostMessage(_hWnd, (int)WinAPI.WMMessage.WM_LBUTTONUP, (IntPtr)1, (IntPtr)0); Thread.Sleep(time); //WinAPI.PostMessage }