private static void SetControlValue(System.IntPtr accObj, int vmId, string controlValue) { if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { System.IntPtr pControlValue = System.Runtime.InteropServices.Marshal.StringToCoTaskMemUni(controlValue); try { if (!pControlValue.Equals((System.IntPtr)System.IntPtr.Zero)) { JavaAccNativeMethods.setTextContents(vmId, accObj, pControlValue); } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } finally { if (!pControlValue.Equals((System.IntPtr)System.IntPtr.Zero)) { System.Runtime.InteropServices.Marshal.FreeCoTaskMem(pControlValue); } } } }
private static string GetVirtualAccessibleName(System.IntPtr accObj, int vmId) { string str = string.Empty; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { System.IntPtr zero = System.IntPtr.Zero; try { zero = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(JavaDataDrivenAdapterConstants.TASK_MEMORY_SIZE); if (!zero.Equals((System.IntPtr)System.IntPtr.Zero) && JavaAccNativeMethods.getVirtualAccessibleName(vmId, accObj, zero, JavaDataDrivenAdapterConstants.TASK_MEMORY_SIZE)) { str = System.Runtime.InteropServices.Marshal.PtrToStringUni(zero); } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(str); } finally { if (!zero.Equals((System.IntPtr)System.IntPtr.Zero)) { System.Runtime.InteropServices.Marshal.FreeCoTaskMem(zero); } } } return(str); }
internal static NativeSnapshotMetadataChange FromPointer(IntPtr pointer) { if (pointer.Equals(IntPtr.Zero)) { return null; } return new NativeSnapshotMetadataChange(pointer); }
internal static string GetAccHyperlink(System.IntPtr accObj, int vmId) { string text = string.Empty; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { AccessibleHypertextInfo hypertextInfo = new AccessibleHypertextInfo(); try { if (JavaAccNativeMethods.getAccessibleHypertext(vmId, accObj, out hypertextInfo)) { AccessibleHyperlinkInfo hyperlinkInfo = new AccessibleHyperlinkInfo(); if (JavaAccNativeMethods.getAccessibleHyperlink(vmId, hypertextInfo.accessibleHypertext, 0, out hyperlinkInfo)) { text = hyperlinkInfo.text; } } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(text); } } return(text); }
internal static void SetAccTableCellValue(System.IntPtr accObj, int vmId, string cellIndex, string cellValue) { if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { int index = 0; if (int.TryParse(cellIndex, out index)) { System.IntPtr accessibleContext = GetAccTableCellInfo(accObj, vmId, index).accessibleContext; try { SetValue(accessibleContext, vmId, cellValue); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } finally { ReleaseObject(accessibleContext, vmId); } } } }
// 子ハンドルのリスト更新 public void Update() { hWndList.Clear(); this.hWnd = GetWindowHandle(windowName); if (hWnd.Equals((IntPtr)0)) { this.hWnd = GetWindowHandle(windowName+"*"); if (hWnd.Equals((IntPtr)0)) { string str = "\"" + windowName + "\"は起動していません"; throw new ApplicationException(str); } this.windowName = windowName + "*"; } GCHandle listHandle = GCHandle.Alloc(hWndList); try { EnumWindowProc childProc = new EnumWindowProc(EnumWindow); EnumChildWindows(hWnd, childProc, GCHandle.ToIntPtr(listHandle)); } finally { if (listHandle.IsAllocated) { listHandle.Free(); } } }
internal static string GetName(System.IntPtr accObj, int vmId) { string str = string.Empty; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { AccessibleContextInfo accContextInfo = new AccessibleContextInfo(); try { if (JavaAccNativeMethods.getAccessibleContextInfo(vmId, accObj, out accContextInfo) && !string.IsNullOrEmpty(accContextInfo.name)) { return(accContextInfo.name); } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(str); } } return(str); }
internal static string GetAccTableCellValue(System.IntPtr accObj, int vmId, string cellIndex) { string str = string.Empty; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { int index = 0; if (!int.TryParse(cellIndex, out index)) { return(str); } System.IntPtr accessibleContext = GetAccTableCellInfo(accObj, vmId, index).accessibleContext; try { str = GetValue(accessibleContext, vmId); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(str); } finally { ReleaseObject(accessibleContext, vmId); } } return(str); }
internal static string BuildAccKey(System.IntPtr accObj, int vmId) { System.Text.StringBuilder builder = new System.Text.StringBuilder(); if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { try { System.IntPtr ptr = JavaAccNativeMethods.getTopLevelObject(vmId, accObj); System.IntPtr hWnd = JavaAccNativeMethods.getHWNDFromAccessibleContext(vmId, ptr); builder.AppendFormat("{0}.{1}.{2:X8}", (int)GetRoleID(accObj, vmId), (int)vmId, (int)hWnd.ToInt32()); LPRECT lpRect = new LPRECT(); Win32NativeMethods.GetWindowRect(hWnd, ref lpRect); AccessibleContextInfo accContextInfo = new AccessibleContextInfo(); JavaAccNativeMethods.getAccessibleContextInfo(vmId, accObj, out accContextInfo); int num = (int)(accContextInfo.x - lpRect.Left); int num2 = (int)(accContextInfo.y - lpRect.Top); int width = accContextInfo.width; int height = accContextInfo.height; builder.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, ".{0},{1},{2},{3}", new object[] { (int)num, (int)num2, (int)width, (int)height }); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } } return(builder.ToString()); }
internal static int GetAccTableCellIndex(System.IntPtr accObj, int vmId, int row, int column) { int num = -1; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { System.IntPtr accTable = GetAccTable(accObj, vmId); if (accTable.Equals((System.IntPtr)System.IntPtr.Zero)) { return(num); } try { num = JavaAccNativeMethods.getAccessibleTableIndex(vmId, accTable, row, column); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(num); } finally { ReleaseObject(accTable, vmId); } } return(num); }
private static AccessibleTableCellInfo GetAccTableCellInfo(System.IntPtr accObj, int vmId, int index) { AccessibleTableCellInfo accTableCellInfo = new AccessibleTableCellInfo(); if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { System.IntPtr accTable = GetAccTable(accObj, vmId); try { if (!accTable.Equals((System.IntPtr)System.IntPtr.Zero)) { int row = JavaAccNativeMethods.getAccessibleTableRow(vmId, accTable, index); int column = JavaAccNativeMethods.getAccessibleTableColumn(vmId, accTable, index); if (JavaAccNativeMethods.getAccessibleTableCellInfo(vmId, accTable, row, column, out accTableCellInfo)) { return(accTableCellInfo); } } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(accTableCellInfo); } finally { ReleaseObject(accTable, vmId); } } return(accTableCellInfo); }
internal static string GetAccSelectionName(System.IntPtr accObj, int vmId) { string name = string.Empty; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { System.IntPtr accSelection = GetAccSelection(accObj, vmId); try { if (!accSelection.Equals((System.IntPtr)System.IntPtr.Zero)) { name = GetName(accSelection, vmId); } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(name); } finally { ReleaseObject(accSelection, vmId); } } return(name); }
internal static void ActivateAccHyperlink(System.IntPtr accObj, int vmId) { if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { AccessibleHypertextInfo hypertextInfo = new AccessibleHypertextInfo(); try { if (JavaAccNativeMethods.getAccessibleHypertext(vmId, accObj, out hypertextInfo)) { AccessibleHyperlinkInfo hyperlinkInfo = new AccessibleHyperlinkInfo(); if (JavaAccNativeMethods.getAccessibleHyperlink(vmId, hypertextInfo.accessibleHypertext, 0, out hyperlinkInfo)) { JavaAccNativeMethods.activateAccessibleHyperlink(vmId, accObj, hyperlinkInfo.accessibleHyperlink); } } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } } }
internal static RealtimeRoomConfig FromPointer(IntPtr selfPointer) { if (selfPointer.Equals(IntPtr.Zero)) { return null; } return new RealtimeRoomConfig(selfPointer); }
public bool Make() { bool flag = false; IntPtr ParenthWnd = new IntPtr(0); IntPtr EdithWnd = new IntPtr(0); // SendMessage(process.MainWindowHandle, 0x112, 0xf060, 0); // SendMessage(process.MainWindowHandle, 0x112, 0xf020, 0); ParenthWnd = FindWindow(null, "添加新任务"); //ParenthWnd = FindWindow(null, "硕鼠 Nano v0.4.7.5 正式版"); SendMessage(ParenthWnd, WM_SYSCOMMAND, SC_CLOSE, 0); if (!ParenthWnd.Equals(IntPtr.Zero)) { //SendMessage(ParenthWnd, WM_SYSCOMMAND, SC_CLOSE, 0); EdithWnd = FindWindowEx(ParenthWnd, EdithWnd, null, "确定"); //获取button句柄 if (!EdithWnd.Equals(IntPtr.Zero)) { MessageBox.Show("保存存在 "); // SendMessage(EdithWnd, 0xf5, 0xf5, 0); flag = true; } else { // MessageBox.Show("保存按扭不存在 "); } } else { //MessageBox.Show("主窗体不存在 "); } return flag; }
public static IHTMLDocument2 DocumentFromDOM(IntPtr hWnd) { IHTMLDocument2 document = null; int lngMsg = 0; int lRes; Win32.EnumProc proc = new Win32.EnumProc(DOM.EnumWindows); Win32.EnumChildWindows(hWnd, proc, ref hWnd); if (!hWnd.Equals(IntPtr.Zero)) { lngMsg = Win32.RegisterWindowMessage("WM_HTML_GETOBJECT"); if (lngMsg != 0) { Win32.SendMessageTimeout(hWnd, lngMsg, 0, 0, Win32.SMTO_ABORTIFHUNG, 1000, out lRes); if (!(bool)(lRes == 0)) { int hr = Win32.ObjectFromLresult(lRes, ref Win32.IID_IHTMLDocument2, 0, ref document); if ((bool)(document == null)) { //MessageBox.Show("No IHTMLDocument Found!", "Warning"); Console.WriteLine("No IHTMLDocument Found!"); } } } } return document; }
internal static NativeRealTimeRoom FromPointer(IntPtr selfPointer) { if (selfPointer.Equals(IntPtr.Zero)) { return null; } return new NativeRealTimeRoom(selfPointer); }
private static string GetAccessibleText(System.IntPtr accObj, int vmId) { string sentence = string.Empty; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { try { AccessibleContextInfo accContextInfo = new AccessibleContextInfo(); JavaAccNativeMethods.getAccessibleContextInfo(vmId, accObj, out accContextInfo); if (accContextInfo.accessibleText) { AccessibleTextInfo accTextInfo = new AccessibleTextInfo(); if (JavaAccNativeMethods.getAccessibleTextInfo(vmId, accObj, out accTextInfo, 0, 0)) { AccessibleTextItemsInfo accTextItems = new AccessibleTextItemsInfo(); if (JavaAccNativeMethods.getAccessibleTextItems(vmId, accObj, out accTextItems, accTextInfo.indexAtPoint)) { sentence = accTextItems.sentence; } } } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(sentence); } } return(sentence); }
internal TrustItem(IntPtr itemPtr) { if (itemPtr.Equals(IntPtr.Zero)) throw new InvalidPtrException("An invalid trust item pointer has been supplied."); UpdateFromMem(itemPtr); }
internal static int GetRoleID(System.IntPtr accObj, int vmId) { if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { bool flag = false; AccessibleContextInfo accContextInfo = new AccessibleContextInfo(); try { flag = JavaAccNativeMethods.getAccessibleContextInfo(vmId, accObj, out accContextInfo); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } if (flag && !string.IsNullOrEmpty(accContextInfo.role)) { if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.PUSH_BUTTON, System.StringComparison.OrdinalIgnoreCase)) { return(0); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.TOGGLE_BUTTON, System.StringComparison.OrdinalIgnoreCase)) { return(6); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.CHECK_BOX, System.StringComparison.OrdinalIgnoreCase)) { return(1); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.RADIO_BUTTON, System.StringComparison.OrdinalIgnoreCase)) { return(2); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.COMBO_BOX, System.StringComparison.OrdinalIgnoreCase)) { return(3); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.TEXT, System.StringComparison.OrdinalIgnoreCase)) { return(4); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.LABEL, System.StringComparison.OrdinalIgnoreCase)) { return(5); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.MENU, System.StringComparison.OrdinalIgnoreCase)) { return(7); } if (accContextInfo.role.Equals(JavaDataDrivenAdapterConstants.MENU_ITEM, System.StringComparison.OrdinalIgnoreCase)) { return(8); } } } return(-1); }
internal static NativeScoreSummary FromPointer(IntPtr pointer) { if (pointer.Equals(IntPtr.Zero)) { return null; } return new NativeScoreSummary(pointer); }
internal static NativeLeaderboard FromPointer(IntPtr pointer) { if (pointer.Equals(IntPtr.Zero)) { return null; } return new NativeLeaderboard(pointer); }
// Methods private EventWaitHandle(IntPtr aHandle) { if (aHandle.Equals(IntPtr.Zero)) { throw new WaitHandleCannotBeOpenedException(); } Handle = aHandle; }
internal static FetchForPlayerResponse FromPointer(IntPtr pointer) { if (pointer.Equals(IntPtr.Zero)) { return null; } return new FetchForPlayerResponse(pointer); }
internal static NativeEndpointDetails FromPointer(IntPtr pointer) { if (pointer.Equals(IntPtr.Zero)) { return null; } return new NativeEndpointDetails(pointer); }
public bool Connect() { device = HidAPI.hid_open_path(path); if (!device.Equals(IntPtr.Zero)) { DoConnected(); return true; } return false; }
void SendMouse(IntPtr hWnd, IContact contact, Action<IntPtr, POINT> action) { POINT point = new POINT((int)contact.X, (int)contact.Y); if(hWnd.Equals(IntPtr.Zero)) hWnd = GetWindowAtPoint(point); NativeMethods.MapWindowPoints(IntPtr.Zero, hWnd, ref point, 1); if(hWnd != IntPtr.Zero) action(hWnd, point); }
private static void FireAccEvent <T>(System.IntPtr source, string eventName, int vmId, System.Type type, T oldObject, T newObject) { if (!source.Equals((System.IntPtr)System.IntPtr.Zero)) { JavaAccEventOccurred((System.IntPtr)source, new Uii.HostedApplicationToolkit.DataDrivenAdapter.JavaAccEventArgs(type, eventName, source, vmId, oldObject, newObject)); } else { JavaAccEventOccurred(null, new Uii.HostedApplicationToolkit.DataDrivenAdapter.JavaAccEventArgs(type, eventName, source, vmId, oldObject, newObject)); } }
internal bool MetafileCallback(EmfPlusRecordType recordType, int flags, int dataSize, IntPtr data, PlayRecordCallback callbackData) { if (!data.Equals(IntPtr.Zero)) { byte[] RecordData = new byte[dataSize]; Marshal.Copy(data, RecordData, 0, dataSize); ProcessRecord(flags, recordType, RecordData); } return true; }
public OutlookWin32Window(string caption, bool isWord) { _windowsHandle = FindWindow(isWord ? "OpusApp" : "rctrl_renwnd32", caption); if (!_windowsHandle.Equals(IntPtr.Zero) || !caption.EndsWith(" - Message")) return; caption = caption.Replace(" - Message", ""); _windowsHandle = FindWindow(isWord ? "OpusApp" : "rctrl_renwnd32", caption); }
public int Load(string dllfile) { m_hinst = LoadLibrary(dllfile); if (m_hinst.Equals(IntPtr.Zero)) { return(-2); } else { return(GetDDfunAddress(m_hinst)); } }
//<summary> //Constructor (New) //The <b>OutlookWin32Window</b> class could be used to get the parent IWin32Window for Windows.Forms and MessageBoxes. //</summary> //<param name="windowObject">The current WindowObject.</param> public OutlookWin32Window(object window,bool isWord) { string caption = window.GetType().InvokeMember("Caption", BindingFlags.GetProperty, null, window, null).ToString(); _windowsHandle = FindWindow(isWord ? "OpusApp" : "rctrl_renwnd32", caption); if (!_windowsHandle.Equals(IntPtr.Zero) || !caption.EndsWith(" - Message")) return; caption = caption.Replace(" - Message", ""); _windowsHandle = FindWindow(isWord ? "OpusApp" : "rctrl_renwnd32", caption); }
private static string GetAccessibleValueInt(System.IntPtr accObj, int vmId) { string str = string.Empty; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { System.IntPtr zero = System.IntPtr.Zero; try { zero = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(4); if (!zero.Equals((System.IntPtr)System.IntPtr.Zero)) { AccessibleContextInfo accContextInfo = new AccessibleContextInfo(); JavaAccNativeMethods.getAccessibleContextInfo(vmId, accObj, out accContextInfo); if (accContextInfo.accessibleInterfaces && JavaAccNativeMethods.getCurrentAccessibleValueFromContext(vmId, accObj, zero, 4)) { str = System.Runtime.InteropServices.Marshal.PtrToStringUni(zero); } } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(str); } finally { if (!zero.Equals((System.IntPtr)System.IntPtr.Zero)) { System.Runtime.InteropServices.Marshal.FreeCoTaskMem(zero); } } } return(str); }
/// <summary> /// Retrieves the handle of the system image list. /// </summary> private static void InitImageList() { // Retrieve the info for a fake file so we can get the image list handle. ShellAPI.SHFILEINFO shInfo = new ShellAPI.SHFILEINFO(); ShellAPI.SHGFI dwAttribs = ShellAPI.SHGFI.SHGFI_USEFILEATTRIBUTES | ShellAPI.SHGFI.SHGFI_SMALLICON | ShellAPI.SHGFI.SHGFI_SYSICONINDEX; m_pImgHandle = ShellAPI.SHGetFileInfo(".txt", ShellAPI.FILE_ATTRIBUTE_NORMAL, out shInfo, (uint)Marshal.SizeOf(shInfo), dwAttribs); // Make sure we got the handle. if (m_pImgHandle.Equals(IntPtr.Zero)) throw new Exception("Unable to retrieve system image list handle."); }
public IntPtr IEFromhWnd(IntPtr hWnd) { if(!hWnd.Equals(0)) { if(!IsIEServerWindow(hWnd)) { // Get 1st child IE server window Win32.USER32.EnumChildProc myEnumChildProc = new Win32.USER32.EnumChildProc(EnumChild); Win32.USER32.EnumChildWindows(hWnd.ToInt32(), myEnumChildProc, hWnd.ToInt32()); } } return GhWnd; }
//キャプチャ開始 public static bool Start(string deviceName,bool promiscuous) { short timeout = 20; short Promiscast = (short)(promiscuous ? 1 : 0); StringBuilder errbuf = new StringBuilder(PCAP_ERRBUF_SIZE); handle = pcap_open(deviceName, MAX_RECV_SIZE, Promiscast, timeout,errbuf); if (handle.Equals(IntPtr.Zero)) { // エラー (エラーの詳細は、errbufに格納されている) return false; } t = new Thread(new ThreadStart(Loop)); t.IsBackground = true; t.Start(); return true; }
private void CloseWindow(object ft) { FileType fileType = (FileType)ft; for (int waitCounter = 0; waitCounter < 20000; ++waitCounter) { if (m_bStopMonitoring) return; string caption = String.Empty; switch (fileType) { case FileType.WordDocument: case FileType.WordDocumentX: case FileType.WordDocumentMacroX: case FileType.WordDocumentTemplateX: case FileType.WordDocumentMacroTemplateX: caption = "Microsoft Office Word"; break; case FileType.ExcelSheet: case FileType.ExcelSheetX: case FileType.ExcelSheetMacroX: case FileType.ExcelSheetTemplateX: case FileType.ExcelSheetMacroTemplateX: caption = "Microsoft Office Excel"; break; default: { string sFileType = Enum.GetName(typeof(FileType), fileType); Logger.LogInfo(string.Format("DocumentUpgradeWindowSuppressor.CloseWindow: Unsupported Document Type - \"{0}\" - Shutting down the window suppressor.", sFileType)); return; // To nothing; } } IntPtr parentWnd = FindWindow("#32770", caption); if (!parentWnd.Equals(IntPtr.Zero)) { IntPtr buttonWnd = new IntPtr(0); buttonWnd = FindWindowEx(parentWnd, buttonWnd, "Button", "&No"); if (!buttonWnd.Equals(IntPtr.Zero)) { SendMessage(buttonWnd, WM_CLICK, (IntPtr)0, "0"); return; } } Thread.Sleep(5); System.Windows.Forms.Application.DoEvents(); } }
private static bool EnumWindowsCallback(IntPtr testWindowHandle, IntPtr includeChildren) { string title = GetWindowTitle(testWindowHandle); if (TitleMatches(title)) { uint pid; GetWindowThreadProcessId(testWindowHandle, out pid); if (pid == WindowUtilities.pid) windowTitles.Add(title); } if (includeChildren.Equals(IntPtr.Zero) == false) { EnumChildWindows(testWindowHandle, EnumWindowsCallback, IntPtr.Zero); } return true; }
/// <summary> /// SwitchToCurrentInstance /// </summary> private static void p_SwitchToCurrentInstance(IntPtr hWnd) { if (!hWnd.Equals(IntPtr.Zero)) { // Restore window if minimised. Do not restore if already in // normal or maximised window state, since we don't want to // change the current state of the window. if (p_IsIconic(hWnd) != 0) { p_ShowWindow(hWnd, _SW_RESTORE); } // Set foreground window. p_SetForegroundWindow(hWnd); } }
private void Send(string msg) { QQHwndSend = FindWindow("TXGuiFoundation", GroupName); if (QQHwndSend.Equals(IntPtr.Zero)) { return; } // 此句会报错,所以改用另一线程实现 //Clipboard.SetDataObject("测试剪切板,自动发消息。", true); textToCopy = msg; Thread runThread = new Thread(new ThreadStart(SetClipboardTextAndSend)); runThread.SetApartmentState(ApartmentState.STA); runThread.Start(); }
internal static void ReleaseObject(System.IntPtr accObj, int vmId) { if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { try { JavaAccNativeMethods.releaseJavaObject(vmId, accObj); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { Trace.WriteLine("Unable to free memory associated with the java accessible node."); } } } }
private static Icon GetAppIcon() { System.IntPtr hLibrary = NativeMethods.LoadLibrary(Assembly.GetEntryAssembly().Location); if (!hLibrary.Equals(System.IntPtr.Zero)) { System.IntPtr hIcon = NativeMethods.LoadIcon(hLibrary, "#32512"); if (!hIcon.Equals(System.IntPtr.Zero)) { var icon = System.Drawing.Icon.FromHandle(hIcon); if (icon != null) { return(icon); } } } return(null); }
/// <summary> /// Checa se a applicação NeoUpdater já esta sendo rodada. /// </summray> private static void CheckNeoUpdaterIsRun() { string lpszParentClass = "NeoPocketUpdater"; lpszParentClass = null; string lpszParentWindow = "NeoPocketUpdater"; IntPtr NeoPocketUpdaterWnd = new IntPtr(0); NeoPocketUpdaterWnd = FindWindow(lpszParentClass, lpszParentWindow); if (NeoPocketUpdaterWnd.Equals(IntPtr.Zero)) { } else { if (BringWindowToTop(lpszParentWindow)) { Application.Exit(); } } }
public bool Make() { bool flag = false; Process[] processesByName = Process.GetProcessesByName("nano"); foreach (Process process in processesByName) { //SendMessage(process.MainWindowHandle, 0x112, 0xf020, 0); //Thread.Sleep(3000); // SendMessage(process.MainWindowHandle, 0x112, 0xf020, 0); IntPtr ParenthWnd = new IntPtr(0); IntPtr EdithWnd = new IntPtr(0); ParenthWnd = FindWindow(null, "添加新任务"); if (!ParenthWnd.Equals(IntPtr.Zero)) { EdithWnd = FindWindowEx(ParenthWnd, EdithWnd, null, "确定"); //获取button句柄 if (!EdithWnd.Equals(IntPtr.Zero)) { SendMessage(EdithWnd, 0xf5, 0xf5, 0); flag = true; while (true) { if (FindWindow(null, "硕鼠初始化").Equals(IntPtr.Zero)) { process.Kill(); break; } } } else { // MessageBox.Show("保存按扭不存在 "); } } else { // MessageBox.Show("主窗体不存在 "); } } return flag; }
private static Icon GetAppIcon(string fileName) { if (!InputBox.IsRunningOnMono) { System.IntPtr hLibrary = NativeMethods.LoadLibrary(fileName); if (!hLibrary.Equals(System.IntPtr.Zero)) { System.IntPtr hIcon = NativeMethods.LoadIcon(hLibrary, "#32512"); if (!hIcon.Equals(System.IntPtr.Zero)) { var icon = System.Drawing.Icon.FromHandle(hIcon); if (icon != null) { return(icon); } } } } return(null); }
private static Bitmap GetAppIcon(string fileName) { if (!AboutBox.IsRunningOnMono) { System.IntPtr hLibrary = NativeMethods.LoadLibrary(fileName); if (!hLibrary.Equals(System.IntPtr.Zero)) { System.IntPtr hIcon = NativeMethods.LoadIcon(hLibrary, "#32512"); if (!hIcon.Equals(System.IntPtr.Zero)) { Bitmap bitmap = System.Drawing.Icon.FromHandle(hIcon).ToBitmap(); if (bitmap != null) { return(bitmap); } } } } return(null); }
internal static System.IntPtr GetAccFromWindow(System.IntPtr hWnd, out int vmId) { System.IntPtr zero = System.IntPtr.Zero; vmId = 0; if (!hWnd.Equals((System.IntPtr)System.IntPtr.Zero)) { try { JavaAccNativeMethods.getAccessibleContextFromHWND(hWnd, out vmId, out zero); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(zero); } } return(zero); }
internal static System.IntPtr GetHWNDFromAccessibleContext(System.IntPtr accObj, int vmId) { System.IntPtr zero = System.IntPtr.Zero; System.IntPtr ptr2 = System.IntPtr.Zero; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { try { zero = JavaAccNativeMethods.getTopLevelObject(vmId, accObj); if (!zero.Equals((System.IntPtr)System.IntPtr.Zero)) { ptr2 = JavaAccNativeMethods.getHWNDFromAccessibleContext(vmId, zero); } } finally { ReleaseObject(zero, vmId); } } return(ptr2); }
/// <summary> /// Retrieves the handle of the system image list. /// </summary> private static void InitImageList() { // Only initialize once. if (m_bImgInit) throw new Exception("The system image list handle has already been retrieved."); // Retrieve the info for a fake file so we can get the image list handle. SHFILEINFO shInfo = new SHFILEINFO(); SHGFI dwAttribs = SHGFI.SHGFI_USEFILEATTRIBUTES | SHGFI.SHGFI_SMALLICON | SHGFI.SHGFI_SYSICONINDEX; m_pImgHandle = NativeShellApi.SHGetFileInfo(".txt", NativeShellApi.FILE_ATTRIBUTE_NORMAL, out shInfo, (uint)Marshal.SizeOf(shInfo), dwAttribs); // Make sure we got the handle. if (m_pImgHandle.Equals(IntPtr.Zero)) throw new Exception("Unable to retrieve system image list handle."); // Only allow one initialization. m_bImgInit = true; }
private static MINMAXINFO AdjustWorkingAreaForAutoHide(IntPtr monitorContainingApplication, MINMAXINFO mmi) { IntPtr hwnd = FindWindow("Shell_TrayWnd", null); if (hwnd == null) return mmi; IntPtr monitorWithTaskbarOnIt = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); if (!monitorContainingApplication.Equals(monitorWithTaskbarOnIt)) return mmi; APPBARDATA abd = new APPBARDATA(); abd.cbSize = Marshal.SizeOf(abd); abd.hWnd = hwnd; SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref abd); int uEdge = GetEdge(abd.rc); bool autoHide = System.Convert.ToBoolean(SHAppBarMessage((int)ABMsg.ABM_GETSTATE, ref abd)); if (!autoHide) return mmi; switch (uEdge) { case (int)ABEdge.ABE_LEFT: mmi.ptMaxPosition.x += 2; mmi.ptMaxTrackSize.x -= 2; mmi.ptMaxSize.x -= 2; break; case (int)ABEdge.ABE_RIGHT: mmi.ptMaxSize.x -= 2; mmi.ptMaxTrackSize.x -= 2; break; case (int)ABEdge.ABE_TOP: mmi.ptMaxPosition.y += 2; mmi.ptMaxTrackSize.y -= 2; mmi.ptMaxSize.y -= 2; break; case (int)ABEdge.ABE_BOTTOM: mmi.ptMaxSize.y -= 2; mmi.ptMaxTrackSize.y -= 2; break; default: return mmi; } return mmi; }
internal static string GetAccNodeLabel(System.IntPtr accObj, int vmId) { System.Text.StringBuilder builder = new System.Text.StringBuilder(); if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { try { builder.Append(GetName(accObj, vmId)); builder.Append(" ["); builder.Append(GetRole(accObj, vmId)); builder.Append("] "); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } } return(builder.ToString()); }
public static void AdjustForAutoHideTaskbar(IntPtr hAppMonitor, ref RECT workspace) { // NOTE: for xp the adjustment for autohidden taskbar makes maximized window movable // but I don't know the way to fix it. IntPtr htaskbar = User32.FindWindow("Shell_TrayWnd", null); if (htaskbar != IntPtr.Zero) { IntPtr monitorWithTaskbarOnIt = User32.MonitorFromWindow(htaskbar, MonitorOption.MONITOR_DEFAULTTONEAREST); if (hAppMonitor.Equals(monitorWithTaskbarOnIt)) { APPBARDATA abd = new APPBARDATA(); abd.cbSize = (uint)Marshal.SizeOf(abd); abd.hWnd = htaskbar; bool autoHide = (Shell32.SHAppBarMessage(AppBarMessage.ABM_GETSTATE, ref abd).ToUInt32() & ABS_AUTOHIDE) == ABS_AUTOHIDE; if (autoHide) { Shell32.SHAppBarMessage(AppBarMessage.ABM_GETTASKBARPOS, ref abd); var uEdge = GetEdge(ref abd.rc); switch (uEdge) { case AppBarEdge.ABE_LEFT: workspace.left += 2; break; case AppBarEdge.ABE_RIGHT: workspace.right -= 2; break; case AppBarEdge.ABE_TOP: workspace.top += 2; break; case AppBarEdge.ABE_BOTTOM: workspace.bottom -= 2; break; } } } } }
internal static bool DoAction(System.IntPtr accObj, out int failure, int vmId, bool isDefaultAction, string actionName) { bool flag = false; failure = 0; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { AccessibleActionsToDo[] actionsToDo = new AccessibleActionsToDo[] { new AccessibleActionsToDo() }; actionsToDo[0].actionsCount = 1; actionsToDo[0].actions = new AccessibleActionInfo[0x20]; actionsToDo[0].actions[0] = new AccessibleActionInfo(); if (isDefaultAction) { actionsToDo[0].actions[0].name = JavaDataDrivenAdapterConstants.DEFAULT_ACTION_NAME; } else { actionsToDo[0].actions[0].name = actionName; } try { flag = JavaAccNativeMethods.doAccessibleActions(vmId, accObj, actionsToDo, out failure); if (flag == false) { throw new Exception("doAccessibleActions failed: " + failure.ToString()); } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(flag); } } return(flag); }
internal static void SetAccSelection(System.IntPtr accSelection, int vmId, string controlValue) { int num = 0; if (!accSelection.Equals((System.IntPtr)System.IntPtr.Zero) && int.TryParse(controlValue, out num)) { try { if (num <= 0) { throw new System.ArgumentException("Incorrect Control Value"); } JavaAccNativeMethods.addAccessibleSelectionFromContext(vmId, accSelection, (int)(num - 1)); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } } }
private static System.IntPtr GetAccSelection(System.IntPtr accObj, int vmId) { System.IntPtr zero = System.IntPtr.Zero; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { try { if (JavaAccNativeMethods.getAccessibleSelectionCountFromContext(vmId, accObj) != -1) { zero = JavaAccNativeMethods.getAccessibleSelectionFromContext(vmId, accObj, 0); } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(zero); } } return(zero); }
internal static string GetRole(System.IntPtr accObj, int vmId) { if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { bool flag = false; AccessibleContextInfo accContextInfo = new AccessibleContextInfo(); try { flag = JavaAccNativeMethods.getAccessibleContextInfo(vmId, accObj, out accContextInfo); } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } } if (flag && !string.IsNullOrEmpty(accContextInfo.role)) { return(accContextInfo.role_en_US); } } return(string.Empty); }
private static System.IntPtr GetAccTable(System.IntPtr accObj, int vmId) { System.IntPtr zero = System.IntPtr.Zero; if (!accObj.Equals((System.IntPtr)System.IntPtr.Zero)) { AccessibleTableInfo accTableInfo = new AccessibleTableInfo(); try { if (JavaAccNativeMethods.getAccessibleTableInfo(vmId, accObj, out accTableInfo)) { zero = accTableInfo.accessibleTable; } } catch (System.Exception exception) { if (!IsJavaAccException(exception) || !IsJavaAccExceptionMaskable(exception)) { throw; } return(zero); } } return(zero); }
private static System.IntPtr FindWindowViaBfs(System.IntPtr hWndRoot) { System.IntPtr zero = System.IntPtr.Zero; Queue <System.IntPtr> queue = new Queue <System.IntPtr>(); queue.Enqueue(hWndRoot); while (!((int)queue.Count).Equals(0) && zero.Equals((System.IntPtr)System.IntPtr.Zero)) { for (System.IntPtr ptr2 = queue.Dequeue(); !ptr2.Equals((System.IntPtr)System.IntPtr.Zero); ptr2 = Win32NativeMethods.GetWindow(ptr2, WinUserConstant.SW_SHOWMINIMIZED)) { if (_CurrWindowComparer(ptr2)) { zero = ptr2; continue; } System.IntPtr window = Win32NativeMethods.GetWindow(ptr2, WinUserConstant.SW_SHOW); if (!window.Equals((System.IntPtr)System.IntPtr.Zero)) { queue.Enqueue(window); } } } return(zero); }
public static bool IsNull(IntPtr ptr) { return (ptr.Equals (IntPtr.Zero)); }
public override bool Equals(object obj) { return(_value.Equals(obj)); }