Jump to content

Recommended Posts

Posted

I am attempting to write my first AutoIt script to detect when a window is present and then click the OK button. Testing has been difficult so I'm looking for some validation of my code from the experts. Am I doing it right?

 

Screenshot of window

Logoff.gif

 

Window Info

>>>> Window <<<<
Title: SIEMENS Soarian® Automatic Logoff -- Webpage Dialog
Class: Internet Explorer_TridentDlgFrame
Position: 665, 450
Size: 356, 152
Style: 0x96C80000
ExStyle: 0x00000101
Handle: 0x00DA0706
 
>>>> Control <<<<
Class: Internet Explorer_Server
Instance: 1
ClassnameNN: Internet Explorer_Server1
Name:
Advanced (Class): [CLASS:Internet Explorer_Server; INSTANCE:1]
ID:
Text:
Position: 0, 0
Size: 350, 120
ControlClick Coords: 281, 62
Style: 0x56000000
ExStyle: 0x00000000
Handle: 0x0080078C
 
>>>> Mouse <<<<
Position: 949, 541
Cursor ID: 0
Color: 0xE8EFFA
 
>>>> StatusBar <<<<
 
>>>> ToolsBar <<<<
 
>>>> Visible Text <<<<
 
 
>>>> Hidden Text <<<<
 
 
Code
#NoTrayIcon
#include <IE.au3>
 
; Wait for logoff window, then click on OK
WinWait("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog")
ControlClick("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog", "", "[CLASS:Button; TEXT:OK; Instance:1;]")

 

Posted
  On 11/20/2013 at 8:23 PM, JLogan3o13 said:

Hi, dleonard. Are you simply looking for someone to say "yup it looks right",  or are you experiencing an issue closing the window?

I currently don't have access to the application to perform testing so I was looking for someone to validate that my code should execute successfully. Assuming it will work, is it the best method?

Posted (edited)

Try this:

Local $sYourTitle = 'SIEMENS Soarian® Automatic Logoff -- Webpage Dialog'
Local $sRegExpTitle = '[REGEXPTITLE:(?i)SIEMENS.*?Webpage.*?Dialog]'
Local $sTitle = WinGetTitle($sRegExpTitle)
ConsoleWrite(StringToBinary($sYourTitle) & @CRLF)
ConsoleWrite(StringToBinary($sTitle) & @CRLF)

and give us console output

EDIT: script correction

Edited by mlipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Compile this and run it and you can practice: :) Emulates your message box

_box()
Func _box()
MsgBox(0, "SIEMENS Soarian® Automatic Logoff -- Webpage Dialog", "Click OK to stop LogOff")
        Sleep(10000)
        _box()
EndFunc   ;==>_box

Your Winwait works but only one time, if you need to keep doing said action you will have to loop it.

Bill

Edited by billo
Posted

@billo

Although it is worth a try, it may not be that simple.
 
I suspect that the name used are white characters are not spaces.
From there the problem.

 

For example look here:

And that's why I suggested the test using the function: StringToBinary()

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Although you'll never meet the max recursion, your general idea is flawed, billo.

You should have a loop calling the function, and not have the function calling itself.

While True
    If _box() > 1 Then Exit  
WEnd
Func _box()
     Sleep(5000)
    Return MsgBox(1,"SIEMENS Soarian® Automatic Logoff -- Webpage Dialog", "Click OK to stop LogOff")
EndFunc
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted
  On 11/20/2013 at 9:14 PM, mlipok said:

Try this:

Local $sYourTitle = 'SIEMENS Soarian® Automatic Logoff -- Webpage Dialog'
Local $sRegExpTitle = '[REGEXPTITLE:(?i)SIEMENS.*?Webpage.*?Dialog]'
Local $sTitle = WinGetTitle($sRegExpTitle)
ConsoleWrite(StringToBinary($sYourTitle) & @CRLF)
ConsoleWrite(StringToBinary($sTitle) & @CRLF)

and give us console output

EDIT: script correction

I hope this is what you mean by console output? This was generated WITHOUT the log off window open.

0x5349454D454E5320536F617269616EAE204175746F6D61746963204C6F676F6666202D2D2057656270616765204469616C6F67
0x30
Posted
  On 11/21/2013 at 2:08 PM, dleonard said:

 

I hope this is what you mean by console output? This was generated WITHOUT the log off window open.

0x5349454D454E5320536F617269616EAE204175746F6D61746963204C6F676F6666202D2D2057656270616765204469616C6F67
0x30

 

 

Unfortunately, I was interested in the results With opened window.

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 11/21/2013 at 2:49 PM, mlipok said:

Unfortunately, I was interested in the results With opened window.

 

Here are the results of your code from the console, with the window open.

Note - I mistakenly ran it twice.

0x5349454D454E5320536F617269616EAE204175746F6D61746963204C6F676F6666202D2D2057656270616765204469616C6F67
0x5349454D454E5320536F617269616EAE204175746F6D61746963204C6F676F6666202D2D2057656270616765204469616C6F67
 
