Jump to content

Change a GUI's title


BALA
 Share

Recommended Posts

I've tried searching for this but I suppose I was to vague in describing it because I kept on getting threads about WinSetTitle and GUICtrlSetData. What I need to know is how to reset the title of a GUI that I've already created.

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

  • Moderators

I've tried searching for this but I suppose I was to vague in describing it because I kept on getting threads about WinSetTitle and GUICtrlSetData. What I need to know is how to reset the title of a GUI that I've already created.

WinSetTitle()

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

WinSetTitle()

Oh, I can't believe it was the command I've been avoiding. Well thanks then

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

  • Moderators

Oh, I can't believe it was the command I've been avoiding. Well thanks then

Don't know why you've been avoiding it, but if you have to customize it so you feel like you are using it app specific, I suppose you could :)
$MainGUI = GUICreate('Some Random Title', 200, 80)
$Input = GUICtrlCreateInput('', 10, 10, 180, 20)
$Button = GUICtrlCreateButton('Change', 10, 40, 180, 25)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Button
            _GUISetTitle(GUICtrlRead($Input))
    EndSwitch
WEnd

Func _GUISetTitle($sTitle, $hWnd = '')
    $hWnd = _GetHWnd($hWnd)
    Return WinSetTitle($hWnd, '', $sTitle)
EndFunc

Func _GetHWnd($hWnd)
    If $hWnd = '' Then
        $hWnd = WinGetHandle('')
    ElseIf IsString($hWnd) And WinExists($hWnd) Then
            $hWnd = WinGetHandle($hWnd)
    ElseIf StringInStr($hWnd, '0x') And IsHWnd($hWnd) = 0 Then
        $hWnd = HWnd($hWnd)
    EndIf
    Return $hWnd
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

  • Moderators

SmOke_N : Why all the extra-stuff ? :)

$gui = GUICreate("")
GUISetState()
Sleep(2000)

WinSetTitle($gui, "", "newTitle")
Sleep(2000)
Did you read my comment? If he felt the need to make it more GUI specific :D.

Edit:

On the plus side of that... if you need to pass a child handle that isn't active, you can do that as well. But yes, the need for the UDFs are primarily useless IMO, it was in jest that I did them (thus the laughing face in my comment).

Edited by SmOke_N

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

It wasn't exactly avoiding, it's just it caused an error when I tried using it the first time so I thought I was using the wrong command. Anyways I found the real problem (a typo in the variable name :) ) that was causing the error so it's fine now. Anyways, thanks for the helpful responds.

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

Did you read my comment? If he felt the need to make it more GUI specific :D.

Sure. I read it alright... I think it's a matter of not understand it instead. I even tilted my head at one point :D

Nevermind... You're not the only one who's been lacking a good night sleep lately :)

Link to comment
Share on other sites

  • Moderators

Sleep(100)

Um... what does that have to do with changing the title of a window :) ?

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

It wasn't exactly avoiding, it's just it caused an error when I tried using it the first time so I thought I was using the wrong command. Anyways I found the real problem (a typo in the variable name :) ) that was causing the error so it's fine now. Anyways, thanks for the helpful responds.

Bala,

You can also use a DllCall

DllCall("user32.dll", "int", "SetWindowText", "hwnd", $hInst, "str", "Changed the Window Title")

Regards

Dougie

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