EntropicBlackhole

General Hotkeys

Oct 20th, 2021 (edited)
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Persistent
  2. #NoEnv
  3. #SingleInstance, Force
  4. SetTitleMatchMode, 2
  5. :*:(::(){left}
  6. :*:{::{{}{}}{left}}
  7. :*:[::[]{left}
  8. *^+d::Run, C:\Users\%A_UserName%\Downloads
  9. ^!m::ToolTipTimer(Morse(Gst(), "t"), 5000)
  10. !WheelUp::GoSub, GeometricVolumeUp
  11. !WheelDown::GoSub, GeometricVolumeDown
  12. !MButton::Send, {Media_Play_Pause}
  13. !RButton::Send, !r
  14. !LButton::Send, ^s
  15. ;^+c::Goto, SearchGoogle
  16. ;^+x::Goto, SearchGoogle
  17. ^!c::Goto, Copy+
  18. ^!x::Goto, Copy+
  19. Numpad1::SetWallpaper("C:\Users\" A_UserName "\OneDrive\Pictures\Saved Pictures\pic1.jpg")
  20. Numpad2::SetWallpaper("C:\Users\" A_UserName "\OneDrive\Pictures\Saved Pictures\pic2.jpg")
  21. Numpad3::SetWallpaper("C:\Users\" A_UserName "\OneDrive\Pictures\Saved Pictures\pic3.jpg")
  22. Numpad4::SetWallpaper("C:\Users\" A_UserName "\OneDrive\Pictures\Saved Pictures\pic4.jpg")
  23. Numpad5::SetWallpaper("C:\Users\" A_UserName "\OneDrive\Pictures\Saved Pictures\pic5.jpg")
  24. #IfWinNotActive ahk_exe javaw.exe
  25. MButton::Send, {Browser_Back}
  26. #If
  27. ^+Space:: Winset, Alwaysontop, , A
  28. >!0::Send,
  29. >!1::Send,
  30. >!2::Send,
  31. >!3::Send,
  32. >!4::Send,
  33. >!5::Send, π
  34. >!6::Send, α
  35. >!7::Send, β
  36. >!8::Send, θ
  37. >!9::Send, °
  38. <!1::Send, ¹
  39. <!2::Send, ²
  40. <!3::Send, ³
  41. <!4::Send,
  42. <!5::Send,
  43. <!6::Send,
  44. <!7::Send,
  45. <!8::Send,
  46. <!9::Send,
  47. <!0::Send,
  48. return
  49.  
  50. ~LButton::
  51. MouseGetPos,,, winID
  52. if (winID = WinExist("ahk_class tooltips_class32"))
  53.     WinClose, ahk_id %winID%
  54. return
  55.  
  56. GeometricVolumeUp:
  57. SoundGet, current_volume
  58. volume_change := current_volume//10
  59. SoundSet, +%volume_change%
  60. Send {Volume_Up}
  61. return
  62.  
  63. GeometricVolumeDown:
  64. SoundGet, current_volume
  65. volume_change := current_volume//10
  66. SoundSet, -%volume_change%
  67. Send {Volume_Down}
  68. return
  69.  
  70. Pause::
  71. gLC := getLinearCoords(x_start, x_end, y_start, y_end)
  72. ToolTip, %gLC%
  73. clipboard := gLC
  74. SetTimer, RemoveToolTip, -5000
  75. return
  76.  
  77. +Pause::
  78. gSC := getSelectionCoords(x_start, x_end, y_start, y_end)
  79. ToolTip, %gSC%
  80. clipboard := gSC
  81. SetTimer, RemoveToolTip, -5000
  82. return
  83.    
  84. #IfWinNotActive, ahk_exe javaw.exe
  85. +WheelUp::
  86. +WheelDown::
  87. #If
  88. NumpadAdd::
  89. NumpadSub::
  90. MouseGetPos,,, currentWindow
  91. if not (%currentWindow%)
  92.     GoSub GetTransparent
  93. if InStr(A_ThisHotkey, "Up") || InStr(A_ThisHotkey, "Add")
  94.     if (%currentWindow% < 255)
  95.         %currentWindow% += 25
  96. if InStr(A_ThisHotkey, "Down") || InStr(A_ThisHotkey, "Sub")
  97.     if (%currentWindow% > 5) ||
  98.         %currentWindow% -= 25
  99. WinSet, Transparent, % %currentWindow%, ahk_id %currentWindow%
  100. return
  101.  
  102.  
  103. GetTransparent:
  104. WinGet, ExStyle, ExStyle, ahk_id %currentWindow%
  105. if (ExStyle & 0x80000)
  106. {
  107.     WinGet, TransLevel, Transparent, ahk_id %currentWindow%
  108.     %currentWindow% := TransLevel
  109. }
  110. else
  111.     %currentWindow% := 255
  112. Return
  113.  
  114. SearchGoogle:
  115. backupclip := clipboard
  116. Send, % StrReplace(A_ThisHotkey, "+")
  117. if (clipboard = backupclip)
  118.     Goto, SearchGoogle
  119. Sleep 50
  120. Msgbox, % WinActive("Chrome")
  121. if WinActive("Chrome")
  122. {
  123.     Send, ^t
  124.     Send, ^v
  125.     Send, {Enter}
  126. }
  127. else
  128.     Run, http://www.google.com/search?q=%clipboard%
  129. return
  130.  
  131. Copy+:
  132. clipbackup := clipboard
  133. Send, % StrReplace(A_ThisHotkey, "!")
  134. clipboard := clipbackup "`n" clipboard
  135. KeyWait, %A_ThisHotkey%
  136. return
  137.  
  138. getSelectionCoords(ByRef x_start, ByRef x_end, ByRef y_start, ByRef y_end) {
  139.     SetSystemCursor("IDC_Cross")
  140.     Gui, Color, FFFFFF
  141.     Gui +LastFound
  142.     WinSet, Transparent, 50
  143.     Gui, -Caption
  144.     Gui, +AlwaysOnTop
  145.     Gui, Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%,"AutoHotkeySnapshotApp"    
  146.     CoordMode, Mouse, Screen
  147.     CoordMode, Tooltip, Screen
  148.     WinGet, hw_frame_m,ID,"AutoHotkeySnapshotApp"
  149.     hdc_frame_m := DllCall( "GetDC", "uint", hw_frame_m)
  150.     KeyWait, LButton, D
  151.     MouseGetPos, scan_x_start, scan_y_start
  152.     Loop
  153.     {
  154.         Sleep, 10  
  155.         KeyIsDown := GetKeyState("LButton")
  156.         if (KeyIsDown = 1)
  157.         {
  158.             MouseGetPos, scan_x, scan_y
  159.             DllCall( "gdi32.dll\Rectangle", "uint", hdc_frame_m, "int", 0,"int",0,"int", A_ScreenWidth,"int",A_ScreenWidth)
  160.             DllCall( "gdi32.dll\Rectangle", "uint", hdc_frame_m, "int", scan_x_start,"int",scan_y_start,"int", scan_x,"int",scan_y)
  161.         } else {
  162.             break
  163.         }
  164.     }
  165.     MouseGetPos, scan_x_end, scan_y_end
  166.     Gui, Destroy
  167.     RestoreCursors()
  168.     return scan_x_start ", "scan_y_start ", "scan_x_end ", "scan_y_end
  169. }
  170. getLinearCoords(ByRef x_start, ByRef x_end, ByRef y_start, ByRef y_end) {
  171.     SetSystemCursor("IDC_Cross")
  172.     Gui, Color, FFFFFF
  173.     Gui +LastFound
  174.     WinSet, Transparent, 50
  175.     Gui, -Caption
  176.     Gui, +AlwaysOnTop +ToolWindow
  177.     Gui, Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%,"AutoHotkeySnapshotApp"  
  178.     GuiHwnd := WinExist()
  179.     CoordMode, Mouse, Screen
  180.     CoordMode, Tooltip, Screen
  181.     WinGet, hw_frame_m,ID,"AutoHotkeySnapshotApp"
  182.     hdc_frame_m := DllCall( "GetDC", "uint", hw_frame_m)
  183.     KeyWait, LButton, D
  184.     MouseGetPos, scan_x_start, scan_y_start
  185.     Loop
  186.     {
  187.         KeyIsDown := GetKeyState("LButton")
  188.         if (KeyIsDown = 1)
  189.         {
  190.             MouseGetPos, M_x, M_y
  191.             If (M_x != Old_M_x or M_y != Old_M_y)
  192.                 WinSet, Redraw,, ahk_id %GuiHwnd%
  193.             Canvas_DrawLine(GuihWnd, scan_x_start, scan_y_start, M_x, M_y, 2)
  194.            
  195.             Old_M_x := M_x
  196.             Old_M_y := M_y
  197.         } else {
  198.             break
  199.         }
  200.     }
  201.     MouseGetPos, scan_x_end, scan_y_end
  202.     Gui, Destroy
  203.     RestoreCursors()
  204.     X := Abs(scan_x_end-scan_x_start)
  205.     Y := Abs(scan_y_end-scan_y_start)
  206.     return X ", " Y
  207. }
  208. Canvas_DrawLine(hWnd, p_x1, p_y1, p_x2, p_y2, p_w) {
  209.     p_x1 -= 1, p_y1 -= 1, p_x2 -= 1, p_y2 -= 1
  210.     hDC := DllCall("GetDC", UInt, hWnd)
  211.     DllCall("gdi32.dll\MoveToEx", UInt, hdc, Uint,p_x1, Uint, p_y1, Uint, 0 )
  212.     DllCall("gdi32.dll\LineTo", UInt, hdc, Uint, p_x2, Uint, p_y2 )
  213. }
  214. RestoreCursors() {
  215.     SPI_SETCURSORS := 0x57
  216.     DllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 ) ;*[General Hotkeys]
  217. }
  218. SetSystemCursor( Cursor = "", cx = 0, cy = 0 ) {
  219.     BlankCursor := 0, SystemCursor := 0, FileCursor := 0 ; init
  220.    
  221.     SystemCursors = 32512IDC_ARROW,32513IDC_IBEAM,32514IDC_WAIT,32515IDC_CROSS
  222.     ,32516IDC_UPARROW,32640IDC_SIZE,32641IDC_ICON,32642IDC_SIZENWSE
  223.     ,32643IDC_SIZENESW,32644IDC_SIZEWE,32645IDC_SIZENS,32646IDC_SIZEALL
  224.     ,32648IDC_NO,32649IDC_HAND,32650IDC_APPSTARTING,32651IDC_HELP
  225.    
  226.     If Cursor = ; empty, so create blank cursor
  227.     {
  228.         VarSetCapacity( AndMask, 32*4, 0xFF ), VarSetCapacity( XorMask, 32*4, 0 )
  229.         BlankCursor = 1 ; flag for later
  230.     }
  231.     Else If SubStr( Cursor,1,4 ) = "IDC_" ; load system cursor
  232.     {
  233.         Loop, Parse, SystemCursors, `,
  234.         {
  235.             CursorName := SubStr( A_Loopfield, 6, 15 ) ; get the cursor name, no trailing space with substr
  236.             CursorID := SubStr( A_Loopfield, 1, 5 ) ; get the cursor id
  237.             SystemCursor = 1
  238.             If ( CursorName = Cursor )
  239.             {
  240.                 CursorHandle := DllCall( "LoadCursor", Uint,0, Int,CursorID )  
  241.                 Break              
  242.             }
  243.         }  
  244.         If CursorHandle = ; invalid cursor name given
  245.         {
  246.             Msgbox,, SetCursor, Error: Invalid cursor name
  247.             CursorHandle = Error
  248.         }
  249.     }  
  250.     Else If FileExist( Cursor )
  251.     {
  252.         SplitPath, Cursor,,, Ext ; auto-detect type
  253.         If Ext = ico
  254.             uType := 0x1  
  255.         Else If Ext in cur,ani
  256.             uType := 0x2      
  257.         Else ; invalid file ext
  258.         {
  259.             Msgbox,, SetCursor, Error: Invalid file type
  260.             CursorHandle = Error
  261.         }      
  262.         FileCursor = 1
  263.     }
  264.     Else
  265.     {  
  266.         Msgbox,, SetCursor, Error: Invalid file path or cursor name
  267.         CursorHandle = Error ; raise for later
  268.     }
  269.     If CursorHandle != Error
  270.     {
  271.         Loop, Parse, SystemCursors, `,
  272.         {
  273.             If BlankCursor = 1
  274.             {
  275.                 Type = BlankCursor
  276.                 %Type%%A_Index% := DllCall( "CreateCursor"
  277.                 , Uint,0, Int,0, Int,0, Int,32, Int,32, Uint,&AndMask, Uint,&XorMask )
  278.                 CursorHandle := DllCall( "CopyImage", Uint,%Type%%A_Index%, Uint,0x2, Int,0, Int,0, Int,0 )
  279.                 DllCall( "SetSystemCursor", Uint,CursorHandle, Int,SubStr( A_Loopfield, 1, 5 ) )
  280.             }        
  281.             Else If SystemCursor = 1
  282.             {
  283.                 Type = SystemCursor
  284.                 CursorHandle := DllCall( "LoadCursor", Uint,0, Int,CursorID )  
  285.                 %Type%%A_Index% := DllCall( "CopyImage"
  286.                 , Uint,CursorHandle, Uint,0x2, Int,cx, Int,cy, Uint,0 )      
  287.                 CursorHandle := DllCall( "CopyImage", Uint,%Type%%A_Index%, Uint,0x2, Int,0, Int,0, Int,0 )
  288.                 DllCall( "SetSystemCursor", Uint,CursorHandle, Int,SubStr( A_Loopfield, 1, 5 ) )
  289.             }
  290.             Else If FileCursor = 1
  291.             {
  292.                 Type = FileCursor
  293.                 %Type%%A_Index% := DllCall( "LoadImageA"
  294.                 , UInt,0, Str,Cursor, UInt,uType, Int,cx, Int,cy, UInt,0x10 )
  295.                 DllCall( "SetSystemCursor", Uint,%Type%%A_Index%, Int,SubStr( A_Loopfield, 1, 5 ) )        
  296.             }          
  297.         }
  298.     }  
  299. }
  300. SetWallpaper(BMPpath) {
  301.     SPI_SETDESKWALLPAPER := 20
  302.     SPIF_SENDWININICHANGE := 2  
  303.     Return DllCall("SystemParametersInfo", UINT, SPI_SETDESKWALLPAPER, UINT, uiParam, STR, BMPpath, UINT, SPIF_SENDWININICHANGE)
  304. }
  305. Gst() {   ; GetSelectedText by Learning one
  306.     IsClipEmpty := (Clipboard = "") ? 1 : 0
  307.     if !IsClipEmpty  {
  308.         ClipboardBackup := ClipboardAll
  309.         While !(Clipboard = "")  {
  310.             Clipboard =
  311.             Sleep, 10
  312.         }
  313.     }
  314.     Send, ^c
  315.     ClipWait, 0.1
  316.     ToReturn := Clipboard, Clipboard := ClipboardBackup
  317.     if !IsClipEmpty
  318.         ClipWait, 0.5, 1
  319.     return ToReturn
  320. }
  321. Morse(string, to := "morse") {
  322.     MorseArrayM2T := {".-" : "A", "-..." : "B", "-.-." : "C", "-.." : "D", "." : "E"
  323.     , "..-." : "F", "--." : "G", "...." : "H", ".." : "I", ".---" : "J", "-.-" : "K"
  324.     , ".-.." : "L", "--" : "M", "-." : "N", "---" : "O", ".--." : "P", "--.-" : "Q"
  325.     , ".-." : "R", "..." : "S", "-" : "T", "..-" : "U", "...-" : "V", ".--" : "W"
  326.     , "-..-" : "X", "-.--" : "Y", "--.." : "Z", "-----" : 0, ".----" : 1, "..---" : 2
  327.     , "...--" : 3, "....-" : 4, "....." : 5, "-...." : 6, "--..." : 7, "---.." : 8, "----." : 9}
  328.     MorseArrayT2M := {"A" : ".-", "B" : "-...", "C" : "-.-.", "D" : "-..", "E" : "."
  329.     , "F" : "..-.", "G" : "--.", "H" : "....", "I" : "..", "J" : ".---", "K" : "-.-"
  330.     , "L" : ".-..", "M" : "--", "N" : "-.", "O" : "---", "P" : ".--.", "Q" : "--.-"
  331.     , "R" : ".-.", "S" : "...", "T" : "-", "U" : "..-", "V" : "...-", "W" : ".--"
  332.     , "X" : "-..-", "Y" : "-.--", "Z" : "--..", 0 : "-----", 1 : ".----", 2 : "..---"
  333.     , 3 : "...--", 4 : "....-", 5 : ".....", 6 : "-....", 7 : "--...", 8 : "---..", 9 : "----."}
  334.     if (to = "morse" || to = "m")
  335.         Loop, Parse, string, %A_Space%
  336.         {
  337.             Loop, Parse, A_LoopField
  338.                 text .= MorseArrayT2M[A_LoopField] . A_Space
  339.             text .= A_Space "/" A_Space
  340.         }
  341.     if (to = "text" || to = "t")
  342.     {
  343.         Loop, Parse, string, /
  344.         {
  345.             Loop, Parse, A_LoopField, %A_Space%
  346.                 text .= MorseArrayM2T[A_LoopField]
  347.             text .= A_Space
  348.         }
  349.     }
  350.     return RTrim(text, "/"" ")
  351. }
  352. ToolTipTimer(Text, Timeout := 2000, x := "", y := "", WhichToolTip := 1) {
  353.     if not x
  354.         MouseGetPos, X
  355.     if not y
  356.         MouseGetPos, , Y
  357.     ToolTip, %Text%, %X%, %Y%, %WhichToolTip%
  358.     SetTimer, RemoveToolTip, -%Timeout%
  359.     return
  360.    
  361.     RemoveToolTip:
  362.     ToolTip
  363.     return
  364. }
  365. IsInternetConnected() {
  366.     static sz := A_IsUnicode ? 408 : 204, addrToStr := "Ws2_32\WSAAddressToString" (A_IsUnicode ? "W" : "A")
  367.     VarSetCapacity(wsaData, 408)
  368.     if DllCall("Ws2_32\WSAStartup", "UShort", 0x0202, "Ptr", &wsaData)
  369.         return false
  370.     if DllCall("Ws2_32\GetAddrInfoW", "wstr", "dns.msftncsi.com", "wstr", "http", "ptr", 0, "ptr*", results)
  371.     {
  372.         DllCall("Ws2_32\WSACleanup")
  373.         return false
  374.     }
  375.     ai_family := NumGet(results+4, 0, "int")    ;address family (ipv4 or ipv6)
  376.     ai_addr := Numget(results+16, 2*A_PtrSize, "ptr")   ;binary ip address
  377.     ai_addrlen := Numget(results+16, 0, "ptr")   ;length of ip
  378.     DllCall(addrToStr, "ptr", ai_addr, "uint", ai_addrlen, "ptr", 0, "str", wsaData, "uint*", 204)
  379.     DllCall("Ws2_32\FreeAddrInfoW", "ptr", results)
  380.     DllCall("Ws2_32\WSACleanup")
  381.     http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
  382.     if (ai_family = 2 && wsaData = "131.107.255.255:80")
  383.         http.Open("GET", "http://www.msftncsi.com/ncsi.txt")
  384.     else if (ai_family = 23 && wsaData = "[fd3e:4f5a:5b81::1]:80")
  385.         http.Open("GET", "http://ipv6.msftncsi.com/ncsi.txt")
  386.     else
  387.         return false
  388.     http.Send()
  389.     return (http.ResponseText = "Microsoft NCSI") ;ncsi.txt will contain exactly this text
  390. }
Add Comment
Please, Sign In to add comment