Jump to content
Sign in to follow this  
darkshadow791

AutoItWinGetTitle & AutoItWinSetTitle

Recommended Posts

Generator

I played around with these functions for a while but I can't get what their real purpose is... Could someone explain + expand on what these func's do? The helpfile doesn't really explain it very well...

It prevents your script from running twice(usually being used in), also a replacement of _Singleton in Misc.au3

Example:

Opt("WinTitleMatchMode",3)
Global $Title="Title"
If WinExists($Title)=1 Then
    Exit
EndIf
AutoItWinSetTitle($Title)
;Rest your script goes here.

Share this post


Link to post
Share on other sites
MHz

AutoItWinGetTitle:

Retrieves the title name of the AutoIt window.

AutoItWinSetTitle:

Sets the title name of the AutoIt window.

Ok, keeping up so far?

Don't worry, as I will explain a little more. AutoIt is a Gui application. Gui applications have a hidden window of some sort which is hidden. This is quite different to the Gui that you can create using Gui functions within an AutoIt script. Every script that is run by AutoIt has a AutoIt hidden window. This window can be used to advantage as such as Generator has mentioned. Another method is for one AutoIt script to politely close another AutoIt script without using the deadly blow of ProcessClose. The example below is not 2 separate scripts, but does demonstrate the idea of politely closing a script, whether the same or another.

$title = AutoitWinGetTitle()
MsgBox(0x40000, 'AutoitWinGetTitle()', '$title = ' & $title)
WinWait($title)
WinSetState($title, '', @SW_MAXIMIZE)
WinSetState($title, '', @SW_SHOW)
Sleep(2000)
WinClose($title)
MsgBox(0x40000, 'Notice', 'End of script')

Exit

Func OnAutoItExit()
    MsgBox(0x40000, 'Notice', 'Script is politely closing the AutoIt hidden window...to close the script')
EndFunc

Func OnAutoItStart()
    If WinExists('AutoIt hidden window') Then Exit
    AutoItWinSetTitle('AutoIt hidden window')
EndFunc

Share this post


Link to post
Share on other sites
therks

Gui applications have a hidden window of some sort which is hidden.

As opposed to having a hidden window of some sort that's... visible? :D

Sorry just couldn't help myself, it made me chuckle. :)

Share this post


Link to post
Share on other sites
darkshadow791

AutoItWinGetTitle:

Retrieves the title name of the AutoIt window.

AutoItWinSetTitle:

Sets the title name of the AutoIt window.

Ok, keeping up so far?

Don't worry, as I will explain a little more. AutoIt is a Gui application. Gui applications have a hidden window of some sort which is hidden. This is quite different to the Gui that you can create using Gui functions within an AutoIt script. Every script that is run by AutoIt has a AutoIt hidden window. This window can be used to advantage as such as Generator has mentioned. Another method is for one AutoIt script to politely close another AutoIt script without using the deadly blow of ProcessClose. The example below is not 2 separate scripts, but does demonstrate the idea of politely closing a script, whether the same or another.

$title = AutoitWinGetTitle()
MsgBox(0x40000, 'AutoitWinGetTitle()', '$title = ' & $title)
WinWait($title)
WinSetState($title, '', @SW_MAXIMIZE)
WinSetState($title, '', @SW_SHOW)
Sleep(2000)
WinClose($title)
MsgBox(0x40000, 'Notice', 'End of script')

Exit

Func OnAutoItExit()
    MsgBox(0x40000, 'Notice', 'Script is politely closing the AutoIt hidden window...to close the script')
EndFunc

Func OnAutoItStart()
    If WinExists('AutoIt hidden window') Then Exit
    AutoItWinSetTitle('AutoIt hidden window')
EndFunc

Thank you! This definitely clears this up, I never quite understood what the purpose of this was, and now I do :)

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.