Function Reference


AutoItWinSetTitle

Changes the title of the AutoIt window.

AutoItWinSetTitle ( "newtitle" )

Parameters

newtitle The new title to give to the window.

Return Value

None.

Remarks

The AutoIt window is usually hidden. The purpose of changing the title is to allow other programs (or other AutoIt scripts) to interact with AutoIt.

Related

AutoItWinGetTitle, WinSetTitle

Example

Example 1

; Check if the script is already running
; Note: The recommended approach is to use _Singleton from Misc.au3

#include <MsgBoxConstants.au3>

Local $sMyAutoItTitle = "ThisIsSomeUniqueStringThatOtherWindowsWontHave"

If WinExists($sMyAutoItTitle) Then
    ; The script is already running

    MsgBox($MB_SYSTEMMODAL, Default, "The script is already running." & @CRLF & @CRLF & _
            "It's PID is: " & WinGetProcess($sMyAutoItTitle))
Else
    ; This is the first instance of the script.

    ; Set the autoit window title
    AutoItWinSetTitle($sMyAutoItTitle)

    ; Run this script again.
    If @Compiled Then
        Run('"' & @ScriptFullPath & '"')
    Else
        Run('"' & @AutoItExe & '" "' & @ScriptFullPath & '"')
    EndIf

    MsgBox($MB_SYSTEMMODAL, Default, "This is the first instance." & @CRLF & @CRLF & _
            "My PID is: " & @AutoItPID)
EndIf

Example 2

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Set the title of the AutoIt Hidden Window.
    AutoItWinSetTitle("My AutoIt Window")

    ; Display AutoIt's Hidden Window.
    AutoItWinShow()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Display AutoIt's Hidden Window. Returns the handle of the window.
Func AutoItWinShow()
    Local $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window.
    WinMove($hWnd, "", (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ; Move the AutoIt Hidden Window and re-size for a better view.
    WinSetState($hWnd, "", @SW_SHOW) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I"m displaying it.
    Return $hWnd
EndFunc   ;==>AutoItWinShow