erik501 Posted April 23, 2023 Posted April 23, 2023 (edited) Hello, i'm not a programmer or similar i only use the pc for passion. I have a problem with a program that I would like to be renamed the title window, only that if I open more instances of the program only the first rename me because there is a variable that adds the progressive number of the windows to the beginning In a nutshell I would like to create an executable that aims at an .ini file to rename the program, take into account the number of application. Thank you in advance if someone can create the script or change my I use to try. $run = 1 Run('.\TOTALCMD64.EXE') $WinWait = "Total Commander" $newname = "Tc Erik 10.52" While $run If WinExists($winpref, "") Then $handle = WinGetHandle($WinWait, "") $currt = WinGetTitle($handle) If $currt <> $newname Then TrayTip("updating title", "", 5) WinSetTitle($handle, "", $newname) EndIf EndIf Exit WEnd Exit Edited April 23, 2023 by Jos added script in codebox
Nine Posted April 23, 2023 Posted April 23, 2023 Before introducing an .ini file into your script, lets make it work properly. Currently this code does not : $winpref is not defined. $WinWait will always be different than $newname as those 2 strings are not equals, so this condition is useless. Same goes with getting a handle out of a title and then getting the title out of the handle makes no sense. To be honest, not sure what the purpose of this script is... ps. when you post code, use the technique described in the link. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
erik501 Posted April 23, 2023 Author Posted April 23, 2023 I don't know anything in programmation but the script works in the first window of program. Can you make example of the correct script for my intention? Thanks
Developers Jos Posted April 23, 2023 Developers Posted April 23, 2023 1 hour ago, erik501 said: I don't know anything in programmation but the script works in the first window of program. Maybe it would be better to understand the program you posted first? Did you make it yourself? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
erik501 Posted April 23, 2023 Author Posted April 23, 2023 The program? Total commander is an example and is make by Ghisler. i,m only configured total commander for my use and i would to rename it.
erik501 Posted April 23, 2023 Author Posted April 23, 2023 The first pic is a modified total commander by a group of people from poland the second pic is the original and not configured of total commander. I don't make Total Commander ,is program made by Christian Ghisler and is very customisable program with addon, link,and internal command. I make my personal version of Total commander with plugin and command for my personal use.
erik501 Posted April 23, 2023 Author Posted April 23, 2023 I Can't editing the thread. In the first photo I like the title of the program, but their package no is too chaotic. I prefer my version of TC with my commands and plugins.
Nine Posted April 23, 2023 Posted April 23, 2023 What @Jos meant is the script you posted first. Not Total Commander. You need to understand your script and understand why it is not working. The question was : Did you make the script yourself ? We do not want a lecture about Total Commander, we want to help you with your script... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
erik501 Posted April 23, 2023 Author Posted April 23, 2023 yes and not I read a little on the internet and I took some parts of scripts around
mistersquirrle Posted April 24, 2023 Posted April 24, 2023 You may not be a programmer now, but AutoIt is a great way to get into scripting/programming. So maybe this'll get you started on that. Check out this script that I think does what you're looking for: expandcollapse popupGlobal $bRun = True ; Check if TOTALCMD64.EXE exists If Not FileExists(@ScriptDir & '\TOTALCMD64.EXE') Then ConsoleWrite('Unable to find totalcmd64.exe file in script directory: ' & @ScriptDir & @CRLF) Exit ; If it doesn't exist, exit the script EndIf ; If it exists, then run it Run(@ScriptDir & '\TOTALCMD64.EXE') ; Setup variables for the existing name/title to check and new title Global $sOldTitle = "Total Commander" Global $sNewName = "Tc Erik 10.52" ; Other variables used below Global $sMsg = '' Global $aWindows ; Just to restore titles when the program ends for testing Global $mChangedWindows[] ; Just for testing end the script and restore previous window titles HotKeySet('{END}', '__Exit') While $bRun Sleep(10) ; Important to have a sleep in your loop, to avoid high CPU usage ; Get an array of all windows that have $sOldTitle in the title $aWindows = WinList($sOldTitle) ; Loop through each found window, if any For $iWindow = 1 To $aWindows[0][0] $sMsg = 'Updating title from ' & $aWindows[$iWindow][0] & ' --> ' & $sNewName TrayTip('Updating title...', $sMsg, 5) ConsoleWrite($sMsg & @CRLF) ; Set the new title WinSetTitle($aWindows[$iWindow][1], '', $sNewName) ; This below is just for testing, but is used to restore changed window titles back to their previous values $mChangedWindows[$aWindows[$iWindow][1] & '.handle'] = $aWindows[$iWindow][1] $mChangedWindows[$aWindows[$iWindow][1] & '.oldTitle'] = $aWindows[$iWindow][0] $mChangedWindows[$aWindows[$iWindow][1] & '.newTitle'] = $sNewName Next WEnd Exit Func __Exit() $bRun = False __RestoreWindows() Exit EndFunc ;==>__Exit Func __RestoreWindows() ; Get the keys in the map Local $aKeys = MapKeys($mChangedWindows) For $sKey In $aKeys ; Check to see if '.handle' is the in key name, since we only need to process on those keys $sKey = StringReplace($sKey, '.handle', '') If @extended = 0 Then ContinueLoop ConsoleWrite('Checking key ' & $sKey & ' to restore previous title' & @CRLF) ; Only change the window title if it's not already its old title If WinGetTitle($mChangedWindows[$sKey & '.handle']) <> $mChangedWindows[$sKey & '.oldTitle'] Then ConsoleWrite('Restoring window title of: ' & $mChangedWindows[$sKey & '.handle'] & ', ' & $mChangedWindows[$sKey & '.newTitle'] & ' --> ' & $mChangedWindows[$sKey & '.oldTitle'] & @CRLF) WinSetTitle($mChangedWindows[$sKey & '.handle'], '', $mChangedWindows[$sKey & '.oldTitle']) EndIf Next EndFunc ;==>__RestoreWindows Note that anything with $mChangedWindows is just something that I added for some testing, so that I didn't mess up my window titles. It'll also help you when you run it multiple times as it'll restore the previous window title when you close the program with the END key. Now for some notes on your provided script: 15 hours ago, erik501 said: If WinExists($winpref, "") Then You didn't provide us with $winpref, however likely this needs to be your $WinWait variable. 15 hours ago, erik501 said: $handle = WinGetHandle($WinWait, "") $currt = WinGetTitle($handle) If $currt <> $newname Then You already know that the current title isn't the new title, since they don't share a common name, so you don't really need to do this check. Just the WinExists, and if so, then you can change the title, the handle isn't needed either since it'll match on the title text. 15 hours ago, erik501 said: Exit WEnd Exit This section means that your "loop" will only run once, because you put an Exit before the end of the loop. So the script can only check for 1 window to change then it exits. The Exit after the WEnd is fine, and even not explicitly needed. We ought not to misbehave, but we should look as though we could.
erik501 Posted April 24, 2023 Author Posted April 24, 2023 I tried the script and this error comes out
erik501 Posted April 24, 2023 Author Posted April 24, 2023 I updated Autoit (I had an old version) The script works now only on the first window of the program, if I open another copy of the program I don't change the title I think because the program adds the number 2 to the window. Example: Total Commander: [2] Total Commander
bdr529 Posted April 24, 2023 Posted April 24, 2023 local $TTOTAL_CMD_class="[CLASS:TTOTAL_CMD]" if WinExists($TTOTAL_CMD_class) Then local $TTOTAL_CMD_windows_array local $TTOTAL_CMD_windows_new_title="AutoIt General Help and Support" while WinExists($TTOTAL_CMD_class) Sleep(10) $TTOTAL_CMD_windows_array=WinList($TTOTAL_CMD_class) for $i=1 to ubound($TTOTAL_CMD_windows_array)-1 if WingetTitle($TTOTAL_CMD_windows_array[$i][0])<>$TTOTAL_CMD_windows_new_title then WinSetTitle($TTOTAL_CMD_windows_array[$i][0],'',$TTOTAL_CMD_windows_new_title) next wend endif To community goes all my regards and thanks
erik501 Posted April 24, 2023 Author Posted April 24, 2023 (edited) 43 minutes ago, bdr529 said: local $TTOTAL_CMD_class="[CLASS:TTOTAL_CMD]" if WinExists($TTOTAL_CMD_class) Then local $TTOTAL_CMD_windows_array local $TTOTAL_CMD_windows_new_title="AutoIt General Help and Support" while WinExists($TTOTAL_CMD_class) Sleep(10) $TTOTAL_CMD_windows_array=WinList($TTOTAL_CMD_class) for $i=1 to ubound($TTOTAL_CMD_windows_array)-1 if WingetTitle($TTOTAL_CMD_windows_array[$i][0])<>$TTOTAL_CMD_windows_new_title then WinSetTitle($TTOTAL_CMD_windows_array[$i][0],'',$TTOTAL_CMD_windows_new_title) next wend endif This script works, only that it remains active in tray instead of going out once the window is renamed. If you can get out and insert the pointing to a text file for the Total Commander version so that at each update I don't have to recreate the launcher would be perfect. I realized that the program is indiscriminately rename both 32 bits and 64 bits with the new name without taking into account the number of windows and version 32/64 Edited April 24, 2023 by erik501
Nine Posted April 24, 2023 Posted April 24, 2023 Maybe this simple ? Local Const $STANDARD_TITLE = "Sans titre" Local Const $CUSTOM_TITLE_PREFIX = "AutoItv.3.3.16." Run('mspaint') Local $hWnd = WinWait($STANDARD_TITLE, "", 5) If Not $hWnd Then Exit MsgBox(0, "Error", "Title not found") Local $sTitle For $i = 1 To 99 $sTitle = $CUSTOM_TITLE_PREFIX & StringFormat("%02i", $i) If Not WinExists($sTitle) Then WinSetTitle($hWnd, "", $sTitle) ExitLoop EndIf Next “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
erik501 Posted April 24, 2023 Author Posted April 24, 2023 39 minutes ago, Nine said: Maybe this simple ? Local Const $STANDARD_TITLE = "Sans titre" Local Const $CUSTOM_TITLE_PREFIX = "AutoItv.3.3.16." Run('mspaint') Local $hWnd = WinWait($STANDARD_TITLE, "", 5) If Not $hWnd Then Exit MsgBox(0, "Error", "Title not found") Local $sTitle For $i = 1 To 99 $sTitle = $CUSTOM_TITLE_PREFIX & StringFormat("%02i", $i) If Not WinExists($sTitle) Then WinSetTitle($hWnd, "", $sTitle) ExitLoop EndIf Next Not working open paint and error message
Nine Posted April 24, 2023 Posted April 24, 2023 Of course you need to adapt to your situation. I used paint to test. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
mistersquirrle Posted April 24, 2023 Posted April 24, 2023 8 hours ago, erik501 said: I updated Autoit (I had an old version) The script works now only on the first window of the program, if I open another copy of the program I don't change the title I think because the program adds the number 2 to the window. Example: Total Commander: [2] Total Commander Add this to the top of the script, so that it matches on any substring in the title, instead of from the start: AutoItSetOption('WinTitleMatchMode', 2) Without it "[2] Total Commander" fails because it doesn't start with "Total Commander". With the above option set to 2, anything that has "Total Commander" or whatever title you set will get matched and changed. I don't use Total Commander, and it wasn't clear before how the title changes with more windows. We ought not to misbehave, but we should look as though we could.
erik501 Posted April 24, 2023 Author Posted April 24, 2023 1 hour ago, mistersquirrle said: Add this to the top of the script, so that it matches on any substring in the title, instead of from the start: AutoItSetOption('WinTitleMatchMode', 2) Without it "[2] Total Commander" fails because it doesn't start with "Total Commander". With the above option set to 2, anything that has "Total Commander" or whatever title you set will get matched and changed. I don't use Total Commander, and it wasn't clear before how the title changes with more windows. Thanks your script works but not as I would like. The problem is that it remains open in the Windows tray instead of performing Totalcmd rename it and exit. Searching the net I managed to create a working script as I would just like this that it also remains in the tray until I close total commanders. Instead, I would like to launch Total Commander renowned him and came out of the script. Here is the best code for moment Run(@ScriptDir & '\TOTALCMD64.EXE', '', @SW_MAXIMIZE) Sleep(100) Local $TTOTAL_CMD_class = "[CLASS:TTOTAL_CMD]" If WinExists($TTOTAL_CMD_class) Then Local $TTOTAL_CMD_windows_array Local $TTOTAL_CMD_windows_new_title = "Tc Ultrapack" Local $version = FileReadLine(@ScriptDir & "\version.ini", 1) Local $new_title_with_version = $TTOTAL_CMD_windows_new_title & " v" & $version WinSetTitle($TTOTAL_CMD_class, '', $new_title_with_version) While WinExists($TTOTAL_CMD_class) Sleep(10) $TTOTAL_CMD_windows_array = WinList($TTOTAL_CMD_class) If IsArray($TTOTAL_CMD_windows_array) Then For $i = 1 To UBound($TTOTAL_CMD_windows_array) If $i > UBound($TTOTAL_CMD_windows_array) - 1 Then ExitLoop If WinGetTitle($TTOTAL_CMD_windows_array[$i][1]) <> $new_title_with_version Then WinSetTitle($TTOTAL_CMD_windows_array[$i][1], '', $new_title_with_version) EndIf Next EndIf WEnd EndIf
erik501 Posted April 25, 2023 Author Posted April 25, 2023 (edited) #NoTrayIcon Run(@ScriptDir & '\TOTALCMD64.EXE') Sleep(100) Local $TTOTAL_CMD_class = "[CLASS:TTOTAL_CMD]" If WinExists($TTOTAL_CMD_class) Then Local $TTOTAL_CMD_windows_array Local $TTOTAL_CMD_windows_new_title = "Tc Ultrapack" Local $version = FileReadLine(@ScriptDir & "\version.ini", 1) Local $new_title_with_version = $TTOTAL_CMD_windows_new_title & " v" & $version WinSetTitle($TTOTAL_CMD_class, '', $new_title_with_version) While WinExists($TTOTAL_CMD_class) Sleep(10) $TTOTAL_CMD_windows_array = WinList($TTOTAL_CMD_class) If IsArray($TTOTAL_CMD_windows_array) Then For $i = 1 To UBound($TTOTAL_CMD_windows_array) If $i > UBound($TTOTAL_CMD_windows_array) - 1 Then ExitLoop If WinGetTitle($TTOTAL_CMD_windows_array[$i][1]) <> $new_title_with_version Then WinSetTitle($TTOTAL_CMD_windows_array[$i][1], '', $new_title_with_version) EndIf Next EndIf WEnd EndIf For the moment this and the best result, the problem is that the script renames both the 32bit version and 64bit version, instead I would like 2 scripts separated for 32bit and 64 bit. Can anyone tell me the solution to do this? Edited April 25, 2023 by erik501
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