Advertisement
DeletusCletus

Intercept Preset

Dec 16th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.83 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  3. ;SetWorkingDir, C:\AHK\2nd-keyboard\ ;Or you could put the directory here. Whatevs.
  4. Menu, Tray, Icon, shell32.dll, 283 ;changes the taskbar icon to something
  5. ;SetKeyDelay, 0 ;IDK exactly what this does.
  6.  
  7. ;;EXACT LOCATION FOR WHERE TO PUT THIS SCRIPT:
  8. ; C:\AHK\2nd-keyboard\Intercept
  9.  
  10. ;;Location for where to put a shortcut to the script, such that it will start when Windows starts:
  11. ;; Here for just yourself:
  12. ;; C:\Users\YOUR_USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
  13. ;; Or here for all users:
  14. ;; C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
  15.  
  16. #NoEnv
  17. SendMode Input
  18. #InstallKeybdHook
  19. ;#InstallMouseHook ;<--You'll want to use this if you have scripts that use the mouse.
  20. #UseHook On
  21. #SingleInstance force ;only one instance of this script may run at a time!
  22. #MaxHotkeysPerInterval 2000
  23.  
  24. ;;The lines below are optional. Delete them if you need to.
  25. #HotkeyModifierTimeout 60 ; https://autohotkey.com/docs/commands/_HotkeyModifierTimeout.htm
  26. #KeyHistory 200 ; https://autohotkey.com/docs/commands/_KeyHistory.htm ; useful for debugging.
  27. #MenuMaskKey vk07 ;https://autohotkey.com/boards/viewtopic.php?f=76&t=57683
  28. #WinActivateForce ;https://autohotkey.com/docs/commands/_WinActivateForce.htm ;prevent taskbar flashing.
  29. ;;The lines above are optional. Delete them if you need to.
  30.  
  31. ;________________________________________________________________________________________
  32. ;
  33. ; 2ND KEYBOARD USING INTERCEPTION AND INTERCEPT.exe (Logitech K120)
  34. ;________________________________________________________________________________________
  35.  
  36. ; Please watch https://www.youtube.com/watch?v=y3e_ri-vOIo for a comprehensive tutorial.
  37. ;________________________________________________________________________________________
  38.  
  39. ; DANGER: Installing interception may cause your USB devices to stop working sometimes, because it is limited to supporting only 10 of each device class. You have to uninstall it to fix that. Here is a follow up video with new information: https://www.youtube.com/watch?v=Hn18vv--sFY
  40.  
  41. ; For this reason, I now use the Hasu USB to USB keyboard converter. It's sweet.
  42. ; https://www.1upkeyboards.com/shop/controllers/usb-to-usb-converter/
  43.  
  44. ;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||;;
  45. ;;||||||||||||| BEGIN SECOND KEYBOARD INTERCEPTION F23 ASSIGNMENTS ||||||||||||;;
  46. ;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||;;
  47.  
  48. ;; You should DEFINITELY not be trying to add a 2nd keyboard unless you're already
  49. ;; familiar with how AutoHotkey works. I recommend that you at least take this tutorial:
  50. ;; https://autohotkey.com/docs/Tutorial.htm
  51.  
  52. ;; You should probably use something better than Notepad for your scripting. (Do NOT use Word.)
  53. ;; I use Notepad++. "Real" programmers recoil from it, but it's fine for my purposes.
  54. ;; https://notepad-plus-plus.org/
  55. ;; You'll probably want the syntax highlighting: https://stackoverflow.com/questions/45466733/autohotkey-syntax-highlighting-in-notepad
  56.  
  57.  
  58. ;;;WARNING - THIS IS KINDA UNTESTED SINCE I STOPPED USING IT. LET ME KNOW IF YOU HAVE ANY ISSUES, BY LEAVING A GITHUB... ISSUE. https://github.com/TaranVH/2nd-keyboard/issues
  59.  
  60.  
  61. #if (getKeyState("F23", "P")) ;<--Everything after this line will only happen on the secondary keyboard that uses F23.
  62. F23::return ;this line is mandatory for proper functionality
  63.  
  64. escape::tooltip, [F23] You might wish to not give a command to escape. Could cause problems. IDK.
  65. ;escape::return ;<--to disable a key, just use a "return," like so.
  66.  
  67. F1::
  68. F2::
  69. F3::
  70. F4::
  71. F5::
  72. F6::
  73. F7::
  74. F9::
  75. F8::
  76. F10::
  77. F11::
  78. F12::
  79. ;;Note that the assignment on the above line will apply to ALL prior lines ending in "::"
  80. ;;...which you should know from the AHK tutorial I linked you to.
  81.  
  82. ;;------------------------NEXT ROW--------------------------;;
  83.  
  84. `::
  85. 1::Send, ^{F2}
  86. 2::Send, +{F3}
  87. 3::Send, +{F4}
  88. 4::
  89. 5::
  90. 6::
  91. 7::
  92. 8::
  93. 9::
  94. 0::Send, ^{F1}
  95. -::
  96. =::
  97. backspace::
  98.  
  99. ;;------------------------NEXT ROW--------------------------;;
  100.  
  101. tab::tooltip, [F23] %A_thisHotKey%
  102. q::
  103. w::
  104. e::
  105. r::
  106. t::
  107. y::
  108. u::
  109. i::
  110. o::
  111. p::
  112. [::
  113. ]::
  114. \::tooltip, [F23] %A_thisHotKey%
  115. ;;capslock::tooltip, [F23] capslock - this should have been remapped to F20. Don't use this line.
  116.  
  117. ;;------------------------NEXT ROW--------------------------;;
  118.  
  119. a::
  120. s::
  121. d::
  122. f::
  123. g::
  124. h:: Send, {Ctrl Down}{` Down}{` Up}{Ctrl Up}
  125. j:: Send, ^!{1}
  126. K::
  127. l::
  128. `;::
  129. ;for the above line, (semicolon) note that the ` is necessary as an escape character -- and that the syntax highlighting might get it wrong.
  130. '::
  131. enter::
  132.  
  133. ;;------------------------NEXT ROW--------------------------;;
  134.  
  135. z::
  136. x::
  137. c::
  138. v::
  139. b::
  140. n::
  141. m::
  142. ,::
  143. .::
  144. /::t
  145.  
  146. space::
  147. tooltip, [F23] SPACEBAR. This will now clear remaining tooltips.
  148. sleep 500
  149. tooltip,
  150. return
  151. ;;And THAT^^ is how you do multi-line instructions in AutoHotkey.
  152. ;;Notice that the very first line, "space::" cannot have anything else on it.
  153. ;;Again, these are fundamentals that you should have learned from the tutorial.
  154.  
  155.  
  156. ;;===================== MODIFIERS =========================;;
  157.  
  158. ;;Keep these commented out, as they are!
  159. ;Lshift::tooltip, do not use
  160. ;Lctrl::tooltip, do not use
  161. ;Lwin::tooltip, do not use
  162. ;Lalt::tooltip, do not use
  163.  
  164. ;Ralt::tooltip, do not use
  165. ;Rwin::tooltip, do not use
  166. ;appskey::tooltip, This is not a modifier, but I replaced it with INTERNATIONAL4 (SC079) anyway, because it was able to misbehave.
  167. ;Rctrl::tooltip, do not use
  168. ;Rshift::tooltip, do not use
  169.  
  170.  
  171. ;;If you leave the modifier keys alone, it allows for lines like the ones below:
  172. ;+z::tooltip, you pressed SHIFT Z on the F23 keyboard.
  173. ;^z::tooltip, you pressed CTRL Z on the F23 keyboard.
  174. ;!z::tooltip, you pressed ALT Z on the F23 keyboard. I don't recommend this... ALT is dangerous because of menu acceleration, even if you try to disable it like I have
  175. ;^!z::tooltip, you pressed CTRL SHIFT Z on the F23 keyboard.
  176. ;;Etc.
  177. ;;However, I use few to no modifiers on my secondary keyboards... I prefer tap dance instead. The decision is up to you.
  178.  
  179.  
  180. ;;================= MODIFIERS REMAPPED ======================;;
  181.  
  182. ;; When you replace these with your own functions, I recommend that you do NOT delete the tooltips. Just comment them out. That way, you always know what was changed to what. It gets very confusing very quickly otherwise.
  183. ;; Here is the full list of scan code substitutions that I made:
  184. ;; https://docs.google.com/spreadsheets/d/1GSj0gKDxyWAecB3SIyEZ2ssPETZkkxn67gdIwL1zFUs/edit#gid=824607963
  185.  
  186. SC070::tooltip, [F23] Lshift -to-> SC070-International 2
  187. SC071::tooltip, [F23] LCtrl -to-> SC071-Language 2
  188. SC072::tooltip, [F23] LWin -to-> SC072-Language 1
  189. SC073::tooltip, [F23] LAlt -to-> SC073-International 1
  190.  
  191. SC077::tooltip, [F23] RAlt -to-> SC077-Language 4
  192. SC078::tooltip, [F23] RWin -to-> SC078-Language 3
  193. SC079::tooltip, [F23] AppsKey -to-> SC079-International 4
  194. SC07B::tooltip, [F23] RCtrl -to-> SC07B-International 5
  195. SC07D::tooltip, [F23] RShift -to-> SC07D-International 3
  196.  
  197. ;;================= LOCKING KEYS ======================;;
  198.  
  199. F20::tooltip, [F23] CapsLock -to-> SC06B-F20
  200. SC05C::tooltip, [F23] NumLock -to-> SC05C-International 6
  201. ;Numlock is an AWFUL key. I prefer to leave it permanently on.
  202. ;It's been changed to International 6, so you can use it with no fear that it'll mess up your numpad.
  203. SC061::tooltip, [F23] ScrollLock -to-> SC061 %A_thishotKey%
  204.  
  205. ;;================= NEXT SECTION ======================;;
  206.  
  207. PrintScreen::tooltip, [F23] %A_thishotKey%
  208. ;;ScrollLock::do not use
  209. SC07E::tooltip, [F23] Pause -to-> SC07E-Brazillian comma
  210.  
  211. ;;Don't use the 3 keys below for your 2nd keyboard!
  212. ;Pause::msgbox, The Pause/Break key is a huge PITA. That's why I remapped it to SC07E
  213. ;Break::msgbox, Or is it THIS key? WHO KNOWS!
  214. ;CtrlBreak::msgbox, I have no idea what Ctrlbreak is. But it shows up sometimes.
  215. ;;Don't use the 3 keys above for your 2nd keyboard! Just don't!!
  216.  
  217. insert::
  218. delete::tooltip, [F23] %A_thishotKey%
  219.  
  220. home::
  221. end::tooltip, [F23] %A_thishotKey%
  222.  
  223. pgup::
  224. pgdn::tooltip, [F23] %A_thishotKey%
  225.  
  226. ;;================= NEXT SECTION ======================;;
  227.  
  228. up::
  229. down::
  230. left::
  231. right::tooltip,[F23] %A_thishotKey%
  232.  
  233. ;;================== THE NUMPAD ======================;;
  234.  
  235. numpad0::
  236. numpad1::
  237. numpad2::
  238. numpad3::
  239. numpad4::
  240. numpad5::
  241. numpad6::
  242. numpad7::
  243. numpad8::
  244. numpad9::tooltip,[F23] %A_thishotKey%
  245.  
  246.  
  247. ;;NumLock::tooltip, DO NOT USE THIS IN YOUR 2ND KEYBOARD!
  248. numpadDiv::
  249. numpadMult::
  250. numpadSub::
  251. numpadAdd::
  252. numpadEnter::
  253. numpadDot::tooltip, [F23] %A_thishotKey%
  254.  
  255.  
  256. #if ;this line will end the F23 secondary keyboard assignments.
  257.  
  258. ;;;--------------------IMPORTANT: HOW TO USE #IF THINGIES----------------------
  259.  
  260. ;;You can use more than one #if thingy at a time, but it must be done like so:
  261. #if (getKeyState("F23", "P")) and if WinActive("ahk_exe Adobe Premiere Pro.exe")
  262. F1::msgbox, You pressed F1 on your secondary keyboard while inside of Premiere Pro
  263.  
  264. ;; HOWEVER, You still would still need to block F1 using #if (getKeyState("F23", "P"))
  265. ;; If you don't, it'll pass through normally, any time Premiere is NOT active.
  266. ;; Does that make sense? I sure hope so.
  267.  
  268. ;; Alternatively, you can use the following: (Comment it in, and comment out other instances of F1::)
  269. ; #if (getKeyState("F23", "P"))
  270. ; F1::
  271. ; if WinActive("ahk_exe Adobe Premiere Pro.exe")
  272. ; {
  273. ; msgbox, You pressed F1 on your secondary keyboard while inside of Premiere Pro
  274. ; msgbox, And you did it by using if WinActive()
  275. ; }
  276. ; else
  277. ; msgbox, You pressed F1 on your secondary keyboard while NOT inside of Premiere Pro
  278. ;;This is easier to understand, but it's not as clean of a solution.
  279.  
  280. ;; #if (getKeyState("F23", "P")) && (uselayer = 0) ;;you can also use a varibable like so, but I don't.
  281.  
  282. ;; Here is a discussion about all this:
  283. ;; https://github.com/TaranVH/2nd-keyboard/issues/65
  284.  
  285. ;;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  286. ;;+|||||||||+ END OF INTERCEPTION SECOND KEYBOARD F23 ASSIGNMENTS +|||||||||||||+
  287. ;;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  288.  
  289. ;;Note that this whole script was written for North American keyboard layouts.
  290. ;;IDK what you foreign language peoples are gonna have to do!
  291. ;;At the very least, you'll have some duplicate keys.
  292.  
  293.  
  294. #if
  295.  
  296. ;;*******************************************************************************
  297. ;;~~~~~~~~~~~~~DEFINE YOUR NORMAL KEY ASSIGNMENTS BELOW THIS LINE~~~~~~~~~~~~~~~~
  298. ;;*******************************************************************************
  299.  
  300. ;;If you assign them BEFORE the second keyboard, they'll overrule it. You don't want that.
  301. #ifwinactive ahk_exe ahk_exe Adobe Premiere Pro.exe
  302. F2::msgbox, You pressed F2 on your normal keyboard while inside of Premiere Pro. `nThis is an autohotkey script by the way - in case you forgot.`nCheck your taskbar to find it.
  303. ;; You can of course delete the above line.
  304. #ifwinactive
  305.  
  306. ;;~~~~~~~~~~~~~~~~~DEFINE YOUR FUNCTIONS BELOW THIS LINE~~~~~~~~~~~~~~~~~~~~~~~~~
  307.  
  308.  
  309. coolFunction(stuff)
  310. {
  311. msgbox, You called a function with the following parameter:`n`n%stuff%`n`nCongrats!
  312. msgbox, You can put whatever you like in here. `nI've provided links to the functions I use.
  313. ; https://github.com/TaranVH/2nd-keyboard/blob/master/Almost_All_Premiere_Functions.ahk
  314. ; https://github.com/TaranVH/2nd-keyboard/blob/master/Almost_All_Windows_Functions.ahk
  315. ; NOTE that I use #include, rather than writing them out in the same .ahk file.
  316. ; https://autohotkey.com/docs/commands/_Include.htm
  317. ; This allows me to do fancy stuff, like direct launching scripts from my Stream Deck.
  318. ; But you don't need to do that at all. Just write out your functions in the same script.
  319. }
  320.  
  321. anotherFunction(yeah)
  322. {
  323. msgbox, yup %yeah%
  324. ;Just delete this function, lol
  325. }
  326.  
  327.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement