public bool SendMessageToButton(string buttonName) { IntPtr mainHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; //IntPtr controlBarHandle = IntPtr.Zero; IntPtr buttonHandle = IntPtr.Zero; //for (int i = 0; i < 30; i++) { //#if Revit2017 // controlBarHandle = FindWindowEx(mainHandle, controlBarHandle, "Afx:ControlBar:347d0000:8:10003:10", null); //#else // controlBarHandle = FindWindowEx(mainHandle, controlBarHandle, "Afx:ControlBar:40000000:8:10003:10", null); //#endif //if (controlBarHandle == IntPtr.Zero) continue; //else { //buttonHandle = FindWindowEx(controlBarHandle, "Button", buttonName, true); IntPtr titleWIntPtr = new CWndManager().SearchByTitle(mainHandle, buttonName); buttonHandle = titleWIntPtr; //if (buttonHandle == IntPtr.Zero) continue; //else { SendMessage(buttonHandle, 0x201, (IntPtr)1, null); SendMessage(buttonHandle, 0x202, (IntPtr)1, null); //break; } } } return(true); }
public ComboxHandle(string titleParent) { IntPtr mainHandle = Process.GetCurrentProcess().MainWindowHandle; this.mng = new CWndManager(); this.data = new List <string>(); IntPtr ptr = this.mng.SearchByTitle(mainHandle, titleParent); if (ptr != IntPtr.Zero) { //父窗口id m_parentHandle = ptr; // IntPtr ptrComb = this.mng.SearchComboBox(ptr); if (ptrComb != IntPtr.Zero) { this.handle = ptrComb; string[] arritem = null; this.mng.GetComboBoxItemAll(ptrComb, ref arritem); foreach (string s in arritem) { this.data.Add(s); } } } }
/// <summary> /// <remarks>修改:郑海盛</remarks> /// 一个标题线有多相同控件根据索引获取 /// </summary> /// <param name="handlTitle"></param> /// <param name="index"></param> public CheckBoxHandle(string handleTitle, int index) { IntPtr mainHandle = Process.GetCurrentProcess().MainWindowHandle; this.mng = new CWndManager(); IntPtr ptr = this.mng.SearchByTitle(mainHandle, handleTitle); if (ptr != IntPtr.Zero) { this.handle = mng.SearchCheckBox(ptr, index); } }
public TextBoxHandle(string handlTitle) { IntPtr mainHandle = Process.GetCurrentProcess().MainWindowHandle; this.mng = new CWndManager(); IntPtr ptr = this.mng.SearchByTitle(mainHandle, handlTitle); if (ptr != IntPtr.Zero) { ParentHandle = ptr; this.handle = this.mng.SearchEditBox(ptr); } }
public bool IsButtonExit(string buttonName) { IntPtr mainHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; IntPtr buttonHandle = IntPtr.Zero; buttonHandle = new CWndManager().SearchByTitle(mainHandle, "完成"); if (buttonHandle == IntPtr.Zero) { return(false); } else { return(true); } }
/// <summary> /// 添加多个同名父对话框下的控件搜索 /// </summary> /// <param name="titleParent">父类对话框控件的title</param> /// <param name="indexParent">同名对话框的序号</param> /// <param name="indexChild">对话框下控件的序号</param> public TextBoxHandle(string titleParent, int indexParent, int indexChild) { IntPtr mainHandle = Process.GetCurrentProcess().MainWindowHandle; this.mng = new CWndManager(); IntPtr ptr = this.mng.SearchDialog(mainHandle, titleParent, indexParent); if (ptr != IntPtr.Zero) { IntPtr ptrComb = this.mng.SearchEditBox(ptr, indexChild); if (ptrComb != IntPtr.Zero) { ParentHandle = ptr; this.handle = ptrComb; } } }