예제 #1
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);
        }
예제 #2
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);
        }