congdantoancau

Left mouse close tab and more

May 23rd, 2020
2,387
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* LBUTTON FUNCTIONS
  2. * LButton close tab when cursor is on the left edge of screen
  3. * Windows + LButton on right: Close windows
  4. * Windows + LButton on top: Minimize current windows
  5. * Windows + LButton on bottom: Minimize all windows
  6. * coordmode: https://autohotkey.com/board/topic/129855-getting-exact-mouse-position-on-the-screen/
  7. * Customize the right and bottom coordinate depend on each screen to make it work.
  8. */
  9.  
  10. ; ================ DECLARE AND INITIAL VARIABLES =================
  11.     h_titlebar := 25 ; height of window title bar
  12.     h_taskbar := 40 ; height of taskbar
  13.     w_winctrls := 140 ; width of the all 3 Windows control button
  14.     w_spacetotray := 200 ; distance from middle taskbar to the system tray
  15.     startbutton := 40 ; width of the start button
  16.  
  17. #LButton::
  18.     CoordMode, Mouse, Screen
  19.     MouseGetPos, x, y
  20.     TrayTip, Mouse, Position: %x%:%y%
  21.  
  22.     if (x >= A_ScreenWidth - 1 && y < A_ScreenHeight - h_taskbar) ; Right edge
  23.         WinClose, a
  24.     else if (y <= 0 and x >= 0 and x < A_ScreenWidth - w_winctrls) ; Top edge
  25.         WinMinimize, a
  26.     else if (x > startbutton && x < A_ScreenWidth / 2 + w_spacetotray && y > A_ScreenHeight - 1 || y == h_taskbar-1) ; Bottom edge
  27.         Send, #m
  28. return
  29.  
  30.  
  31. ~LButton::
  32.     CoordMode, Mouse, Screen
  33.     MouseGetPos, x, y
  34.     ; TrayTip, mouse pos,%x%:%y%
  35.  
  36.     if (x >= 0 and x <= 8 && y > h_titlebar && y < A_ScreenHeight - h_taskbar) ; Left edge
  37.     {
  38.         Send, ^w
  39.         IfWinActive, (Untitled) ; For Notepad++, In case the last tab was closed
  40.             WinClose, (Untitled)
  41.     }
  42.     else if (x >= A_ScreenWidth - 1 and y > h_titlebar && y < A_ScreenHeight - h_taskbar) ; Right edge
  43.         TrayTip, Mouse > Border actions, Current mouse position: %x%:%y%`nHold Windows key while click to exit, 1
  44.     else if (y <= 0 and x >= 0 and x < A_ScreenWidth - w_winctrls) ; Top edge
  45.         TrayTip, Mouse > Border actions, Current mouse position: %x%:%y%`nHold Windows key while click to minimize, 1
  46.     else if (x > startbutton && x < A_ScreenWidth / 2 + w_spacetotray && y == A_ScreenHeight - 1 || y == h_taskbar-1) ; Bottom edge
  47.         TrayTip, Mouse > Border actions, Current mouse position: %x%:%y%`nHold Windows key while click to minimize all, 1
  48. return
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×