Advertisement
dale3h

[AutoHotKey] System Startup Script

Apr 5th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Create a shortcut to: "C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\ahk\init.d.ahk"
  2.  
  3. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  4. #SingleInstance force
  5. #NoTrayIcon
  6.  
  7. ; Run any Autohotkey scripts inside of .\init.d\
  8. Loop, .\init.d\*.ahk
  9.   Run, %A_LoopFileLongPath%
  10.  
  11. ; Run any compiled Autohotkey scripts inside of .\init.d\
  12. Loop, .\init.d\*.exe
  13.   Run, %A_LoopFileLongPath%
  14.  
  15. ;Run, .\ISense\ISense.ahk
  16.  
  17. ;;;;;;;;;;;;;;;;;; Custom Text Shortcuts ;;;;;;;;;;;;;;;;;;
  18.  
  19. ;::skp::http://db.tt/g3NLgMy
  20.  
  21. ;;;;;;;;;;;;;;;;;; Custom Key Maps ;;;;;;;;;;;;;;;;;;
  22.  
  23. ; Map Ctrl+F12 to reload the script
  24. ^F12::
  25. {
  26.   Reload
  27.   Return
  28. }
  29.  
  30. #s::
  31. {
  32.   Run, nircmd lockws
  33.   Sleep, 2000
  34.   Run, nircmd monitor off
  35.   Return
  36. }
  37.  
  38. ; Map Pause to middle click (for stupid FK'n SetPoint)
  39. Pause::
  40. {
  41.   Click, Middle
  42.   Return
  43. }
  44.  
  45. ; Map Alt+9 to hyperlink text
  46. !9::
  47. {
  48.   Sleep, 100
  49.   clipurl := Clipboard
  50.   Send ^c
  51.   Sleep, 50
  52.   clipurl2 := "<a href=""" . clipurl . """ title="""">" . clipboard . "</a>"
  53.   SendInput {Raw}%clipurl2%
  54.   Clipboard := clipurl
  55.   clipurl =;
  56.   Return
  57. }
  58.  
  59. ; Map Alt+0 to img the clipboard
  60. !0::
  61. {
  62.   Sleep, 100
  63.   clipurl := Clipboard
  64.   clipurl2 := "<img src=""" . clipurl . """ width="""" height="""" border=""0"" alt="""" />"
  65.   SendInput {Raw}%clipurl2%
  66.   clipurl =;
  67.   Return
  68. }
  69.  
  70. ; Map Win+KeypadN to resizing windows to sections on the desktop
  71. #Numpad1::
  72. {
  73.   ; Bottom-Left Monitor: Left Side of Screen
  74.   WinMove, A, , -1920, 0, 1287, 1040
  75.   Return
  76. }
  77. #Numpad2::
  78. {
  79.   ; Bottom-Left Monitor: Right Side of Screen
  80.   WinMove, A, , -1287, 0, 1287, 1040
  81.   Return
  82. }
  83. #Numpad4::
  84. {
  85.   ; Bottom-Center Monitor: Left Side of Screen
  86.   WinMove, A, , 0, 0, 1287, 1040
  87.   Return
  88. }
  89. #Numpad5::
  90. {
  91.   ; Bottom-Center Monitor: Right Side of Screen
  92.   WinMove, A, , 633, 0, 1287, 1040
  93.   Return
  94. }
  95. #Numpad3::
  96. {
  97.   ; Bottom-Right Monitor: Left Side of Screen
  98.   WinMove, A, , 1920, 0, 1287, 1040
  99.   Return
  100. }
  101. #Numpad6::
  102. {
  103.   ; Bottom-Right Monitor: Right Side of Screen
  104.   WinMove, A, , 2553, 0, 1287, 1040
  105.   Return
  106. }
  107. #Numpad7::
  108. {
  109.   ; Top-Center Monitor: Left Side of Screen
  110.   WinMove, A, , 0, -1080, 1287, 1040
  111.   Return
  112. }
  113. #Numpad8::
  114. {
  115.   ; Top-Center Monitor: Right Side of Screen
  116.   WinMove, A, , 633, -1080, 1287, 1040
  117.   Return
  118. }
  119.  
  120. ; Map Ctrl+Win+P to copy current IP to clipboard
  121. ^#p::
  122. {
  123.   UrlDownloadToFile, https://api.ipify.org/, ip.txt
  124.   FileRead, currentIP, ip.txt
  125.   FileDelete, ip.txt
  126.  
  127.   Clipboard = %currentIP%
  128.   Return
  129. }
  130.  
  131. ; Map Win+P to output current IP
  132. #p::
  133. {
  134.   UrlDownloadToFile, https://api.ipify.org/, ip.txt
  135.   FileRead, currentIP, ip.txt
  136.   FileDelete, ip.txt
  137.  
  138.   Send, %currentIP%
  139.   Return
  140. }
  141.  
  142. ; Map Double RShift to Launchy
  143. ;~RShift::DoubleKey("{Alt Down}{Space}{Alt Up}", 350)
  144. ;~LShift::DoubleKey("{Alt Down}{Space}{Alt Up}", 350)
  145.  
  146. ; Map Double LShift to KeePass
  147. ;~LShift Up::DoubleKey("^!k", 350)
  148.  
  149. ; Map Double LCtrl to KeePass Auto-fill
  150. ;~LCtrl Up::DoubleKey("^!a", 350)
  151.  
  152. ; Map Ctrl+Shift+F5 to build Dropbox.u3p
  153. ;^+F5::
  154. ;{
  155. ;  Run, C:\ahk\u3\Dropbox\Build.lnk
  156. ;  Return
  157. ;}
  158.  
  159. ; Detect clipboard change and trim contents
  160. ;OnClipboardChange:
  161. ;{
  162. ;  Clipboard = %Clipboard%
  163. ;  ToolTip, Clipboard contents have been trimmed
  164. ;  Sleep, 1500
  165. ;  ToolTip
  166. ;  Return
  167. ;}
  168.  
  169. ; Map Win+Capslock as a dedicated minimize button
  170. IfEqual, A_ComputerName, DALE3H-MOBILE
  171. {
  172.   #IfWinNotActive, ahk_class SynergyDesk
  173.   {
  174.     #Capslock::WinMinimize,A
  175.     Return
  176.   }
  177.   Return
  178. }
  179.  
  180. ; Map Insert key to nothing
  181. ;Insert::
  182. ;{
  183. ;  Return
  184. ;}
  185.  
  186. ; Map Ctrl+Insert key to append-to-clipboard
  187. ;+Insert::
  188. ;{
  189. ;  bak = %Clipboard%
  190. ;  Send, ^c
  191. ;  Clipboard = %bak%`r`n%Clipboard%
  192. ;  Return
  193. ;}
  194.  
  195. ; Map Alt+Insert as a template paste feature
  196. ;!Insert::
  197. ;{
  198. ;  bak = %Clipboard%
  199. ;  Send, ^c
  200. ;  StringReplace, Clipboard, bak, @@, %Clipboard%
  201. ;  Send, ^v
  202. ;  Clipboard = %bak%
  203. ;  Return
  204. ;}
  205.  
  206. ; Map Alt+` to hide/show launch TeamViewer
  207. !`::
  208. {
  209.   DetectHiddenWindows, On
  210.   IfWinExist, TeamViewer ahk_class #32770
  211.   {
  212.     IfWinActive
  213.     {
  214.       WinHide
  215.       WinActivate, Program Manager
  216.     }
  217.     Else
  218.     {
  219.       WinShow
  220.       WinActivate
  221.     }
  222.   }
  223.   Else
  224.   {
  225.     Run, "C:\Program Files (x86)\TeamViewer\TeamViewer.exe"
  226.   }
  227.   DetectHiddenWindows, Off
  228.   Return
  229. }
  230.  
  231. ; Map Ctrl+Shift+K to open www version file of current file
  232. #IfWinActive, EditPlus -
  233. {
  234.   ^+k::
  235.   {
  236.     Send, ^+g
  237.     Send, ^c
  238.     Send, {Esc}
  239.     Send, ^+o
  240.     Send, ^v
  241.     Send, {Home}{Right}
  242.     Send, {Shift Down}{Right}{Right}{Right}{Right}{Shift Up}
  243.     Send, www{Enter}
  244.   }
  245.   Return
  246. }
  247.  
  248. #IfWinActive, ahk_class Console_2_Main
  249. {
  250.   Esc::
  251.   {
  252.     WinHide, ahk_class Console_2_Main
  253.     WinActivate, ahk_class Shell_TrayWnd
  254.   }
  255.   ^d::
  256.   {
  257.     WinHide, ahk_class Console_2_Main
  258.     WinActivate, ahk_class Shell_TrayWnd
  259.   }
  260.   Return
  261. }
  262.  
  263. ; Map Ctrl+D in command prompt to exit
  264. #IfWinActive, ahk_class ConsoleWindowClass
  265. {
  266.   ^d::
  267.   {
  268.     WinKill, A
  269.   }
  270.   Return
  271. }
  272.  
  273. ; Map Ctrl+L to F6 (location bar) in IE
  274. #IfWinActive, ahk_class IEFrame
  275. {
  276.   ^l::
  277.   {
  278.     Send, {F6}
  279.   }
  280.   Return
  281. }
  282.  
  283. ; Map Ctrl+W to Exit in HomeSeer
  284. #IfWinActive, ahk_class WindowsForms10.Window.8.app.0.378734a
  285. {
  286.   ^w::
  287.   {
  288.     Send, !f
  289.     Send, {Up}{Enter}
  290.   }
  291.   Return
  292. }
  293.  
  294. ; Double tap extender
  295. ;DoubleKey(sendKeys, timeout)
  296. ;{
  297. ;  If (A_PriorHotKey = A_ThisHotKey AND A_TimeSincePriorHotkey < timeout)
  298. ;    Send, %sendKeys%
  299. ;}
  300.  
  301. ; Custom functions for code listed above
  302. UrlDownloadToVar(URL, Proxy="", ProxyBypass="") {
  303.   AutoTrim, Off
  304.   hModule := DllCall("LoadLibrary", "str", "wininet.dll")
  305.  
  306.   If (Proxy != "")
  307.     AccessType=3
  308.   Else
  309.     AccessType=1
  310.   ;INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
  311.   ;INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
  312.   ;INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
  313.   ;INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS
  314.  
  315.   io_hInternet := DllCall("wininet\InternetOpenA"
  316.   , "str", "" ;lpszAgent
  317.   , "uint", AccessType
  318.   , "str", Proxy
  319.   , "str", ProxyBypass
  320.   , "uint", 0) ;dwFlags
  321.  
  322.   iou := DllCall("wininet\InternetOpenUrlA"
  323.   , "uint", io_hInternet
  324.   , "str", url
  325.   , "str", "" ;lpszHeaders
  326.   , "uint", 0 ;dwHeadersLength
  327.   , "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item
  328.   , "uint", 0) ;dwContext
  329.  
  330.   If (ErrorLevel != 0 or iou = 0) {
  331.     DllCall("FreeLibrary", "uint", hModule)
  332.     return 0
  333.   }
  334.  
  335.   VarSetCapacity(buffer, 512, 0)
  336.   VarSetCapacity(NumberOfBytesRead, 4, 0)
  337.   Loop
  338.   {
  339.     irf := DllCall("wininet\InternetReadFile", "uint", iou, "uint", &buffer, "uint", 512, "uint", &NumberOfBytesRead)
  340.     NOBR = 0
  341.     Loop 4  ; Build the integer by adding up its bytes. - ExtractInteger
  342.       NOBR += *(&NumberOfBytesRead + A_Index-1) << 8*(A_Index-1)
  343.     IfEqual, NOBR, 0, break
  344.     ;BytesReadTotal += NOBR
  345.     DllCall("lstrcpy", "str", buffer, "uint", &buffer)
  346.     res = %res%%buffer%
  347.   }
  348.   StringTrimRight, res, res, 2
  349.  
  350.   DllCall("wininet\InternetCloseHandle",  "uint", iou)
  351.   DllCall("wininet\InternetCloseHandle",  "uint", io_hInternet)
  352.   DllCall("FreeLibrary", "uint", hModule)
  353.   AutoTrim, on
  354.   return, res
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement