|
发表于 2010-4-7 20:54:57
|
显示全部楼层
这个会不会太难 AccExplorer32
本帖最后由 lainline 于 2010-4-8 10:57 编辑
控件本身
$htemp =ControlGetHandle("[CLASS:ToolbarWindow32]","","[CLASSNN:ToolbarWindow322")
$text =WinGetText($htemp,"")
ToolTip($htemp)
MsgBox(0,$text,"存在:"& BitAND(WinGetState($htemp,""),1))
MsgBox(0,$text,"可用:"& BitAND(WinGetState($htemp,""),4))
MsgBox(0,$text,"可见:"& BitAND(WinGetState($htemp,""),2))
MsgBox(0,$text,"激活:"& BitAND(WinGetState($htemp,""),8))
MsgBox(0,$text,"最小化:"& BitAND(WinGetState($htemp,""),16))
MsgBox(0,$text,"最大化:"& BitAND(WinGetState($htemp,""),32))
下面具体到按钮就有些难了
工具:
示例代码从英文站上找来的如果要看原文可以到英文站上搜索#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>
;~ opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
Global Const $hOLE32 = DllOpen("ole32.dll")
Global Const $hOLEACC = DllOpen("oleacc.dll")
Global Const $hOleAut = DllOpen("oleaut.dll")
Global Const $VT_EMPTY = 0
Global Const $VT_NULL = 1
Global Const $VT_I2 = 2
Global Const $VT_I4 = 3
Global Const $VT_R4 = 4
Global Const $VT_R8 = 5
Global Const $VT_CY = 6
Global Const $VT_DATE = 7
Global Const $VT_BSTR = 8
Global Const $VT_DISPATCH = 9
Global Const $VT_ERROR = 10
Global Const $VT_BOOL = 11
Global Const $VT_VARIANT = 12
Global Const $VT_UNKNOWN = 13
Global Const $VT_DECIMAL = 14
Global Const $VT_I1 = 16
Global Const $VT_UI1 = 17
Global Const $VT_UI2 = 18
Global Const $VT_UI4 = 19
Global Const $VT_I8 = 20
Global Const $VT_UI8 = 21
Global Const $VT_INT = 22
Global Const $VT_UINT = 23
Global Const $VT_VOID = 24
Global Const $VT_HRESULT = 25
Global Const $VT_PTR = 26
Global Const $VT_SAFEARRAY = 27
Global Const $VT_CARRAY = 28
Global Const $VT_USERDEFINED = 29
Global Const $VT_LPSTR = 30
Global Const $VT_LPWSTR = 31
Global Const $VT_RECORD = 36
Global Const $VT_INT_PTR = 37
Global Const $VT_UINT_PTR = 38
Global Const $VT_FILETIME = 64
Global Const $VT_BLOB = 65
Global Const $VT_STREAM = 66
Global Const $VT_STORAGE = 67
Global Const $VT_STREAMED_OBJECT = 68
Global Const $VT_STORED_OBJECT = 69
Global Const $VT_BLOB_OBJECT = 70
Global Const $VT_CF = 71
Global Const $VT_CLSID = 72
Global Const $VT_VERSIONED_STREAM = 73
Global Const $VT_BSTR_BLOB = 0xfff
Global Const $VT_VECTOR = 0x1000
Global Const $VT_ARRAY = 0x2000
Global Const $VT_BYREF = 0x4000
Global Const $VT_RESERVED = 0x8000
Global Const $VT_ILLEGAL = 0xffff
Global Const $VT_ILLEGALMASKED = 0xfff
Global Const $VT_TYPEMASK = 0xfff
;~ Global Const $tagGUID = "ulong;ushort;ushort;byte[8]"
Global Const $tagCLSID = $tagGUID
Global Const $tagUUID = $tagGUID
Global Const $CLSCTX_INPROC_SERVER = 0x1
Global Const $S_OK = 0
Global Const $DISP_E_UNKNOWNNAME = 2147614726
Global Const $DISPID_UNKNOWN = 4294967295
Global Const $DISP_E_MEMBERNOTFOUND = 2147614723
Global Const $tagVARIANT = "ushort vt;ushort r1;ushort r2;ushort r3;uint64 data"
Global Const $tagDISPPARAMS = "ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;"
Global Const $DISPATCH_METHOD = 0x1
Global Const $DISPATCH_PROPERTYGET = 0x2
Global Const $DISPATCH_PROPERTYPUT = 0x4
Global Const $DISPATCH_PROPERTYPUTREF = 0x8
Global Const $tagLOOKUP_TABLE_ENTRY = "ptr name;ptr value;dword flags;"
Global Const $LOOKUP_TABLE_ENTRY_SIZE = DllStructGetSize(DllStructCreate($tagLOOKUP_TABLE_ENTRY))
Global Const $LOOKUP_TABLE_METHOD = 1
Global Const $LOOKUP_TABLE_PROPERTY = 2
Global Const $LOOKUP_TABLE_PUBLIC = 0
Global Const $LOOKUP_TABLE_PRIVATE = 4
Global Const $tagOBJECT_INFO = "dword refcount;ptr release;"
Global Const $hOLEOUT = DllOpen("oleaut32.dll")
Global Const $SizeOfPtr = DllStructGetSize(DllStructCreate("ptr"))
Global $myEdit
GUICreate("MSAA Spy")
$myEdit = GUICtrlCreateEdit("First line" & @CRLF, 10, 10, 400, 300, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUISetOnEvent(-3, "_Quit")
GUISetState()
Global $aMousePos, $aCall, $oIAccesible
Global $tInfo
global $oChild
Global Const $__Au3Obj_tagVARIANT = "ushort vt;ushort r1;ushort r2;ushort r3;ptr data; ptr"
Global $tVar = DllStructCreate($__Au3Obj_tagVARIANT)
Global $pVar = DllStructGetPtr($tVar)
__Au3Obj_VariantInit($pVar)
While 1
$aMousePos = MouseGetPos()
$aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromPoint", _
"int", $aMousePos[0], _
"int", $aMousePos[1], _
"ptr*", 0, _
"ptr", $pVar)
;~ "ptr", $pVar)
If @error Or $aCall[0]<>0 Then
ConsoleWrite("!DLLCall-Error or error on receiving IAccesible" & @CRLF)
Sleep(500)
ContinueLoop
EndIf
$oIAccesible = __Au3Obj_ConvertPtrToIDispatch($aCall[3]) ; create IDispatch when no error occured
If IsObj($oIAccesible) Then
; ConsoleWrite("accChild: " & $oAccessibleObject.accChild($Param) & @CRLF) ;<-
GUICtrlSetData($myedit, "")
;~ $oChild=$oIAccesible.accchild
$x=int(2+$oChild)-2
dim $array[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
if COMVariantToValue($pVar)<15 then
$oChild=$array[COMVariantToValue($pVar)]
Else
$oChild=0
endif
$tInfo=$x & @CRLF
$tInfo = $tinfo & "accChildCount: " & $oIAccesible.accChildCount($oChild)& @CRLF
$tInfo = $tinfo & "accDefaultAction: " & $oIAccesible.accDefaultAction($oChild) & @CRLF
$tInfo = $tinfo & "accDescription: " & $oIAccesible.accDescription($oChild) & @CRLF
$tInfo = $tinfo & "accFocus: " & $oIAccesible.accFocus($oChild) & @CRLF
$tInfo = $tinfo & "accHelp: " & $oIAccesible.accHelp($oChild) & @CRLF
;~ $tInfo = $tinfo & "accHelpTopic: " & $oIAccesible.accHelpTopic($Param) & @CRLF
$tInfo = $tinfo & "accKeyboardShortcut: " & $oIAccesible.accKeyboardShortcut & @CRLF
$tInfo = $tinfo & "accName: " & $oIAccesible.accName($oChild) & @CRLF
;~ $tInfo = $tinfo & "accName: " & $oIAccesible.accName(number($oChild)) & @CRLF
;~ $tInfo = $tinfo & "accName: " & $oIAccesible.accName(int($oChild)) & @CRLF
$tInfo = $tinfo & "accParent: " & $oIAccesible.accParent($oChild) & @CRLF
dim $sText
;- Get the textual description of the role
local $aRoleCall = DllCall($hOLEACC, "int", "GetRoleText", "DWORD", $oIAccesible.accRole($oChild), "str", $sText, "int", 255)
$tInfo = $tinfo & "accRole: " & $oIAccesible.accRole($oChild) & ":" & $aRoleCall[2] & @CRLF
$tInfo = $tinfo & "accSelection: " & $oIAccesible.accSelection($oChild) & @CRLF
$tInfo = $tinfo & "accState: " & $oIAccesible.accState($oChild) & @CRLF
$tInfo = $tinfo & "accValue: " & $oIAccesible.accValue($oChild) & @CRLF
dim $pX,$pY,$cX,$cY
;~ $oIAccesible.accLocation($px,$py,$cx,$cy,$oChild)
$oIAccesible.accLocation($px,$py,$cx,$cy,$pVar)
$tInfo = $tinfo & "accLocation: " & $px & $py & $cx & $cy & @CRLF
GUICtrlSetData($myedit, $tInfo)
Else
ConsoleWrite("! NOT OBJECT" & @CRLF)
EndIf
;~ Do not forget to clean the return result
__Au3Obj_VariantClear($aCall[4])
$oIAccesible = 0 ; free Object
Sleep(500)
WEnd
Func MyErrFunc()
ConsoleWrite("!COM Error! " & "Number is: " & Hex($oMyError.number, 8) & " description is: " & $oMyError.windescription & @CRLF)
EndFunc ;==>MyErrFunc
; FUNCTIONS:
Func _GetObjectWinHandle($oObject)
Local $aCall = DllCall("oleacc.dll", "int", "WindowFromAccessibleObject", _
"idispatch", $oObject, _
"hwnd*", 0)
If @error Or $aCall[0] Then
Return SetError(1, 0, 0)
EndIf
Return $aCall[2]
EndFunc ;==>_GetObjectWinHandle
Func _AccessibleObjectFromWindow($hWnd)
Local $sIID_IAccessible = "{618736E0-3C3D-11CF-810C-00AA00389B71}"
Local $tGUID = _WinAPI_GUIDFromString($sIID_IAccessible)
Local $pGUID = DllStructGetPtr($tGUID)
Local $aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromWindow", _
"hwnd", $hWnd, _
"dword", 0, _ ; OBJID_WINDOW
"ptr", $pGUID, _
"idispatch*", 0)
If @error Or $aCall[0] Then
Return SetError(1, 0, 0)
EndIf
Return $aCall[4]
EndFunc ;==>_AccessibleObjectFromWindow
Func _AccessibleObjectFromPoint($x,$y)
Local $tPoint=DllStructCreate($tagPOINT)
dllstructsetdata($tPoint,1,$x)
dllstructsetdata($tPoint,2,$y)
;~ STDAPI AccessibleObjectFromWindow( __in HWND hwnd, __in DWORD dwObjectID, __in REFIID riid, __out void **ppvObject);
;~ STDAPI AccessibleObjectFromPoint( __in POINT ptScreen, __out IAccessible **ppacc, __out VARIANT *pvarChild);
;~ local $aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromPoint", "ptr", DllStructGetPtr($tPOINT), "idispatch*", 0, "ptr", 0)
;~ local $aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromPoint", "long", DllStructGetPtr($tPOINT), "idispatch", 0, "ptr", 0)
local $aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromPoint", "int", $x, "int", $y, "idispatch*", 0, "ptr", 0)
If @error Or $aCall[0] Then
Return SetError(1, 0, 0)
EndIf
Return ConvertPtrToIDispatch($aCall[3])
EndFunc ;==>_AccessibleObjectFromWindow
; In the end we still want the autoit object. This function converts a raw pointer to an autoit object
Func ConvertPtrToIDispatch($pIDispatch)
; This would have been 10000x easier if autoit had supported the idispatch* type in dllstructs...
; Fortunetely memcpy can copy the pointer into a idispatch*, lucky us.
Local $aCall = DllCall("kernel32.dll", "none", "RtlMoveMemory", _
"idispatch*", 0, _
"ptr*", $pIDispatch, _
"dword", 4)
If @error Then
Return SetError(1, 0, 0)
EndIf
Return $aCall[1]
EndFunc ;==>ConvertPtrToIDispatch
Func __Au3Obj_ConvertPtrToIDispatch($pIDispatch)
; Author: monoceres
Local $iSize = 4+(4*@AutoItX64)
Local $aCall = DllCall("kernel32.dll", "none", "RtlMoveMemory", "idispatch*", 0, "ptr*", $pIDispatch, "dword", $iSize)
If @error Then Return SetError(1, 0, 0)
Return $aCall[1]
EndFunc ;==>__Au3Obj_ConvertPtrToIDispatch
Func __Au3Obj_VariantClear($pvarg)
; Author: Prog@ndy
Local $aCall = DllCall($hOleAut, "long", "VariantClear", "ptr", $pvarg)
If @error Then Return SetError(1, 0, 1)
Return $aCall[0]
EndFunc ;==>__Au3Obj_VariantClear
Func __Au3Obj_VariantInit($pvarg)
; Author: Prog@ndy
Local $aCall = DllCall($hOleAut, "long", "VariantInit", "ptr", $pvarg)
If @error Then Return SetError(1, 0, 1)
Return $aCall[0]
EndFunc ;==>__Au3Obj_VariantInit
Func VTType2AutoitType($iVT_Type)
ConsoleWrite("! " & $iVT_Type & @CRLF)
Switch $iVT_Type
Case $VT_I1
Return "byte"
Case $VT_I2
Return "short"
Case $VT_I4
Return "int"
Case $VT_BSTR
Return "wstr"
Case $VT_R8
Return "double"
Case $VT_DISPATCH
Return "idispatch"
EndSwitch
EndFunc ;==>VTType2AutoitType
Func COMVariantToValue($pVariant)
Local $hVariant = DllStructCreate($tagVARIANT, $pVariant)
; Translate the vt id to a autoit dllcall type
$sType = VTType2AutoitType(DllStructGetData($hVariant, "vt"))
If $sType = "wstr" Then
$pString = DllStructCreate("ptr", DllStructGetPtr($hVariant, "data"))
; Getting random crashes when trusting autoit to automatically use right size.
; doing it myself instead (also, it should be a BSTR, but it's not. Is autoit not obeying the rules!?
$iString_Size = wcslen(DllStructGetData($pString, 1))
; Sorry trancexx, doesn't seem to work on large strings (crashes like crazy when trying to use on 1 MB string)
;$tSub = DllStructCreate("dword", DllStructGetData($str_ptr, 1) - 4) ; <- move pointer back 4 bytes!
$hData = DllStructCreate("wchar[" & $iString_Size & "]", DllStructGetData($pString, 1))
ElseIf $sType = "idispatch" Then
Return ConvertPtrToIDispatch(DllStructGetData(DllStructCreate("ptr", DllStructGetPtr($hVariant, "data")), 1))
Else
$hData = DllStructCreate($sType, DllStructGetPtr($hVariant, "data"))
EndIf
Return DllStructGetData($hData, 1)
EndFunc ;==>COMVariantToValue
; Find out length of string. I do not trust autoit to do this.
Func wcslen($pWString)
$aCall = DllCall("ntdll.dll", "dword:cdecl", "wcslen", "ptr", $pWString)
Return $aCall[0]
EndFunc ;==>wcslen
Func _Quit()
Exit
EndFunc ;==>_Quit
;
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
评分
-
查看全部评分
|