SHARE
TWEET

AHK window borders

a guest Dec 20th, 2012 2,822 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Uncomment this if you want a hotkey to set it for every
  2. ; !+r::GoSub, AdjustAllWindows
  3.  
  4. ; Initalise the hook
  5. GoSub, HookWindow
  6. ; Run it once for every window
  7. GoSub, AdjustAllWindows
  8. Return
  9.  
  10. HookWindow:
  11.    ; New Window Hook
  12.     Gui +LastFound
  13.     hWnd := WinExist()
  14.  
  15.     DllCall( "RegisterShellHookWindow", UInt,hWnd )
  16.     MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  17.     OnMessage( MsgNum, "ShellMessage" )
  18.  
  19.     ShellMessage(wParam,lParam) {
  20.         If (wParam = 1) ;  HSHELL_WINDOWCREATED := 1
  21.         {
  22.             Sleep, 10
  23.             AdjustWindow(lParam)
  24.         }
  25.     }
  26. Return
  27.  
  28. ; Adjust Window
  29. AdjustWindow(id)
  30. {
  31.     WinId := id
  32.     WinTitle := id = "A" ? "A" : "ahk_id " . id
  33.  
  34.     ; This is to check if the window is shown in the alt-tab menu, you don't want to do it on every single frame
  35.     WinGet, WinExStyle, ExStyle, %WinTitle%
  36.     If (WinExStyle & 0x80)
  37.     {
  38.         Return
  39.     }
  40.  
  41.     ; This is to match classes and/or processes
  42.     WinGetClass, WinClass, %WinTitle%
  43.     WinGet, WinProcess, ProcessName, %WinTitle%
  44.  
  45.     ; Explorer
  46.     If WinClass In % "CabinetWClass"
  47.     If WinProcess In % "explorer.exe"
  48.     {
  49.         WinSet, Style, -0xC00000, %WinTitle%
  50.     }
  51.  
  52.     ; foobar2000
  53.     If WinClass In % "{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}"
  54.     {
  55.         ; This removes titlebar AND borders, just an example
  56.         WinSet, Style, -0xC40000, %WinTitle%
  57.     }
  58.  
  59.     ; uTorrent
  60.     If WinProcess In % "uTorrent.exe"
  61.     {
  62.         WinSet, Style, -0xC00000, %WinTitle%
  63.     }
  64.  
  65.     ; Uncomment this and comment the above if you don't want it to work on every window
  66.     ; WinSet, Style, -0xC00000, %WinTitle%
  67. }
  68.  
  69. AdjustAllWindows:
  70.    WinGet, id, list,,, Program Manager
  71.     Loop, %id%
  72.     {
  73.         AdjustWindow(id%A_Index%)
  74.     }
  75. Return
RAW Paste Data
Top