chaohershi / cclose

A Windows utility that helps you close windows faster or pin windows always on top.
https://chaohershi.github.io/cclose/
MIT License
374 stars 16 forks source link

add autopin rule? #2

Closed yingxiaoGuo closed 4 years ago

yingxiaoGuo commented 4 years ago

is it possible to add autopin rule for specific window? Like every time it opens, it will be pined

chaohershi commented 4 years ago

It's achievable, but I probably won't add it. It feels a bit unnecessary to add this as a feature.

Here is the code:

Loop
{
    WinGet, PinList, List, ahk_class Notepad ; change here (use Window Spy for help)
    Loop, %PinList%
    {
        WinGet, ExStyle, ExStyle, % "ahk_id " PinList%A_Index% ; get ExStyle
        if !(ExStyle & 0x8) ; if not AlwaysOnTop (0x8 is WS_EX_TOPMOST)
        {
            Winset, Alwaysontop, On, % "ahk_id " PinList%A_Index%
        }
    }
}

To run it, you will need to have AutoHotkey installed. Then save the code as AutoPin.ahk.