What does this mean?
Posted (edited)
  On 11/21/2013 at 7:39 PM, dleonard said:

0x5349454D454E5320536F617269616EAE204175746F6D61746963204C6F676F6666202D2D2057656270616765204469616C6F67

0x5349454D454E5320536F617269616EAE204175746F6D61746963204C6F676F6666202D2D2057656270616765204469616C6F67
 
What does this mean?

 

They are the same.


try this

WinWait("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog")
TrayTip('Test','Logoff Window appeared',100)
ControlClick("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog", "", "[CLASS:Button; TEXT:OK; Instance:1;]")

I think Logoff window appears, WinWait catch that fact, but ControlClick() can't  click because it is not a normal Button.

Is it     IE GUI ?  Am I right?

If so, try something like this:

 

#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, 'hwnd')
    ConsoleWrite(@CRLF)
    ConsoleWrite('===============================================')
    ConsoleWrite(@CRLF)
    $sHTML = _IEPropertyGet($oIELogOff, "outerhtml")
    ClipPut($sHTML)
    ConsoleWrite($sHTML)
    ConsoleWrite(@CRLF)
    ConsoleWrite('===============================================')
    ConsoleWrite(@CRLF)
EndIf
Based on this you can use something like this:
_IEAction ($oButtonOK, "click")
 
Edit: small script correction
Edited by mlipok

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

yes, it is IE GUI (a webpage dialog) so _IEAction shud work if his script isn't paused with no problems, ControlClick can work 2 but only on ControlClick Coords instead

Edited by bogQ

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)

  Reveal hidden contents


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.

 
Posted
  On 11/21/2013 at 9:05 PM, bogQ said:

ControlClick can work 2 but only on ControlClick Coords instead

 

In fact, I thought about it too, but I noticed that the OP uses
#include <IE.au3>
So it seemed to me to be a natural choice to use _IEAction

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 11/21/2013 at 8:14 PM, mlipok said:
#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, 'hwnd')
    ConsoleWrite(@CRLF)
    ConsoleWrite('===============================================')
    ConsoleWrite(@CRLF)
    $sHTML = _IEPropertyGet($oIELogOff, "outerhtml")
    ClipPut($sHTML)
    ConsoleWrite($sHTML)
    ConsoleWrite(@CRLF)
    ConsoleWrite('===============================================')
    ConsoleWrite(@CRLF)
EndIf
Console output for the code above is...
 
--> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch
 
===============================================
--> IE.au3 V2.4-0 Error from function _IEPropertyGet, $_IEStatus_InvalidDataType
0
===============================================
 
 
Also, the following code did not click on the OK button to interrupt the log off...
#include <IE.au3>

AdlibRegister("dodgeLogoff",3500)

WinWait("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog")
dodgeLogoff()

Func dodgeLogoff()
    local $sTitle = "Local $sYourTitle = 'SIEMENS Soarian® Automatic Logoff -- Webpage Dialog'"
    Local $oIE = _IEAttach($sTitle)
    If @error = 0 then
    _IEAction ($oButtonOK, "click")
    EndIf
EndFunc
Posted

First problem is here:

  On 11/22/2013 at 3:21 PM, dleonard said:

 


Console output for the code above is...
 
--> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch
 
===============================================
--> IE.au3 V2.4-0 Error from function _IEPropertyGet, $_IEStatus_InvalidDataType
0
===============================================
 

 

 

Second problem you can't just use _IEAction like that:

 

 

  On 11/22/2013 at 3:21 PM, dleonard said:

 

#include <IE.au3>

AdlibRegister("dodgeLogoff",3500)

WinWait("SIEMENS Soarian® Automatic Logoff -- Webpage Dialog")
dodgeLogoff()

Func dodgeLogoff()
local $sTitle = "Local $sYourTitle = 'SIEMENS Soarian® Automatic Logoff -- Webpage Dialog'"
Local $oIE = _IEAttach($sTitle)
If @error = 0 then
    _IEAction ($oButtonOK, "click")
EndIf
EndFunc

 

You must get a reference to this IE Object - I mean to this button.

But for this you must resolve first problem.

Like I say "thinking does not hurt, but it takes time"

So you must wait, for my or others additional hints ;)

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Change:

$oIELogOff = _IEAttach($hLogOff, 'hwnd')

to this:

$oIELogOff = _IEAttach($hLogOff, 'DialogBox')

 
 
Be careful
before pasting, see the "outerHTML" does not contain sensitive data.

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

you're not getting a title match, I'd settle for a partial match and leave out the 'circled R' symbol.

local $sTitle = "Automatic Logoff -- Webpage Dialog"
    Local $oIE = _IEAttach($sTitle,"WindowTitle")

Post the html behind that page and someone will help you.

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
  • Recently Browsing   0 members

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