EmptySpace Posted December 26, 2012 Share Posted December 26, 2012 (edited) Cant manage to make it myself. For example I want script to wait till I click submit button in example form. I think I need to read values somehow or smth.. #include Local $oIE = _IE_Example("form") $oForm = _IEFormGetCollection($oIE, 0) Global $oQuery = _IEFormElementGetObjByName($oForm, "submitExample") While 1 WEnd Any ideas? Edited December 26, 2012 by EdgarT Link to comment Share on other sites More sharing options...
ileandros Posted December 27, 2012 Share Posted December 27, 2012 Get the property of the button (example $oQuery.name) and do a sleep until that property returns false. Should exist better solutions but thats the only thing passing through my head now I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
EmptySpace Posted December 27, 2012 Author Share Posted December 27, 2012 Ah, I tried it. But I need script to react immediately when I click button. Its too late when other webpage is opened.. Link to comment Share on other sites More sharing options...
junkew Posted December 27, 2012 Share Posted December 27, 2012 should be possible with ui automation AddAutomationEventHandler should be able to grab the click event will need some study first to understand the ui automation model FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
junkew Posted December 27, 2012 Share Posted December 27, 2012 (edited) some not working code as a start unable to register the invoke events of ui automation ;~ ;~ http://msdn.microsoft.com/en-us/library/windows/desktop/ff625914(v=vs.85).aspx not sure if watching the right part of the tree expandcollapse popup#include <WinAPI.au3> #include <AutoItObject.au3> #include "CUIAutomation.au3" ;~ http://www.autoitscript.com/forum/topic/128406-interface-autoitobject-iuiautomation/ ;~ http://msdn.microsoft.com/en-us/library/windows/desktop/ff625914(v=vs.85).aspx HotKeySet("{ESC}", "Terminate") Global $oDesktop ;Desktop will be frequently the starting point _AutoItObject_StartUp() ;Starting the autoit object library Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF) EndFunc ;==>_ErrFunc ;~ The main object with acces to the windows automation api 3.0 Global $objUIAutomation = _AutoItObject_ObjCreate($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If IsObj($objUIAutomation) Then ConsoleWrite("At least it seems we have the core object to start with" & @CRLF) EndIf ;~ Try to get the desktop as a generic reference/global for all samples $aCall = $objUIAutomation.GetRootElement(0) $oDesktop = _AutoItObject_WrapperCreate($aCall[1], $dtagIUIAutomationElement) If IsObj($oDesktop) Then ConsoleWrite("At least it seems I have the desktop as a frequently used starting point" & @CRLF) EndIf ;enum TreeScope ;=============================================================================== ;~ Global Const $TreeScope_Element=1 ;~ Global Const $TreeScope_Children=2 ;~ Global Const $TreeScope_Descendants=4 ;~ Global Const $TreeScope_Parent=8 ;~ Global Const $TreeScope_Ancestors=16 ;~ Global Const $TreeScope_Subtree=7 ;~ Event Handler Global $oAEHandler = _AutoItObject_ObjectFromDtag("_MyHandler_", $dtagIUIAutomationEventHandler) $objUIAutomation.AddAutomationEventHandler($UIA_Invoke_InvokedEventId, $oDesktop.__ptr__, $TreeScope_Children, 0, $oAEHandler.__ptr__) ;~ $objUIAutomation.AddAutomationEventHandler($UIA_Window_WindowOpenedEventId, $oDesktop.__ptr__, $TreeScope_Subtree, 0, $oAEHandler.__ptr__) ;~ $objUIAutomation.AddAutomationEventHandler($UIA_Window_WindowClosedEventId, $oDesktop.__ptr__, $TreeScope_Subtree, 0, $oAEHandler.__ptr__) While 1 Sleep(100) WEnd Func Terminate() $objUIAutomation.RemoveAllEventHandlers() $objUIAutomation = 0 $oAEEHandler = 0 Exit 0 EndFunc ;==>Terminate ; Handler methods. "_MyHandler_" is the specified prefix: Func _MyHandler_QueryInterface($pSelf, $pRIID, $pObj) ConsoleWrite("_MyHandler_QueryInterface called " & $pSelf & " " & _WinAPI_StringFromGUID($pRIID) & " ") Local $tStruct = DllStructCreate("ptr", $pObj) Switch _WinAPI_StringFromGUID($pRIID) Case $sIID_IUnknown ConsoleWrite("IUnknown" & @CRLF) Case $sIID_IUIAutomationfocusChangedEventHandler ConsoleWrite("IUIAutomationfocusChangedEventHandler" & @CRLF) Case Else ConsoleWrite(@CRLF) Return 0x80004002 ; E_NOINTERFACE EndSwitch DllStructSetData($tStruct, 1, $pSelf) Return 0 ; S_OK EndFunc ;==>_MyHandler_QueryInterface Func _MyHandler_AddRef($pSelf) #forceref $pSelf ConsoleWrite("_MyHandler_AddRef called" & @CRLF) Return 0 ; S_OK EndFunc ;==>_MyHandler_AddRef Func _MyHandler_Release($pSelf) #forceref $pSelf ConsoleWrite("_MyHandler_Release called" & @CRLF) Return 0 ; S_OK EndFunc ;==>_MyHandler_Release Func _MyHandler_HandleAutomationEvent($pSelf, $pElem, $iEvent) #forceref $pSelf ConsoleWrite("! _MyHandler_HandleAutomationEvent called: $pElem = " & $pElem & @CRLF) If $pElem Then Local $oElem = _AutoItObject_WrapperCreate($pElem, $dtagIUIAutomationElement) $oElem.AddRef() Local $aCall = $oElem.CurrentClassName(0) ConsoleWrite(">>> Somebody is clicking on: " & $aCall[1] & @CRLF) EndIf Return 0 ; S_OK EndFunc ;==>_MyHandler_HandleAutomationEvent Edited December 27, 2012 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now