Hey Guys!
So I am the SCCM Administrator of 3 different environments therefore frequently have 3 SCCM 2012 Console sessions open at once - each connected to a different site / environment. For those not familiar with SCCM, it is very powerful and is capable of wiping all servers & workstations within minutes so obviously I need to ensure that whatever I do within the console is for the correct site. Unfortunately, the 3 windows look exactly the same except for one small thing - the title bar of each application does show which site it's currently connected to.
I'm trying to find some method where I can easily distinguish between each of these 3 windows. The best thing I could think of would be for each to have a designated title bar color where depending on the contents of the title bar (site its connected to) it would be a specific color. I couldn't find any existing scripts or utilities so having used AutoHotKey many times before, looked in these forums but that seems to be a challenge. If so, anything will work as long as I can easily tell them apart.
I did launch Active Window Monitor and the site it's connected to does also appear within it so identifying the windows shouldn't be an issue - it's really just how to distinguish between each
Any suggestions for what I could do and perhaps how to implement it?
Thanks!!
Distinguishing Between Multiple Windows of Same Application
Re: Distinguishing Between Multiple Windows of Same Application
Quick tip below. Not sure what exactly you're looking for. Pressing Home checks which of the 3 is active. With WinActive and other window commands you should be able to do what you want.
Code: Select all
Home:: ; Press Home to trigger check
If WinActive("SCCM (Connected to Site 1") ; change these 3 to exact window title (case sensitive, I believe)
msgbox, Site 1 is active
If WinActive("SCCM (Connected to Site 2")
msgbox, Site 2 is active
If WinActive("SCCM (Connected to Site 3")
msgbox, Site 3 is active
else
msgbox, none of the 3 are active
return
try it and see
...
...
Re: Distinguishing Between Multiple Windows of Same Application
Thanks for the reply!
I don't think I explained what I was trying to do too well as I don't know if that will help. Long story, shot; an example of what I'm trying to do is assign a specific color to a window's title bar depending on what it's title is. It doesn't have to be title bar color even though that seems ideal - just something where I can quickly distinguish which of the 3 windows I'm working on. Whatever is used would not require a hotkey but would just be active whenever the script was running.
Hope that helps - Please let me know if you have any suggestions or if that makes a difference. Thanks!
I don't think I explained what I was trying to do too well as I don't know if that will help. Long story, shot; an example of what I'm trying to do is assign a specific color to a window's title bar depending on what it's title is. It doesn't have to be title bar color even though that seems ideal - just something where I can quickly distinguish which of the 3 windows I'm working on. Whatever is used would not require a hotkey but would just be active whenever the script was running.
Hope that helps - Please let me know if you have any suggestions or if that makes a difference. Thanks!
Re: Distinguishing Between Multiple Windows of Same Application
You could have your script create a new gui without title bars but specific background color or image and use a setparent dllcall to attach it to to any of your SCCM windows.
Re: Distinguishing Between Multiple Windows of Same Application
Sorry I did misunderstand you @bzowk. And I'm not expert enough to help you. I should have stayed clear... :)
try it and see
...
...
Re: Distinguishing Between Multiple Windows of Same Application
Place a colour over part of a window:
cover window region - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35259
Replace window icon with a one-colour icon:
Replace window icon with specific icon:
I don't know if this has code that could set the taskbar button colour for an external program:
[class][v1/v2] taskbar ornaments and controls - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35348
cover window region - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35259
Replace window icon with a one-colour icon:
Code: Select all
;based on:
;Crazy Scripting : Include an Icon in your script - Scripts and Functions - AutoHotkey Community
;https://autohotkey.com/board/topic/31044-crazy-scripting-include-an-icon-in-your-script/
;colour list:
;Progress/SplashImage
;https://autohotkey.com/docs/commands/Progress.htm
q:: ;set a window's icon to be one colour
WinGet, hWnd, ID, A
vColRGB := "FF0000" ;red
;vColRGB := "FFFF00" ;yellow
;vColRGB := "00FF00" ;lime
;vColRGB := "0000FF" ;blue
vCol := SubStr(vColRGB,5,2) SubStr(vColRGB,3,2) SubStr(vColRGB,1,2) "00"
vDataHex := "000001000100101010000100040028010000160000002800000010000000200000000100040000000000C000000000000000000000000000000000000000" vCol Format("{:0504}", 0)
VarSetCapacity(vData, vSize := StrLen(vDataHex)//2)
;Loop, % vSize
Loop, % 66 ;ignore null bytes
NumPut("0x" SubStr(vDataHex,2*A_Index-1,2), vData, A_Index-1, "UChar")
vDataHex := ""
hIcon := DllCall("user32\CreateIconFromResourceEx", Ptr,&vData+22, UInt,NumGet(vData,14,"UInt"), Int,1, UInt,0x30000, Int,16, Int,16, UInt,0)
SendMessage, 0x80, 0, % hIcon,, % "ahk_id " hWnd ;WM_SETICON := 0x80 ;sets title bar icon + taskbar icon
SendMessage, 0x80, 1, % hIcon,, % "ahk_id " hWnd ;WM_SETICON := 0x80 ;sets alt+tab icon
return
Code: Select all
q:: ;set a window's icon
WinGet, hWnd, ID, A
hIcon := LoadPicture(A_AhkPath, "", vType)
SendMessage, 0x80, 0, % hIcon,, % "ahk_id " hWnd ;WM_SETICON := 0x80 ;sets title bar icon + taskbar icon
SendMessage, 0x80, 1, % hIcon,, % "ahk_id " hWnd ;WM_SETICON := 0x80 ;sets alt+tab icon
return
[class][v1/v2] taskbar ornaments and controls - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=35348
Last edited by jeeswg on 11 Aug 2017, 21:44, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
- FanaticGuru
- Posts: 1907
- Joined: 30 Sep 2013, 22:25
Re: Distinguishing Between Multiple Windows of Same Application
This is relatively simply but has the limitation of the Gui must be in the client area of the parent window. So you can not use it to overlay the title bar. But if you have some blank real estate that can be covered up this works well.Nextron wrote:You could have your script create a new gui without title bars but specific background color or image and use a setparent dllcall to attach it to to any of your SCCM windows.
This puts a simple Gui text box on an existing Excel window.
Code: Select all
Win_Hwnd := WinExist("ahk_exe excel.exe ahk_class XLMAIN")
; Gui Create
Gui, Color, Green
Gui, Font, s12 cRed, Bold Verdana
Gui, Add, Text,, This is Text
Gui, +LastFound +ToolWindow +AlwaysOnTop -Caption -Border HWNDGui_Hwnd
DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd)
Gui, Show, x200 y100 ; Position on Gui Parent
return
Esc::ExitApp
Here is an example that uses a class called WindowWatch that monitors shell hook events and when it detects an Excel window being created it adds a child button to the Excel window.
Code: Select all
WindowWatch.Start()
WindowWatch.Add("WW_Excel_Created",, "XLMAIN", "EXCEL.EXE",1)
WW_Excel_Created(Win_Hwnd)
{
WinGetPos,,,Win_W,, ahk_id %Win_Hwnd%
Gui_X := Win_W - 190
; Gui Create
Gui Excel:Default
Gui +Resize
Gui, Font, s12, Bold Verdana
Gui, Margin, 0, 0
Gui, Add, Button, xp yp Default gExcelButton, Button
Gui, +LastFound +ToolWindow +AlwaysOnTop -Caption -Border HWNDGui_Hwnd
DllCall("SetParent", "uint", Gui_Hwnd, "uint", Win_Hwnd)
Gui, Show, x%Gui_X% y120
return
; Gui Action when Button is Clicked
ExcelButton:
MsgBox Clicked
return
}
Esc::ExitApp
; [Class] WindowWatch
; Fanatic Guru
; 2017 08 10
;
; Class to watch for shell hook events of specified windows
;
;{-----------------------------------------------
;
; Method:
; WindowWatch.Start()
;
; Desc: Initialize Shell Hook
;
; ----------
;
; Method:
; WindowWatch.Add(Func, wTitle:="", wClass:="", wExe:="", Event:=1)
;
; Desc: Add Event to watch
;
; Parameters:
; 1) {Func} Function to Call on Event (Default = "", All Windows)
; 2) {wTitle} Window Title to watch for Event (Default = "", All Windows)
; 3) {wClass} Window Class to watch for Event (Default = "", All Windows)
; 4) {wExe} Window Exe to watch for Event (Default = "", All Windows)
; 5) {Event} Event (Default = 1, Window Created)
; Shell Hook Events:
; 1 = HSHELL_WINDOWCREATED
; 2 = HSHELL_WINDOWDESTROYED
; 3 = HSHELL_ACTIVATESHELLWINDOW
; 4 = HSHELL_WINDOWACTIVATED
; 5 = HSHELL_GETMINRECT
; 6 = HSHELL_REDRAW
; 7 = HSHELL_TASKMAN
; 8 = HSHELL_LANGUAGE
; 9 = HSHELL_SYSMENU
; 10 = HSHELL_ENDTASK
; 11 = HSHELL_ACCESSIBILITYSTATE
; 12 = HSHELL_APPCOMMAND
; 13 = HSHELL_WINDOWREPLACED
; 14 = HSHELL_WINDOWREPLACING
; 15 = HSHELL_HIGHBIT
; 16 = HSHELL_FLASH
; 17 = HSHELL_RUDEAPPACTIVATED
;
; ----------
;
; Desc: Function Called on Event
; Func(Win_Hwnd, Win_Title, Win_Class, Win_Exe, Win_Event)
;
; Parameters:
; 1) {Win_Hwnd} Window Handle ID of Window with Event
; 2) {Win_Title} Window Title of Window with Event
; 3) {Win_Class} Window Class of Window with Event
; 4) {Win_Exe} Window Exe of Window with Event
; 5) {Win_Event} Window Event
;
;}
class WindowWatch
{
Message(wParam, lParam )
{
If ( this.Events ~= wParam)
{
wId:= lParam
WinGetTitle, wTitle, ahk_id %wId%
WinGetClass, wClass, ahk_id %wId%
WinGet, wExe, ProcessName, ahk_id %wId%
for key, element in this.Windows
{
if ((element.Title = wTitle or element.Title = "") and (element.Class = wClass or element.Class = "") and (element.Exe = wExe or element.Exe = "") and (element.Event = wParam))
if IsFunc(Func := element.Func)
%Func%(wId, wTitle, wClass, wExe, wParam)
}
}
}
Add(Func, wTitle:="", wClass:="", wExe:="", Event:=1)
{
if !this.Windows
this.Windows := {}
this.Windows.Push({Func: Func, Title: wTitle, Class: wClass, Exe: wExe, Event: Event})
if !(this.Events ~= Event)
this.Events .= Event " "
return
}
Start()
{
DllCall("RegisterShellHookWindow", UInt, A_ScriptHwnd)
MsgNum := DllCall("RegisterWindowMessage", Str, "SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
}
}
ShellMessage(wParam,lParam)
{
WindowWatch.Message(wParam,lParam)
}
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Distinguishing Between Multiple Windows of Same Application
This example shows how to change the colour of taskbar buttons for any window (red/yellow/green):
Code: Select all
;based on example at bottom of:
;DllCall
;https://autohotkey.com/docs/commands/DllCall.htm
;CLSIDs from:
;taskbarInterface/taskbarInterface.ahk at master · HelgeffegleH/taskbarInterface · GitHub
;https://github.com/HelgeffegleH/taskbarInterface/blob/master/taskbarInterface.ahk
;offset values from:
;COM-Classes/TaskbarList3.ahk at master · maul-esel/COM-Classes · GitHub
;https://github.com/maul-esel/COM-Classes/blob/master/TaskbarList3/TaskbarList3.ahk
q:: ;set taskbar button colour to red/yellow/green
WinGet, hWnd, ID, A
;IID_ITaskbarList := "{56FDF342-FD6D-11d0-958A-006097C9A090}"
IID_ITaskbarList3 := "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}"
CLSID_TaskbarList := "{56FDF344-FD6D-11d0-958A-006097C9A090}"
itbl := ComObjCreate(CLSID_TaskbarList, IID_ITaskbarList3)
;TBPF_ERROR := 0x4 ;red
;TBPF_PAUSED := 0x8 ;yellow
;TBPF_NORMAL := 0x2 ;green
vState := 0x4 ;red
vState := 0x8 ;yellow
vState := 0x2 ;green
DllCall(vtable(itbl,9), Ptr,itbl, Ptr,hWnd, Int64,100, Int64,100) ;SetProgressValue
DllCall(vtable(itbl,10), Ptr,itbl, Ptr,hWnd, UInt,vState) ;SetProgressState
ObjRelease(itbl)
return
vtable(ptr, n)
{
return NumGet(NumGet(ptr+0), n*A_PtrSize)
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: No registered users and 173 guests