コード例 #1
1
        public bool checkHandle()
        {
            Guid guid = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");
            object obj = null;
            int retVal = AccessibleObjectFromWindow(handle, (uint)OBJID.WINDOW, ref guid, ref obj);
            iAccessible = (IAccessible)obj;

            //The AccWindowName returned is Add-ons Manager - Mozilla Firefox
            //There is a special child id called CHILDID_SELF (this constant equals 0) that, when used with a function like get_accChild, returns the element itself rather than a child.

            string accWindowName = iAccessible.get_accName(0);
            string accWindowVal = iAccessible.get_accValue(0);

            Console.WriteLine("IAccessible Name : " + accWindowName);
            Console.WriteLine("IAccessible value : " + accWindowVal);
            Console.WriteLine("IAccessible Role is : " + iAccessible.get_accRole(0));

            Console.WriteLine("IAccessible Type: " + iAccessible.GetType());
            Console.WriteLine("IAccessible Focus is: " + iAccessible.accFocus);
            Console.WriteLine("IAccessible Selection is " + iAccessible.get_accState());
            //iAccessible.accSelect((int)OBJID.SELFLAG_TAKEFOCUS, 0);
            if (!accWindowName.Contains("Mozilla Firefox"))
                return false;

            getChild(iAccessible,false);

            //End of for window
            Console.WriteLine("End of checkHandle");
            iAccessible = null;
            return false;
        }
コード例 #2
0
        public bool checkHandle()
        {
            Guid   guid   = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");
            object obj    = null;
            int    retVal = AccessibleObjectFromWindow(handle, (uint)OBJID.WINDOW, ref guid, ref obj);

            iAccessible = (IAccessible)obj;

            //The AccWindowName returned is Add-ons Manager - Mozilla Firefox
            //There is a special child id called CHILDID_SELF (this constant equals 0) that, when used with a function like get_accChild, returns the element itself rather than a child.

            string accWindowName = iAccessible.get_accName(0);
            string accWindowVal  = iAccessible.get_accValue(0);

            Console.WriteLine("IAccessible Name : " + accWindowName);
            Console.WriteLine("IAccessible value : " + accWindowVal);
            Console.WriteLine("IAccessible Role is : " + iAccessible.get_accRole(0));

            Console.WriteLine("IAccessible Type: " + iAccessible.GetType());
            Console.WriteLine("IAccessible Focus is: " + iAccessible.accFocus);
            Console.WriteLine("IAccessible Selection is " + iAccessible.get_accState());
            //iAccessible.accSelect((int)OBJID.SELFLAG_TAKEFOCUS, 0);
            if (!accWindowName.Contains("Mozilla Firefox"))
            {
                return(false);
            }

            getChild(iAccessible, false);

            //End of for window
            Console.WriteLine("End of checkHandle");
            iAccessible = null;
            return(false);
        }
コード例 #3
0
        /* int GetCopyCount()
         * get how many copies need to print currently
         */
        public static int GetCopyCount()
        {
            if (_copyCountHandle != IntPtr.Zero)
            {
                try
                {
                    //get MSAA interface for copy count.
                    Win32API.AccessibleObjectFromWindow(_copyCountHandle, (int)Win32API.IACC.OBJID_CLIENT, ref Win32API.IACCUID, ref _paccCopyCount);

                    if (_paccCopyCount != null)
                    {
                        string countStr = _paccCopyCount.get_accValue(_selfID);

                        //if string is not null, convert to int, else return -1.
                        return(countStr == null ? -1 : int.Parse(countStr));
                    }
                }
                catch
                {
                    return(-1);
                }
            }

            return(-1);
        }
コード例 #4
0
ファイル: QqWindowHelper.cs プロジェクト: WillPerfect/TestTk
 /// <summary>
 /// 返回消息框内容
 /// </summary>
 /// <returns></returns>
 public string GetContent()
 {
     if (_inputBox != null)
     {
         string value = (string)_inputBox.get_accValue(Win32.CHILDID_SELF);
         return(value);
     }
     return("");
 }
コード例 #5
0
ファイル: Accessible.cs プロジェクト: victor0225/NeuralAction
        public void UpdateValue()
        {
            string value = IAccessible.get_accValue(ChildId);

            if (value == null)
            {
                value = "";
            }

            Value = value;
        }
