public IEAccessible(IntPtr ieHandle, string tabCaptionToActivate) { TabFound = false; IEAccessible ieDirectUIHWND = new IEAccessible(ieHandle); foreach (IEAccessible accessor in ieDirectUIHWND.Children) { foreach (IEAccessible child in accessor.Children) { foreach (IEAccessible tab in child.Children) { if (tab.Name == tabCaptionToActivate) { TabFound = true; WindowHandler = ieHandle; tab.Activate(); return; } } } } }
public IEAccessible(IntPtr ieHandle, int tabIndexToActivate) { AccessibleObjectFromWindow(GetDirectUIHWND(ieHandle), OBJID.OBJID_WINDOW, ref accessible); if (accessible == null) throw new Exception(); int index = 0; IEAccessible ieDirectUIHWND = new IEAccessible(ieHandle); foreach (IEAccessible accessor in ieDirectUIHWND.Children) { foreach (IEAccessible child in accessor.Children) { foreach (IEAccessible tab in child.Children) { if (tabIndexToActivate >= child.ChildCount - 1) return; if (index == tabIndexToActivate) { tab.Activate(); return; } index++; } } } }
public int GetTabCount(IntPtr ieHandle) { AccessibleObjectFromWindow(GetDirectUIHWND(ieHandle), OBJID.OBJID_WINDOW, ref accessible); if (accessible == null) return 0; // throw new Exception(); IEAccessible ieDirectUIHWND = new IEAccessible(ieHandle); foreach (IEAccessible accessor in ieDirectUIHWND.Children) { foreach (IEAccessible child in accessor.Children) { foreach (IEAccessible tab in child.Children) return child.ChildCount - 1; } } return 0; }
public List<string> GetTabCaptions(IntPtr ieHandle) { AccessibleObjectFromWindow(GetDirectUIHWND(ieHandle), OBJID.OBJID_WINDOW, ref accessible); if (accessible == null) throw new Exception(); IEAccessible ieDirectUIHWND = new IEAccessible(ieHandle); List<string> captionList = new List<string>(); foreach (IEAccessible accessor in ieDirectUIHWND.Children) { foreach (IEAccessible child in accessor.Children) foreach (IEAccessible tab in child.Children) captionList.Add(tab.Name); } if (captionList.Count > 0) captionList.RemoveAt(captionList.Count - 1); return captionList; }
public string GetActiveTabUrl(IntPtr ieHandle) { AccessibleObjectFromWindow(GetDirectUIHWND(ieHandle), OBJID.OBJID_WINDOW, ref accessible); if (accessible == null) throw new Exception(); IEAccessible ieDirectUIHWND = new IEAccessible(ieHandle); foreach (IEAccessible accessor in ieDirectUIHWND.Children) { foreach (IEAccessible child in accessor.Children) { foreach (IEAccessible tab in child.Children) { object tabIndex = tab.accessible.get_accState(CHILDID_SELF); if ((int)tabIndex == IE_ACTIVE_TAB) { string description = tab.accessible.get_accDescription(CHILDID_SELF); if (!string.IsNullOrEmpty(description)) { if (description.Contains(Environment.NewLine)) { string url = description.Substring(description.IndexOf(Environment.NewLine)).Trim(); return url; } } } } } } return String.Empty; }
public int GetActiveTabIndex(IntPtr ieHandle) { AccessibleObjectFromWindow(GetDirectUIHWND(ieHandle), OBJID.OBJID_WINDOW, ref accessible); if (accessible == null) throw new Exception(); int index = 0; IEAccessible ieDirectUIHWND = new IEAccessible(ieHandle); foreach (IEAccessible accessor in ieDirectUIHWND.Children) { foreach (IEAccessible child in accessor.Children) { foreach (IEAccessible tab in child.Children) { object tabIndex = tab.accessible.get_accState(0); if ((int)tabIndex == IE_ACTIVE_TAB) return index; index++; } } } return -1; }
/// <summary> /// BtnGetMrnClick is used to get the Signature page setup on the user's desktop environment for the Sikuli Script to scrape the MRN # and store the value into the textbox that is used to send the data to the patients Allscripts EHR /// </summary> /// <param name="sender">Object</param> /// <param name="e">EventArgs</param> void BtnGetMrnClick(object sender, EventArgs e) { // Gets the Main Screen's Width and Height (minus 40 pixels) to setup the Internet Explorer window that is running OAS Gold Client int winWidth = MainScreen.Bounds.Width; int winHeight = MainScreen.Bounds.Height - 40; // Get this form's information to be used to set it on top of the OAS Screen after getting the MRN # if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal; RECT formRect = new RECT(); Process process = Process.GetCurrentProcess(); IntPtr formHandle = process.MainWindowHandle; User32.GetWindowRect(formHandle, ref formRect); // Window Handle of OAS Gold running (either on local instance of IE or Citrix) IntPtr foundHnd = IntPtr.Zero; // Checks the User's Desktop to find a local copy of IE running that has the tabe name of the title passed to the method // Once found will set the foundHnd (Window Hanlde of IE that has title running somehwere in it). // Get all local instances (not Citrix) of Internet Explorere that the user is running Process[] procsInterExp = Process.GetProcessesByName("iexplore"); if (procsInterExp != null) { IEAccessible access = null; foreach (Process proc in procsInterExp) { try { access = new IEAccessible(proc.MainWindowHandle, OasTabName); if (access != null && access.TabFound) { foundHnd = access.WindowHandler; break; } } catch { } } } // Try to get all local instances of Citrix that conatins Internet Explorer running OAS Gold Client if (foundHnd == IntPtr.Zero) { Process[] procsCitrix = Process.GetProcessesByName("wfica32"); foreach (Process proc in procsCitrix) { if (proc.MainWindowTitle.StartsWith(OasTabName)) { foundHnd = proc.MainWindowHandle; break; } } } // If a window of OAS Gold is running get the MRN number if (foundHnd != IntPtr.Zero) { ShowWindow(foundHnd, (int)ShowWindowOption.SW_MAXIMIZE); User32.SetWindowPos(foundHnd, HWndValues.HWND_TOPMOST, 0, 0, winWidth, winHeight, 0); String mrn = null; for (int i = 0; i < 5; i++) { mrn = GetMrn(); if (!String.IsNullOrEmpty(mrn)) { mrn = mrn.Trim(); if (mrn.Length > 7) mrn = mrn.Substring(mrn.Length - 7, 7); break; } } User32.SetWindowPos(foundHnd, HWndValues.HWND_NOTOPMOST, 0, 0, winWidth, winHeight, 0); Thread.Sleep(1000); User32.SetWindowPos(formHandle, HWndValues.HWND_TOP, formRect.left, formRect.top, formRect.Width, formRect.Height, 0); this.txtMrn.Text = mrn; } else { MessageBox.Show( @"Please open an AMC Signature ""Patient Verification"" Screen and click the [Get MRN#] button before continuing.", "No Signature Screen Available", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.btnSend.Enabled = true; this.AcceptButton = this.btnSend; }