AutoHotkey: NiftyWindows Mod


 / Published in: Other
 

URL: http://www.enovatic.org/products/niftywindows/introduction/

A modification of the NiftyWindows AutoHotkey script, this snippet attempts to solve the following issues that I have been experiencing with the original script: * Middle click sends double click. This causes an issue for me as I use middle clicks to close: * Tabs * Applications using the title bar (this snippet adds this functionality) * Applications using the task bar (this snippet allows middle clicks through to non-title bar areas if right button is not also pressed)

  1. /*
  2. * Copyright (c) 2004-2005 by Enovatic-Solutions. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. * ----------------------------------------------------------------------
  18. * If you have any suggestions of new features or further questions
  19. * feel free to contact the author.
  20. *
  21. * Company: Enovatic-Solutions (IT Service Provider)
  22. * Author: Oliver Pfeiffer, Bremen (GERMANY)
  23. * Homepage: http://www.enovatic.org/
  24. * Email: [email protected]
  25. */
  26.  
  27.  
  28.  
  29. ; NiftyWindows Version 0.9.3.1
  30. ; http://www.enovatic.org/products/niftywindows/
  31.  
  32. ; AutoHotkey Version 1.0.36.01
  33. ; http://www.autohotkey.com/
  34.  
  35.  
  36.  
  37. #SingleInstance force
  38. #HotkeyInterval 1000
  39. #MaxHotkeysPerInterval 100
  40. #NoTrayIcon
  41.  
  42.  
  43.  
  44. ; [SYS] autostart section
  45.  
  46. SplitPath, A_ScriptFullPath, SYS_ScriptNameExt, SYS_ScriptDir, SYS_ScriptExt, SYS_ScriptNameNoExt, SYS_ScriptDrive
  47. SYS_ScriptVersion = 0.9.3.1
  48. SYS_ScriptBuild = 20050702195845
  49. SYS_ScriptInfo = %SYS_ScriptNameNoExt% %SYS_ScriptVersion%
  50.  
  51. Process, Priority, , HIGH
  52. SetBatchLines, -1
  53. ; TODO : a nulled key delay may produce problems for WinAmp control
  54. SetKeyDelay, 0, 0
  55. SetMouseDelay, 0
  56. SetDefaultMouseSpeed, 0
  57. SetWinDelay, 0
  58. SetControlDelay, 0
  59.  
  60. Gosub, SYS_ParseCommandLine
  61. Gosub, CFG_LoadSettings
  62. Gosub, CFG_ApplySettings
  63.  
  64. MIR_MirandaFullPath = %ProgramFiles%\Miranda\Miranda32.exe
  65. SplitPath, MIR_MirandaFullPath, , MIR_MirandaDir
  66.  
  67. if ( !A_IsCompiled )
  68. SetTimer, REL_ScriptReload, 1000
  69.  
  70. OnExit, SYS_ExitHandler
  71.  
  72. Gosub, TRY_TrayInit
  73. Gosub, SYS_ContextCheck
  74. Gosub, UPD_AutoCheckForUpdate
  75.  
  76. Return
  77.  
  78.  
  79.  
  80. ; [SYS] parses command line parameters
  81.  
  82. SYS_ParseCommandLine:
  83. Loop %0%
  84. If ( (%A_Index% = "/x") or (%A_Index% = "/exit") )
  85. ExitApp
  86. Return
  87.  
  88.  
  89.  
  90. ; [SYS] exit handler
  91.  
  92. SYS_ExitHandler:
  93. Gosub, AOT_ExitHandler
  94. Gosub, ROL_ExitHandler
  95. Gosub, TRA_ExitHandler
  96. Gosub, CFG_SaveSettings
  97. ExitApp
  98.  
  99.  
  100.  
  101. ; [SYS] context check
  102.  
  103. SYS_ContextCheck:
  104. Gosub, SYS_TrayTipBalloonCheck
  105. If ( !SYS_TrayTipBalloon )
  106. {
  107. Gosub, SUS_SuspendSaveState
  108. Suspend, On
  109. MsgBox, 4148, Balloon Handler - %SYS_ScriptInfo%, The balloon messages are disabled on your system. These visual messages`nabove the system tray are often used by tools as additional information four`nyour interest.`n`nNiftyWindows uses balloon messages to show you some important operating`ndetails. If you leave the messages disabled NiftyWindows will show some plain`nmessages as tooltips instead (in front of the system tray).`n`nDo you want to enable balloon messages now (highly recommended)?
  110. Gosub, SUS_SuspendRestoreState
  111. IfMsgBox, Yes
  112. {
  113. SYS_TrayTipBalloon = 1
  114. RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, EnableBalloonTips, %SYS_TrayTipBalloon%
  115. RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, EnableBalloonTips, %SYS_TrayTipBalloon%
  116. SendMessage, 0x001A, , , , ahk_id 0xFFFF ; 0x001A is WM_SETTINGCHANGE ; 0xFFFF is HWND_BROADCAST
  117. Sleep, 500 ; lets the other windows relax
  118. }
  119. }
  120.  
  121. IfNotExist, %A_ScriptDir%\readme.txt
  122. {
  123. TRY_TrayEvent := "Help"
  124. Gosub, TRY_TrayEvent
  125. Suspend, On
  126. Sleep, 10000
  127. ExitApp, 1
  128. }
  129.  
  130. IfNotExist, %A_ScriptDir%\license.txt
  131. {
  132. TRY_TrayEvent := "View License"
  133. Gosub, TRY_TrayEvent
  134. Suspend, On
  135. Sleep, 10000
  136. ExitApp, 1
  137. }
  138.  
  139. TRY_TrayEvent := "About"
  140. Gosub, TRY_TrayEvent
  141. Return
  142.  
  143.  
  144.  
  145. ; [SYS] handles tooltips
  146.  
  147. SYS_ToolTipShow:
  148. If ( SYS_ToolTipText )
  149. {
  150. If ( !SYS_ToolTipSeconds )
  151. SYS_ToolTipSeconds = 2
  152. SYS_ToolTipMillis := SYS_ToolTipSeconds * 1000
  153. CoordMode, Mouse, Screen
  154. CoordMode, ToolTip, Screen
  155. If ( !SYS_ToolTipX or !SYS_ToolTipY )
  156. {
  157. MouseGetPos, SYS_ToolTipX, SYS_ToolTipY
  158. SYS_ToolTipX += 16
  159. SYS_ToolTipY += 24
  160. }
  161. ToolTip, %SYS_ToolTipText%, %SYS_ToolTipX%, %SYS_ToolTipY%
  162. SetTimer, SYS_ToolTipHandler, %SYS_ToolTipMillis%
  163. }
  164. SYS_ToolTipText =
  165. SYS_ToolTipSeconds =
  166. SYS_ToolTipX =
  167. SYS_ToolTipY =
  168. Return
  169.  
  170. SYS_ToolTipFeedbackShow:
  171. If ( SYS_ToolTipFeedback )
  172. Gosub, SYS_ToolTipShow
  173. SYS_ToolTipText =
  174. SYS_ToolTipSeconds =
  175. SYS_ToolTipX =
  176. SYS_ToolTipY =
  177. Return
  178.  
  179. SYS_ToolTipHandler:
  180. SetTimer, SYS_ToolTipHandler, Off
  181. ToolTip
  182. Return
  183.  
  184.  
  185.  
  186. ; [SYS] handles balloon messages
  187.  
  188. SYS_TrayTipShow:
  189. If ( SYS_TrayTipText )
  190. {
  191. If ( !SYS_TrayTipTitle )
  192. SYS_TrayTipTitle = %SYS_ScriptInfo%
  193. If ( !SYS_TrayTipSeconds )
  194. SYS_TrayTipSeconds = 10
  195. If ( !SYS_TrayTipOptions )
  196. SYS_TrayTipOptions = 17
  197. SYS_TrayTipMillis := SYS_TrayTipSeconds * 1000
  198. Gosub, SYS_TrayTipBalloonCheck
  199. If ( SYS_TrayTipBalloon and !A_IconHidden )
  200. {
  201. TrayTip, %SYS_TrayTipTitle%, %SYS_TrayTipText%, %SYS_TrayTipSeconds%, %SYS_TrayTipOptions%
  202. SetTimer, SYS_TrayTipHandler, %SYS_TrayTipMillis%
  203. }
  204. Else
  205. {
  206. TrayTip
  207. SYS_ToolTipText = %SYS_TrayTipTitle%:`n`n%SYS_TrayTipText%
  208. SYS_ToolTipSeconds = %SYS_TrayTipSeconds%
  209. SysGet, SYS_TrayTipDisplay, Monitor
  210. SYS_ToolTipX = %SYS_TrayTipDisplayRight%
  211. SYS_ToolTipY = %SYS_TrayTipDisplayBottom%
  212. Gosub, SYS_ToolTipShow
  213. }
  214. }
  215. SYS_TrayTipTitle =
  216. SYS_TrayTipText =
  217. SYS_TrayTipSeconds =
  218. SYS_TrayTipOptions =
  219. Return
  220.  
  221. SYS_TrayTipHandler:
  222. SetTimer, SYS_TrayTipHandler, Off
  223. TrayTip
  224. Return
  225.  
  226. SYS_TrayTipBalloonCheck:
  227. RegRead, SYS_TrayTipBalloonCU, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, EnableBalloonTips
  228. SYS_TrayTipBalloonCU := ErrorLevel or SYS_TrayTipBalloonCU
  229. RegRead, SYS_TrayTipBalloonLM, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, EnableBalloonTips
  230. SYS_TrayTipBalloonLM := ErrorLevel or SYS_TrayTipBalloonLM
  231. SYS_TrayTipBalloon := SYS_TrayTipBalloonCU and SYS_TrayTipBalloonLM
  232. Return
  233.  
  234.  
  235.  
  236. ; [SUS] provides suspend services
  237.  
  238. #Esc::
  239. SUS_SuspendToggle:
  240. Suspend, Permit
  241. If ( !A_IsSuspended )
  242. {
  243. Suspend, On
  244. SYS_TrayTipText = NiftyWindows is suspended now.`nPress WIN+ESC to resume it again.
  245. SYS_TrayTipOptions = 2
  246. }
  247. Else
  248. {
  249. Suspend, Off
  250. SYS_TrayTipText = NiftyWindows is resumed now.`nPress WIN+ESC to suspend it again.
  251. }
  252. Gosub, SYS_TrayTipShow
  253. Gosub, TRY_TrayUpdate
  254. Return
  255.  
  256. SUS_SuspendSaveState:
  257. SUS_Suspended := A_IsSuspended
  258. Return
  259.  
  260. SUS_SuspendRestoreState:
  261. If ( SUS_Suspended )
  262. Suspend, On
  263. Else
  264. Suspend, Off
  265. Return
  266.  
  267. SUS_SuspendHandler:
  268. IfWinActive, A
  269. {
  270. WinGet, SUS_WinID, ID
  271. If ( !SUS_WinID )
  272. Return
  273. WinGet, SUS_WinMinMax, MinMax, ahk_id %SUS_WinID%
  274. WinGetPos, SUS_WinX, SUS_WinY, SUS_WinW, SUS_WinH, ahk_id %SUS_WinID%
  275.  
  276. If ( (SUS_WinMinMax = 0) and (SUS_WinX = 0) and (SUS_WinY = 0) and (SUS_WinW = A_ScreenWidth) and (SUS_WinH = A_ScreenHeight) )
  277. {
  278. WinGetClass, SUS_WinClass, ahk_id %SUS_WinID%
  279. WinGet, SUS_ProcessName, ProcessName, ahk_id %SUS_WinID%
  280. SplitPath, SUS_ProcessName, , , SUS_ProcessExt
  281. If ( (SUS_WinClass != "Progman") and (SUS_ProcessExt != "scr") and !SUS_FullScreenSuspend )
  282. {
  283. SUS_FullScreenSuspend = 1
  284. SUS_FullScreenSuspendState := A_IsSuspended
  285. If ( !A_IsSuspended )
  286. {
  287. Suspend, On
  288. SYS_TrayTipText = A full screen window was activated.`nNiftyWindows is suspended now.`nPress WIN+ESC to resume it again.
  289. SYS_TrayTipOptions = 2
  290. Gosub, SYS_TrayTipShow
  291. Gosub, TRY_TrayUpdate
  292. }
  293. }
  294. }
  295. Else
  296. {
  297. If ( SUS_FullScreenSuspend )
  298. {
  299. SUS_FullScreenSuspend = 0
  300. If ( A_IsSuspended and !SUS_FullScreenSuspendState )
  301. {
  302. Suspend, Off
  303. SYS_TrayTipText = A full screen window was deactivated.`nNiftyWindows is resumed now.`nPress WIN+ESC to suspend it again.
  304. Gosub, SYS_TrayTipShow
  305. Gosub, TRY_TrayUpdate
  306. }
  307. }
  308. }
  309. }
  310. Return
  311.  
  312.  
  313.  
  314. ; [SYS] provides reversion of all visual effects
  315.  
  316. /**
  317. * This powerful hotkey removes all visual effects (like on exit) that have
  318. * been made before by NiftyWindows. You can use this action as a fall-back
  319. * solution to quickly revert any always-on-top, rolled windows and
  320. * transparency features you've set before.
  321. */
  322.  
  323. ^#BS::
  324. ^!BS::
  325. SYS_RevertVisualEffects:
  326. Gosub, AOT_SetAllOff
  327. Gosub, ROL_RollDownAll
  328. Gosub, TRA_TransparencyAllOff
  329. SYS_TrayTipText = All visual effects (AOT, Roll, Transparency) were reverted.
  330. Gosub, SYS_TrayTipShow
  331. Return
  332.  
  333.  
  334.  
  335. ; [NWD] nifty window dragging
  336.  
  337. /**
  338. * This is the most powerful feature of NiftyWindows. The area of every window
  339. * is tiled in a virtual 9-cell grid with three columns and rows. The center
  340. * cell is the largest one and you can grab and move a window around by clicking
  341. * and holding it with the right mouse button. The other eight corner cells are
  342. * used to resize a resizable window in the same manner.
  343. */
  344.  
  345. $RButton::
  346. $+RButton::
  347. $+!RButton::
  348. $+^RButton::
  349. $+#RButton::
  350. $+!^RButton::
  351. $+!#RButton::
  352. $+^#RButton::
  353. $+!^#RButton::
  354. $!RButton::
  355. $!^RButton::
  356. $!#RButton::
  357. $!^#RButton::
  358. $^RButton::
  359. $^#RButton::
  360. $#RButton::
  361. NWD_ResizeGrids = 5
  362. CoordMode, Mouse, Screen
  363. MouseGetPos, NWD_MouseStartX, NWD_MouseStartY, NWD_WinID
  364. If ( !NWD_WinID )
  365. Return
  366. WinGetPos, NWD_WinStartX, NWD_WinStartY, NWD_WinStartW, NWD_WinStartH, ahk_id %NWD_WinID%
  367. WinGet, NWD_WinMinMax, MinMax, ahk_id %NWD_WinID%
  368. WinGet, NWD_WinStyle, Style, ahk_id %NWD_WinID%
  369. WinGetClass, NWD_WinClass, ahk_id %NWD_WinID%
  370. GetKeyState, NWD_CtrlState, Ctrl, P
  371.  
  372. ; the and'ed condition checks for popup window:
  373. ; (WS_POPUP) and !(WS_DLGFRAME | WS_SYSMENU | WS_THICKFRAME)
  374. If ( (NWD_WinClass = "Progman") or ((NWD_CtrlState = "U") and (((NWD_WinStyle & 0x80000000) and !(NWD_WinStyle & 0x4C0000)) or (NWD_WinClass = "ExploreWClass") or (NWD_WinClass = "CabinetWClass") or (NWD_WinClass = "IEFrame") or (NWD_WinClass = "MozillaWindowClass") or (NWD_WinClass = "OpWindow") or (NWD_WinClass = "ATL:ExplorerFrame") or (NWD_WinClass = "ATL:ScrapFrame"))) )
  375. {
  376. NWD_ImmediateDownRequest = 1
  377. NWD_ImmediateDown = 0
  378. NWD_PermitClick = 1
  379. }
  380. Else
  381. {
  382. NWD_ImmediateDownRequest = 0
  383. NWD_ImmediateDown = 0
  384. NWD_PermitClick = 1
  385. }
  386.  
  387. NWD_Dragging := (NWD_WinClass != "Progman") and ((NWD_CtrlState = "D") or ((NWD_WinMinMax != 1) and !NWD_ImmediateDownRequest))
  388.  
  389. ; checks wheter the window has a sizing border (WS_THICKFRAME)
  390. If ( (NWD_CtrlState = "D") or (NWD_WinStyle & 0x40000) )
  391. {
  392. If ( (NWD_MouseStartX >= NWD_WinStartX + NWD_WinStartW / NWD_ResizeGrids) and (NWD_MouseStartX <= NWD_WinStartX + (NWD_ResizeGrids - 1) * NWD_WinStartW / NWD_ResizeGrids) )
  393. NWD_ResizeX = 0
  394. Else
  395. If ( NWD_MouseStartX > NWD_WinStartX + NWD_WinStartW / 2 )
  396. NWD_ResizeX := 1
  397. Else
  398. NWD_ResizeX := -1
  399.  
  400. If ( (NWD_MouseStartY >= NWD_WinStartY + NWD_WinStartH / NWD_ResizeGrids) and (NWD_MouseStartY <= NWD_WinStartY + (NWD_ResizeGrids - 1) * NWD_WinStartH / NWD_ResizeGrids) )
  401. NWD_ResizeY = 0
  402. Else
  403. If ( NWD_MouseStartY > NWD_WinStartY + NWD_WinStartH / 2 )
  404. NWD_ResizeY := 1
  405. Else
  406. NWD_ResizeY := -1
  407. }
  408. Else
  409. {
  410. NWD_ResizeX = 0
  411. NWD_ResizeY = 0
  412. }
  413.  
  414. If ( NWD_WinStartW and NWD_WinStartH )
  415. NWD_WinStartAR := NWD_WinStartW / NWD_WinStartH
  416. Else
  417. NWD_WinStartAR = 0
  418.  
  419. ; TODO : this is a workaround (checks for popup window) for the activation
  420. ; bug of AutoHotkey -> can be removed as soon as the known bug is fixed
  421. If ( !((NWD_WinStyle & 0x80000000) and !(NWD_WinStyle & 0x4C0000)) )
  422. IfWinNotActive, ahk_id %NWD_WinID%
  423. WinActivate, ahk_id %NWD_WinID%
  424.  
  425. ; TODO : the hotkeys must be enabled in the 2nd block because the 1st block
  426. ; activates them only for the first call (historical problem of AutoHotkey)
  427. Hotkey, Shift, NWD_IgnoreKeyHandler
  428. Hotkey, Ctrl, NWD_IgnoreKeyHandler
  429. Hotkey, Alt, NWD_IgnoreKeyHandler
  430. Hotkey, LWin, NWD_IgnoreKeyHandler
  431. Hotkey, RWin, NWD_IgnoreKeyHandler
  432. Hotkey, Shift, On
  433. Hotkey, Ctrl, On
  434. Hotkey, Alt, On
  435. Hotkey, LWin, On
  436. Hotkey, RWin, On
  437. SetTimer, NWD_IgnoreKeyHandler, 100
  438. SetTimer, NWD_WindowHandler, 10
  439. Return
  440.  
  441. NWD_SetDraggingOff:
  442. NWD_Dragging = 0
  443. Return
  444.  
  445. NWD_SetClickOff:
  446. NWD_PermitClick = 0
  447. NWD_ImmediateDownRequest = 0
  448. Return
  449.  
  450. NWD_SetAllOff:
  451. Gosub, NWD_SetDraggingOff
  452. Gosub, NWD_SetClickOff
  453. Return
  454.  
  455. NWD_IgnoreKeyHandler:
  456. GetKeyState, NWD_RButtonState, RButton, P
  457. GetKeyState, NWD_ShiftState, Shift, P
  458. GetKeyState, NWD_CtrlState, Ctrl, P
  459. GetKeyState, NWD_AltState, Alt, P
  460. ; TODO : unlike the other modifiers, Win does not exist
  461. ; as a virtual key (but Ctrl, Alt and Shift do)
  462. GetKeyState, NWD_LWinState, LWin, P
  463. GetKeyState, NWD_RWinState, RWin, P
  464. If ( (NWD_LWinState = "D") or (NWD_RWinState = "D") )
  465. NWD_WinState = D
  466. Else
  467. NWD_WinState = U
  468.  
  469. If ( (NWD_RButtonState = "U") and (NWD_ShiftState = "U") and (NWD_CtrlState = "U") and (NWD_AltState = "U") and (NWD_WinState = "U") )
  470. {
  471. SetTimer, NWD_IgnoreKeyHandler, Off
  472. Hotkey, Shift, Off
  473. Hotkey, Ctrl, Off
  474. Hotkey, Alt, Off
  475. Hotkey, LWin, Off
  476. Hotkey, RWin, Off
  477. }
  478. Return
  479.  
  480. NWD_WindowHandler:
  481. SetWinDelay, -1
  482. CoordMode, Mouse, Screen
  483. MouseGetPos, NWD_MouseX, NWD_MouseY
  484. WinGetPos, NWD_WinX, NWD_WinY, NWD_WinW, NWD_WinH, ahk_id %NWD_WinID%
  485. GetKeyState, NWD_RButtonState, RButton, P
  486. GetKeyState, NWD_ShiftState, Shift, P
  487. GetKeyState, NWD_AltState, Alt, P
  488. ; TODO : unlike the other modifiers, Win does not exist
  489. ; as a virtual key (but Ctrl, Alt and Shift do)
  490. GetKeyState, NWD_LWinState, LWin, P
  491. GetKeyState, NWD_RWinState, RWin, P
  492. If ( (NWD_LWinState = "D") or (NWD_RWinState = "D") )
  493. NWD_WinState = D
  494. Else
  495. NWD_WinState = U
  496.  
  497. If ( NWD_RButtonState = "U" )
  498. {
  499. SetTimer, NWD_WindowHandler, Off
  500.  
  501. If ( NWD_ImmediateDown )
  502. MouseClick, RIGHT, %NWD_MouseX%, %NWD_MouseY%, , , U
  503. Else
  504. If ( NWD_PermitClick and (!NWD_Dragging or ((NWD_MouseStartX = NWD_MouseX) and (NWD_MouseStartY = NWD_MouseY))) )
  505. {
  506. MouseClick, RIGHT, %NWD_MouseStartX%, %NWD_MouseStartY%, , , D
  507. MouseClick, RIGHT, %NWD_MouseX%, %NWD_MouseY%, , , U
  508. }
  509.  
  510. Gosub, NWD_SetAllOff
  511. NWD_ImmediateDown = 0
  512. }
  513. Else
  514. {
  515. NWD_MouseDeltaX := NWD_MouseX - NWD_MouseStartX
  516. NWD_MouseDeltaY := NWD_MouseY - NWD_MouseStartY
  517.  
  518. If ( NWD_MouseDeltaX or NWD_MouseDeltaY )
  519. {
  520. If ( NWD_ImmediateDownRequest and !NWD_ImmediateDown )
  521. {
  522. MouseClick, RIGHT, %NWD_MouseStartX%, %NWD_MouseStartY%, , , D
  523. MouseMove, %NWD_MouseX%, %NWD_MouseY%
  524. NWD_ImmediateDown = 1
  525. NWD_PermitClick = 0
  526. }
  527.  
  528. If ( NWD_Dragging )
  529. {
  530. If ( !NWD_ResizeX and !NWD_ResizeY )
  531. {
  532. NWD_WinNewX := NWD_WinStartX + NWD_MouseDeltaX
  533. NWD_WinNewY := NWD_WinStartY + NWD_MouseDeltaY
  534. NWD_WinNewW := NWD_WinStartW
  535. NWD_WinNewH := NWD_WinStartH
  536. }
  537. Else
  538. {
  539. NWD_WinDeltaW = 0
  540. NWD_WinDeltaH = 0
  541. If ( NWD_ResizeX )
  542. NWD_WinDeltaW := NWD_ResizeX * NWD_MouseDeltaX
  543. If ( NWD_ResizeY )
  544. NWD_WinDeltaH := NWD_ResizeY * NWD_MouseDeltaY
  545. If ( NWD_WinState = "D" )
  546. {
  547. If ( NWD_ResizeX )
  548. NWD_WinDeltaW *= 2
  549. If ( NWD_ResizeY )
  550. NWD_WinDeltaH *= 2
  551. }
  552. NWD_WinNewW := NWD_WinStartW + NWD_WinDeltaW
  553. NWD_WinNewH := NWD_WinStartH + NWD_WinDeltaH
  554. If ( NWD_WinNewW < 0 )
  555. If ( NWD_WinState = "D" )
  556. NWD_WinNewW *= -1
  557. Else
  558. NWD_WinNewW := 0
  559. If ( NWD_WinNewH < 0 )
  560. If ( NWD_WinState = "D" )
  561. NWD_WinNewH *= -1
  562. Else
  563. NWD_WinNewH := 0
  564. If ( (NWD_AltState = "D") and NWD_WinStartAR )
  565. {
  566. NWD_WinNewARW := NWD_WinNewH * NWD_WinStartAR
  567. NWD_WinNewARH := NWD_WinNewW / NWD_WinStartAR
  568. If ( NWD_WinNewW < NWD_WinNewARW )
  569. NWD_WinNewW := NWD_WinNewARW
  570. If ( NWD_WinNewH < NWD_WinNewARH )
  571. NWD_WinNewH := NWD_WinNewARH
  572. }
  573. NWD_WinDeltaX = 0
  574. NWD_WinDeltaY = 0
  575. If ( NWD_WinState = "D" )
  576. {
  577. NWD_WinDeltaX := NWD_WinStartW / 2 - NWD_WinNewW / 2
  578. NWD_WinDeltaY := NWD_WinStartH / 2 - NWD_WinNewH / 2
  579. }
  580. Else
  581. {
  582. If ( NWD_ResizeX = -1 )
  583. NWD_WinDeltaX := NWD_WinStartW - NWD_WinNewW
  584. If ( NWD_ResizeY = -1 )
  585. NWD_WinDeltaY := NWD_WinStartH - NWD_WinNewH
  586. }
  587. NWD_WinNewX := NWD_WinStartX + NWD_WinDeltaX
  588. NWD_WinNewY := NWD_WinStartY + NWD_WinDeltaY
  589. }
  590.  
  591. If ( NWD_ShiftState = "D" )
  592. NWD_WinNewRound = -1
  593. Else
  594. NWD_WinNewRound = 0
  595.  
  596. Transform, NWD_WinNewX, Round, %NWD_WinNewX%, %NWD_WinNewRound%
  597. Transform, NWD_WinNewY, Round, %NWD_WinNewY%, %NWD_WinNewRound%
  598. Transform, NWD_WinNewW, Round, %NWD_WinNewW%, %NWD_WinNewRound%
  599. Transform, NWD_WinNewH, Round, %NWD_WinNewH%, %NWD_WinNewRound%
  600.  
  601. If ( (NWD_WinNewX != NWD_WinX) or (NWD_WinNewY != NWD_WinY) or (NWD_WinNewW != NWD_WinW) or (NWD_WinNewH != NWD_WinH) )
  602. {
  603. WinMove, ahk_id %NWD_WinID%, , %NWD_WinNewX%, %NWD_WinNewY%, %NWD_WinNewW%, %NWD_WinNewH%
  604.  
  605. If ( SYS_ToolTipFeedback )
  606. {
  607. WinGetPos, NWD_ToolTipWinX, NWD_ToolTipWinY, NWD_ToolTipWinW, NWD_ToolTipWinH, ahk_id %NWD_WinID%
  608. SYS_ToolTipText = Window Drag: (X:%NWD_ToolTipWinX%, Y:%NWD_ToolTipWinY%, W:%NWD_ToolTipWinW%, H:%NWD_ToolTipWinH%)
  609. Gosub, SYS_ToolTipFeedbackShow
  610. }
  611. }
  612. }
  613. }
  614. }
  615. Return
  616.  
  617.  
  618.  
  619. ; [MIW {NWD}] minimize/roll on right + left mouse button
  620.  
  621. /**
  622. * Minimizes the selected window (if minimizable) to the task bar. If you press
  623. * the left button over the titlebar the selected window will be rolled up
  624. * instead of being minimized. You have to apply this action again to roll the
  625. * window back down.
  626. */
  627.  
  628. $LButton::
  629. $^LButton::
  630. GetKeyState, MIW_RButtonState, RButton, P
  631. If ( (MIW_RButtonState = "D") and (!NWD_ImmediateDown) and (NWD_WinClass != "Progman") )
  632. {
  633. GetKeyState, MIW_CtrlState, Ctrl, P
  634. WinGet, MIW_WinStyle, Style, ahk_id %NWD_WinID%
  635. SysGet, MIW_CaptionHeight, 4 ; SM_CYCAPTION
  636. SysGet, MIW_BorderHeight, 7 ; SM_CXDLGFRAME
  637. MouseGetPos, , MIW_MouseY
  638.  
  639. If ( MIW_MouseY <= MIW_CaptionHeight + MIW_BorderHeight )
  640. {
  641. ; checks wheter the window has a sizing border (WS_THICKFRAME)
  642. If ( (MIW_CtrlState = "D") or (MIW_WinStyle & 0x40000) )
  643. {
  644. Gosub, NWD_SetAllOff
  645. ROL_WinID = %NWD_WinID%
  646. Gosub, ROL_RollToggle
  647. }
  648. }
  649. Else
  650. {
  651. ; the second condition checks for minimizable window:
  652. ; (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX)
  653. If ( (MIW_CtrlState = "D") or (MIW_WinStyle & 0xCA0000 = 0xCA0000) )
  654. {
  655. Gosub, NWD_SetAllOff
  656. WinMinimize, ahk_id %NWD_WinID%
  657. SYS_ToolTipText = Window Minimize
  658. Gosub, SYS_ToolTipFeedbackShow
  659. }
  660. }
  661. }
  662. Else
  663. {
  664. ; this feature should be implemented by using a timer because
  665. ; AutoHotkeys threading blocks the first thread if another
  666. ; one is started (until the 2nd is stopped)
  667.  
  668. Thread, priority, 1
  669. MouseClick, LEFT, , , , , D
  670. KeyWait, LButton
  671. MouseClick, LEFT, , , , , U
  672. }
  673. Return
  674.  
  675.  
  676.  
  677. ; [CLW {NWD}] close/send bottom on right + middle mouse button || double click on middle mouse button
  678.  
  679. /**
  680. * Closes the selected window (if closeable) as if you click the close button
  681. * in the titlebar. If you press the middle button over the titlebar the
  682. * selected window will be sent to the bottom of the window stack instead of
  683. * being closed.
  684. *
  685. * Edited Aug 6, 2010 by Karl Horky to add clickthrough if not over title bar area or right mouse button held
  686. */
  687.  
  688. $MButton::
  689. $^MButton::
  690. SetBatchLines, -1
  691. CoordMode, Mouse, Screen
  692. SetMouseDelay, -1 ; no pause after mouse clicks
  693. SetKeyDelay, -1 ; no pause after keys sent
  694. MouseGetPos, ClickX, ClickY, WindowUnderMouseID
  695. WinActivate, ahk_id %WindowUnderMouseID%
  696.  
  697. ; WM_NCHITTEST
  698. SendMessage, 0x84,, ( ClickY << 16 )|ClickX,, ahk_id %WindowUnderMouseID%
  699. WM_NCHITTEST_Result =%ErrorLevel%
  700. /*
  701. #define HTERROR (-2)
  702. #define HTTRANSPARENT (-1)
  703. #define HTNOWHERE 0
  704. #define HTCLIENT 1
  705. #define HTCAPTION 2
  706. #define HTSYSMENU 3
  707. #define HTGROWBOX 4
  708. #define HTSIZE HTGROWBOX
  709. #define HTMENU 5
  710. #define HTHSCROLL 6
  711. #define HTVSCROLL 7
  712. #define HTMINBUTTON 8
  713. #define HTMAXBUTTON 9
  714. #define HTLEFT 10
  715. #define HTRIGHT 11
  716. #define HTTOP 12
  717. #define HTTOPLEFT 13
  718. #define HTTOPRIGHT 14
  719. #define HTBOTTOM 15
  720. #define HTBOTTOMLEFT 16
  721. #define HTBOTTOMRIGHT 17
  722. #define HTBORDER 18
  723. #define HTREDUCE HTMINBUTTON
  724. #define HTZOOM HTMAXBUTTON
  725. #define HTSIZEFIRST HTLEFT
  726. #define HTSIZELAST HTBOTTOMRIGHT
  727. #if(WINVER >= 0x0400)
  728. #define HTOBJECT 19
  729. #define HTCLOSE 20
  730. #define HTHELP 21
  731. */
  732.  
  733. GetKeyState, CLW_RButtonState, RButton, P
  734. If ( (CLW_RButtonState = "D") and (!NWD_ImmediateDown) and (NWD_WinClass != "Progman") )
  735. {
  736. GetKeyState, CLW_CtrlState, Ctrl, P
  737. WinGet, CLW_WinStyle, Style, ahk_id %NWD_WinID%
  738. SysGet, CLW_CaptionHeight, 4 ; SM_CYCAPTION
  739. SysGet, CLW_BorderHeight, 7 ; SM_CXDLGFRAME
  740. MouseGetPos, , CLW_MouseY
  741.  
  742. If ( CLW_MouseY <= CLW_CaptionHeight + CLW_BorderHeight )
  743. {
  744. Gosub, NWD_SetAllOff
  745. Send, !{Esc}
  746. SYS_ToolTipText = Window Bottom
  747. Gosub, SYS_ToolTipFeedbackShow
  748. }
  749. Else
  750. {
  751. ; the second condition checks for closeable window:
  752. ; (WS_CAPTION | WS_SYSMENU)
  753. If ( (CLW_CtrlState = "D") or (CLW_WinStyle & 0xC80000 = 0xC80000) )
  754. {
  755. Gosub, NWD_SetAllOff
  756. WinClose, ahk_id %NWD_WinID%
  757. SYS_ToolTipText = Window Close
  758. Gosub, SYS_ToolTipFeedbackShow
  759. }
  760. }
  761. }
  762. ; Close window with titlebar click
  763. Else If WM_NCHITTEST_Result in 2,3,8,9,20,21 ; in titlebar enclosed area - top of window
  764. {
  765. IfWinNotActive, ahk_class Shell_TrayWnd
  766. {
  767. PostMessage, 0x112, 0xF060,,, ahk_id %WindowUnderMouseID% ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
  768. }
  769. Else
  770. {
  771. Thread, Priority, 1
  772. MouseClick, MIDDLE, , , , , D
  773. KeyWait, MButton
  774. MouseClick, MIDDLE, , , , , U
  775. }
  776. }
  777. Else
  778. {
  779. ; TODO : workaround for "MouseClick, LEFT, , , 2" due to inactive titlebar problem
  780.  
  781. Thread, Priority, 1
  782. MouseClick, MIDDLE, , , , , D
  783. KeyWait, MButton
  784. MouseClick, MIDDLE, , , , , U
  785. }
  786.  
  787. Return
  788.  
  789.  
  790.  
  791. ; [TSM {NWD}] toggles windows start menu || moves window to previous display || maximize to multiple windows on the left
  792.  
  793. /**
  794. * This additional button is used to toggle the windows start menu.
  795. */
  796.  
  797. $XButton1::
  798. $^XButton1::
  799. If ( NWD_ImmediateDown )
  800. Return
  801.  
  802. GetKeyState, TSM_RButtonState, RButton, P
  803. If ( TSM_RButtonState = "U" )
  804. {
  805. Send, {LWin}
  806. }
  807. Else
  808. IfWinActive, A
  809. {
  810. WinGet, TSM_WinID, ID
  811. If ( !TSM_WinID )
  812. Return
  813. WinGetClass, TSM_WinClass, ahk_id %TSM_WinID%
  814.  
  815. If ( TSM_WinClass != "Progman" )
  816. {
  817. Gosub, NWD_SetAllOff
  818. GetKeyState, TSM_CtrlState, Ctrl, P
  819. If ( TSM_CtrlState = "U" )
  820. {
  821. Send, ^<
  822. SYS_ToolTipText = Window Move: LEFT
  823. Gosub, SYS_ToolTipFeedbackShow
  824. }
  825. ; Else
  826. ; TODO : maximize to multiple displays on the left (planned feature)
  827. }
  828. }
  829. Return
  830.  
  831.  
  832.  
  833. ; [MAW {NWD}] toggles window maximizing || moves window to next display || maximize to multiple windows on the right
  834.  
  835. /**
  836. * This additional button is used to toggle the maximize state of the active
  837. * window (if maximizable).
  838. */
  839.  
  840. $XButton2::
  841. $^XButton2::
  842. If ( NWD_ImmediateDown )
  843. Return
  844.  
  845. IfWinActive, A
  846. {
  847. WinGet, MAW_WinID, ID
  848. If ( !MAW_WinID )
  849. Return
  850. WinGetClass, MAW_WinClass, ahk_id %MAW_WinID%
  851. If ( MAW_WinClass = "Progman" )
  852. Return
  853.  
  854. GetKeyState, MAW_RButtonState, RButton, P
  855. If ( MAW_RButtonState = "U" )
  856. {
  857. GetKeyState, MAW_CtrlState, Ctrl, P
  858. WinGet, MAW_WinStyle, Style
  859.  
  860. ; the second condition checks for maximizable window:
  861. ; (WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX)
  862. If ( (MAW_CtrlState = "D") or (MAW_WinStyle & 0xC90000 = 0xC90000) )
  863. {
  864. WinGet, MAW_MinMax, MinMax
  865. If ( MAW_MinMax = 0 )
  866. {
  867. WinMaximize
  868. SYS_ToolTipText = Window Maximize
  869. Gosub, SYS_ToolTipFeedbackShow
  870. }
  871. Else
  872. If ( MAW_MinMax = 1 )
  873. {
  874. WinRestore
  875. SYS_ToolTipText = Window Restore
  876. Gosub, SYS_ToolTipFeedbackShow
  877. }
  878. }
  879. }
  880. Else
  881. {
  882. Gosub, NWD_SetAllOff
  883. GetKeyState, MAW_CtrlState, Ctrl, P
  884. If ( MAW_CtrlState = "U" )
  885. {
  886. Send, ^>
  887. SYS_ToolTipText = Window Move: RIGHT
  888. Gosub, SYS_ToolTipFeedbackShow
  889. }
  890. ; Else
  891. ; TODO : maximize to multiple displays on the right (planned feature)
  892. }
  893. }
  894. Return
  895.  
  896.  
  897.  
  898. ; [TSW {NWD}] provides alt-tab-menu to the right mouse button + mouse wheel
  899.  
  900. /**
  901. * Provides a quick task switcher (alt-tab-menu) controlled by the mouse wheel.
  902. */
  903.  
  904. WheelDown::
  905. GetKeyState, TSW_RButtonState, RButton, P
  906. If ( (TSW_RButtonState = "D") and (!NWD_ImmediateDown) )
  907. {
  908. ; TODO : this is a workaround because the original tabmenu
  909. ; code of AutoHotkey is buggy on some systems
  910. GetKeyState, TSW_LAltState, LAlt
  911. If ( TSW_LAltState = "U" )
  912. {
  913. Gosub, NWD_SetAllOff
  914. Send, {LAlt down}{Tab}
  915. SetTimer, TSW_WheelHandler, 1
  916. }
  917. Else
  918. Send, {Tab}
  919. }
  920. Else
  921. Send, {WheelDown}
  922. Return
  923.  
  924. WheelUp::
  925. GetKeyState, TSW_RButtonState, RButton, P
  926. If ( (TSW_RButtonState = "D") and (!NWD_ImmediateDown) )
  927. {
  928. ; TODO : this is a workaround because the original tabmenu
  929. ; code of AutoHotkey is buggy on some systems
  930. GetKeyState, TSW_LAltState, LAlt
  931. If ( TSW_LAltState = "U" )
  932. {
  933. Gosub, NWD_SetAllOff
  934. Send, {LAlt down}+{Tab}
  935. SetTimer, TSW_WheelHandler, 1
  936. }
  937. Else
  938. Send, +{Tab}
  939. }
  940. Else
  941. Send, {WheelUp}
  942. Return
  943.  
  944. TSW_WheelHandler:
  945. GetKeyState, TSW_RButtonState, RButton, P
  946. If ( TSW_RButtonState = "U" )
  947. {
  948. SetTimer, TSW_WheelHandler, Off
  949. GetKeyState, TSW_LAltState, LAlt
  950. If ( TSW_LAltState = "D" )
  951. Send, {LAlt up}
  952. }
  953. Return
  954.  
  955.  
  956.  
  957. ; [AOT] toggles always on top
  958.  
  959. /**
  960. * Toggles the always-on-top attribute of the selected/active window.
  961. */
  962.  
  963. #SC029::
  964. #LButton::
  965. AOT_SetToggle:
  966. Gosub, AOT_CheckWinIDs
  967. SetWinDelay, -1
  968.  
  969. IfInString, A_ThisHotkey, LButton
  970. {
  971. MouseGetPos, , , AOT_WinID
  972. If ( !AOT_WinID )
  973. Return
  974. IfWinNotActive, ahk_id %AOT_WinID%
  975. WinActivate, ahk_id %AOT_WinID%
  976. }
  977.  
  978. IfWinActive, A
  979. {
  980. WinGet, AOT_WinID, ID
  981. If ( !AOT_WinID )
  982. Return
  983. WinGetClass, AOT_WinClass, ahk_id %AOT_WinID%
  984. If ( AOT_WinClass = "Progman" )
  985. Return
  986.  
  987. WinGet, AOT_ExStyle, ExStyle, ahk_id %AOT_WinID%
  988. If ( AOT_ExStyle & 0x8 ) ; 0x8 is WS_EX_TOPMOST
  989. {
  990. SYS_ToolTipText = Always on Top: OFF
  991. Gosub, AOT_SetOff
  992. }
  993. Else
  994. {
  995. SYS_ToolTipText = Always on Top: ON
  996. Gosub, AOT_SetOn
  997. }
  998. Gosub, SYS_ToolTipFeedbackShow
  999. }
  1000. Return
  1001.  
  1002. AOT_SetOn:
  1003. Gosub, AOT_CheckWinIDs
  1004. SetWinDelay, -1
  1005. IfWinNotExist, ahk_id %AOT_WinID%
  1006. Return
  1007. IfNotInString, AOT_WinIDs, |%AOT_WinID%
  1008. AOT_WinIDs = %AOT_WinIDs%|%AOT_WinID%
  1009. WinSet, AlwaysOnTop, On, ahk_id %AOT_WinID%
  1010. Return
  1011.  
  1012. AOT_SetOff:
  1013. Gosub, AOT_CheckWinIDs
  1014. SetWinDelay, -1
  1015. IfWinNotExist, ahk_id %AOT_WinID%
  1016. Return
  1017. StringReplace, AOT_WinIDs, AOT_WinIDs, |%A_LoopField%, , All
  1018. WinSet, AlwaysOnTop, Off, ahk_id %AOT_WinID%
  1019. Return
  1020.  
  1021. AOT_SetAllOff:
  1022. Gosub, AOT_CheckWinIDs
  1023. Loop, Parse, AOT_WinIDs, |
  1024. If ( A_LoopField )
  1025. {
  1026. AOT_WinID = %A_LoopField%
  1027. Gosub, AOT_SetOff
  1028. }
  1029. Return
  1030.  
  1031. #^SC029::
  1032. Gosub, AOT_SetAllOff
  1033. SYS_ToolTipText = Always on Top: ALL OFF
  1034. Gosub, SYS_ToolTipFeedbackShow
  1035. Return
  1036.  
  1037. AOT_CheckWinIDs:
  1038. DetectHiddenWindows, On
  1039. Loop, Parse, AOT_WinIDs, |
  1040. If ( A_LoopField )
  1041. IfWinNotExist, ahk_id %A_LoopField%
  1042. StringReplace, AOT_WinIDs, AOT_WinIDs, |%A_LoopField%, , All
  1043. Return
  1044.  
  1045. AOT_ExitHandler:
  1046. Gosub, AOT_SetAllOff
  1047. Return
  1048.  
  1049.  
  1050.  
  1051. ; [ROL] rolls up/down a window to/from its title bar
  1052.  
  1053. ROL_RollToggle:
  1054. Gosub, ROL_CheckWinIDs
  1055. SetWinDelay, -1
  1056. IfWinNotExist, ahk_id %ROL_WinID%
  1057. Return
  1058. WinGetClass, ROL_WinClass, ahk_id %ROL_WinID%
  1059. If ( ROL_WinClass = "Progman" )
  1060. Return
  1061.  
  1062. IfNotInString, ROL_WinIDs, |%ROL_WinID%
  1063. {
  1064. SYS_ToolTipText = Window Roll: UP
  1065. Gosub, ROL_RollUp
  1066. }
  1067. Else
  1068. {
  1069. WinGetPos, , , , ROL_WinHeight, ahk_id %ROL_WinID%
  1070. If ( ROL_WinHeight = ROL_WinRolledHeight%ROL_WinID% )
  1071. {
  1072. SYS_ToolTipText = Window Roll: DOWN
  1073. Gosub, ROL_RollDown
  1074. }
  1075. Else
  1076. {
  1077. SYS_ToolTipText = Window Roll: UP
  1078. Gosub, ROL_RollUp
  1079. }
  1080. }
  1081. Gosub, SYS_ToolTipFeedbackShow
  1082. Return
  1083.  
  1084. ROL_RollUp:
  1085. Gosub, ROL_CheckWinIDs
  1086. SetWinDelay, -1
  1087. IfWinNotExist, ahk_id %ROL_WinID%
  1088. Return
  1089. WinGetClass, ROL_WinClass, ahk_id %ROL_WinID%
  1090. If ( ROL_WinClass = "Progman" )
  1091. Return
  1092.  
  1093. WinGetPos, , , , ROL_WinHeight, ahk_id %ROL_WinID%
  1094. IfInString, ROL_WinIDs, |%ROL_WinID%
  1095. If ( ROL_WinHeight = ROL_WinRolledHeight%ROL_WinID% )
  1096. Return
  1097. SysGet, ROL_CaptionHeight, 4 ; SM_CYCAPTION
  1098. SysGet, ROL_BorderHeight, 7 ; SM_CXDLGFRAME
  1099. If ( ROL_WinHeight > (ROL_CaptionHeight + ROL_BorderHeight) )
  1100. {
  1101. IfNotInString, ROL_WinIDs, |%ROL_WinID%
  1102. ROL_WinIDs = %ROL_WinIDs%|%ROL_WinID%
  1103. ROL_WinOriginalHeight%ROL_WinID% := ROL_WinHeight
  1104. WinMove, ahk_id %ROL_WinID%, , , , , (ROL_CaptionHeight + ROL_BorderHeight)
  1105. WinGetPos, , , , ROL_WinRolledHeight%ROL_WinID%, ahk_id %ROL_WinID%
  1106. }
  1107. Return
  1108.  
  1109. ROL_RollDown:
  1110. Gosub, ROL_CheckWinIDs
  1111. SetWinDelay, -1
  1112. If ( !ROL_WinID )
  1113. Return
  1114. IfNotInString, ROL_WinIDs, |%ROL_WinID%
  1115. Return
  1116. WinGetPos, , , , ROL_WinHeight, ahk_id %ROL_WinID%
  1117. If( ROL_WinHeight = ROL_WinRolledHeight%ROL_WinID% )
  1118. WinMove, ahk_id %ROL_WinID%, , , , , ROL_WinOriginalHeight%ROL_WinID%
  1119. StringReplace, ROL_WinIDs, ROL_WinIDs, |%ROL_WinID%, , All
  1120. ROL_WinOriginalHeight%ROL_WinID% =
  1121. ROL_WinRolledHeight%ROL_WinID% =
  1122. Return
  1123.  
  1124. ROL_RollDownAll:
  1125. Gosub, ROL_CheckWinIDs
  1126. Loop, Parse, ROL_WinIDs, |
  1127. If ( A_LoopField )
  1128. {
  1129. ROL_WinID = %A_LoopField%
  1130. Gosub, ROL_RollDown
  1131. }
  1132. Return
  1133.  
  1134. #^r::
  1135. Gosub, ROL_RollDownAll
  1136. SYS_ToolTipText = Window Roll: ALL DOWN
  1137. Gosub, SYS_ToolTipFeedbackShow
  1138. Return
  1139.  
  1140. ROL_CheckWinIDs:
  1141. DetectHiddenWindows, On
  1142. Loop, Parse, ROL_WinIDs, |
  1143. If ( A_LoopField )
  1144. IfWinNotExist, ahk_id %A_LoopField%
  1145. {
  1146. StringReplace, ROL_WinIDs, ROL_WinIDs, |%A_LoopField%, , All
  1147. ROL_WinOriginalHeight%A_LoopField% =
  1148. ROL_WinRolledHeight%A_LoopField% =
  1149. }
  1150. Return
  1151.  
  1152. ROL_ExitHandler:
  1153. Gosub, ROL_RollDownAll
  1154. Return
  1155.  
  1156.  
  1157.  
  1158. ; [TRA] provides window transparency
  1159.  
  1160. /**
  1161. * Adjusts the transparency of the active window in ten percent steps
  1162. * (opaque = 100%) which allows the contents of the windows behind it to shine
  1163. * through. If the window is completely transparent (0%) the window is still
  1164. * there and clickable. If you loose a transparent window it will be extremly
  1165. * complicated to find it again because it's invisible (see the first hotkey
  1166. * in this list for emergency help in such situations).
  1167. */
  1168.  
  1169. #WheelUp::
  1170. #+WheelUp::
  1171. #WheelDown::
  1172. #+WheelDown::
  1173. Gosub, TRA_CheckWinIDs
  1174. SetWinDelay, -1
  1175. IfWinActive, A
  1176. {
  1177. WinGet, TRA_WinID, ID
  1178. If ( !TRA_WinID )
  1179. Return
  1180. WinGetClass, TRA_WinClass, ahk_id %TRA_WinID%
  1181. If ( TRA_WinClass = "Progman" )
  1182. Return
  1183.  
  1184. IfNotInString, TRA_WinIDs, |%TRA_WinID%
  1185. TRA_WinIDs = %TRA_WinIDs%|%TRA_WinID%
  1186. TRA_WinAlpha := TRA_WinAlpha%TRA_WinID%
  1187. TRA_PixelColor := TRA_PixelColor%TRA_WinID%
  1188.  
  1189. IfInString, A_ThisHotkey, +
  1190. TRA_WinAlphaStep := 255 * 0.01 ; 1 percent steps
  1191. Else
  1192. TRA_WinAlphaStep := 255 * 0.1 ; 10 percent steps
  1193.  
  1194. If ( TRA_WinAlpha = "" )
  1195. TRA_WinAlpha = 255
  1196.  
  1197. IfInString, A_ThisHotkey, WheelDown
  1198. TRA_WinAlpha -= TRA_WinAlphaStep
  1199. Else
  1200. TRA_WinAlpha += TRA_WinAlphaStep
  1201.  
  1202. If ( TRA_WinAlpha > 255 )
  1203. TRA_WinAlpha = 255
  1204. Else
  1205. If ( TRA_WinAlpha < 0 )
  1206. TRA_WinAlpha = 0
  1207.  
  1208. If ( !TRA_PixelColor and (TRA_WinAlpha = 255) )
  1209. {
  1210. Gosub, TRA_TransparencyOff
  1211. SYS_ToolTipText = Transparency: OFF
  1212. }
  1213. Else
  1214. {
  1215. TRA_WinAlpha%TRA_WinID% = %TRA_WinAlpha%
  1216.  
  1217. If ( TRA_PixelColor )
  1218. WinSet, TransColor, %TRA_PixelColor% %TRA_WinAlpha%, ahk_id %TRA_WinID%
  1219. Else
  1220. WinSet, Transparent, %TRA_WinAlpha%, ahk_id %TRA_WinID%
  1221.  
  1222. TRA_ToolTipAlpha := TRA_WinAlpha * 100 / 255
  1223. Transform, TRA_ToolTipAlpha, Round, %TRA_ToolTipAlpha%
  1224. SYS_ToolTipText = Transparency: %TRA_ToolTipAlpha% `%
  1225. }
  1226. Gosub, SYS_ToolTipFeedbackShow
  1227. }
  1228. Return
  1229.  
  1230. #^LButton::
  1231. #^MButton::
  1232. Gosub, TRA_CheckWinIDs
  1233. SetWinDelay, -1
  1234. CoordMode, Mouse, Screen
  1235. CoordMode, Pixel, Screen
  1236. MouseGetPos, TRA_MouseX, TRA_MouseY, TRA_WinID
  1237. If ( !TRA_WinID )
  1238. Return
  1239. WinGetClass, TRA_WinClass, ahk_id %TRA_WinID%
  1240. If ( TRA_WinClass = "Progman" )
  1241. Return
  1242.  
  1243. IfWinNotActive, ahk_id %TRA_WinID%
  1244. WinActivate, ahk_id %TRA_WinID%
  1245. IfNotInString, TRA_WinIDs, |%TRA_WinID%
  1246. TRA_WinIDs = %TRA_WinIDs%|%TRA_WinID%
  1247.  
  1248. IfInString, A_ThisHotkey, MButton
  1249. {
  1250. AOT_WinID = %TRA_WinID%
  1251. Gosub, AOT_SetOn
  1252. TRA_WinAlpha%TRA_WinID% := 25 * 255 / 100
  1253. }
  1254.  
  1255. TRA_WinAlpha := TRA_WinAlpha%TRA_WinID%
  1256.  
  1257. ; TODO : the transparency must be set off first,
  1258. ; this may be a bug of AutoHotkey
  1259. WinSet, TransColor, OFF, ahk_id %TRA_WinID%
  1260. PixelGetColor, TRA_PixelColor, %TRA_MouseX%, %TRA_MouseY%, RGB
  1261. WinSet, TransColor, %TRA_PixelColor% %TRA_WinAlpha%, ahk_id %TRA_WinID%
  1262. TRA_PixelColor%TRA_WinID% := TRA_PixelColor
  1263.  
  1264. IfInString, A_ThisHotkey, MButton
  1265. SYS_ToolTipText = Transparency: 25 `% + %TRA_PixelColor% color (RGB) + Always on Top
  1266. Else
  1267. SYS_ToolTipText = Transparency: %TRA_PixelColor% color (RGB)
  1268. Gosub, SYS_ToolTipFeedbackShow
  1269. Return
  1270.  
  1271. #MButton::
  1272. Gosub, TRA_CheckWinIDs
  1273. SetWinDelay, -1
  1274. MouseGetPos, , , TRA_WinID
  1275. If ( !TRA_WinID )
  1276. Return
  1277. IfWinNotActive, ahk_id %TRA_WinID%
  1278. WinActivate, ahk_id %TRA_WinID%
  1279. IfNotInString, TRA_WinIDs, |%TRA_WinID%
  1280. Return
  1281. Gosub, TRA_TransparencyOff
  1282.  
  1283. SYS_ToolTipText = Transparency: OFF
  1284. Gosub, SYS_ToolTipFeedbackShow
  1285. Return
  1286.  
  1287. TRA_TransparencyOff:
  1288. Gosub, TRA_CheckWinIDs
  1289. SetWinDelay, -1
  1290. If ( !TRA_WinID )
  1291. Return
  1292. IfNotInString, TRA_WinIDs, |%TRA_WinID%
  1293. Return
  1294. StringReplace, TRA_WinIDs, TRA_WinIDs, |%TRA_WinID%, , All
  1295. TRA_WinAlpha%TRA_WinID% =
  1296. TRA_PixelColor%TRA_WinID% =
  1297. ; TODO : must be set to 255 first to avoid the black-colored-window problem
  1298. WinSet, Transparent, 255, ahk_id %TRA_WinID%
  1299. WinSet, TransColor, OFF, ahk_id %TRA_WinID%
  1300. WinSet, Transparent, OFF, ahk_id %TRA_WinID%
  1301. WinSet, Redraw, , ahk_id %TRA_WinID%
  1302. Return
  1303.  
  1304. TRA_TransparencyAllOff:
  1305. Gosub, TRA_CheckWinIDs
  1306. Loop, Parse, TRA_WinIDs, |
  1307. If ( A_LoopField )
  1308. {
  1309. TRA_WinID = %A_LoopField%
  1310. Gosub, TRA_TransparencyOff
  1311. }
  1312. Return
  1313.  
  1314. #^t::
  1315. Gosub, TRA_TransparencyAllOff
  1316. SYS_ToolTipText = Transparency: ALL OFF
  1317. Gosub, SYS_ToolTipFeedbackShow
  1318. Return
  1319.  
  1320. TRA_CheckWinIDs:
  1321. DetectHiddenWindows, On
  1322. Loop, Parse, TRA_WinIDs, |
  1323. If ( A_LoopField )
  1324. IfWinNotExist, ahk_id %A_LoopField%
  1325. {
  1326. StringReplace, TRA_WinIDs, TRA_WinIDs, |%A_LoopField%, , All
  1327. TRA_WinAlpha%A_LoopField% =
  1328. TRA_PixelColor%A_LoopField% =
  1329. }
  1330. Return
  1331.  
  1332. TRA_ExitHandler:
  1333. Gosub, TRA_TransparencyAllOff
  1334. Return
  1335.  
  1336.  
  1337.  
  1338. ; [EJC] opens/closes a drive
  1339.  
  1340. /**
  1341. * Opens or closes an installed CD/DVD-ROM reader/writer drive tray. The drives
  1342. * are assigned to their hotkeys by the certain drive number in your system. The
  1343. * hotkeys are used in the sequence of the key placement on your physical
  1344. * keyboard from left to right (1 refers to the first and 0 to the tenth drive).
  1345. * So you are limited to a total number of 10 drives controlled by NiftyWindows.
  1346. */
  1347.  
  1348. #MaxThreadsBuffer On
  1349. $#0::
  1350. $#1::
  1351. $#2::
  1352. $#3::
  1353. $#4::
  1354. $#5::
  1355. $#6::
  1356. $#7::
  1357. $#8::
  1358. $#9::
  1359. DriveGet, EJC_DriveList, List, CDROM
  1360. StringLen, EJC_DriveListLength, EJC_DriveList
  1361. StringRight, EJC_PressedDrive, A_ThisHotkey, 1
  1362.  
  1363. If ( !EJC_PressedDrive )
  1364. EJC_PressedDrive := 10
  1365.  
  1366. If ( EJC_PressedDrive <= EJC_DriveListLength )
  1367. {
  1368. StringMid, EJC_DriveLabel, EJC_DriveList, EJC_PressedDrive, 1
  1369. SYS_ToolTipText = Drive Eject: %EJC_DriveLabel%
  1370. Gosub, SYS_ToolTipFeedbackShow
  1371. Gosub, SUS_SuspendSaveState
  1372. Suspend, On
  1373. Drive, Eject, %EJC_DriveLabel%:
  1374. If ( A_TimeSinceThisHotkey < 250 )
  1375. Drive, Eject, %EJC_DriveLabel%:, 1
  1376. Gosub, SUS_SuspendRestoreState
  1377. }
  1378. Else
  1379. {
  1380. Transform, EJC_PressedDrive, Mod, %EJC_PressedDrive%, 10
  1381. Send, #%EJC_PressedDrive%
  1382. }
  1383. Return
  1384. #MaxThreadsBuffer Off
  1385.  
  1386.  
  1387.  
  1388. ; [MUT] toggles the audio mute
  1389.  
  1390. /**
  1391. * Toggles the muteness of an installed audio card.
  1392. */
  1393.  
  1394. Pause::
  1395. SoundSet, +1, , Mute
  1396. SoundGet, MUT_MuteState, , MUTE
  1397. SYS_ToolTipText = Audio Mute: %MUT_MuteState%
  1398. Gosub, SYS_ToolTipFeedbackShow
  1399. Return
  1400.  
  1401.  
  1402.  
  1403. ; [SCR] starts the user defined screensaver
  1404.  
  1405. /**
  1406. * Starts the user defined screensaver (password protection aware).
  1407. */
  1408.  
  1409. #s up::
  1410. ^#s up::
  1411. RegRead, SCR_Saver, HKEY_CURRENT_USER, Control Panel\Desktop, SCRNSAVE.EXE
  1412. If ( !ErrorLevel and SCR_Saver )
  1413. {
  1414. SendMessage, 0x112, 0xF140, 0, , Program Manager ; 0x112 is WM_SYSCOMMAND ; 0xF140 is SC_SCREENSAVE
  1415.  
  1416. If ( A_ThisHotkey != "^#s up" )
  1417. Return
  1418.  
  1419. SplitPath, SCR_Saver, SCR_SaverFileName
  1420. Process, Wait, %SCR_SaverFileName%, 5
  1421. If ( ErrorLevel )
  1422. {
  1423. Gosub, SUS_SuspendSaveState
  1424. Suspend, On
  1425. Sleep, 5000
  1426. Gosub, SUS_SuspendRestoreState
  1427. Process, Exist, %SCR_SaverFileName%
  1428. If ( ErrorLevel )
  1429. SendMessage, 0x112, 0xF170, 2, , Program Manager ; 0x112 is WM_SYSCOMMAND ; 0xF170 is SC_MONITORPOWER ; (2 = off, 1 = standby, -1 = on)
  1430. }
  1431. }
  1432. Else
  1433. {
  1434. SYS_TrayTipText = No screensaver specified in display settings (control panel).
  1435. SYS_TrayTipOptions = 2
  1436. Gosub, SYS_TrayTipShow
  1437. }
  1438. Return
  1439.  
  1440.  
  1441.  
  1442. ; [SIZ {NWD}] provides several size adjustments to windows
  1443.  
  1444. /**
  1445. * Adjusts the transparency of the active window in ten percent steps
  1446. * (opaque = 100%) which allows the contents of the windows behind it to shine
  1447. * through. If the window is completely transparent (0%) the window is still
  1448. * there and clickable. If you loose a transparent window it will be extremly
  1449. * complicated to find it again because it's invisible (see the first hotkey in
  1450. * this list for emergency help in such situations).
  1451. */
  1452.  
  1453. !WheelUp::
  1454. !+WheelUp::
  1455. !^WheelUp::
  1456. !#WheelUp::
  1457. !+^WheelUp::
  1458. !+#WheelUp::
  1459. !^#WheelUp::
  1460. !+^#WheelUp::
  1461. !WheelDown::
  1462. !+WheelDown::
  1463. !^WheelDown::
  1464. !#WheelDown::
  1465. !+^WheelDown::
  1466. !+#WheelDown::
  1467. !^#WheelDown::
  1468. !+^#WheelDown::
  1469. ; TODO : the following code block is a workaround to handle
  1470. ; virtual ALT calls in WheelDown/Up functions
  1471. GetKeyState, SIZ_AltState, Alt, P
  1472. If ( SIZ_AltState = "U" )
  1473. {
  1474. IfInString, A_ThisHotkey, WheelDown
  1475. Gosub, WheelDown
  1476. Else
  1477. Gosub, WheelUp
  1478. Return
  1479. }
  1480.  
  1481. If ( NWD_Dragging or NWD_ImmediateDown )
  1482. Return
  1483.  
  1484. SetWinDelay, -1
  1485. CoordMode, Mouse, Screen
  1486. IfWinActive, A
  1487. {
  1488. WinGet, SIZ_WinID, ID
  1489. If ( !SIZ_WinID )
  1490. Return
  1491. WinGetClass, SIZ_WinClass, ahk_id %SIZ_WinID%
  1492. If ( SIZ_WinClass = "Progman" )
  1493. Return
  1494.  
  1495. GetKeyState, SIZ_CtrlState, Ctrl, P
  1496. WinGet, SIZ_WinMinMax, MinMax, ahk_id %SIZ_WinID%
  1497. WinGet, SIZ_WinStyle, Style, ahk_id %SIZ_WinID%
  1498.  
  1499. ; checks wheter the window isn't maximized and has a sizing border (WS_THICKFRAME)
  1500. If ( (SIZ_CtrlState = "D") or ((SIZ_WinMinMax != 1) and (SIZ_WinStyle & 0x40000)) )
  1501. {
  1502. WinGetPos, SIZ_WinX, SIZ_WinY, SIZ_WinW, SIZ_WinH, ahk_id %SIZ_WinID%
  1503.  
  1504. If ( SIZ_WinW and SIZ_WinH )
  1505. {
  1506. SIZ_AspectRatio := SIZ_WinW / SIZ_WinH
  1507.  
  1508. IfInString, A_ThisHotkey, WheelDown
  1509. SIZ_Direction = 1
  1510. Else
  1511. SIZ_Direction = -1
  1512.  
  1513. IfInString, A_ThisHotkey, +
  1514. SIZ_Factor = 0.01
  1515. Else
  1516. SIZ_Factor = 0.1
  1517.  
  1518. SIZ_WinNewW := SIZ_WinW + SIZ_Direction * SIZ_WinW * SIZ_Factor
  1519. SIZ_WinNewH := SIZ_WinH + SIZ_Direction * SIZ_WinH * SIZ_Factor
  1520.  
  1521. IfInString, A_ThisHotkey, #
  1522. {
  1523. SIZ_WinNewX := SIZ_WinX + (SIZ_WinW - SIZ_WinNewW) / 2
  1524. SIZ_WinNewY := SIZ_WinY + (SIZ_WinH - SIZ_WinNewH) / 2
  1525. }
  1526. Else
  1527. {
  1528. SIZ_WinNewX := SIZ_WinX
  1529. SIZ_WinNewY := SIZ_WinY
  1530. }
  1531.  
  1532. If ( SIZ_WinNewW > A_ScreenWidth )
  1533. {
  1534. SIZ_WinNewW := A_ScreenWidth
  1535. SIZ_WinNewH := SIZ_WinNewW / SIZ_AspectRatio
  1536. }
  1537. If ( SIZ_WinNewH > A_ScreenHeight )
  1538. {
  1539. SIZ_WinNewH := A_ScreenHeight
  1540. SIZ_WinNewW := SIZ_WinNewH * SIZ_AspectRatio
  1541. }
  1542.  
  1543. Transform, SIZ_WinNewX, Round, %SIZ_WinNewX%
  1544. Transform, SIZ_WinNewY, Round, %SIZ_WinNewY%
  1545. Transform, SIZ_WinNewW, Round, %SIZ_WinNewW%
  1546. Transform, SIZ_WinNewH, Round, %SIZ_WinNewH%
  1547.  
  1548. WinMove, ahk_id %SIZ_WinID%, , SIZ_WinNewX, SIZ_WinNewY, SIZ_WinNewW, SIZ_WinNewH
  1549.  
  1550. If ( SYS_ToolTipFeedback )
  1551. {
  1552. WinGetPos, SIZ_ToolTipWinX, SIZ_ToolTipWinY, SIZ_ToolTipWinW, SIZ_ToolTipWinH, ahk_id %SIZ_WinID%
  1553. SYS_ToolTipText = Window Size: (X:%SIZ_ToolTipWinX%, Y:%SIZ_ToolTipWinY%, W:%SIZ_ToolTipWinW%, H:%SIZ_ToolTipWinH%)
  1554. Gosub, SYS_ToolTipFeedbackShow
  1555. }
  1556. }
  1557. }
  1558. }
  1559. Return
  1560.  
  1561. !NumpadAdd::
  1562. !^NumpadAdd::
  1563. !#NumpadAdd::
  1564. !^#NumpadAdd::
  1565. !NumpadSub::
  1566. !^NumpadSub::
  1567. !#NumpadSub::
  1568. !^#NumpadSub::
  1569. If ( NWD_Dragging or NWD_ImmediateDown )
  1570. Return
  1571.  
  1572. SetWinDelay, -1
  1573. CoordMode, Mouse, Screen
  1574. IfWinActive, A
  1575. {
  1576. WinGet, SIZ_WinID, ID
  1577. If ( !SIZ_WinID )
  1578. Return
  1579. WinGetClass, SIZ_WinClass, ahk_id %SIZ_WinID%
  1580. If ( SIZ_WinClass = "Progman" )
  1581. Return
  1582.  
  1583. GetKeyState, SIZ_CtrlState, Ctrl, P
  1584. WinGet, SIZ_WinMinMax, MinMax, ahk_id %SIZ_WinID%
  1585. WinGet, SIZ_WinStyle, Style, ahk_id %SIZ_WinID%
  1586.  
  1587. ; checks wheter the window isn't maximized and has a sizing border (WS_THICKFRAME)
  1588. If ( (SIZ_CtrlState = "D") or ((SIZ_WinMinMax != 1) and (SIZ_WinStyle & 0x40000)) )
  1589. {
  1590. WinGetPos, SIZ_WinX, SIZ_WinY, SIZ_WinW, SIZ_WinH, ahk_id %SIZ_WinID%
  1591.  
  1592. IfInString, A_ThisHotkey, NumpadAdd
  1593. If ( SIZ_WinW < 160 )
  1594. SIZ_WinNewW = 160
  1595. Else
  1596. If ( SIZ_WinW < 320 )
  1597. SIZ_WinNewW = 320
  1598. Else
  1599. If ( SIZ_WinW < 640 )
  1600. SIZ_WinNewW = 640
  1601. Else
  1602. If ( SIZ_WinW < 800 )
  1603. SIZ_WinNewW = 800
  1604. Else
  1605. If ( SIZ_WinW < 1024 )
  1606. SIZ_WinNewW = 1024
  1607. Else
  1608. If ( SIZ_WinW < 1152 )
  1609. SIZ_WinNewW = 1152
  1610. Else
  1611. If ( SIZ_WinW < 1280 )
  1612. SIZ_WinNewW = 1280
  1613. Else
  1614. If ( SIZ_WinW < 1400 )
  1615. SIZ_WinNewW = 1400
  1616. Else
  1617. If ( SIZ_WinW < 1600 )
  1618. SIZ_WinNewW = 1600
  1619. Else
  1620. SIZ_WinNewW = 1920
  1621. Else
  1622. If ( SIZ_WinW <= 320 )
  1623. SIZ_WinNewW = 160
  1624. Else
  1625. If ( SIZ_WinW <= 640 )
  1626. SIZ_WinNewW = 320
  1627. Else
  1628. If ( SIZ_WinW <= 800 )
  1629. SIZ_WinNewW = 640
  1630. Else
  1631. If ( SIZ_WinW <= 1024 )
  1632. SIZ_WinNewW = 800
  1633. Else
  1634. If ( SIZ_WinW <= 1152 )
  1635. SIZ_WinNewW = 1024
  1636. Else
  1637. If ( SIZ_WinW <= 1280 )
  1638. SIZ_WinNewW = 1152
  1639. Else
  1640. If ( SIZ_WinW <= 1400 )
  1641. SIZ_WinNewW = 1280
  1642. Else
  1643. If ( SIZ_WinW <= 1600 )
  1644. SIZ_WinNewW = 1400
  1645. Else
  1646. If ( SIZ_WinW <= 1920 )
  1647. SIZ_WinNewW = 1600
  1648. Else
  1649. SIZ_WinNewW = 1920
  1650.  
  1651. If ( SIZ_WinNewW > A_ScreenWidth )
  1652. SIZ_WinNewW := A_ScreenWidth
  1653. SIZ_WinNewH := 3 * SIZ_WinNewW / 4
  1654. If ( SIZ_WinNewW = 1280 )
  1655. SIZ_WinNewH := 1024
  1656.  
  1657. IfInString, A_ThisHotkey, #
  1658. {
  1659. SIZ_WinNewX := SIZ_WinX + (SIZ_WinW - SIZ_WinNewW) / 2
  1660. SIZ_WinNewY := SIZ_WinY + (SIZ_WinH - SIZ_WinNewH) / 2
  1661. }
  1662. Else
  1663. {
  1664. SIZ_WinNewX := SIZ_WinX
  1665. SIZ_WinNewY := SIZ_WinY
  1666. }
  1667.  
  1668. Transform, SIZ_WinNewX, Round, %SIZ_WinNewX%
  1669. Transform, SIZ_WinNewY, Round, %SIZ_WinNewY%
  1670. Transform, SIZ_WinNewW, Round, %SIZ_WinNewW%
  1671. Transform, SIZ_WinNewH, Round, %SIZ_WinNewH%
  1672.  
  1673. WinMove, ahk_id %SIZ_WinID%, , SIZ_WinNewX, SIZ_WinNewY, SIZ_WinNewW, SIZ_WinNewH
  1674.  
  1675. If ( SYS_ToolTipFeedback )
  1676. {
  1677. WinGetPos, SIZ_ToolTipWinX, SIZ_ToolTipWinY, SIZ_ToolTipWinW, SIZ_ToolTipWinH, ahk_id %SIZ_WinID%
  1678. SYS_ToolTipText = Window Size: (X:%SIZ_ToolTipWinX%, Y:%SIZ_ToolTipWinY%, W:%SIZ_ToolTipWinW%, H:%SIZ_ToolTipWinH%)
  1679. Gosub, SYS_ToolTipFeedbackShow
  1680. }
  1681. }
  1682. }
  1683. Return
  1684.  
  1685.  
  1686.  
  1687. ; [XWN] provides X Window like focus switching (focus follows mouse)
  1688.  
  1689. /**
  1690. * Provided a 'X Window' like focus switching by mouse cursor movement. After
  1691. * activation of this feature (by using the responsible entry in the tray icon
  1692. * menu) the focus will follow the mouse cursor with a delayed focus change
  1693. * (after movement end) of 500 milliseconds (half a second). This feature is
  1694. * disabled per default to avoid any confusion due to the new user-interface-flow.
  1695. */
  1696.  
  1697. XWN_FocusHandler:
  1698. CoordMode, Mouse, Screen
  1699. MouseGetPos, XWN_MouseX, XWN_MouseY, XWN_WinID
  1700. If ( !XWN_WinID )
  1701. Return
  1702.  
  1703. If ( (XWN_MouseX != XWN_MouseOldX) or (XWN_MouseY != XWN_MouseOldY) )
  1704. {
  1705. IfWinNotActive, ahk_id %XWN_WinID%
  1706. XWN_FocusRequest = 1
  1707. Else
  1708. XWN_FocusRequest = 0
  1709.  
  1710. XWN_MouseOldX := XWN_MouseX
  1711. XWN_MouseOldY := XWN_MouseY
  1712. XWN_MouseMovedTickCount := A_TickCount
  1713. }
  1714. Else
  1715. If ( XWN_FocusRequest and (A_TickCount - XWN_MouseMovedTickCount > 500) )
  1716. {
  1717. WinGetClass, XWN_WinClass, ahk_id %XWN_WinID%
  1718. If ( XWN_WinClass = "Progman" )
  1719. Return
  1720.  
  1721. ; checks wheter the selected window is a popup menu
  1722. ; (WS_POPUP) and !(WS_DLGFRAME | WS_SYSMENU | WS_THICKFRAME)
  1723. WinGet, XWN_WinStyle, Style, ahk_id %XWN_WinID%
  1724. If ( (XWN_WinStyle & 0x80000000) and !(XWN_WinStyle & 0x4C0000) )
  1725. Return
  1726.  
  1727. IfWinNotActive, ahk_id %XWN_WinID%
  1728. WinActivate, ahk_id %XWN_WinID%
  1729.  
  1730. XWN_FocusRequest = 0
  1731. }
  1732. Return
  1733.  
  1734.  
  1735.  
  1736. ; [GRP] groups windows for quick task switching
  1737.  
  1738. /**
  1739. * Activates the next window in a process window group that was defined
  1740. * gradually before with the given CTRL modifier. This feature causes the first
  1741. * window of the responsible group to be activated. Using it a second time will
  1742. * activate the next window in the series and so on. By using process window
  1743. * groups you can organize and access your process windows in semantic groups
  1744. * quickly.
  1745. */
  1746.  
  1747. ^#F1::
  1748. ^#F2::
  1749. ^#F3::
  1750. ^#F4::
  1751. ^#F5::
  1752. ^#F6::
  1753. ^#F7::
  1754. ^#F8::
  1755. ^#F9::
  1756. ^#F10::
  1757. ^#F11::
  1758. ^#F12::
  1759. ^#F13::
  1760. ^#F14::
  1761. ^#F15::
  1762. ^#F16::
  1763. ^#F17::
  1764. ^#F18::
  1765. ^#F19::
  1766. ^#F20::
  1767. ^#F21::
  1768. ^#F22::
  1769. ^#F23::
  1770. ^#F24::
  1771. IfWinActive, A
  1772. {
  1773. WinGet, GRP_WinID, ID
  1774. If ( !GRP_WinID )
  1775. Return
  1776. WinGetClass, GRP_WinClass, ahk_id %GRP_WinID%
  1777. If ( GRP_WinClass = "Progman" )
  1778. Return
  1779. WinGet, GRP_WinPID, PID
  1780. If ( !GRP_WinPID )
  1781. Return
  1782.  
  1783. StringMid, GRP_GroupNumber, A_ThisHotkey, 3, 3
  1784. GroupAdd, Group%GRP_GroupNumber%, ahk_PID %GRP_WinPID%
  1785.  
  1786. SYS_ToolTipText = Active window was added to group %GRP_GroupNumber%.
  1787. Gosub, SYS_ToolTipFeedbackShow
  1788. }
  1789. Return
  1790.  
  1791. #F1::
  1792. #F2::
  1793. #F3::
  1794. #F4::
  1795. #F5::
  1796. #F6::
  1797. #F7::
  1798. #F8::
  1799. #F9::
  1800. #F10::
  1801. #F11::
  1802. #F12::
  1803. #F13::
  1804. #F14::
  1805. #F15::
  1806. #F16::
  1807. #F17::
  1808. #F18::
  1809. #F19::
  1810. #F20::
  1811. #F21::
  1812. #F22::
  1813. #F23::
  1814. #F24::
  1815. StringMid, GRP_GroupNumber, A_ThisHotkey, 2, 3
  1816. GroupActivate, Group%GRP_GroupNumber%
  1817.  
  1818. SYS_ToolTipText = Activated next window in group %GRP_GroupNumber%.
  1819. Gosub, SYS_ToolTipFeedbackShow
  1820. Return
  1821.  
  1822. !#F1::
  1823. !#F2::
  1824. !#F3::
  1825. !#F4::
  1826. !#F5::
  1827. !#F6::
  1828. !#F7::
  1829. !#F8::
  1830. !#F9::
  1831. !#F10::
  1832. !#F11::
  1833. !#F12::
  1834. !#F13::
  1835. !#F14::
  1836. !#F15::
  1837. !#F16::
  1838. !#F17::
  1839. !#F18::
  1840. !#F19::
  1841. !#F20::
  1842. !#F21::
  1843. !#F22::
  1844. !#F23::
  1845. !#F24::
  1846. StringMid, GRP_GroupNumber, A_ThisHotkey, 3, 3
  1847. GroupClose, Group%GRP_GroupNumber%, A
  1848.  
  1849. SYS_ToolTipText = Closed all windows in group %GRP_GroupNumber%.
  1850. Gosub, SYS_ToolTipFeedbackShow
  1851. Return
  1852.  
  1853.  
  1854.  
  1855. ; [MIR] toggles the visibility of miranda buddy list
  1856.  
  1857. /**
  1858. * Toggles the visibility of the Miranda buddy list (if installed). Currently
  1859. * Miranda does not provide a hotkey to activate the buddy list if the window
  1860. * is still visible. Instead the opened (but not activated) buddy list will be
  1861. * minimized. This is not expected so this NiftyWindows feature provides the
  1862. * needed service asked by so many people.
  1863. */
  1864.  
  1865. ^+b::
  1866. IfExist, %MIR_MirandaFullPath%
  1867. {
  1868. SetTitleMatchMode, 3
  1869. DetectHiddenWindows, On
  1870. MIR_MirandaStart = 0
  1871. IfWinNotExist, Miranda IM
  1872. {
  1873. Run, %MIR_MirandaFullPath%, %MIR_MirandaDir%
  1874. WinWait, Miranda IM
  1875. MIR_MirandaStart=1
  1876. Sleep, 500
  1877. }
  1878. DetectHiddenWindows, Off
  1879. IfWinActive, Miranda IM
  1880. {
  1881. If ( !MIR_MirandaStart )
  1882. WinHide
  1883. }
  1884. Else
  1885. IfWinExist, Miranda IM
  1886. WinActivate
  1887. Else
  1888. {
  1889. DetectHiddenWindows, On
  1890. IfWinExist, Miranda IM
  1891. {
  1892. WinShow
  1893. WinActivate
  1894. }
  1895. }
  1896. }
  1897. Else
  1898. Send, ^+b
  1899. Return
  1900.  
  1901.  
  1902.  
  1903. ; [MIR] toggles the visibility of last used miranda message container
  1904.  
  1905. /**
  1906. * Toggles the visibility of the last used Miranda message container
  1907. * (if installed). Currently Miranda does not provide a hotkey to activate the
  1908. * last used message container if there is no unread message waiting for your
  1909. * attention. So this hotkey will make a container visible (if it is minimized)
  1910. * and activate it. If there is no existing message container, this hotkey will
  1911. * do nothing.
  1912. */
  1913.  
  1914. ~^+u::
  1915. IfExist, %MIR_MirandaFullPath%
  1916. {
  1917. Sleep, 500
  1918. SetTitleMatchMode, 3
  1919. IfWinExist, ahk_class #32770
  1920. {
  1921. WinGetTitle, MIR_Title
  1922. IfNotInString MIR_Title, Mail
  1923. IfWinNotActive
  1924. WinActivate
  1925. }
  1926. }
  1927. Else
  1928. Send, ^+u
  1929. Return
  1930.  
  1931.  
  1932.  
  1933. ; [TRY] handles the tray icon/menu
  1934.  
  1935. TRY_TrayInit:
  1936. Menu, TRAY, NoStandard
  1937. Menu, TRAY, Tip, %SYS_ScriptInfo%
  1938.  
  1939. If ( !A_IsCompiled )
  1940. {
  1941. Menu, AutoHotkey, Standard
  1942. Menu, TRAY, Add, AutoHotkey, :AutoHotkey
  1943. Menu, TRAY, Add
  1944. }
  1945.  
  1946. Menu, TRAY, Add, Help, TRY_TrayEvent
  1947. Menu, TRAY, Default, Help
  1948. Menu, TRAY, Add
  1949. Menu, TRAY, Add, About, TRY_TrayEvent
  1950. Menu, TRAY, Add
  1951. Menu, TRAY, Add, Mail Author, TRY_TrayEvent
  1952. Menu, TRAY, Add, View License, TRY_TrayEvent
  1953. Menu, TRAY, Add, Visit Website, TRY_TrayEvent
  1954. Menu, TRAY, Add, Check For Update, TRY_TrayEvent
  1955. Menu, TRAY, Add
  1956.  
  1957. Menu, MouseHooks, Add, Left Mouse Button, TRY_TrayEvent
  1958. Menu, MouseHooks, Add, Middle Mouse Button, TRY_TrayEvent
  1959. Menu, MouseHooks, Add, Right Mouse Button, TRY_TrayEvent
  1960. Menu, MouseHooks, Add, Fourth Mouse Button, TRY_TrayEvent
  1961. Menu, MouseHooks, Add, Fifth Mouse Button, TRY_TrayEvent
  1962. Menu, TRAY, Add, Mouse Hooks, :MouseHooks
  1963.  
  1964. Menu, TRAY, Add, ToolTip Feedback, TRY_TrayEvent
  1965. Menu, TRAY, Add, Auto Suspend, TRY_TrayEvent
  1966. Menu, TRAY, Add, Focus Follows Mouse, TRY_TrayEvent
  1967. Menu, TRAY, Add, Suspend All Hooks, TRY_TrayEvent
  1968. Menu, TRAY, Add, Revert Visual Effects, TRY_TrayEvent
  1969. Menu, TRAY, Add, Hide Tray Icon, TRY_TrayEvent
  1970. Menu, TRAY, Add
  1971. Menu, TRAY, Add, Exit, TRY_TrayEvent
  1972.  
  1973. Gosub, TRY_TrayUpdate
  1974.  
  1975. If ( A_IconHidden )
  1976. Menu, TRAY, Icon
  1977. Return
  1978.  
  1979. TRY_TrayUpdate:
  1980. If ( CFG_LeftMouseButtonHook )
  1981. Menu, MouseHooks, Check, Left Mouse Button
  1982. Else
  1983. Menu, MouseHooks, UnCheck, Left Mouse Button
  1984. If ( CFG_MiddleMouseButtonHook )
  1985. Menu, MouseHooks, Check, Middle Mouse Button
  1986. Else
  1987. Menu, MouseHooks, UnCheck, Middle Mouse Button
  1988. If ( CFG_RightMouseButtonHook )
  1989. Menu, MouseHooks, Check, Right Mouse Button
  1990. Else
  1991. Menu, MouseHooks, UnCheck, Right Mouse Button
  1992. If ( CFG_FourthMouseButtonHook )
  1993. Menu, MouseHooks, Check, Fourth Mouse Button
  1994. Else
  1995. Menu, MouseHooks, UnCheck, Fourth Mouse Button
  1996. If ( CFG_FifthMouseButtonHook )
  1997. Menu, MouseHooks, Check, Fifth Mouse Button
  1998. Else
  1999. Menu, MouseHooks, UnCheck, Fifth Mouse Button
  2000. If ( SYS_ToolTipFeedback )
  2001. Menu, TRAY, Check, ToolTip Feedback
  2002. Else
  2003. Menu, TRAY, UnCheck, ToolTip Feedback
  2004. If ( SUS_AutoSuspend )
  2005. Menu, TRAY, Check, Auto Suspend
  2006. Else
  2007. Menu, TRAY, UnCheck, Auto Suspend
  2008. If ( XWN_FocusFollowsMouse )
  2009. Menu, TRAY, Check, Focus Follows Mouse
  2010. Else
  2011. Menu, TRAY, UnCheck, Focus Follows Mouse
  2012. If ( A_IsSuspended )
  2013. Menu, TRAY, Check, Suspend All Hooks
  2014. Else
  2015. Menu, TRAY, UnCheck, Suspend All Hooks
  2016. Return
  2017.  
  2018. TRY_TrayEvent:
  2019. If ( !TRY_TrayEvent )
  2020. TRY_TrayEvent = %A_ThisMenuItem%
  2021.  
  2022. If ( TRY_TrayEvent = "Help" )
  2023. IfExist, %A_ScriptDir%\readme.txt
  2024. Run, "%A_ScriptDir%\readme.txt"
  2025. Else
  2026. {
  2027. SYS_TrayTipText = File couldn't be accessed:`n%A_ScriptDir%\readme.txt
  2028. SYS_TrayTipOptions = 3
  2029. Gosub, SYS_TrayTipShow
  2030. }
  2031.  
  2032. If ( TRY_TrayEvent = "About" )
  2033. {
  2034. SYS_TrayTipText = Copyright (c) 2004-2005 by Enovatic-Solutions.`nAll rights reserved. Use is subject to license terms.`n`nCompany:`tEnovatic-Solutions (IT Service Provider)`nAuthor:`t`tOliver Pfeiffer`, Bremen (GERMANY)`nEmail:`t`[email protected]
  2035. Gosub, SYS_TrayTipShow
  2036. }
  2037.  
  2038. If ( TRY_TrayEvent = "Mail Author" )
  2039. Run, mailto:[email protected]?subject=%SYS_ScriptInfo% (build %SYS_ScriptBuild%)
  2040.  
  2041. If ( TRY_TrayEvent = "View License" )
  2042. IfExist, %A_ScriptDir%\license.txt
  2043. Run, "%A_ScriptDir%\license.txt"
  2044. Else
  2045. {
  2046. SYS_TrayTipText = File couldn't be accessed:`n%A_ScriptDir%\license.txt
  2047. SYS_TrayTipOptions = 3
  2048. Gosub, SYS_TrayTipShow
  2049. }
  2050.  
  2051. If ( TRY_TrayEvent = "Visit Website" )
  2052. Run, http://www.enovatic.org/products/niftywindows/
  2053.  
  2054. If ( TRY_TrayEvent = "Check For Update" )
  2055. Gosub, UPD_CheckForUpdate
  2056.  
  2057. If ( TRY_TrayEvent = "ToolTip Feedback" )
  2058. SYS_ToolTipFeedback := !SYS_ToolTipFeedback
  2059.  
  2060. If ( TRY_TrayEvent = "Auto Suspend" )
  2061. {
  2062. SUS_AutoSuspend := !SUS_AutoSuspend
  2063. Gosub, CFG_ApplySettings
  2064. }
  2065.  
  2066. If ( TRY_TrayEvent = "Focus Follows Mouse" )
  2067. {
  2068. XWN_FocusFollowsMouse := !XWN_FocusFollowsMouse
  2069. Gosub, CFG_ApplySettings
  2070. }
  2071.  
  2072. If ( TRY_TrayEvent = "Suspend All Hooks" )
  2073. Gosub, SUS_SuspendToggle
  2074.  
  2075. If ( TRY_TrayEvent = "Revert Visual Effects" )
  2076. Gosub, SYS_RevertVisualEffects
  2077.  
  2078. If ( TRY_TrayEvent = "Hide Tray Icon" )
  2079. {
  2080. SYS_TrayTipText = Tray icon will be hidden now.`nPress WIN+X to show it again.
  2081. SYS_TrayTipOptions = 2
  2082. SYS_TrayTipSeconds = 5
  2083. Gosub, SYS_TrayTipShow
  2084. SetTimer, TRY_TrayHide, 5000
  2085. }
  2086.  
  2087. If ( TRY_TrayEvent = "Exit" )
  2088. ExitApp
  2089.  
  2090. If ( TRY_TrayEvent = "Left Mouse Button" )
  2091. {
  2092. CFG_LeftMouseButtonHook := !CFG_LeftMouseButtonHook
  2093. Gosub, CFG_ApplySettings
  2094. }
  2095.  
  2096. If ( TRY_TrayEvent = "Middle Mouse Button" )
  2097. {
  2098. CFG_MiddleMouseButtonHook := !CFG_MiddleMouseButtonHook
  2099. Gosub, CFG_ApplySettings
  2100. }
  2101.  
  2102. If ( TRY_TrayEvent = "Right Mouse Button" )
  2103. {
  2104. CFG_RightMouseButtonHook := !CFG_RightMouseButtonHook
  2105. Gosub, CFG_ApplySettings
  2106. }
  2107.  
  2108. If ( TRY_TrayEvent = "Fourth Mouse Button" )
  2109. {
  2110. CFG_FourthMouseButtonHook := !CFG_FourthMouseButtonHook
  2111. Gosub, CFG_ApplySettings
  2112. }
  2113.  
  2114. If ( TRY_TrayEvent = "Fifth Mouse Button" )
  2115. {
  2116. CFG_FifthMouseButtonHook := !CFG_FifthMouseButtonHook
  2117. Gosub, CFG_ApplySettings
  2118. }
  2119.  
  2120. Gosub, TRY_TrayUpdate
  2121. TRY_TrayEvent =
  2122. Return
  2123.  
  2124. TRY_TrayHide:
  2125. SetTimer, TRY_TrayHide, Off
  2126. Menu, TRAY, NoIcon
  2127. Return
  2128.  
  2129.  
  2130.  
  2131. ; [EDT] edits this script in notepad
  2132.  
  2133. ^#!F9::
  2134. If ( A_IsCompiled )
  2135. Return
  2136.  
  2137. Gosub, SUS_SuspendSaveState
  2138. Suspend, On
  2139. MsgBox, 4129, Edit Handler - %SYS_ScriptInfo%, You pressed the hotkey for editing this script:`n`n%A_ScriptFullPath%`n`nDo you really want to edit?
  2140. Gosub, SUS_SuspendRestoreState
  2141. IfMsgBox, OK
  2142. Run, notepad.exe %A_ScriptFullPath%
  2143. Return
  2144.  
  2145.  
  2146.  
  2147. ; [REL] reloads this script on change
  2148.  
  2149. REL_ScriptReload:
  2150. If ( A_IsCompiled )
  2151. Return
  2152.  
  2153. FileGetAttrib, REL_Attribs, %A_ScriptFullPath%
  2154. IfInString, REL_Attribs, A
  2155. {
  2156. FileSetAttrib, -A, %A_ScriptFullPath%
  2157. If ( REL_InitDone )
  2158. {
  2159. Gosub, SUS_SuspendSaveState
  2160. Suspend, On
  2161. MsgBox, 4145, Update Handler - %SYS_ScriptInfo%, The following script has changed:`n`n%A_ScriptFullPath%`n`nReload and activate this script?
  2162. Gosub, SUS_SuspendRestoreState
  2163. IfMsgBox, OK
  2164. Reload
  2165. }
  2166. }
  2167. REL_InitDone = 1
  2168. Return
  2169.  
  2170.  
  2171.  
  2172. ; [EXT] exits this script
  2173.  
  2174. #x::
  2175. If ( A_IconHidden )
  2176. {
  2177. Menu, TRAY, Icon
  2178. SYS_TrayTipText = Tray icon is shown now.`nPress WIN+X again to exit NiftyWindows.
  2179. SYS_TrayTipSeconds = 5
  2180. Gosub, SYS_TrayTipShow
  2181. Return
  2182. }
  2183.  
  2184. If ( A_IsCompiled )
  2185. {
  2186. SYS_TrayTipText = NiftyWindows will exit now.`nYou can find it here (to start it again):`n%A_ScriptFullPath%
  2187. SYS_TrayTipOptions = 2
  2188. SYS_TrayTipSeconds = 5
  2189. Gosub, SYS_TrayTipShow
  2190. Suspend, On
  2191. Sleep, 5000
  2192. ExitApp
  2193. }
  2194.  
  2195. Gosub, SUS_SuspendSaveState
  2196. Suspend, On
  2197. MsgBox, 4145, Exit Handler - %SYS_ScriptInfo%, You pressed the hotkey for exiting this script:`n`n%A_ScriptFullPath%`n`nDo you really want to exit?
  2198. Gosub, SUS_SuspendRestoreState
  2199. IfMsgBox, OK
  2200. ExitApp
  2201. Return
  2202.  
  2203.  
  2204.  
  2205. ; [CFG] handles the persistent configuration
  2206.  
  2207. CFG_LoadSettings:
  2208. CFG_IniFile = %A_ScriptDir%\%SYS_ScriptNameNoExt%.ini
  2209. IniRead, SUS_AutoSuspend, %CFG_IniFile%, Main, AutoSuspend, 1
  2210. IniRead, XWN_FocusFollowsMouse, %CFG_IniFile%, WindowHandling, FocusFollowsMouse, 0
  2211. IniRead, SYS_ToolTipFeedback, %CFG_IniFile%, Visual, ToolTipFeedback, 1
  2212. IniRead, UPD_LastUpdateCheck, %CFG_IniFile%, UpdateCheck, LastUpdateCheck, %A_MM%
  2213. IniRead, CFG_LeftMouseButtonHook, %CFG_IniFile%, MouseHooks, LeftMouseButton, 1
  2214. IniRead, CFG_MiddleMouseButtonHook, %CFG_IniFile%, MouseHooks, MiddleMouseButton, 1
  2215. IniRead, CFG_RightMouseButtonHook, %CFG_IniFile%, MouseHooks, RightMouseButton, 1
  2216. IniRead, CFG_FourthMouseButtonHook, %CFG_IniFile%, MouseHooks, FourthMouseButton, 1
  2217. IniRead, CFG_FifthMouseButtonHook, %CFG_IniFile%, MouseHooks, FifthMouseButton, 1
  2218. Return
  2219.  
  2220. CFG_SaveSettings:
  2221. CFG_IniFile = %A_ScriptDir%\%SYS_ScriptNameNoExt%.ini
  2222. IniWrite, %SUS_AutoSuspend%, %CFG_IniFile%, Main, AutoSuspend
  2223. IniWrite, %XWN_FocusFollowsMouse%, %CFG_IniFile%, WindowHandling, FocusFollowsMouse
  2224. IniWrite, %SYS_ToolTipFeedback%, %CFG_IniFile%, Visual, ToolTipFeedback
  2225. IniWrite, %UPD_LastUpdateCheck%, %CFG_IniFile%, UpdateCheck, LastUpdateCheck
  2226. IniWrite, %CFG_LeftMouseButtonHook%, %CFG_IniFile%, MouseHooks, LeftMouseButton
  2227. IniWrite, %CFG_MiddleMouseButtonHook%, %CFG_IniFile%, MouseHooks, MiddleMouseButton
  2228. IniWrite, %CFG_RightMouseButtonHook%, %CFG_IniFile%, MouseHooks, RightMouseButton
  2229. IniWrite, %CFG_FourthMouseButtonHook%, %CFG_IniFile%, MouseHooks, FourthMouseButton
  2230. IniWrite, %CFG_FifthMouseButtonHook%, %CFG_IniFile%, MouseHooks, FifthMouseButton
  2231. Return
  2232.  
  2233. CFG_ApplySettings:
  2234. If ( SUS_AutoSuspend )
  2235. SetTimer, SUS_SuspendHandler, 1000
  2236. Else
  2237. SetTimer, SUS_SuspendHandler, Off
  2238.  
  2239. If ( XWN_FocusFollowsMouse )
  2240. SetTimer, XWN_FocusHandler, 100
  2241. Else
  2242. SetTimer, XWN_FocusHandler, Off
  2243.  
  2244. If ( CFG_LeftMouseButtonHook )
  2245. CFG_LeftMouseButtonHookStr = On
  2246. Else
  2247. CFG_LeftMouseButtonHookStr = Off
  2248.  
  2249. If ( CFG_MiddleMouseButtonHook )
  2250. CFG_MiddleMouseButtonHookStr = On
  2251. Else
  2252. CFG_MiddleMouseButtonHookStr = Off
  2253.  
  2254. If ( CFG_RightMouseButtonHook )
  2255. CFG_RightMouseButtonHookStr = On
  2256. Else
  2257. CFG_RightMouseButtonHookStr = Off
  2258.  
  2259. If ( CFG_FourthMouseButtonHook )
  2260. CFG_FourthMouseButtonHookStr = On
  2261. Else
  2262. CFG_FourthMouseButtonHookStr = Off
  2263.  
  2264. If ( CFG_FifthMouseButtonHook )
  2265. CFG_FifthMouseButtonHookStr = On
  2266. Else
  2267. CFG_FifthMouseButtonHookStr = Off
  2268.  
  2269. Hotkey, $LButton, %CFG_LeftMouseButtonHookStr%
  2270. Hotkey, $^LButton, %CFG_LeftMouseButtonHookStr%
  2271. Hotkey, #LButton, %CFG_LeftMouseButtonHookStr%
  2272. Hotkey, #^LButton, %CFG_LeftMouseButtonHookStr%
  2273.  
  2274. Hotkey, #MButton, %CFG_MiddleMouseButtonHookStr%
  2275. Hotkey, #^MButton, %CFG_MiddleMouseButtonHookStr%
  2276. Hotkey, $MButton, %CFG_MiddleMouseButtonHookStr%
  2277. Hotkey, $^MButton, %CFG_MiddleMouseButtonHookStr%
  2278.  
  2279. Hotkey, $RButton, %CFG_RightMouseButtonHookStr%
  2280. Hotkey, $+RButton, %CFG_RightMouseButtonHookStr%
  2281. Hotkey, $+!RButton, %CFG_RightMouseButtonHookStr%
  2282. Hotkey, $+^RButton, %CFG_RightMouseButtonHookStr%
  2283. Hotkey, $+#RButton, %CFG_RightMouseButtonHookStr%
  2284. Hotkey, $+!^RButton, %CFG_RightMouseButtonHookStr%
  2285. Hotkey, $+!#RButton, %CFG_RightMouseButtonHookStr%
  2286. Hotkey, $+^#RButton, %CFG_RightMouseButtonHookStr%
  2287. Hotkey, $+!^#RButton, %CFG_RightMouseButtonHookStr%
  2288. Hotkey, $!RButton, %CFG_RightMouseButtonHookStr%
  2289. Hotkey, $!^RButton, %CFG_RightMouseButtonHookStr%
  2290. Hotkey, $!#RButton, %CFG_RightMouseButtonHookStr%
  2291. Hotkey, $!^#RButton, %CFG_RightMouseButtonHookStr%
  2292. Hotkey, $^RButton, %CFG_RightMouseButtonHookStr%
  2293. Hotkey, $^#RButton, %CFG_RightMouseButtonHookStr%
  2294. Hotkey, $#RButton, %CFG_RightMouseButtonHookStr%
  2295.  
  2296. Hotkey, $XButton1, %CFG_FourthMouseButtonHookStr%
  2297. Hotkey, $^XButton1, %CFG_FourthMouseButtonHookStr%
  2298.  
  2299. Hotkey, $XButton2, %CFG_FifthMouseButtonHookStr%
  2300. Hotkey, $^XButton2, %CFG_FifthMouseButtonHookStr%
  2301. Return
  2302.  
  2303.  
  2304.  
  2305. ; [UPD] checks for a new build
  2306.  
  2307. UPD_CheckForUpdate:
  2308. UPD_CheckSuccess =
  2309. Random, UPD_Random
  2310. If ( TEMP )
  2311. UPD_BuildFile = %TEMP%\%SYS_ScriptNameNoExt%.%UPD_Random%.tmp
  2312. Else
  2313. UPD_BuildFile = %SYS_ScriptDir%\%SYS_ScriptNameNoExt%.%UPD_Random%.tmp
  2314. Gosub, SUS_SuspendSaveState
  2315. Suspend, On
  2316. URLDownloadToFile, http://www.enovatic.org/products/niftywindows/files/build.txt?random=%UPD_Random%, %UPD_BuildFile%
  2317. Gosub, SUS_SuspendRestoreState
  2318. If ( !ErrorLevel )
  2319. {
  2320. FileReadLine, UPD_Build, %UPD_BuildFile%, 1
  2321. If ( !ErrorLevel )
  2322. If UPD_Build is digit
  2323. {
  2324. UPD_CheckSuccess = 1
  2325. UPD_LastUpdateCheck = %A_MM%
  2326. If ( UPD_Build > SYS_ScriptBuild )
  2327. {
  2328. SYS_TrayTipText = There is a new version available. Please check website.
  2329. SYS_TrayTipOptions = 1
  2330. Run, http://www.enovatic.org/products/niftywindows/
  2331. }
  2332. Else
  2333. SYS_TrayTipText = There is no new version available.
  2334. }
  2335. Else
  2336. SYS_TrayTipText = wrong build pattern in downloaded build file
  2337. Else
  2338. SYS_TrayTipText = downloaded build file couldn't be read
  2339. }
  2340. Else
  2341. SYS_TrayTipText = build file couldn't be downloaded
  2342. FileDelete, %UPD_BuildFile%
  2343. If ( !UPD_CheckSuccess )
  2344. {
  2345. SYS_TrayTipText = Check for update failed:`n%SYS_TrayTipText%
  2346. SYS_TrayTipOptions = 3
  2347. }
  2348. Gosub, SYS_TrayTipShow
  2349. Return
  2350.  
  2351. UPD_AutoCheckForUpdate:
  2352. If ( UPD_LastUpdateCheck != A_MM )
  2353. {
  2354. Gosub, SUS_SuspendSaveState
  2355. Suspend, On
  2356. MsgBox, 4132, Update Handler - %SYS_ScriptInfo%, You haven't checked for updates for a long period of time (at least one month).`n`nDo you want NiftyWindows to check for a new version now (highly recommended)?
  2357. Gosub, SUS_SuspendRestoreState
  2358. IfMsgBox, Yes
  2359. Gosub, UPD_CheckForUpdate
  2360. Else
  2361. UPD_LastUpdateCheck = %A_MM%
  2362. }
  2363. Return
  2364.  
  2365. ^#!b::
  2366. If ( !A_IsCompiled )
  2367. {
  2368. UPD_VersionFile = %SYS_ScriptDir%\version.txt
  2369. IfExist, %UPD_VersionFile%
  2370. {
  2371. FileDelete, %UPD_VersionFile%
  2372. If ( ErrorLevel )
  2373. Return
  2374. }
  2375. FileAppend, %SYS_ScriptVersion%, %UPD_VersionFile%
  2376. If ( ErrorLevel )
  2377. Return
  2378.  
  2379. UPD_BuildFile = %SYS_ScriptDir%\build.txt
  2380. IfExist, %UPD_BuildFile%
  2381. {
  2382. FileDelete, %UPD_BuildFile%
  2383. If ( ErrorLevel )
  2384. Return
  2385. }
  2386. FileAppend, %A_NowUTC%, %UPD_BuildFile%
  2387. If ( ErrorLevel )
  2388. Return
  2389.  
  2390. SYS_TrayTipText = Version and build files were written successfully:`n%UPD_VersionFile%`n%UPD_BuildFile%
  2391. SYS_TrayTipOptions = 2
  2392. SYS_TrayTipSeconds = 5
  2393. Gosub, SYS_TrayTipShow
  2394. }
  2395. Return

Report this snippet  

You need to login to post a comment.