Guest User

titlebarscript

a guest
Jun 26th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.91 KB | None | 0 0
  1. ; Process,Class,Title,BORDER,SIZEBOX,CAPTION,SYSMENU,HSCROLL,VSCROLL,ALWAYS_ON_TOP,BOTTOM,TOP,ALT_TAB,TRANSPARENCY:0-255,REMOVEALL,DISABLE,CLOSE,REDRAW
  2.  
  3. ; Example:
  4. ProgramRules =
  5. (
  6. ,MozillaWindowClass,,SIZEBOX
  7. ,{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8},,REMOVEALL,BOTTOM,REDRAW
  8. ,WindowsForms10.Window.8.app.0.bb8560_r27_ad1,,REMOVEALL,BOTTOM
  9. photoshop.exe
  10. illustrator.exe
  11. EXCEL.EXE
  12. WINWORD.EXE
  13. ,Shell_TrayWnd
  14. )
  15.  
  16. AdjustOnRedraw := 0
  17.  
  18. ; This function is called when no program rules are matched, useful for creating blacklists instead of whitelists
  19. DefaultAction(WinTitle)
  20. {
  21. ; Remove Border
  22. ; WinSet, Style, -0x800000, % WinTitle
  23.  
  24. ; Add Sizing Border
  25. ; WinSet, Style, +0x40000, % WinTitle
  26.  
  27. ; Remove Caption (Titlebar)
  28. WinSet, Style, -0xC00000, % WinTitle
  29.  
  30. ; Remove System Menu
  31. ; WinSet, Style, -0xC00000, % WinTitle
  32.  
  33. ; Remove horizontal scrollbars
  34. ; WinSet, Style, -0x100000, % WinTitle
  35.  
  36. ; Remove vertical scrollbars
  37. ; WinSet, Style, -0x200000, % WinTitle
  38.  
  39. ; Set always on top
  40. ; WinSet, AlwaysOnTop, On, % WinTitle
  41.  
  42. ; Send to bottom
  43. ; WinSet, Bottom,, % WinTitle
  44.  
  45. ; Send to top
  46. ; WinSet, Top,, % WinTitle
  47.  
  48. ; Remove from alt-tab list
  49. ; WinSet, ExStyle, ^0x80, % WinTitle
  50.  
  51. ; Set transparency
  52. ; WinSet, Transparency, 255, % WinTitle
  53. }
  54.  
  55. ; Parse the program rules
  56. ReadConfig()
  57. ; Initalise the hook
  58. GoSub, HookWindow
  59. ; Run it once for every window
  60. GoSub, AdjustAllWindows
  61. ; And again after 10 seconds (after everything has loaded)
  62. Sleep,10000
  63. GoSub, AdjustAllWindows
  64. Return
  65.  
  66. ; Fullscreen Windowed Mode
  67. ^!f::
  68. WinSet, Style, -0xC40000, A
  69. WinMove, A, , 0, 0, 1920, 1080
  70. Return
  71.  
  72. ; Toggle Border
  73. ^!b::
  74. WinSet, Style, ^0x800000, A
  75. Return
  76.  
  77. ; Toggle Sizing Border
  78. ^!g::
  79. WinSet, Style, ^0x40000, A
  80. Return
  81.  
  82. ; Toggle Caption
  83. ^!t::
  84. WinSet, Style, -0x800000, A
  85. WinSet, Style, ^0xC00000, A
  86. Return
  87.  
  88. ; Adjust all windows
  89. +!r::
  90. GoSub, AdjustAllWindows
  91. Return
  92.  
  93. ReadConfig()
  94. {
  95. Global
  96. Local LineIndex := 0
  97. Loop, Parse, ProgramRules, % "`n"
  98. {
  99. LineIndex := A_Index
  100. Loop, Parse, A_LoopField, % ","
  101. {
  102. If (A_Index = 1)
  103. {
  104. ProgramRule%LineIndex%Process := A_LoopField
  105. }
  106. Else If (A_Index = 2)
  107. {
  108. ProgramRule%LineIndex%Class := A_LoopField
  109. }
  110. Else If (A_Index = 3)
  111. {
  112. ProgramRule%LineIndex%Title := A_LoopField
  113. }
  114. Else If (A_LoopField = "BORDER")
  115. ProgramRule%LineIndex%Border := 1
  116. Else If (A_LoopField = "SIZEBOX")
  117. ProgramRule%LineIndex%SizeBox := 1
  118. Else If (A_LoopField = "CAPTION")
  119. ProgramRule%LineIndex%Caption := 1
  120. Else If (A_LoopField = "SYSMENU")
  121. ProgramRule%LineIndex%SysMenu := 1
  122. Else If (A_LoopField = "HSCROLL")
  123. ProgramRule%LineIndex%HScroll := 1
  124. Else If (A_LoopField = "VSCROLL")
  125. ProgramRule%LineIndex%VScroll := 1
  126. Else If (A_LoopField = "ALWAYS_ON_TOP")
  127. ProgramRule%LineIndex%AlwaysOnTop := 1
  128. Else If (A_LoopField = "BOTTOM")
  129. ProgramRule%LineIndex%Bottom := 1
  130. Else If (A_LoopField = "TOP")
  131. ProgramRule%LineIndex%Top := 1
  132. Else If (A_LoopField = "ALT_TAB")
  133. ProgramRule%LineIndex%AltTab := 1
  134. Else If A_LoopField contains % "TRANSPARENCY:"
  135. ProgramRule%LineIndex%Transparency := SubStr(A_LoopField, 14)
  136. Else If (A_LoopField = "REMOVEALL")
  137. ProgramRule%LineIndex%RemoveAll := 1
  138. Else If (A_LoopField = "DISABLE")
  139. ProgramRule%LineIndex%Disable := 1
  140. Else If (A_LoopField = "CLOSE")
  141. ProgramRule%LineIndex%Close := 1
  142. Else If (A_LoopField = "REDRAW")
  143. ProgramRule%LineIndex%Redraw := 1
  144. }
  145. }
  146. ProgramRulesCount := LineIndex
  147. }
  148.  
  149. HookWindow:
  150. ; New Window Hook
  151. Gui +LastFound
  152. hWnd := WinExist()
  153.  
  154. DllCall( "RegisterShellHookWindow", UInt,hWnd )
  155. MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
  156. OnMessage( MsgNum, "ShellMessage" )
  157.  
  158. ShellMessage(wParam,lParam) {
  159. Global AdjustOnRedraw
  160. Sleep, 10
  161. If (AdjustOnRedraw)
  162. {
  163. If wParam in 1,6
  164. AdjustWindow(lParam)
  165. }
  166. Else
  167. If (wParam = 1)
  168. AdjustWindow(lParam)
  169. }
  170. Return
  171.  
  172. ; Adjust Window
  173. AdjustWindow(id)
  174. {
  175. Global
  176. WinTitle := id = "A" ? "A" : "ahk_id " . id
  177. WinGet, WinProcess, ProcessName, % WinTitle
  178. WinGetClass, WinClass, % WinTitle
  179. WinGetTitle, WinRealTitle, % WinTitle
  180. Found := 0
  181. Loop % ProgramRulesCount
  182. {
  183. If (ProgramRule%A_Index%Process and ProgramRule%A_Index%Process <> WinProcess)
  184. Continue
  185. If (ProgramRule%A_Index%Class)
  186. If ProgramRule%A_Index%Class not contains % WinClass
  187. Continue
  188. If (ProgramRule%A_Index%Title)
  189. If ProgramRule%A_Index%Title not contains % WinRealTitle
  190. Continue
  191. Found := 1
  192.  
  193. If (ProgramRule%A_Index%Border)
  194. WinSet, Style, ^0x800000, % WinTitle
  195. If (ProgramRule%A_Index%SizeBox)
  196. WinSet, Style, ^0x40000, % WinTitle
  197. If (ProgramRule%A_Index%Caption)
  198. WinSet, Style, ^0x80000, % WinTitle
  199. If (ProgramRule%A_Index%SysMenu)
  200. WinSet, Style, ^0xC00000, % WinTitle
  201. If (ProgramRule%A_Index%HScroll)
  202. WinSet, Style, ^0x100000, % WinTitle
  203. If (ProgramRule%A_Index%VScroll)
  204. WinSet, Style, ^0x200000, % WinTitle
  205. If (ProgramRule%A_Index%AlwaysOnTop)
  206. WinSet, AlwaysOnTop, ON, % WinTitle
  207. If (ProgramRule%A_Index%Bottom)
  208. WinSet, Bottom,, % WinTitle
  209. If (ProgramRule%A_Index%Top)
  210. WinSet, Top,, % WinTitle
  211. If (ProgramRule%A_Index%AltTab)
  212. WinSet, ExStyle, ^0x80, % WinTitle
  213. If (ProgramRule%A_Index%Transparency)
  214. WinSet, Transparent, % ProgramRule%A_Index%Transparency, % WinTitle
  215. If (ProgramRule%A_Index%RemoveAll)
  216. WinSet, Style, -0xCF0000, % WinTitle
  217. If (ProgramRule%A_Index%Disable)
  218. WinSet, Disable,, % WinTitle
  219. If (ProgramRule%A_Index%Close)
  220. WinClose, % WinTitle
  221. If (ProgramRule%A_Index%Redraw)
  222. {
  223. WinGetPos, X, Y, W, H, % WinTitle
  224. WinMove, % WinTitle,, % X, % Y, % W, % H + 1
  225. WinMove, % WinTitle,, % X, % Y, % W, % H
  226. }
  227. }
  228. If (!Found)
  229. {
  230. DefaultAction(WinTitle)
  231. }
  232. }
  233.  
  234. AdjustAllWindows:
  235. WinGet, id, list,,, Program Manager
  236. Loop, %id%
  237. {
  238. AdjustWindow(id%A_Index%)
  239. }
  240. Return
Advertisement
Add Comment
Please, Sign In to add comment