コード例 #6
0
        private void SetAccessibleProperties()
        {
            //Here we are consuming the COM Exceptions which happens in case
            //the property/Method we need is not available with IAccessible Object.

            try
            {
                _name = _accessible.get_accName(0);
            }
            catch (Exception ex)
            {
            }

            try
            {
                _value = _accessible.get_accValue(0);
            }
            catch (Exception ex)
            {
            }

            try
            {
                uint stateId = Convert.ToUInt32(_accessible.get_accState(0));
                _state = MSAA.GetStateText(stateId);
            }
            catch (Exception ex)
            {
            }

            try
            {
                uint roleId = Convert.ToUInt32(_accessible.get_accRole(0));
                _role = MSAA.GetRoleText(roleId);
            }
            catch (Exception ex)
            {
            }


            _handle = MSAA.GetHandle(_accessible);

            try
            {
                _defaultAction = _accessible.get_accDefaultAction(0);
            }
            catch (Exception ex)
            {
            }

            SetLocation(_accessible);
        }
コード例 #7
0
        internal static string GetValue(IAccessible accObj, int childId)
        {
            string bstr = null;

            try
            {
                bstr = accObj.get_accValue(childId);
            }
            catch (Exception exception)
            {
                if (!IsOleAccException(exception) || !IsOleAccExceptionMaskable(exception))
                {
                    throw;
                }
            }
            return(FixBstr(bstr) ?? string.Empty);
        }
コード例 #8
0
 string?IAccessibleInternal.get_accValue(object childID)
 => publicIAccessible.get_accValue(childID);
コード例 #9
0
        private void getChild(IAccessible iAccessible,bool done)
        {
            if (iAccessible == null)
            {
                Console.WriteLine(" The iAccessible object is null");
                return;
            }
            string accWindowName = iAccessible.get_accName(0);
            string accWindowVal = iAccessible.get_accValue(0);

            IAccessible[] childs = new IAccessible[iAccessible.accChildCount];

            int obtained = 0;

            AccessibleChildren(iAccessible, 0, iAccessible.accChildCount - 1, childs, out obtained);
            int i = 0;
            foreach (IAccessible child in childs)
            {
                if (child != null && child.GetType().IsCOMObject)
                {
                    Console.WriteLine("The value of i : " + i);
                    i++;
                    if (child == null)
                    {
                        Console.WriteLine("Child is NULL");
                        continue;
                    }
                    string cname = child.get_accName(0);
                    string cvalue = child.get_accValue(0);
                    string cdesc = child.get_accDescription(0);
                    int crole = child.get_accRole(0);

                    if (cname != null && cname.Trim() != "")
                        Console.WriteLine("Name is : " + cname);
                    else
                        Console.WriteLine("Name is : null");
                    if (cvalue != null && cvalue.Trim() != "")
                        Console.WriteLine("Value is : " + cvalue);
                    else
                        Console.WriteLine("Value is : null");

                    if (cdesc != null && cdesc.Trim() != "")
                        Console.WriteLine("Description is : " + cdesc);
                    else
                        Console.WriteLine("Description is : null");
                    if (crole != null)
                        Console.WriteLine("Role is : " + crole);
                    else
                        Console.WriteLine("Role is : null");
                    if (cname!=null && cname.Contains("Firebug"))
                    {
                        Console.WriteLine("Firebug");

                    }
                    getChild(child,true);
                }

            }
        }
コード例 #10
0
        //private static string GetClassNameOfWindow(IntPtr hwnd)
        //{
        //    string className = "";
        //    StringBuilder classText = null;
        //    try
        //    {
        //        int cls_max_length = 1000;
        //        classText = new StringBuilder("", cls_max_length + 5);
        //        GetClassName(hwnd, classText, cls_max_length + 2);

        //        if (!String.IsNullOrEmpty(classText.ToString()) && !String.IsNullOrWhiteSpace(classText.ToString()))
        //            className = classText.ToString();

        //        classText.Clear();

        //    }
        //    catch (Exception ex)
        //    {
        //        className = ex.Message;
        //    }
        //    finally
        //    {
        //        classText = null;
        //    }
        //    return className;
        //}

        private static string windowEventCallback2(IntPtr hWinEventHook, uint eventType,
                                                   IntPtr hwnd,
                                                   int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            //C++ code
            //IAccessible* pAcc = NULL;
            IAccessible pAcc = null;

            string result = null;

            //VARIANT varChild;
            object varChild;


            //HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, pAcc, varChild);
            uint hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, out pAcc, out varChild);

            if ((hr == 0) && (pAcc != null))
            {
                //BSTR bstrName, bstrValue;
                //pAcc->get_accValue(varChild, &bstrValue);
                //pAcc->get_accName(varChild, &bstrName);

                string bstrName  = "";
                string bstrValue = "";

                try
                {
                    if (varChild != null)
                    {
                        //bstrName = pAcc.accValue[varChild];
                        bstrValue = pAcc.get_accValue(varChild);
                        bstrName  = pAcc.get_accName(varChild);
                        //bstrValue = pAcc.accName[varChild];
                    }
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e.Message);
                }

                if (bstrValue != null && !bstrValue.Equals(""))
                {
                    //Console.WriteLine(bstrValue);
                }

                //string className = "";

                //if (isIEServerWindow(hwnd))
                //{
                //    //Console.WriteLine("CEVA");
                //}

                //GetClassNameOfWindow(hwnd);

                StringBuilder sb = new StringBuilder(200);
                GetClassName(hwnd, sb, 100);
                sb.Clear();



                //if (classText != null)
                //{

                //    Console.WriteLine(classText);
                //    //if (!String.IsNullOrEmpty(classText) &&
                //    //!String.IsNullOrWhiteSpace(classText))
                //    //    className = classText;

                //}

                //if (className.Equals("Chrome_WidgetWin_1") && bstrValue != null && !bstrValue.Equals(""))
                //{
                //    Console.WriteLine(className + " -> " + bstrValue);
                //    //result = bstrValue;
                //}

                //if (className.Equals("MozillaWindowClass") && !bstrValue.Equals(""))
                //{
                //    //Console.WriteLine(className + " -> " + bstrValue);
                //    //result = bstrValue;
                //}

                //if (className.Equals("OperaWindowClass") && !bstrValue.Equals(""))
                //{
                //    //Console.WriteLine(className + " -> " + bstrValue);
                //    //result = bstrValue;
                //}

                //pAcc->Release();
            }
            //C++ code

            return(result);
        }
コード例 #11
0
        private void getChild(IAccessible iAccessible, bool done)
        {
            if (iAccessible == null)
            {
                Console.WriteLine(" The iAccessible object is null");
                return;
            }
            string accWindowName = iAccessible.get_accName(0);
            string accWindowVal  = iAccessible.get_accValue(0);

            IAccessible[] childs = new IAccessible[iAccessible.accChildCount];

            int obtained = 0;

            AccessibleChildren(iAccessible, 0, iAccessible.accChildCount - 1, childs, out obtained);
            int i = 0;

            foreach (IAccessible child in childs)
            {
                if (child != null && child.GetType().IsCOMObject)
                {
                    Console.WriteLine("The value of i : " + i);
                    i++;
                    if (child == null)
                    {
                        Console.WriteLine("Child is NULL");
                        continue;
                    }
                    string cname  = child.get_accName(0);
                    string cvalue = child.get_accValue(0);
                    string cdesc  = child.get_accDescription(0);
                    int    crole  = child.get_accRole(0);


                    if (cname != null && cname.Trim() != "")
                    {
                        Console.WriteLine("Name is : " + cname);
                    }
                    else
                    {
                        Console.WriteLine("Name is : null");
                    }
                    if (cvalue != null && cvalue.Trim() != "")
                    {
                        Console.WriteLine("Value is : " + cvalue);
                    }
                    else
                    {
                        Console.WriteLine("Value is : null");
                    }

                    if (cdesc != null && cdesc.Trim() != "")
                    {
                        Console.WriteLine("Description is : " + cdesc);
                    }
                    else
                    {
                        Console.WriteLine("Description is : null");
                    }
                    if (crole != null)
                    {
                        Console.WriteLine("Role is : " + crole);
                    }
                    else
                    {
                        Console.WriteLine("Role is : null");
                    }
                    if (cname != null && cname.Contains("Firebug"))
                    {
                        Console.WriteLine("Firebug");
                    }
                    getChild(child, true);
                }
            }
        }
コード例 #12
0
 string UnsafeNativeMethods.IAccessibleInternal.get_accValue(object childID)
 {
     IntSecurity.UnmanagedCode.Assert();
     return(publicIAccessible.get_accValue(childID));
 }