Jump to content

$temp = WinGetTitle("")


Recommended Posts

WinGetTitle("") returns the active window's title.

$ActiveWindow = WinGetTitle("")
MsgBox(262144,'Debug line ~23','Selection:' & @lf & '$ActiveWindow' & @lf & @lf & 'Return:' & @lf & $ActiveWindow & @lf & @lf & '@Error:' & @lf & @Error) ;### Debug MSGBOX
  Select
      Case $ActiveWindow = $a
           ; test case one
          $ExitCode = DoFunctionOne()
          Exit $ExitCode
      Case $ActiveWindow = $b
           ; test case two
          $ExitCode = DoFunctionTwo()
          Exit $ExitCode
      Case Else
          ; bomb
          Exit 5000
  EndSelect

F5 - runs...

Selection:

$ActiveWindow

Return:

1

@Error

0

!>AutoIT3.exe ended.rc:5000

>Exit code: 5000 Time: 14.583

I'm always getting a neumeric one. It should be returning the name of the SciTE window. Any other reliable way to do this?

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

  • Moderators

Guess you could try this:

MsgBox(0,'', _WinGetActive())

Func _WinGetActive()
    $OptWSC = Opt('WinSearchChildren', 1)
    $aWinList = WinList()
    For $iCount = 1 To $aWinList[0][0]
        If $aWinList[$iCount][0] <> '' And WinActive($aWinList[$iCount][0]) Then
            Opt('WinSearchChildren', $OptWSC)
            Return $aWinList[$iCount][0]
        EndIf
    Next
    Opt('WinSearchChildren', $OptWSC)
    Return 0
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Guess you could try this:

MsgBox(0,'', _WinGetActive())

Func _WinGetActive()
    $OptWSC = Opt('WinSearchChildren', 1)
    $aWinList = WinList()
    For $iCount = 1 To $aWinList[0][0]
        If $aWinList[$iCount][0] <> '' And WinActive($aWinList[$iCount][0]) Then
            Opt('WinSearchChildren', $OptWSC)
            Return $aWinList[$iCount][0]
        EndIf
    Next
    Opt('WinSearchChildren', $OptWSC)
    Return 0
EndFunc

Nifty little UDF. Thanks.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Guess you could try this:

MsgBox(0,'', _WinGetActive())

Func _WinGetActive()
    $OptWSC = Opt('WinSearchChildren', 1)
    $aWinList = WinList()
    For $iCount = 1 To $aWinList[0][0]
        If $aWinList[$iCount][0] <> '' And WinActive($aWinList[$iCount][0]) Then
            Opt('WinSearchChildren', $OptWSC)
            Return $aWinList[$iCount][0]
        EndIf
    Next
    Opt('WinSearchChildren', $OptWSC)
    Return 0
EndFunc
kind of longhand for

Opt("WinTitleMatchMode",4)
Opt("WinSearchChildren",1)
WinGetTitle("active")

isn't it? :D

Link to comment
Share on other sites

  • Moderators

kind of longhand for

Opt("WinTitleMatchMode",4)
Opt("WinSearchChildren",1)
WinGetTitle("active")

isn't it? :D

Do I ever do anything easy? :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...