Advertisement
wwww

ww AHK remove borders/captions

Dec 23rd, 2012
3,343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. programRules := [   { class: "MozillaWindowClass"
  2.                         , sizebox: 0 }
  3.                 ,   { class: "{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}"
  4.                         , all: 0
  5.                         , redraw: 1 }
  6.                 ,   { class: "CabinetWClass"
  7.                         , caption: 0
  8.                         , border: 0 }
  9.                 ,   { class: "TabbedHostWndClass"
  10.                         , caption: 0
  11.                         , border: 0 }
  12.                 ,   { class: "MSBLWindowClass"
  13.                         , caption: 0    
  14.                         , border: 0 }
  15.                 ,   { class: "µTorrent4823DF041B09"
  16.                         , caption: 0
  17.                         , border: 0 }
  18.                 ,   { class: "PX_WINDOW_CLASS"
  19.                         , caption: 0
  20.                         , border: 0 }
  21.                 ,   { class: "classFoxitReader"
  22.                         , caption: 0
  23.                         , border: 0 }
  24.                 ,   { class: "SunAwtFrame"
  25.                         , caption: 0
  26.                         , border: 0 } ]
  27.  
  28. AdjustOnRedraw := 0
  29.  
  30. adjustAllWindows()
  31. GoSub, HookWindow
  32. Sleep,10000
  33. adjustAllWindows()
  34. Return
  35.  
  36. ; Toggle Border
  37. ^!b::
  38.     WinSet, Style, ^0x800000, A
  39. Return
  40.  
  41. ; Toggle Sizing Border
  42. ^!g::
  43.     WinSet, Style, ^0x40000, A
  44. Return
  45.  
  46. ; Toggle Caption
  47. ^!t::
  48.     WinSet, Style, -0x800000, A
  49.     WinSet, Style, ^0xC00000, A
  50. Return
  51.  
  52. ; Adjust all windows
  53. +!r::
  54.     adjustAllWindows()
  55. Return
  56.  
  57. ; Toggle Menubar
  58. ^!m::
  59.     WinSet, Style, ^0xC00000, A
  60. Return
  61.  
  62. ;Toggle taskbar
  63. ^!Space::
  64. if toggle := !toggle
  65. {
  66.   WinHide ahk_class Shell_TrayWnd
  67.   WinHide Start ahk_class Button
  68. }
  69. else
  70. {
  71.   WinShow ahk_class Shell_TrayWnd
  72.   WinShow Start ahk_class Button
  73. }
  74. Return
  75.  
  76. adjustWindow(_id)
  77. {
  78.     global programRules
  79.     id := _id = "A" ? "A" : "ahk_id " . _id
  80.  
  81.     for _, program in programRules
  82.     {
  83.         if program.class
  84.         {
  85.             WinGetClass, class, % id
  86.             if (class <> program.class)
  87.             {
  88.                 continue
  89.             }
  90.         }
  91.         if program.process
  92.         {
  93.             WinGet, process, ProcessName, % id
  94.             if (process <> program.process)
  95.             {
  96.                 continue
  97.             }
  98.         }
  99.         if program.title
  100.         {
  101.             WinGetTitle, title, % id
  102.             if (title <> program.title)
  103.             {
  104.                 continue
  105.             }
  106.         }
  107.  
  108.         for rule, value in program
  109.         {
  110.             if (rule = "class" or rule = "process" or rule = "title")
  111.                 continue
  112.             else if (rule = "border")
  113.             {
  114.                 WinSet, Style, % (value = 0 ? "-" : value = 1 ? "+" : "^") . 0x800000, % id
  115.             }
  116.             else if (rule = "sizebox")
  117.                 WinSet, Style, % (value = 0 ? "-" : value = 1 ? "+" : "^") . 0x40000, % id
  118.             else if (rule = "caption")
  119.                 WinSet, Style, % (value = 0 ? "-" : value = 1 ? "+" : "^") . 0x80000, % id
  120.             else if (rule = "all")
  121.                 WinSet, Style, % (value = 0 ? "-" : value = 1 ? "+" : "^") . 0xCF0000, % id
  122.             else if (rule = "always_on_top")
  123.                 WinSet, AlwaysOnTop, % (value = 0 ? "OFF" : value = 1 ? "ON" : "TOGGLE"), % id
  124.             else if (rule = "top")
  125.                 WinSet, Top,, % id
  126.             else if (rule = "bottom")
  127.                 WinSet, Top,, % id
  128.             else if (rule = "alt_tab")
  129.                 WinSet, ExStyle, % (value = 0 ? "-" : value = 1 ? "+" : "^") . 0x80, % id
  130.             else if (rule = "transparent")
  131.                 WinSet, Transparent, % value, % id
  132.             else if (rule = "transcolor")
  133.                 WinSet, TransColor, % value, % id
  134.             else if (rule = "alt_tab")
  135.                 WinSet, ExStyle, % (value = 0 ? "-" : value = 1 ? "+" : "^") . 0x80, % id
  136.             else if (rule = "alt_tab")
  137.                 WinSet, ExStyle, % (value = 0 ? "-" : value = 1 ? "+" : "^") . 0x80, % id
  138.             else if (rule = "close")
  139.                 WinClose, % id
  140.             else if (rule = "redraw")
  141.             {
  142.                 WinGetPos, X, Y, W, H, % id
  143.                 WinMove, % id,, % X, % Y, % W, % H + 1
  144.                 WinMove, % id,, % X, % Y, % W, % H
  145.             }
  146.             else if (rule = "x")
  147.             {
  148.                 WinGetPos, X, Y, W, H, % id
  149.                 WinMove, % id,, % value, % Y, % W, % H
  150.             }
  151.             else if (rule = "y")
  152.             {
  153.                 WinGetPos, X, Y, W, H, % id
  154.                 WinMove, % id,, % X, % value, % W, % H
  155.             }
  156.             else if (rule = "w")
  157.             {
  158.                 WinGetPos, X, Y, W, H, % id
  159.                 WinMove, % id,, % X, % Y, % value, % H
  160.             }
  161.             else if (rule = "h")
  162.             {
  163.                 WinGetPos, X, Y, W, H, % id
  164.                 WinMove, % id,, % X, % Y, % W, % value
  165.             }
  166.             else if (rule = "rx")
  167.             {
  168.                 WinGetPos, X, Y, W, H, % id
  169.                 WinMove, % id,, % X + value, % Y, % W, % H
  170.             }
  171.             else if (rule = "ry")
  172.             {
  173.                 WinGetPos, X, Y, W, H, % id
  174.                 WinMove, % id,, % X, % Y + value, % W, % H
  175.             }
  176.             else if (rule = "rw")
  177.             {
  178.                 WinGetPos, X, Y, W, H, % id
  179.                 WinMove, % id,, % X, % Y, % W + value, % H
  180.             }
  181.             else if (rule = "rh")
  182.             {
  183.                 WinGetPos, X, Y, W, H, % id
  184.                 WinMove, % id,, % X, % Y, % W, % H + value
  185.             }
  186.             else
  187.                 OutputDebug, "Invalid rule: " . rule
  188.         }
  189.     }
  190. }
  191.  
  192. adjustAllWindows()
  193. {
  194.     WinGet, id, list,,, Program Manager
  195.     Loop, %id%
  196.     {
  197.         AdjustWindow(id%A_Index%)
  198.     }
  199. }
  200.  
  201. HookWindow:
  202.    ; New Window Hook
  203.     Gui +LastFound
  204.     hWnd := WinExist()
  205.  
  206.     DllCall( "RegisterShellHookWindow", UInt,hWnd )
  207.     MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  208.     OnMessage( MsgNum, "ShellMessage" )
  209.  
  210.     ShellMessage(wParam,lParam) {
  211.         Global AdjustOnRedraw
  212.         Sleep, 10
  213.         If (AdjustOnRedraw)
  214.         {
  215.             If wParam in 1,6
  216.                 adjustWindow(lParam)
  217.         }
  218.         Else
  219.             If (wParam = 1)
  220.                 adjustWindow(lParam)
  221.     }
  222. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement