Jump to content

Need help with wingettitle


geasiki
 Share

Recommended Posts

I want to make a program that can change the name of the title.

This is what I got so far... not sure what i'm doing wrong :)

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\..\Desktop\test.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 260, 139, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 257, 137)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Change")
$Label1 = GUICtrlCreateLabel("Prev name", 8, 24, 71, 17)
$Input1 = GUICtrlCreateInput($oldname, 8, 40, 137, 21)
$Label2 = GUICtrlCreateLabel("New name", 8, 72, 55, 17)
$Input2 = GUICtrlCreateInput($newname, 8, 88, 137, 21)
$Change = GUICtrlCreateButton("Change", 160, 40, 81, 73, 0)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$TabSheet4 = GUICtrlCreateTabItem("TabSheet4")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$old = GUICtrlRead($oldname)
$new = GUICtrlRead($newname)
$msg=0
GuiSetState()

While $msg <> $GUI_EVENT_CLOSE
      $msg = GuiGetMsg()
      WinGetTitle($old)
      WinSetTitle($old, "", $new)
WEnd
Link to comment
Share on other sites

Thank you for the fast help, FireFox.

Umm.. can you help me one more time?

C:\Users\DW\Desktop\test.au3(18,38) : WARNING: $oldname: possibly used before declaration.
$Input1 = GUICtrlCreateInput($oldname,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\DW\Desktop\test.au3(20,38) : WARNING: $newname: possibly used before declaration.
$Input2 = GUICtrlCreateInput($newname,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\DW\Desktop\test.au3(18,38) : ERROR: $oldname: undeclared global variable.
$Input1 = GUICtrlCreateInput($oldname,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\DW\Desktop\test.au3 - 1 error(s), 2 warning(s)

I'm not sure how to fix this... :)

Link to comment
Share on other sites

Thanks to FireFox, I got it to compile but it isn't doing anything when I press the button :)

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\..\Desktop\test.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
Local $oldname, $newname
$Form1 = GUICreate("Form1", 260, 139, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 257, 137)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Change")
$Label1 = GUICtrlCreateLabel("Prev name", 8, 24, 71, 17)
$Input1 = GUICtrlCreateInput($oldname, 8, 40, 137, 21)
$Label2 = GUICtrlCreateLabel("New name", 8, 72, 55, 17)
$Input2 = GUICtrlCreateInput($newname, 8, 88, 137, 21)
$Change = GUICtrlCreateButton("Change", 160, 40, 81, 73, 0)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$TabSheet4 = GUICtrlCreateTabItem("TabSheet4")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$old = GUICtrlRead($oldname)
$new = GUICtrlRead($newname)
$msg=0
GuiSetState()

While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
$wgt = WinGetTitle($old)
WinSetTitle($wgt, '', $new)
WEnd

How do I copy this in colors?

Link to comment
Share on other sites

try putting your code in a AutoIt tag like FireFox did. It makes it so much easier to read and understand.

Like this

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=..\..\..\Desktop\test.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
    Local $oldname, $newname
    $Form1 = GUICreate("Form1", 260, 139, 192, 124)
    $Tab1 = GUICtrlCreateTab(0, 0, 257, 137)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Change")
    $Label1 = GUICtrlCreateLabel("Prev name", 8, 24, 71, 17)
    $Input1 = GUICtrlCreateInput($oldname, 8, 40, 137, 21)
    $Label2 = GUICtrlCreateLabel("New name", 8, 72, 55, 17)
    $Input2 = GUICtrlCreateInput($newname, 8, 88, 137, 21)
    $Change = GUICtrlCreateButton("Change", 160, 40, 81, 73, 0)
    $TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
    $TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
    $TabSheet4 = GUICtrlCreateTabItem("TabSheet4")
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$old = GUICtrlRead($oldname)
$new = GUICtrlRead($newname)
$msg = 0
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    $wgt = WinGetTitle($old)
    WinSetTitle($wgt, '', $new)
WEnd

As for the button not working try abandon GuiGetMsg() and use GuiOnEventMode. (See help file.)

Thank PsaltyDS for that advice.

Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Thanks for the advice bo8ster. PsaltyDS

I did look up the help file but it's not clear...

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\..\Desktop\test.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

#Region ### START Koda GUI section ### Form=
Local $oldname, $newname
$Form1 = GUICreate("Form1", 260, 139, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 257, 137)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Change")
$Label1 = GUICtrlCreateLabel("Prev name", 8, 24, 71, 17)
$Input1 = GUICtrlCreateInput($oldname, 8, 40, 137, 21)
$Label2 = GUICtrlCreateLabel("New name", 8, 72, 55, 17)
$Input2 = GUICtrlCreateInput($newname, 8, 88, 137, 21)
$Change = GUICtrlCreateButton("Change", 160, 40, 81, 73, 0)
GUICtrlSetOnEvent(-1, "ChangePressed")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$TabSheet4 = GUICtrlCreateTabItem("TabSheet4")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$old = GUICtrlRead($oldname)
$new = GUICtrlRead($newname)
$msg=0

Func ChangePressed()
    $wgt = WinGetTitle($old)
    WinSetTitle($wgt, '', $new)
EndFunc

While 1
$msg = ChangePressed()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect

WEnd

Pleas tell me what I did wrong...

And how can I get the code in colors? I tried pushing the A button next to the 'wrap in code tags' but its not doing anything

Edited by geasiki
Link to comment
Share on other sites

Insert Special Item -> AutoIt

Have u read http://www.autoitscript.com/forum/index.php?showtopic=37289?

GuiOnEventMode is turns on a action listener for events like a button being pressed. This will allow you to intercept them. Search the help or forum for examples, i'm sure there are many.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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