Jump to content

WinWait and ControlClick


dleonard
 Share

Recommended Posts

The following code...

#include <ie.au3>

Local $hLogOff = WinWait("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog")
If IsHWnd($hLogOff) = 0 Then
    TrayTip('$hLogOff', 'Is not HWnd', 100)
Else
    $oIELogOff = _IEAttach($hLogOff, 'DialogBox')
    ConsoleWrite(@CRLF)
    ConsoleWrite('===============================================')
    ConsoleWrite(@CRLF)
    $sHTML = _IEPropertyGet($oIELogOff, "outerhtml")
    ClipPut($sHTML)
    ConsoleWrite($sHTML)
    ConsoleWrite(@CRLF)
    ConsoleWrite('===============================================')
    ConsoleWrite(@CRLF)
EndIf

...produced the following output...

 
===============================================
 
<BODY class=pgBody onunload=terminate() onload=windowOnload(); scroll=no><LINK rel=stylesheet href="/dynamic/uia/style/uia/sui_msgDialog.css?v=05050708">
<SCRIPT language=javascript src="/dynamic/soarian/sframe/sframeAutomaticLogoff.js?v=05050708"></SCRIPT>
 
<TABLE class=hw100 border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD class=mainBody>
<TABLE border=0 cellSpacing=0 cellPadding=0 width="100%" height="100%">
<TBODY>
<TR>
<TD id=imgTD class=iconHeader vAlign=top width="1%"><IMG id=msgImg src="/dynamic/uia/img/uia/sui_warning.gif"></TD>
<TD class=textHeader vAlign=top align=left>
<DIV style="PADDING-BOTTOM: 20px" id=msgDiv class=oflowAuto>You will be automatically logged off in&nbsp; <SPAN id=numberOfSecondsSpan>15</SPAN>&nbsp; seconds.<BR><BR>Click OK to prevent an automatic logoff.</DIV></TD></TR></TBODY></TABLE></TD></TR>
<TR id=btnRow>
<TD class=footer align=middle><SPAN style="VISIBILITY: visible" id=ctlokBtn class=IccButtonNoBorder iccELEM="CO"><BUTTON style="VISIBILITY: visible" id=ctlokBtnButton__ class=IccButtonGradient iccVector="0,1,,IccButtonGradient,IccButtonGradientDisabled,IccButtonLatched,IccButtonNoBorder,IccButtonGradientDown" class="IccButtonGradient">OK</BUTTON> </SPAN></TD></TR></TBODY></TABLE></BODY>
===============================================
Link to comment
Share on other sites

Try it with the logic as can be found here

'?do=embed' frameborder='0' data-embedContent>>

#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=N

;~ Set the system under test UID objects to recognize
local $UID_IEDialog[2][2] = [ _
["mainwindow","SIEMENS.*Dialog"], _
["btnOk","name:=Ok"] _
]
_UIA_setVarsFromArray($UID_IEDialog,"IEDialog.")


;~ To be moved to 1 or multiple scriptfiles
;- Set the script
;~ The actual script, 50,10 is only there if a lot of lines and parameters are needed

local $script[50][10]= [ _
["IEDialog.Mainwindow","setfocus"], _
["IEDialog.btnOk",   "click"] _
]

_UIA_launchScript($script)

Exit
Edited by junkew
Link to comment
Share on other sites

do this woks?

#include <IE.au3>
$hLogOff = WinWait("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog")
$oIELogOff = _IEAttach($hLogOff, 'DialogBox')
$oSubmit = _IEGetObjByID($oIELogOff, "ctlokBtnButton__")
_IEAction ($oSubmit, "click")

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

 

Try it with the logic as can be found here

'?do=embed' frameborder='0' data-embedContent>>

#include "UIAWrappers.au3"

#AutoIt3Wrapper_UseX64=N

;~ Set the system under test UID objects to recognize
local $UID_IEDialog[2][2] = [ _
["mainwindow","SIEMENS.*Dialog"], _
["btnOk","name:=Ok"] _
]
_UIA_setVarsFromArray($UID_IEDialog,"IEDialog.")


;~ To be moved to 1 or multiple scriptfiles
;- Set the script
;~ The actual script, 50,10 is only there if a lot of lines and parameters are needed

local $script[50][10]= [ _
["IEDialog.Mainwindow","setfocus"], _
["IEDialog.btnOk",   "click"] _
]

_UIA_launchScript($script)

Exit

This code produced an error...

Line 4773

"Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded."

Link to comment
Share on other sites

This did not work.

Any console output ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

This code produced an error...

 

Line 4773

 

"Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded."

'?do=embed' frameborder='0' data-embedContent>>

 

In the first post there is a simply spy.

Hover over the popup and post the contents of the spy

