Advertisement
layr

AHK

Nov 8th, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; =================== Keymaps to use without bug.n ========================
  2. ; ===================================================================
  3. #HotkeyModifierTimeout 100
  4.  
  5. RaiseWindowBelowCursor() {
  6.     ;       '''Activates window below the cursor'''
  7.    
  8.     MouseGetPos, , , id, control
  9.     WinActivate, ahk_id %id%
  10.     return
  11. }
  12.  
  13.    
  14. FF_tabgroup_back() {
  15.     WinActivate, ahk_class MozillaWindowClass
  16.     ;if WinActive("ahk_class MozillaWindowClass")
  17.     caps()
  18.     Send, ^+p
  19.     return
  20. }
  21.  
  22. FF_tabgroup_fwd() {
  23.     WinActivate, ahk_class MozillaWindowClass
  24.     ;if WinActive("ahk_class MozillaWindowClass")
  25.     ;Send, {Esc}^+n      ; The {Esc} key is for exiting possible Insert mode        <-- old solution when not using caps-esc switching
  26.     caps()
  27.     Send, ^+n
  28.     return
  29. }
  30.  
  31. SkypeConversationUp() {
  32.     Send, {AltDown}2{AltUp}
  33.     Sleep, 10
  34.     Send, {Up}{Enter}
  35.     return
  36. }
  37.  
  38. SkypeConversationDown() {
  39.     Send, {AltDown}2{AltUp}
  40.     Sleep, 10
  41.     Send, {Down}{Enter}
  42.     return
  43. }
  44.  
  45.  
  46. HistoryBack() {
  47.     RaiseWindowBelowCursor()
  48.     Send, !{Left}
  49.     return
  50. }
  51.  
  52. HistoryFwd() {
  53.     RaiseWindowBelowCursor()
  54.     Send, !{Right}
  55.     return
  56. }
  57.  
  58. TabBack() {
  59.     RaiseWindowBelowCursor()
  60.     if WinActive("ahk_class tSkMainForm")
  61.         SkypeConversationUp()
  62.     else
  63.         Send, ^+{Tab}
  64.     return
  65. }
  66.  
  67. TabFwd() {
  68.     RaiseWindowBelowCursor()
  69.     if WinActive("ahk_class tSkMainForm")
  70.         SkypeConversationDown()
  71.     else
  72.         Send, ^{Tab}
  73.     return
  74. }
  75.  
  76.  
  77. ; Maximize active window and restore already maximized window:
  78. max_restore() {
  79.     WinGet, winstate, MinMax, A
  80.     if winstate = 1
  81.         WinRestore, A
  82.     else
  83.         WinMaximize, A
  84.     return
  85. }
  86.  
  87. caps() {
  88.     ;suspend to prevent calling esc
  89.     Suspend on
  90.     Send, {ESC}
  91.     Suspend off
  92.     return
  93. }
  94.  
  95. ; ==============================================================
  96. ; SKYPE HACK: (dirty, dirty hack, but works)
  97.  
  98. one() {
  99.     if WinActive("ahk_class tSkMainForm") {
  100.         Send, {AltDown}2{AltUp}
  101.         Sleep, 10
  102.         Send, {PgUp}{Enter}
  103.     }
  104.     else
  105.         Send, ^1
  106.     return
  107. }
  108.  
  109. two() {
  110.     if WinActive("ahk_class tSkMainForm") {
  111.         Send, {AltDown}2{AltUp}
  112.         Sleep, 10
  113.         Send, {PgUp}{Down}{Enter}
  114.     }
  115.     else
  116.         Send, ^2
  117.     return
  118. }
  119.  
  120. three() {
  121.     if WinActive("ahk_class tSkMainForm") {
  122.         Send, {AltDown}2{AltUp}
  123.         Sleep, 10
  124.         Send, {PgUp}{Down}{Down}{Enter}
  125.     }
  126.     else
  127.         Send, ^3
  128.     return
  129. }
  130.  
  131. four() {
  132.     if WinActive("ahk_class tSkMainForm") {
  133.         Send, {AltDown}2{AltUp}
  134.         Sleep, 10
  135.         Send, {PgUp}{Down}{Down}{Down}{Enter}
  136.     }
  137.     else
  138.         Send, ^4
  139.     return
  140. }
  141.  
  142. five() {
  143.     if WinActive("ahk_class tSkMainForm") {
  144.         Send, {AltDown}2{AltUp}
  145.         Sleep, 10
  146.         Send, {PgUp}{Down}{Down}{Down}{Down}{Enter}
  147.     }
  148.     else
  149.         Send, ^5
  150.     return
  151. }
  152.  
  153. six() {
  154.     if WinActive("ahk_class tSkMainForm") {
  155.         Send, {AltDown}2{AltUp}
  156.         Sleep, 10
  157.         Send, {PgUp}{Down}{Down}{Down}{Down}{Down}{Enter}
  158.     }
  159.     else
  160.         Send, ^6
  161.     return
  162. }
  163.  
  164. seven() {
  165.     if WinActive("ahk_class tSkMainForm") {
  166.         Send, {AltDown}2{AltUp}
  167.         Sleep, 10
  168.         Send, {PgUp}{Down}{Down}{Down}{Down}{Down}{Down}{Enter}
  169.     }
  170.     else
  171.         Send, ^7
  172.     return
  173. }
  174.  
  175. eight() {
  176.     if WinActive("ahk_class tSkMainForm") {
  177.         Send, {AltDown}2{AltUp}
  178.         Sleep, 10
  179.         Send, {PgUp}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Enter}
  180.     }
  181.     else
  182.         Send, ^8
  183.     return
  184. }
  185.  
  186. nine() {
  187.     if WinActive("ahk_class tSkMainForm") {
  188.         Send, {AltDown}2{AltUp}
  189.         Sleep, 10
  190.         Send, {PgUp}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Down}{Enter}
  191.     }
  192.     else
  193.         Send, ^9
  194.     return
  195. }
  196. ; =========== End of functions =====================================
  197.  
  198. ; Tab Back & Forward:
  199. *^WheelLeft::TabBack()
  200. *^WheelRight::TabFwd()
  201. *^Left::TabBack()
  202. *^Right::TabFwd()
  203.  
  204. ; Skype only tab switching:
  205. *^Down::SkypeConversationDown()
  206. *^Up::SkypeConversationUp()
  207.  
  208. ; History Back & Forward:
  209. LAlt & WheelLeft::HistoryBack()
  210. LAlt & WheelRight::HistoryFwd()
  211.  
  212.  
  213. ; Switch tabs using alt+nr instead of ctrl; in case of Skype, switch chat windows (uses different function):
  214. LAlt & 1::one()
  215. LAlt & 2::two()
  216. LAlt & 3::three()
  217. LAlt & 4::four()
  218. LAlt & 5::five()
  219. LAlt & 6::six()
  220. LAlt & 7::seven()
  221. LAlt & 8::eight()
  222. LAlt & 9::nine()
  223.  
  224. ; Firefox tabgroup movement:
  225. ^+WheelLeft::FF_tabgroup_back()
  226. ^+WheelRight::FF_tabgroup_fwd()
  227.  
  228. ; Close active window witn Win + c
  229. LWin & c::Send !{F4}
  230.  
  231. ; Maximize or restore window:
  232. LWin & x::max_restore()
  233.  
  234. ; ==============================================================
  235. ; ======== Swap Esc and Caps Lock ========
  236. CapsOn=false
  237.  
  238.  
  239. Capslock::caps()
  240.  
  241.  
  242. Esc::
  243.     ;use global variable to keep track of state
  244.     if CapsOn = false
  245.     {
  246.      CapsOn = true
  247.      SetCapsLockState, on
  248.     }
  249.     else
  250.     {
  251.      CapsOn = false
  252.      SetCapsLockState, off
  253.     }
  254.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement