geasiki Posted January 22, 2009 Share Posted January 22, 2009 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 expandcollapse popup#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 More sharing options...
FireFox Posted January 22, 2009 Share Posted January 22, 2009 (edited) @geasiki Welcome to autoit forum your looping is wrong... While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect $wgt = WinGetTitle($old) WinSetTitle($wgt, '', $new) WEnd Cheers, FireFox. Edited January 22, 2009 by FireFox Link to comment Share on other sites More sharing options...
geasiki Posted January 22, 2009 Author Share Posted January 22, 2009 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 More sharing options...
FireFox Posted January 22, 2009 Share Posted January 22, 2009 @geasiki Place this before your gui : Local $oldname, $newname Cheers, FireFox. Link to comment Share on other sites More sharing options...
geasiki Posted January 22, 2009 Author Share Posted January 22, 2009 Thanks to FireFox, I got it to compile but it isn't doing anything when I press the button expandcollapse popup#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 More sharing options...
bo8ster Posted January 22, 2009 Share Posted January 22, 2009 (edited) try putting your code in a AutoIt tag like FireFox did. It makes it so much easier to read and understand. Like this expandcollapse popup#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 January 22, 2009 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 More sharing options...
geasiki Posted January 23, 2009 Author Share Posted January 23, 2009 (edited) Thanks for the advice bo8ster. PsaltyDS I did look up the help file but it's not clear... expandcollapse popup#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 January 23, 2009 by geasiki Link to comment Share on other sites More sharing options...
bo8ster Posted January 23, 2009 Share Posted January 23, 2009 Insert Special Item -> AutoItHave 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 More sharing options...
geasiki Posted January 23, 2009 Author Share Posted January 23, 2009 I made my first script with autoit with the help of you two(three) I wanted to keep it simple so I kept the $msg = $Change(button) I had the "GUICtrlRead(there)" part wrong Anyway, Thanks for the help^^ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now