do the same for the button

 

Is there any public website where we can see a comparable example of what you are trying to accomplish? Can you create a dummy standalone HTML page to reproduce the popup you show

 

for example if I have on Autoit the full editor and choose to insert code I get a similar overlay/popup

which I identify as

Title is: <Code> Class   := <> controltype:= <UIA_CustomControlTypeId> ,<50025> , (0000C369)

and the Ok button

Title is: <OK> Class   := <> controltype:= <UIA_ButtonControlTypeId> ,<50000> , (0000C350)

 

In its most simplified form this can lead to this code (the other example was especially for when you create larger scripts)

#include "UIAWrappers.au3" 

#AutoIt3Wrapper_UseX64=N

_UIA_Action("name:=Code; controltype:=Custom", "setfocus")
_UIA_Action("name:=OK;controltype:=Button;instance:=2", "click")
To have above working you have to patch a little in UIAWrappers.AU3

$startElement="RTI." & stringleft($obj_or_string,stringinstr($obj_or_string,".")) & "mainwindow"
                $oStart=_UIA_getVar($startElement)
;~              if isobj($oStart) Then
;~                  _UIA_DEBUG("Its an object ")
;~              Endif
should become

 

$startElement="RTI." & stringleft($obj_or_string,stringinstr($obj_or_string,".")) & "mainwindow"
                $oStart=_UIA_getVar($startElement)
                if isobj($oStart) Then
;~                  _UIA_DEBUG("Its an object ")
                Else
                    $oStart=$oDesktop
                endif
Edited by junkew
Link to comment
Share on other sites

'?do=embed' frameborder='0' data-embedContent>>

 

In the first post there is a simply spy.

Hover over the popup and post the contents of the spy

 

Here are the "spy" results from the popup window...

 

