Jump to content

WinGetTitle always return 0 - nothings helps

Recommended Posts


I have autoit program on my computer only portable version. I use Autoit vs

I want to use WinGetTitle but it always return 0. 

I want to use it for retriev windows title and then i want to switch between windows. 

E.g. - On start is msgbox where is info - "now choose yourt first window", i click first win - e.g. Excel, then 2. msgbox "now choose your 2. window" and i choose e.g. window folder. Then i want, that my script will switch between this windws and make my routine. 

But my test code for retrieve win title still return 0. I try this on comp in work. I dont have admin rights but i belive, that this is not a reason, bacause Au3.SPY, show me win title correctly. 

This is my sample code. 

Pls. any suggestions?

thx a lot

Sleep( 2000 ) ; Allows switching to some other window to see if can get its title.
$title = WinGetTitle("[active]")
If $title Then
    MsgBox(0, "", $title)
    MsgBox(0, "", "nothing")


Link to post
Share on other sites

This will get Active WIndows

Global $g_sTitle = ""


Func _WinGetTitle()
    Local $_sTitle = ""
    While 1
        $_sTitle = WinGetTitle("[Active]", "")
            If $_sTitle = $g_sTitle Or StringStripWS($_sTitle, 8) = "" Then ContinueLoop Sleep(100)
        $g_sTitle = $_sTitle
        MsgBox(4096, "Window Title", "Window Title = " & $g_sTitle, 2)


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

    No registered users viewing this page.

  • Similar Content

    • By Yirrlaar
      #Include <WinAPI.au3> local $ClassName = _WinAPI_GetClassName(WinGetHandle(WinGetTitle("[ACTIVE]"))) ControlClick(WinGetTitle("[ACTIVE]"), "", "[CLASS:"&$ClassName&"; INSTANCE:1]", "primary") When I am running this script it just gives me a ConsoleWrite output of "0x001D04A8"
      When using "AutoIT v3 Window Info" all the info I need for the ControlClick is there and displayed perfectly as if I typed it in normally.
      Upon click the button it should be clicking it, I see the following inn the console window:
      If I replace the $ClassName with the actual ClassName of "WindowsForms10.BUTTON.app.0.3296db7_r14_ad1" it works just fine, any ideas???
    • By TheFixer
      Basically i am trying to make a script that detects if the currently active window is 1920 x 1080 or bigger. If it detects a window that is active, that is indeed that size. It will do some stuff. 
      The problem i am having is that it is detecting my desktop whenever i click on my desktop, so it's doing stuff when i don't want it to.

      So all i need to know, is how can i do a simple check to see if a window = a title.

      Here is what i have so far
      $wintitledesktop = WinGetTitle("[ACTIVE]") If not $wintitledesktop = "Program Manager" Then ;does stuff endif Program Manager is what my desktop is called btw. 

      The problem with that code is that the script is still detecting the desktop and doing the code.
      In case you need the whole section of the code, here it is.

      $winsizecheck1 = WinGetClientSize("[ACTIVE]") $wintitledesktop = WinGetTitle("[ACTIVE]") If WinActive("[ACTIVE]") Then sleep(100) If $winsizecheck1[0] >= 1920 Then If $winsizecheck1[1] >= 1080 Then If not $wintitledesktop = "Program Manager" Then $gamesfolderstate = WinGetState($gamesfolder) If WinExists($gamesfolder) Then If Not BitAND($gamesfolderstate, 16) Then WinSetState($gamesfolder,"",@SW_MINIMIZE) EndIf EndIf EndIf EndIf EndIf EndIf  
    • By rm65453
      Hi Everyone,
      I have been using a script at work for the last 6 months or so. It gets some information from the window title and keeps it in its memory for retrieval. 
      currently I am running an infinite loop to look for the window title, the information in the memory is only updated if a few window title is detected.
      The trouble with this approach as you can see, is the cpu usage. I was wondering if somehow I can only run this script when a windows change event occurs, otherwise the script stays dormant.
      I have no idea how to do that, searched on forum and found some solutions that were years old and did not work for me.
    • By johnmcloud
      Hi guys, i have this script:

      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Misc.au3> Opt("GUICloseOnESC", 1) Global $GUI_1 $GUIHeight = 25 $GUIWidth = 50 $GUI_1 = GUICreate("A", $GUIWidth, $GUIHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW) $Focus_GUI_1 = GUICtrlCreateLabel("", 0, 0, $GUIWidth, $GUIHeight) GUISetState() Global_Func() Func Global_Func() While 1 If _IsPressed(01) Then If WinGetTitle("A") = True Then $GUI_Pos_1 = GUIGetCursorInfo($GUI_1) If IsArray($GUI_Pos_1) Then If $GUI_Pos_1[4] = $Focus_GUI_1 Then MsgBox(0, 0, "click") EndIf EndIf EndIf EndIf WEnd EndFunc ;==>Global_Func
      Work, but work everytime, also if a window/software/whatever is on it, so it's a problem for me. How to make _IsPressed work only if the GUI is Active or Focus?

      Thanks for help
    • By Mucho
      If I run the following code in SciTE, I get the first seven characters of the title. But if I run its executable, I got a "0" in the msgbox. What am I missing?

  • Create New...