Changing Window Titles

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
down_keeper
Posts: 1
Joined: 17 Jul 2018, 22:30

Changing Window Titles

17 Jul 2018, 22:48

I've used two scripting languages for many years. AHK is not one of them.

I've got a lengthy script with a zillion flow control functions, boolean operators, strings, etc.
I'm attempting to manage too many windows with similar or identical titles. My script is a
failure, and the only fix might be AHK WinSetTitle.

I just read that AHK scripts can be compiled into EXE files. I could use WinSetTitle as a
plug-in for my larger script.

This tiny script looks deceptively simple. I've never used AHK, so I need help.

https://autohotkey.com/docs/commands/WinSetTitle.htm

I don't need the "Run" line. My own script opens and closes all windows, apps, services, etc.
I do need to add a "No Icon" command. Seeing the AHK icon in the tray (notification area) would
be very confusing to other people. I noticed the WinSetTitle example script does not have a
final command like "End" or something similar. This may not be needed if the script terminates
after executing the last line.

I know I'm asking for a lot, but I need a window title changer if my larger script has any chance
of success. Since I am a complete AHK newbie, can someone provide the exact command lines
so I don't screw it up.

Thanks guys.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Changing Window Titles

18 Jul 2018, 00:38

  • compile this script as WinSetTitle.exe
  • call from batch file like this:
    WinSetTitle.exe "Untitled - Notepad" "This is a new title"

Code: Select all

#NoTrayIcon
WinSetTitle, %1%,, %2%
I hope that helps.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Changing Window Titles

18 Jul 2018, 07:30

- Setting the window title natively via AutoHotkey's WinSetTitle command is relatively easy.
- However, presumably the scripting languages you use (maybe you could mention which ones) have some support for using the Winapi, and you could translate the SetWindowText example below.

Code: Select all

q:: ;set window title
WinGet, hWnd, ID, ahk_class Notepad
WinSetTitle, % "ahk_id " hWnd,, NEW TITLE
return

w:: ;set window title
WinGet, hWnd, ID, ahk_class Notepad
DllCall("user32\SetWindowText", Ptr,hWnd, Str,"NEW TITLE")
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, Frogrammer, Google [Bot] and 271 guests