Put a mark on a window and remove when window closes (in case it is reopened later)
Put a mark on a window and remove when window closes (in case it is reopened later)
I'm looking to put a small mark on a window, by mark I mean for example a small blob of color, letter X, anything that signifies to me an action has taken place, in addition if the window got closed and reopened with the same id, I would want the mark not to be there.
I'm not sure how to do either part of this at the moment. I'm going to look into it myself further, but would appreciate any help.
I'm not sure how to do either part of this at the moment. I'm going to look into it myself further, but would appreciate any help.
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
There are a couple of ways I’ve made indicators that certain windows have been acted upon. One is by changing the text of the window title. Another is to change the window’s icon in the title bar. You could change it to an X or a blob of color or whatever. Would either of those work for you?
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
what does closed and reopened with the same id mean?
windows are assigned new hwnds upon creation by the window manager by whatever method it implements. the odds of a window u closed and reopened reusing the same hwnd it was previously assigned are astronomically low
windows are assigned new hwnds upon creation by the window manager by whatever method it implements. the odds of a window u closed and reopened reusing the same hwnd it was previously assigned are astronomically low
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
@boilerboiler wrote: There are a couple of ways I’ve made indicators that certain windows have been acted upon. One is by changing the text of the window title. Another is to change the window’s icon in the title bar. You could change it to an X or a blob of color or whatever. Would either of those work for you?
Thanks for your reply boiler.
Changing the icon might work for me, any pointers on how to do that.
As an aside, I saw some examples with Winslet, region subcommand used to draw shapes within Notepad, it looked interesting, but seems more like a transformation, rather than a simple way to mark a window.
@swagfag
Thanks for your reply. Yes, I meant hwnd. I think I have seen instances where the hwnd gets used again, anyway, guess it's not the important part.
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
Like this:
Code: Select all
IconFile := "PathToMyIcon.ico" ; can be relative to the script's working directory or absoulte
WinID := WinExist("ahk_exe notepad.exe") ; replace with WinTitle of desired window
hIcon := DllCall( "LoadImage", "UInt", 0, "Str", IconFile, "UInt", 1, "UInt", 0, "UInt", 0, "UInt", 0x10)
SendMessage, 0x80, 0, hIcon,, ahk_id %WinID% ; affects small icon such as title bar
SendMessage, 0x80, 1, hIcon,, ahk_id %WinID% ; affects big icon such as Alt+Tab menu
Yes, it is a transformation. It could be used to mark a window if you wanted, such as rounding its corners or something. If it's not a fixed window size, you'll need to get the size of the window and then dynamically build the details of the shape you're drawing based on it, which would be kind of a pain for simply marking a window. The icon seems much easier to me.
You have almost surely never seen instances where it is used again. If you saw the same hwnd, it was because the window was never really closed and re-created. It was just hidden and the same window was shown again. The program doesn't make the choice as to what its hwnd is going to be. Windows assigns an hwnd to new windows, and there is almost zero chance you saw the same one again and even less of a chance that it happened to be re-used on that same window the next time it was created.
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
@boiler
Thanks for the code snippet, it works, but not for all windows (perhaps protected ones), so I'm still in need of something that will mark the window under the mouse when I press a hotkey for example.
Thanks for the code snippet, it works, but not for all windows (perhaps protected ones), so I'm still in need of something that will mark the window under the mouse when I press a hotkey for example.
Thanks for the info, yeah, I think the window was just hidden and used again.boiler wrote: ↑19 Jan 2022, 08:33You have almost surely never seen instances where it is used again. If you saw the same hwnd, it was because the window was never really closed and re-created. It was just hidden and the same window was shown again. The program doesn't make the choice as to what its hwnd is going to be. Windows assigns an hwnd to new windows, and there is almost zero chance you saw the same one again and even less of a chance that it happened to be re-used on that same window the next time it was created.
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
You could use my other suggestion and change the title of the window. As a demo, this script toggles a circle on and off the beginning of the active window's title when you press Ctrl+Tab:
Code: Select all
^Tab::
WinGetActiveTitle, Title
if InStr(Title, "⬤")
WinSetTitle, A,, % StrReplace(Title, "⬤")
else
WinSetTitle, A,, % "⬤" Title
return
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
@boiler
thanks once again for the suggestion and code snippet, but I don't actually want to change the title, and also the title can get updated by the app itself, so it would lose that mark then.
Edit: Again it doesn't work for certain windows also.
Is there no easy way to just put a slash, blob or color, x, or basically anything to mark the window in autohotkey, I'm obviously no expert, but seems like it should be a fairly straightforward thing to do?
thanks once again for the suggestion and code snippet, but I don't actually want to change the title, and also the title can get updated by the app itself, so it would lose that mark then.
Edit: Again it doesn't work for certain windows also.
Is there no easy way to just put a slash, blob or color, x, or basically anything to mark the window in autohotkey, I'm obviously no expert, but seems like it should be a fairly straightforward thing to do?
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
You can create a small GUI that would just be a blob of color and use Dock to attach it to another window. Is that "easy"? That's up to you.
Re: Put a mark on a window and remove when window closes (in case it is reopened later)
@boiler Thanks and apologies for not thanking sooner, just got distracted by other stuff and haven't been on the forum for a while. I currently don't need to do this, but it's good to know anyway in case I need to try again in the future.