Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ------------------------------------------------------------------------------
- ; http://L.AutoHotKey.net/ (v1.1.09.04) -- yunga.palatino@gmail.com
- ; ------------------------------------------------------------------------------
- ; See http://www.autohotkey.com/docs/scripts/
- ; ----- Directives:
- #NoEnv
- #MaxThreadsPerHotkey 2
- #MaxHotkeysPerInterval 100 ; Avoid when mouse wheel turned very fast
- #Hotstring EndChars -()[]{}:;'"/\,.?!`n `t
- ; ----- GlobalVars
- EnvGet, HomeDir, USERPROFILE
- AutoFireClickToggle = 0
- ; Windows Resizing Vars
- A_ScreenChatWidth := 512 ; Change this
- A_ScreenWorkWidth := A_ScreenWidth - A_ScreenChatWidth
- A_ScreenHalfWidth := Round( A_ScreenWidth / 2 )
- A_ScreenHalfHeight := Round(A_ScreenHeight / 2 )
- A_ScreenThirdWidth := Round( A_ScreenWidth / 3 )
- A_ScreenTwoThirdWidth := 2 * A_ScreenThirdWidth
- ; #!m::MsgBox %A_ScreenWidth%x%A_ScreenHeight%`n%A_ScreenHalfWidth%x%A_ScreenHalfHeight%`n%A_ScreenWorkWidth%-%A_ScreenChatWidth%`nA_ScreenThirdWidth
- ; Scroll Whell Vars
- MinLinesPerNotch := 1
- MaxLinesPerNotch := 5
- AccelerationThreshold := 100
- AccelerationType := "L" ;Change to "P" for parabolic acceleration
- StutterThreshold := 10
- ; ----- End of Init:
- Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Ctrl-Alt-Win-R Reload the current AutoHotKey script
- ^#!r::
- SplashTextOn, , , Reloading....
- Reload
- Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
- SplashTextOff
- MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
- IfMsgBox, Yes, Edit
- Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Launchers Hot Keys:
- ; Launchy is on #^Space
- #c::Run, C:\Windows\system32\calc.exe ; Calculator
- #+c::Run, C:\Program Files\Ditto\Ditto.exe ; Clipboard tool
- #e::Run C:\Windows\Explorer.exe D:\ ; Explorer
- #+e::Run, C:\Prg\Far\Far.exe ; Explorer
- #f::Run, C:\Program Files\Everything\Everything.exe ; Find
- #+f::Run, C:\Program Files (x86)\FileZilla\Client\filezilla.exe ; FTP
- #m::Run C:\Program Files\VideoLAN\VLC\vlc.exe ; Media
- #+m::Run C:\Program Files (x86)\Winamp ; Media
- #o::Run, C:\Program Files\Microsoft Office\Office15\WINWORD.EXE ; Office
- #+o::Run, C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe ; Office - mails
- #+r::Run, C:\Program Files (x86)\PuTTY\putty.exe ; Remote shell
- #^r::Run, C:\Program Files (x86)\TeamViewer\Version8\TeamViewer.exe ; Remote desktop
- #s::Run, C:\prg\cygwin\bin\mintty.exe -e screen -ln -D -RR , %HomeDir% ; bash Shell
- #+s::Run, C:\Prg\4Dos\tcc.exe , %HomeDir% ; 4dos Shell
- #^s::Run, C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe , %HomeDir% ; powerShell
- #^!s::Run, C:\Program Files (x86)\Git\bin\sh.exe --login -i ; git Shell
- #t::Run, C:\Program Files (x86)\Notepad++\notepad++.exe ; Text editor
- #+t::Run, C:\Program Files\Sublime Text 3\sublime_text.exe ; Text editor
- #^t::Run, C:\Program Files\KDiff3\kdiff3.exe ; Text diff
- #w::Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe ; Web browser
- #+w::Run, C:\Program Files (x86)\Mozilla Firefox\firefox.exe ; Web browser
- #^w::Run, C:\Program Files (x86)\Opera\launcher.exe ; Web browser
- #Break::Run, C:\Program Files\ProcessHacker\ProcessHacker.exe ; TaskManager
- #+Break::Run, C:\Prg\OllyDbg\ollydbg.exe ; Debugger
- #PrintScreen::Run, C:\Program Files\Greenshot\Greenshot.exe ; Screenshots
- #+PrintScreen::Run, C:\Program Files (x86)\ABBYY FineReader 11\Bonus.ScreenshotReader.exe ; Screenshots reader
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Abbrevs
- ::btw::by the way ; btw: Abbrev Example
- :O:@yunga::yunga.palatino@gmail.com
- :O:@date::
- FormatTime, CurrentDateTime,, yyyyMMdd
- SendInput %CurrentDateTime%
- Return
- :O:@time::
- FormatTime, CurrentDateTime,, HHmmss
- SendInput %CurrentDateTime%
- Return
- :O:@ts::
- FormatTime, CurrentDateTime,, yyyyMMdd_HHmmss
- SendInput %CurrentDateTime%
- Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Win(-Shift)-F1 for Auto-Fire for clicks (1/10sec delay, shift for 1 second delay)
- #F1::
- AutoFireClickToggle := !AutoFireClickToggle
- While AutoFireClickToggle {
- Click
- Sleep 100
- }
- Return
- #+F1::
- AutoFireClickToggle := !AutoFireClickToggle
- While AutoFireClickToggle {
- Click
- Sleep 1000
- }
- Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Ctrl-Shift-c: Copy and Search Google (from AutoHotKey Examples)
- ^+c::
- Send, ^c
- Sleep 100
- Run "http://www.google.com/search?q=%clipboard%"
- Return
- ^!c::
- Send, ^c
- Sleep 100
- Run "https://en.wikipedia.org/w/index.php?title=Special:Search&search=%clipboard%"
- Return
- ;^+v::
- ; TempText := ClipBoard
- ; If (TempText != "")
- ; PutText(ClipBoard)
- ;Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Always on Top
- #!SPACE::Winset, Alwaysontop, Toggle, A ; Control-Space Toggle AlwaysOnTop on Active Window
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Resize Windows Function
- ResizeWin(Width = 0,Height = 0) {
- WinGetPos,X,Y,W,H,A
- If %Width% = 0
- Width := W
- If %Height% = 0
- Height := H
- ; WinSet Style, -0xC00000, A ; Remove the active window's title bar (WS_CAPTION).
- WinMove,A,,%X%,%Y%,%Width%,%Height%
- }
- ; #!u::ResizeWin(800,600)
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Maps windows Positions on the keyboard
- ; a zer t
- ; q sdf g
- ; w xcv b
- #!a::WinMove,A,,0,0,%A_ScreenWorkWidth%,%A_ScreenHalfHeight%
- #!q::WinMove,A,,0,0,%A_ScreenWorkWidth%,%A_ScreenHeight%
- #!w::WinMove,A,,0,%A_ScreenHalfHeight%,%A_ScreenWorkWidth%,%A_ScreenHalfHeight%
- #!+a::WinMove,A,,0,0,%A_ScreenChatWidth%,%A_ScreenHalfHeight%
- #!+q::WinMove,A,,0,0,%A_ScreenChatWidth%,%A_ScreenHeight%
- #!+w::WinMove,A,,0,%A_ScreenHalfHeight%,%A_ScreenChatWidth%,%A_ScreenHalfHeight%
- #!z::WinMove,A,,0,0,%A_ScreenHalfWidth%,%A_ScreenHalfHeight%
- #!e::WinMove,A,,0,0,%A_ScreenWidth%,%A_ScreenHalfHeight%
- #!r::WinMove,A,,%A_ScreenHalfWidth%,0,%A_ScreenHalfWidth%,%A_ScreenHalfHeight%
- #!+z::WinMove,A,,0,0,%A_ScreenThirdWidth%,%A_ScreenHeight%
- #!+e::WinMove,A,,%A_ScreenThirdWidth%,0,%A_ScreenThirdWidth%,%A_ScreenHeight%
- #!+r::WinMove,A,,%A_ScreenTwoThirdWidth%,0,%A_ScreenThirdWidth%,%A_ScreenHeight%
- #!s::WinMove,A,,0,0,%A_ScreenHalfWidth%,%A_ScreenHeight%
- #!d::WinMove,A,,320,156,1280,768
- #!f::WinMove,A,,%A_ScreenHalfWidth%,0,%A_ScreenHalfWidth%,%A_ScreenHeight%
- #!x::WinMove,A,,0,%A_ScreenHalfHeight%,%A_ScreenHalfWidth%,%A_ScreenHalfHeight%
- #!c::WinMove,A,,0,%A_ScreenHalfHeight%,%A_ScreenWidth%,%A_ScreenHalfHeight%
- #!v::WinMove,A,,%A_ScreenHalfWidth%,%A_ScreenHalfHeight%,%A_ScreenHalfWidth%,%A_ScreenHalfHeight%
- #!t::WinMove,A,,%A_ScreenWorkWidth%,0,%A_ScreenChatWidth%,%A_ScreenHalfHeight%
- #!g::WinMove,A,,%A_ScreenWorkWidth%,0,%A_ScreenChatWidth%,%A_ScreenHeight%
- #!b::WinMove,A,,%A_ScreenWorkWidth%,%A_ScreenHalfHeight%,%A_ScreenChatWidth%,%A_ScreenHalfHeight%
- #!+t::WinMove,A,,%A_ScreenChatWidth%,0,%A_ScreenWorkWidth%,%A_ScreenHalfHeight%
- #!+g::WinMove,A,,%A_ScreenChatWidth%,0,%A_ScreenWorkWidth%,%A_ScreenHeight%
- #!+b::WinMove,A,,%A_ScreenChatWidth%,%A_ScreenHalfHeight%,%A_ScreenWorkWidth%,%A_ScreenHalfHeight%
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Move mouse with arrow keys
- #!Left::MouseMove, -1, 0, 0, R
- #!Right::MouseMove, 1, 0, 0, R
- #!Up::MouseMove, 0, -1, 0, R
- #!Down::MouseMove, 0, 1, 0, R
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Windows Transparency
- ; Win-Alt y/Y - transparency level +/-
- ; Win-Ctrl-Alt y/Y - turn transparency off/60%
- #^!y::WinSet, Transparent, OFF, A
- #^!+y::WinSet, Transparent, 154, A
- #!y::
- WinGet Trans, Transparent, A
- If Trans =
- Trans := 255
- Trans := Trans - 17
- If Trans < 16
- Trans = 17
- WinSet, Transparent, %Trans%, A
- Return
- #!+y::
- WinGet Trans, Transparent, A
- If Trans =
- Trans := 255
- Trans := Trans + 17
- If Trans > 255
- WinSet, Transparent, OFF, A
- Else
- WinSet, Transparent, %Trans%, A
- Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Remove window frame
- #!n::WinSet, Style, ^0xC00000, A
- ;#!n::
- ; WinGet Style, Style, A
- ; Style := Style ^0xC00000
- ; WinSet, Style, %Style%, A
- ;Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Alt-Drag from http://www.autohotkey.com/docs/scripts/EasyWindowDrag.htm
- Alt & LButton::
- CoordMode, Mouse ; Switch to screen/absolute coordinates.
- MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
- WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
- WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
- if EWD_WinState = 0 ; Only if the window isn't maximized
- {
- SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
- }
- Return
- EWD_WatchMouse:
- GetKeyState, EWD_LButtonState, LButton, P
- if EWD_LButtonState = U ; Button has been released, so drag is complete.
- {
- SetTimer, EWD_WatchMouse, off
- return
- }
- GetKeyState, EWD_EscapeState, Escape, P
- if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled.
- {
- SetTimer, EWD_WatchMouse, off
- WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
- return
- }
- ; Otherwise, reposition the window to match the change in mouse coordinates
- ; caused by the user having dragged the mouse:
- CoordMode, Mouse
- MouseGetPos, EWD_MouseX, EWD_MouseY
- WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
- SetWinDelay, -1 ; Makes the below move faster/smoother.
- WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
- EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine.
- EWD_MouseStartY := EWD_MouseY
- Return
- ; ----------------------------------------------------- (#Win !Alt ^Ctrl +Shift)
- ; ----- Focus-less ScrollWheel from http://www.autohotkey.com/board/topic/6292-send-mouse-scrolls-to-window-under-mouse/page-9?hl=%2Bmouse+%2Bwheel#entry620251
- ;Function definitions
- ;See above for details
- FocuslessScroll(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType, StutterThreshold)
- {
- SetBatchLines, -1 ;Run as fast as possible
- CoordMode, Mouse, Screen ;All coords relative to screen
- ;Stutter filter: Prevent stutter caused by cheap mice by ignoring successive WheelUp/WheelDown events that occur to close together.
- If(A_TimeSincePriorHotkey < StutterThreshold) ;Quickest succession time in ms
- If(A_PriorHotkey = "WheelUp" Or A_PriorHotkey ="WheelDown")
- Return
- MouseGetPos, m_x, m_y,, ControlClass2, 2
- ControlClass1 := DllCall( "WindowFromPoint", "int64", (m_y << 32) | (m_x & 0xFFFFFFFF), "Ptr") ;32-bit and 64-bit support
- lParam := (m_y << 16) | (m_x & 0x0000FFFF)
- wParam := (120 << 16) ;Wheel delta is 120, as defined by MicroSoft
- ;Detect WheelDown event
- If(A_ThisHotkey = "WheelDown" Or A_ThisHotkey = "^WheelDown" Or A_ThisHotkey = "+WheelDown" Or A_ThisHotkey = "*WheelDown")
- wParam := -wParam ;If scrolling down, invert scroll direction
- ;Detect modifer keys held down (only Shift and Control work)
- If(GetKeyState("Shift","p"))
- wParam := wParam | 0x4
- If(GetKeyState("Ctrl","p"))
- wParam := wParam | 0x8
- ;Adjust lines per notch according to scrolling speed
- Lines := LinesPerNotch(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType)
- If(ControlClass1 != ControlClass2)
- {
- Loop %Lines%
- {
- SendMessage, 0x20A, wParam, lParam,, ahk_id %ControlClass1%
- SendMessage, 0x20A, wParam, lParam,, ahk_id %ControlClass2%
- }
- }
- Else ;Avoid using Loop when not needed (most normal controls). Greately improves momentum problem!
- {
- SendMessage, 0x20A, wParam * Lines, lParam,, ahk_id %ControlClass1%
- }
- }
- ;All parameters are the same as the parameters of FocuslessScroll()
- ;Return value: Returns the number of lines to be scrolled calculated from the current scroll speed.
- LinesPerNotch(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType)
- {
- T := A_TimeSincePriorHotkey
- ;Normal slow scrolling, separationg between scroll events is greater than AccelerationThreshold miliseconds.
- If((T > AccelerationThreshold) Or (T = -1)) ;T = -1 if this is the first hotkey ever run
- {
- Lines := MinLinesPerNotch
- }
- ;Fast scrolling, use acceleration
- Else
- {
- If(AccelerationType = "P")
- {
- ;Parabolic scroll speed curve
- ;f(t) = At^2 + Bt + C
- A := (MaxLinesPerNotch-MinLinesPerNotch)/(AccelerationThreshold**2)
- B := -2 * (MaxLinesPerNotch - MinLinesPerNotch)/AccelerationThreshold
- C := MaxLinesPerNotch
- Lines := Round(A*(T**2) + B*T + C)
- }
- Else
- {
- ;Linear scroll speed curve
- ;f(t) = Bt + C
- B := (MinLinesPerNotch-MaxLinesPerNotch)/AccelerationThreshold
- C := MaxLinesPerNotch
- Lines := Round(B*T + C)
- }
- }
- Return Lines
- }
- ;All hotkeys with the same parameters can use the same instance of FocuslessScroll().
- ; No need to have separate calls unless each hotkey requires different parameters (e.g. you want to disable acceleration for Ctrl-WheelUp and Ctrl-WheelDown).
- ; If you want a single set of parameters for all scrollwheel actions, you can simply use *WheelUp:: and *WheelDown:: instead.
- #MaxThreadsPerHotkey 6 ;Adjust to taste. The lower the value, the lesser the momentum problem on certain smooth-scrolling GUI controls (e.g. AHK helpfile main pane, WordPad...), but also the lesser the acceleration feel. The good news is that this setting does no affect most controls, only those that exhibit the momentum problem. Nice.
- ;Scroll with acceleration
- WheelUp::
- WheelDown::FocuslessScroll(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType, StutterThreshold)
- ;Ctrl-Scroll zoom with no acceleration (MaxLinesPerNotch = MinLinesPerNotch).
- ^WheelUp::
- ^WheelDown::FocuslessScroll(MinLinesPerNotch, MinLinesPerNotch, AccelerationThreshold, AccelerationType, StutterThreshold)
- ;If you want zoom acceleration, replace above line with this: FocuslessScroll(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType, StutterThreshold)
- #MaxThreadsPerHotkey 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement