Sign in to follow this  
Followers 0
geasiki

Need help with wingettitle

9 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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... :)

Share this post


Link to post
Share on other sites

@geasiki

Place this before your gui :

Local $oldname, $newname

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

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

Share this post


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
Sign in to follow this  
Followers 0