Mouse position is retrieved 809-453
At least we have an element [][]
Having the following values for all properties: 
Title is: <> Class   := <> controltype:= <UIA_TitleBarControlTypeId> ,<50037> , (0000C375)
*** Parent Information ***
Title is: <SIEMENS Soarian® Automatic Logoff -- Webpage Dialog> Class   := <Internet Explorer_TridentDlgFrame> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370)
*** Detailed properties of the highlighted element ***
UIA_AcceleratorKeyPropertyId :=
UIA_AccessKeyPropertyId :=
UIA_AriaPropertiesPropertyId :=
UIA_AriaRolePropertyId :=
UIA_AutomationIdPropertyId :=
UIA_BoundingRectanglePropertyId :=693;453;325;26
UIA_ClassNamePropertyId :=
UIA_ClickablePointPropertyId :=
UIA_ControllerForPropertyId :=
UIA_ControlTypePropertyId :=50037
UIA_CulturePropertyId :=0
UIA_DescribedByPropertyId :=
UIA_DockDockPositionPropertyId :=5
UIA_ExpandCollapseExpandCollapseStatePropertyId :=3
UIA_FlowsToPropertyId :=
UIA_FrameworkIdPropertyId :=
UIA_GridColumnCountPropertyId :=0
UIA_GridItemColumnPropertyId :=0
UIA_GridItemColumnSpanPropertyId :=1
UIA_GridItemContainingGridPropertyId :=
UIA_GridItemRowPropertyId :=0
UIA_GridItemRowSpanPropertyId :=1
UIA_GridRowCountPropertyId :=0
UIA_HasKeyboardFocusPropertyId :=False
UIA_HelpTextPropertyId :=
UIA_IsContentElementPropertyId :=False
UIA_IsControlElementPropertyId :=True
UIA_IsDataValidForFormPropertyId :=False
UIA_IsDockPatternAvailablePropertyId :=False
UIA_IsEnabledPropertyId :=True
UIA_IsExpandCollapsePatternAvailablePropertyId :=False
UIA_IsGridItemPatternAvailablePropertyId :=False
UIA_IsGridPatternAvailablePropertyId :=False
UIA_IsInvokePatternAvailablePropertyId :=False
UIA_IsItemContainerPatternAvailablePropertyId :=False
UIA_IsKeyboardFocusablePropertyId :=True
UIA_IsLegacyIAccessiblePatternAvailablePropertyId :=True
UIA_IsMultipleViewPatternAvailablePropertyId :=False
UIA_IsOffscreenPropertyId :=False
UIA_IsPasswordPropertyId :=False
UIA_IsRangeValuePatternAvailablePropertyId :=False
UIA_IsRequiredForFormPropertyId :=False
UIA_IsScrollItemPatternAvailablePropertyId :=False
UIA_IsScrollPatternAvailablePropertyId :=False
UIA_IsSelectionItemPatternAvailablePropertyId :=False
UIA_IsSelectionPatternAvailablePropertyId :=False
UIA_IsSynchronizedInputPatternAvailablePropertyId :=False
UIA_IsTableItemPatternAvailablePropertyId :=False
UIA_IsTablePatternAvailablePropertyId :=False
UIA_IsTextPatternAvailablePropertyId :=False
UIA_IsTogglePatternAvailablePropertyId :=False
UIA_IsTransformPatternAvailablePropertyId :=False
UIA_IsValuePatternAvailablePropertyId :=True
UIA_IsVirtualizedItemPatternAvailablePropertyId :=False
UIA_IsWindowPatternAvailablePropertyId :=False
UIA_ItemStatusPropertyId :=
UIA_ItemTypePropertyId :=
UIA_LabeledByPropertyId :=
UIA_LegacyIAccessibleChildIdPropertyId :=0
UIA_LegacyIAccessibleDefaultActionPropertyId :=
UIA_LegacyIAccessibleDescriptionPropertyId :=Displays the name of the window and contains controls to manipulate it
UIA_LegacyIAccessibleHelpPropertyId :=
UIA_LegacyIAccessibleKeyboardShortcutPropertyId :=
UIA_LegacyIAccessibleNamePropertyId :=
UIA_LegacyIAccessibleRolePropertyId :=1
UIA_LegacyIAccessibleSelectionPropertyId :=
UIA_LegacyIAccessibleStatePropertyId :=1048576
UIA_LegacyIAccessibleValuePropertyId :=SIEMENS Soarian® Automatic Logoff -- Webpage Dialog
UIA_LocalizedControlTypePropertyId :=title bar
UIA_MultipleViewCurrentViewPropertyId :=0
UIA_MultipleViewSupportedViewsPropertyId :=
UIA_NamePropertyId :=
UIA_NativeWindowHandlePropertyId :=0
UIA_OrientationPropertyId :=0
UIA_ProcessIdPropertyId :=3628
UIA_ProviderDescriptionPropertyId :=[pid:1176,hwnd:0x0 Annotation:Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]
UIA_RangeValueIsReadOnlyPropertyId :=True
UIA_RangeValueLargeChangePropertyId :=0
UIA_RangeValueMaximumPropertyId :=0
UIA_RangeValueMinimumPropertyId :=0
UIA_RangeValueSmallChangePropertyId :=0
UIA_RangeValueValuePropertyId :=0
UIA_RuntimeIdPropertyId :=42;3803234;1;-2147483647;3803234;-2;0
UIA_ScrollHorizontallyScrollablePropertyId :=False
UIA_ScrollHorizontalScrollPercentPropertyId :=0
UIA_ScrollHorizontalViewSizePropertyId :=100
UIA_ScrollVerticallyScrollablePropertyId :=False
UIA_ScrollVerticalScrollPercentPropertyId :=0
UIA_ScrollVerticalViewSizePropertyId :=100
UIA_SelectionCanSelectMultiplePropertyId :=False
UIA_SelectionIsSelectionRequiredPropertyId :=False
UIA_SelectionselectionPropertyId :=
UIA_SelectionItemIsSelectedPropertyId :=False
UIA_SelectionItemSelectionContainerPropertyId :=
UIA_TableColumnHeadersPropertyId :=
UIA_TableItemColumnHeaderItemsPropertyId :=
UIA_TableRowHeadersPropertyId :=
UIA_TableRowOrColumnMajorPropertyId :=2
UIA_TableItemRowHeaderItemsPropertyId :=
UIA_ToggleToggleStatePropertyId :=2
UIA_TransformCanMovePropertyId :=False
UIA_TransformCanResizePropertyId :=False
UIA_TransformCanRotatePropertyId :=False
UIA_ValueIsReadOnlyPropertyId :=False
UIA_ValueValuePropertyId :=SIEMENS Soarian® Automatic Logoff -- Webpage Dialog
UIA_WindowCanMaximizePropertyId :=False
UIA_WindowCanMinimizePropertyId :=False
UIA_WindowIsModalPropertyId :=False
UIA_WindowIsTopmostPropertyId :=False
UIA_WindowWindowInteractionStatePropertyId :=0
UIA_WindowWindowVisualStatePropertyId :=0
Link to comment
Share on other sites

Something like this (do not forget to patch UIAWrappers with the comment I gave earlier)

and if there are multiple buttons ok around it could be you have to add instance property

like

_UIA_Action("name:=OK;controltype:=Button; instance:=2", "click")
#include "UIAWrappers.au3" 

#AutoIt3Wrapper_UseX64=N

_UIA_Action("name:=SIEMENS Soarian.*; class:=Internet Explorer_TridentDlgFrame", "setfocus")
_UIA_Action("name:=OK;controltype:=Button", "click")
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...