Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Process,Class,Title,BORDER,SIZEBOX,CAPTION,SYSMENU,HSCROLL,VSCROLL,ALWAYS_ON_TOP,BOTTOM,TOP,ALT_TAB,TRANSPARENCY:0-255,REMOVEALL,DISABLE,CLOSE,REDRAW
- ; Example:
- ProgramRules =
- (
- ,MozillaWindowClass,,SIZEBOX
- ,{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8},,REMOVEALL,BOTTOM,REDRAW
- ,WindowsForms10.Window.8.app.0.bb8560_r27_ad1,,REMOVEALL,BOTTOM
- photoshop.exe
- illustrator.exe
- EXCEL.EXE
- WINWORD.EXE
- ,Shell_TrayWnd
- )
- AdjustOnRedraw := 0
- ; This function is called when no program rules are matched, useful for creating blacklists instead of whitelists
- DefaultAction(WinTitle)
- {
- ; Remove Border
- ; WinSet, Style, -0x800000, % WinTitle
- ; Add Sizing Border
- ; WinSet, Style, +0x40000, % WinTitle
- ; Remove Caption (Titlebar)
- WinSet, Style, -0xC00000, % WinTitle
- ; Remove System Menu
- ; WinSet, Style, -0xC00000, % WinTitle
- ; Remove horizontal scrollbars
- ; WinSet, Style, -0x100000, % WinTitle
- ; Remove vertical scrollbars
- ; WinSet, Style, -0x200000, % WinTitle
- ; Set always on top
- ; WinSet, AlwaysOnTop, On, % WinTitle
- ; Send to bottom
- ; WinSet, Bottom,, % WinTitle
- ; Send to top
- ; WinSet, Top,, % WinTitle
- ; Remove from alt-tab list
- ; WinSet, ExStyle, ^0x80, % WinTitle
- ; Set transparency
- ; WinSet, Transparency, 255, % WinTitle
- }
- ; Parse the program rules
- ReadConfig()
- ; Initalise the hook
- GoSub, HookWindow
- ; Run it once for every window
- GoSub, AdjustAllWindows
- ; And again after 10 seconds (after everything has loaded)
- Sleep,10000
- GoSub, AdjustAllWindows
- Return
- ; Fullscreen Windowed Mode
- ^!f::
- WinSet, Style, -0xC40000, A
- WinMove, A, , 0, 0, 1920, 1080
- Return
- ; Toggle Border
- ^!b::
- WinSet, Style, ^0x800000, A
- Return
- ; Toggle Sizing Border
- ^!g::
- WinSet, Style, ^0x40000, A
- Return
- ; Toggle Caption
- ^!t::
- WinSet, Style, -0x800000, A
- WinSet, Style, ^0xC00000, A
- Return
- ; Adjust all windows
- +!r::
- GoSub, AdjustAllWindows
- Return
- ReadConfig()
- {
- Global
- Local LineIndex := 0
- Loop, Parse, ProgramRules, % "`n"
- {
- LineIndex := A_Index
- Loop, Parse, A_LoopField, % ","
- {
- If (A_Index = 1)
- {
- ProgramRule%LineIndex%Process := A_LoopField
- }
- Else If (A_Index = 2)
- {
- ProgramRule%LineIndex%Class := A_LoopField
- }
- Else If (A_Index = 3)
- {
- ProgramRule%LineIndex%Title := A_LoopField
- }
- Else If (A_LoopField = "BORDER")
- ProgramRule%LineIndex%Border := 1
- Else If (A_LoopField = "SIZEBOX")
- ProgramRule%LineIndex%SizeBox := 1
- Else If (A_LoopField = "CAPTION")
- ProgramRule%LineIndex%Caption := 1
- Else If (A_LoopField = "SYSMENU")
- ProgramRule%LineIndex%SysMenu := 1
- Else If (A_LoopField = "HSCROLL")
- ProgramRule%LineIndex%HScroll := 1
- Else If (A_LoopField = "VSCROLL")
- ProgramRule%LineIndex%VScroll := 1
- Else If (A_LoopField = "ALWAYS_ON_TOP")
- ProgramRule%LineIndex%AlwaysOnTop := 1
- Else If (A_LoopField = "BOTTOM")
- ProgramRule%LineIndex%Bottom := 1
- Else If (A_LoopField = "TOP")
- ProgramRule%LineIndex%Top := 1
- Else If (A_LoopField = "ALT_TAB")
- ProgramRule%LineIndex%AltTab := 1
- Else If A_LoopField contains % "TRANSPARENCY:"
- ProgramRule%LineIndex%Transparency := SubStr(A_LoopField, 14)
- Else If (A_LoopField = "REMOVEALL")
- ProgramRule%LineIndex%RemoveAll := 1
- Else If (A_LoopField = "DISABLE")
- ProgramRule%LineIndex%Disable := 1
- Else If (A_LoopField = "CLOSE")
- ProgramRule%LineIndex%Close := 1
- Else If (A_LoopField = "REDRAW")
- ProgramRule%LineIndex%Redraw := 1
- }
- }
- ProgramRulesCount := LineIndex
- }
- HookWindow:
- ; New Window Hook
- Gui +LastFound
- hWnd := WinExist()
- DllCall( "RegisterShellHookWindow", UInt,hWnd )
- MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
- OnMessage( MsgNum, "ShellMessage" )
- ShellMessage(wParam,lParam) {
- Global AdjustOnRedraw
- Sleep, 10
- If (AdjustOnRedraw)
- {
- If wParam in 1,6
- AdjustWindow(lParam)
- }
- Else
- If (wParam = 1)
- AdjustWindow(lParam)
- }
- Return
- ; Adjust Window
- AdjustWindow(id)
- {
- Global
- WinTitle := id = "A" ? "A" : "ahk_id " . id
- WinGet, WinProcess, ProcessName, % WinTitle
- WinGetClass, WinClass, % WinTitle
- WinGetTitle, WinRealTitle, % WinTitle
- Found := 0
- Loop % ProgramRulesCount
- {
- If (ProgramRule%A_Index%Process and ProgramRule%A_Index%Process <> WinProcess)
- Continue
- If (ProgramRule%A_Index%Class)
- If ProgramRule%A_Index%Class not contains % WinClass
- Continue
- If (ProgramRule%A_Index%Title)
- If ProgramRule%A_Index%Title not contains % WinRealTitle
- Continue
- Found := 1
- If (ProgramRule%A_Index%Border)
- WinSet, Style, ^0x800000, % WinTitle
- If (ProgramRule%A_Index%SizeBox)
- WinSet, Style, ^0x40000, % WinTitle
- If (ProgramRule%A_Index%Caption)
- WinSet, Style, ^0x80000, % WinTitle
- If (ProgramRule%A_Index%SysMenu)
- WinSet, Style, ^0xC00000, % WinTitle
- If (ProgramRule%A_Index%HScroll)
- WinSet, Style, ^0x100000, % WinTitle
- If (ProgramRule%A_Index%VScroll)
- WinSet, Style, ^0x200000, % WinTitle
- If (ProgramRule%A_Index%AlwaysOnTop)
- WinSet, AlwaysOnTop, ON, % WinTitle
- If (ProgramRule%A_Index%Bottom)
- WinSet, Bottom,, % WinTitle
- If (ProgramRule%A_Index%Top)
- WinSet, Top,, % WinTitle
- If (ProgramRule%A_Index%AltTab)
- WinSet, ExStyle, ^0x80, % WinTitle
- If (ProgramRule%A_Index%Transparency)
- WinSet, Transparent, % ProgramRule%A_Index%Transparency, % WinTitle
- If (ProgramRule%A_Index%RemoveAll)
- WinSet, Style, -0xCF0000, % WinTitle
- If (ProgramRule%A_Index%Disable)
- WinSet, Disable,, % WinTitle
- If (ProgramRule%A_Index%Close)
- WinClose, % WinTitle
- If (ProgramRule%A_Index%Redraw)
- {
- WinGetPos, X, Y, W, H, % WinTitle
- WinMove, % WinTitle,, % X, % Y, % W, % H + 1
- WinMove, % WinTitle,, % X, % Y, % W, % H
- }
- }
- If (!Found)
- {
- DefaultAction(WinTitle)
- }
- }
- AdjustAllWindows:
- WinGet, id, list,,, Program Manager
- Loop, %id%
- {
- AdjustWindow(id%A_Index%)
- }
- Return
Advertisement
Add Comment
Please, Sign In to add comment