Jump to content

Force Window New Title


Recommended Posts

Im trying to force my apps window title to be the what i specify regardless to if the executable name is changed etc.

My current code:

;~ Change Title Of Console Window
WinActivate(-1)
$Window = WinGetTitle('[ACTIVE]')
WinSetTitle($Window, '', 'Dekaron Server Manager (Build ' & $nVersion & ')')

It works but is there a 100% way to do this? or is this the best method?

Link to comment
Share on other sites

Use something more reliable to get the window handle and use that, similar to:

;~ Change Title Of Console Window
$hWin = WinGetHandle("[CLASS:DekaronSvr; INSTANCE:1]", "")
WinSetTitle($hWin, '', 'Dekaron Server Manager (Build ' & $nVersion & ')')

See help file under Window Title and Text - Advanced.

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Use something more reliable to get the window handle and use that, similar to:

;~ Change Title Of Console Window
$hWin = WinGetHandle("[CLASS:DekaronSvr; INSTANCE:1]", "")
WinSetTitle($hWin, '', 'Dekaron Server Manager (Build ' & $nVersion & ')')

See help file under Window Title and Text - Advanced.

:unsure:

The problem is, im using Console.au3 UDF and the window is being ran off a cmd prompt. So it has a "ConsoleClass" and there are several for the use of this tool. That's the problem im having. I have it run that code during program run-time, so it is the active window 99% of the time. Im just looking for a for-sure way of doing it regardless to file name edits, or window checking etc.
Link to comment
Share on other sites

I am not familiar with Console.au3.

But your script should be keeping track of the windows\consoles you open with the handles in an array, or something similar. If you have an array of five already opened windows and your script creates another, WinList("[CLASS:ConsoleClass]", "") them all and the one that isn't already listed in your array, or already named by your convention, is the new one.

:unsure:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I am not familiar with Console.au3.

But your script should be keeping track of the windows\consoles you open with the handles in an array, or something similar. If you have an array of five already opened windows and your script creates another, WinList("[CLASS:ConsoleClass]", "") them all and the one that isn't already listed in your array, or already named by your convention, is the new one.

:unsure:

The other console windows are separate server files entirely. Im just looking for a sure-way to point the WinSetTitle to the launched program. Without using match modes etc. I been down each road so far this is the only thing working with any script. In other words im looking for the "global" solution. That people can just copy + paste and change a few words to make it work for them aswell. Edited by Warmonger
Link to comment
Share on other sites

"Match modes" should never be used any more. Since many versions ago, AutoIt defaults to "Advanced" (what used to be mode 4) and the advanced specifications such as "[CLASS:ConsoleClass]", REGEXPTITLE, or REGEXPCLASS work fine and should be used. [see help file under "Window Title and Text - Advanced".]

If you've been down these roads before, post the CLASS or REGEXPCLASS strings you used to find your "Dekaron Server" console windows. Or maybe how you handled the array from WinList() without finding the one you want.

:unsure:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 3 weeks later...

"Match modes" should never be used any more. Since many versions ago, AutoIt defaults to "Advanced" (what used to be mode 4) and the advanced specifications such as "[CLASS:ConsoleClass]", REGEXPTITLE, or REGEXPCLASS work fine and should be used. [see help file under "Window Title and Text - Advanced".]

If you've been down these roads before, post the CLASS or REGEXPCLASS strings you used to find your "Dekaron Server" console windows. Or maybe how you handled the array from WinList() without finding the one you want.

:huh2:

WinSetTitle('[REGEXPTITLE:DSM;CLASS:ConsoleWindowClass]', '', 'Manager (Version ' & $nVersion & ')')

But that still isn't good enough for me. It can be bypassed by renaming the executable.

Link to comment
Share on other sites

Use WinList() with the CLASS spec to get a list of the console windows. Then walk through the array to match up the window handle with the parent process PID using WinGetProcess().

:huh2:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...