Jump to content

Help with renaming win title


lbrtdy
 Share

Recommended Posts

Hello, I come to you guys once again for help. I'm still pretty poor at this but hoping to get better. I have a problem with renaming window titles. There is a button that when clicked, it'll rename the selected item in $list1 to the text field $NewWinTitle. But I keep coming up with some number lol.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Albert Zhen\My Documents\Autoit\GUI\AutoResser.kxf
$Window = GUICreate("Auto Resser", 186, 189, 435, 386)
$Key = GUICtrlCreateInput("0", 8, 24, 33, 21)
$Wait = GUICtrlCreateInput("500", 48, 24, 49, 21)
$NewWinTitle = GUICtrlCreateInput("Resser", 104, 24, 57, 21)
$Label1 = GUICtrlCreateLabel("Key:", 8, 8, 25, 16)
$Label2 = GUICtrlCreateLabel("Wait (ms):", 48, 8, 51, 16)
$Label3 = GUICtrlCreateLabel("Window:", 112, 8, 46, 16)
$Group1 = GUICtrlCreateGroup("", 0, 48, 185, 105, -1, $WS_EX_TRANSPARENT)
$List1 = GUICtrlCreateList("", 8, 62, 169, 84)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ChangeWinNameButton = GUICtrlCreateButton("...", 160, 24, 19, 21, $WS_GROUP)
$Start = GUICtrlCreateButton("Start", 8, 160, 75, 25, $WS_GROUP)
$Stop = GUICtrlCreateButton("Stop", 104, 160, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$auto = 0

;getting the windows 
$aWinlist = WinList("[Class:CLIENT]")
$sWinlist = ""

for $i = 1 to UBound($aWinlist)-1
    $sWinlist &= $aWinlist[$i][0]
Next

;places win titles in box
GUICtrlSetData($List1,$sWinlist)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

;renaming the window title
Case $ChangeWinNameButton
    $hwd = GUICtrlRead($List1)
    WinSetTitle($hwd,"",$NewWinTitle)

;starts key spamming
Case $Start
    $auto = 1
;stops key spamming
Case $Stop
    $auto = 0
    
While $auto = 1
    ControlSend($Window,"","",$Key)
    Sleep($Wait)
WEnd

EndSwitch
WEnd

one more thing I need help on, how do you make a right click menu when clicking inside of the list to have an option to refresh the window title listings? Thanks for your time and effort - albert.

Edited by lbrtdy
Link to comment
Share on other sites

Hello, I come to you guys once again for help. I'm still pretty poor at this but hoping to get better. I have a problem with renaming window titles. There is a button that when clicked, it'll rename the selected item in $list1 to the text field $NewWinTitle. But I keep coming up with some number lol.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\Albert Zhen\My Documents\Autoit\GUI\AutoResser.kxf
$Window = GUICreate("Auto Resser", 186, 189, 435, 386)
$Key = GUICtrlCreateInput("0", 8, 24, 33, 21)
$Wait = GUICtrlCreateInput("500", 48, 24, 49, 21)
$NewWinTitle = GUICtrlCreateInput("Resser", 104, 24, 57, 21)
$Label1 = GUICtrlCreateLabel("Key:", 8, 8, 25, 16)
$Label2 = GUICtrlCreateLabel("Wait (ms):", 48, 8, 51, 16)
$Label3 = GUICtrlCreateLabel("Window:", 112, 8, 46, 16)
$Group1 = GUICtrlCreateGroup("", 0, 48, 185, 105, -1, $WS_EX_TRANSPARENT)
$List1 = GUICtrlCreateList("", 8, 62, 169, 84)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ChangeWinNameButton = GUICtrlCreateButton("...", 160, 24, 19, 21, $WS_GROUP)
$Start = GUICtrlCreateButton("Start", 8, 160, 75, 25, $WS_GROUP)
$Stop = GUICtrlCreateButton("Stop", 104, 160, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$auto = 0

;getting the windows 
$aWinlist = WinList("[Class:CLIENT]")
$sWinlist = ""

for $i = 1 to UBound($aWinlist)-1
    $sWinlist &= $aWinlist[$i][0]
Next

;places win titles in box
GUICtrlSetData($List1,$sWinlist)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

;renaming the window title
Case $ChangeWinNameButton
    $hwd = GUICtrlRead($List1)
    WinSetTitle($hwd,"",$NewWinTitle)

;starts key spamming
Case $Start
    $auto = 1
;stops key spamming
Case $Stop
    $auto = 0
    
While $auto = 1
    ControlSend($Window,"","",$Key)
    Sleep($Wait)
WEnd

EndSwitch
WEnd

one more thing I need help on, how do you make a right click menu when clicking inside of the list to have an option to refresh the window title listings? Thanks for your time and effort - albert.

ok... 1 thing at a time ...

you have a line like this in the code

$NewWinTitle = GUICtrlCreateInput("Resser", 104, 24, 57, 21)

if u see the help file it says if success it returns the identifier (controlID) of the new control. not the text.but you need the text here not the control.

by the way i dunno how the code's working there but i had to modify the code a little to get it working.. anyways i'm trying to get the text.I'll update if i succeed.

good luck. ;)

Edited by iamsandeep
Link to comment
Share on other sites

  • Moderators

lbrtdy,

Change this line:

WinSetTitle($hwd, "", $NewWinTitle)

to read:

WinSetTitle($hwd, "", GUICtrlRead($NewWinTitle))

You are currently setting the window title to the ControlID of the input, not the content. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you iamsandeep and Melba23 it works! :evil: Yeah it was returning the controller ID lol. Learning something new everyday ;) Umm one more thing, how do you make it so that when right clicking within the list, a menu will come up? I tried looking in the help file but I have no idea what it's called. Thanks again!

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