Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void Click()
        {
            Log.INFO(string.Format("Click ListBox:[{0}, {1}] win[{2}] ", _Text, _hWnd.ToString("X8"), _hWndWin.ToString("X8")));

            IntPtr text = Marshal.StringToCoTaskMemUni(_Text);

            WinAPI.SendMessage(_hWnd, (int)WinAPI.ListBoxMessages.LB_SELECTSTRING, (IntPtr)(-1), _Text);
            Marshal.FreeCoTaskMem(text);

            Thread.Sleep(2000);

            IntPtr parenthWnd = WinAPI.GetWindowLongPtr(_hWnd, (int)WinAPI.GWL.GWL_HWNDPARENT);
            IntPtr nID        = WinAPI.GetWindowLongPtr(_hWnd, (int)WinAPI.GWL.GWL_ID);
            int    ctrl_id    = nID.ToInt32();

            WinAPI.PostMessage(parenthWnd, (int)WinAPI.WMMessage.WM_COMMAND, (IntPtr)WinAPI.MakeWParam(ctrl_id, (int)WinAPI.ListBoxMessages.LBN_SELCHANGE), _hWnd);


            //WinAPI.LVITEM lvi = new WinAPI.LVITEM();
            //lvi.stateMask = (uint)WinAPI.LVITEM.STATE.LVIS_SELECTED;
            //lvi.state = (uint)WinAPI.LVITEM.STATE.LVIS_SELECTED;

            //IntPtr ptrLvi = Marshal.AllocHGlobal(Marshal.SizeOf(lvi));
            //Marshal.StructureToPtr(lvi, ptrLvi, false);

            //int rowId = (int)_param;
            //WinAPI.SendMessage(_hWnd, (int)WinAPI.ListBoxMessages.LB_SETCURSEL, new IntPtr(rowId), ptrLvi);
        }
Exemplo n.º 3
0
        internal void Click()
        {
            Log.INFO(string.Format("Click Toolbar Button:[{0}]", _Text));

            int param = (int)_param;

            WinAPI.PostMessage(_hWnd, (int)WinAPI.WMMessage.WM_COMMAND, (IntPtr)param, (IntPtr)0);
        }
Exemplo n.º 4
0
        public void Click()
        {
            if (parent != null)
            {
                parent.Click();
            }

            if (_uID == UInt32.MaxValue)
            {
                return;
            }

            Log.INFO(string.Format("Click Menu:[{0}, {1}], hWnd[{2}]", _Text, _uID, _hWndWin.ToString("X8")));
            WinAPI.PostMessage(_hWndWin, (int)WinAPI.WMMessage.WM_COMMAND, (IntPtr)_uID, IntPtr.Zero);
        }
Exemplo n.º 5
0
        public void Select(string value)
        {
            Log.INFO(string.Format("Select ComboBox:[{0}] value:[{1}] Win:[{2}]", _Text, value, _hWndWin.ToString("X8")));

            IntPtr text = Marshal.StringToCoTaskMemUni(value);

            WinAPI.SendMessage(_hWnd, (int)WinAPI.ComboBoxMessage.CB_SELECTSTRING, (IntPtr)(-1), value);
            Marshal.FreeCoTaskMem(text);

            Thread.Sleep(2000);

            IntPtr parenthWnd = WinAPI.GetWindowLongPtr(_hWnd, (int)WinAPI.GWL.GWL_HWNDPARENT);
            IntPtr nID        = WinAPI.GetWindowLongPtr(_hWnd, (int)WinAPI.GWL.GWL_ID);
            int    ctrl_id    = nID.ToInt32();

            WinAPI.PostMessage(parenthWnd, (int)WinAPI.WMMessage.WM_COMMAND, (IntPtr)WinAPI.MakeWParam(ctrl_id, (int)WinAPI.ComboBoxMessage.CBN_SELCHANGE), _hWnd);
        }
Exemplo n.º 6
0
        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
        }