FallafelFaffel

AutoHotkey - HoarderProblem

Jan 8th, 2026 (edited)
110
0
363 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Autohotkey 11.73 KB | Source Code | 0 0
  1. #SingleInstance Force  ; Prevents multiple instances of the script
  2. #Requires AutoHotkey v2.0
  3. ;#NoTrayIcon
  4. ;Send, {AppsKey}
  5. ;InstallKeybdHook ; Installs the keyhook analyzing - doubleclick tray icon and then ^k shortcut
  6.  
  7. ;Try ContextSensitive Input - Goal don't overwrite preestablished Hotkeys like Adobes ^e
  8. ;https://stackoverflow.com/questions/65527892/conditional-key-remapping-ahk?rq=3
  9. ;if (ergo)
  10. ;  SendInput, {Blind}e
  11.  
  12. ;====================
  13. ; System Tray Icon
  14. ;https://www.autohotkey.com/board/topic/121982-how-to-give-your-scripts-unique-icons-in-the-windows-tray/
  15. ;====================
  16. global UserProfile := EnvGet("UserProfile")
  17. I_Icon := UserProfile "\source\repos\.ICO\AHK_Ice.ico"
  18. if FileExist(I_Icon)
  19.     TraySetIcon(I_Icon)
  20.  
  21. Spotify := Spotify_Basic()
  22.  
  23. ;====================
  24. ;temp Stuff
  25. ;====================
  26.  
  27. ;RControl::AppsKey
  28. ;^g::Run "\\A02\BackUps\2026" ;Send("Pass")
  29. ;F1:: Send("{F2}")
  30.  
  31. ;====================
  32. ;General
  33. ;====================
  34.  
  35. ;Open Screenshot folder
  36. ^PrintScreen:: Run("C:\Users\" A_UserName "\Pictures\Screenshots")
  37.  
  38. ;Opens image in paint
  39. #p::f_GetExplorerSelectionPath()
  40.  
  41. ;Creates empty.png
  42. #^p::Create_emptyPNG()
  43.  
  44. ;open current explorer window in Everything search
  45. !+e::OpenCurrentExplorerPathInEverything()
  46.  
  47. ;Change Explorer View
  48. ~RButton & F17::ChangeWinExplorerViewThumbnailToDetails()
  49.  
  50. ;SPOTIFY
  51. ;Spotify := Spotify_Basic()
  52.  
  53. ^F10::Spotify.Previous()
  54. ^F11::Spotify.TogglePlay()
  55. ^F12::Spotify.Next()
  56. ;F10::Spotify.Pause()
  57. ;F11::Spotify.Play()
  58.  
  59.  
  60. ;open current explorer window in Everything search
  61. OpenCurrentExplorerPathInEverything()
  62. {
  63.     if WinActive("ahk_exe explorer.exe") {
  64.         A_Clipboard := ""
  65.         Send("!{d}")
  66.         sleep 50
  67.         Send("^{c}")
  68.         ClipWait(2)
  69.         Send("!{e}")
  70.         Sleep 250
  71.         Send(A_Clipboard)
  72.     }
  73. }
  74.  
  75. ChangeWinExplorerViewThumbnailToDetails()
  76. {
  77.     extraLarge := 255
  78.     for window in ComObject("Shell.Application").Windows {
  79.         if WinActive("ahk_id" window.HWND) {
  80.             doc := window.Document
  81.             doc.CurrentViewMode := (doc.CurrentViewMode = 1 ? 4 : 1)
  82.             doc.IconSize := extraLarge
  83.     }
  84. }}
  85.  
  86.  
  87. class Spotify_Basic {
  88.  
  89.     _actions := Map("Next",11, "Pause",47, "Play",46, "Previous",12, "TogglePlay",14)
  90.  
  91.     __Call(Name, Params) {
  92.         if (!this._actions.Has(Name))
  93.             throw Error("Invalid action: " Name)
  94.  
  95.         DetectHiddenWindows true
  96.         SetTitleMatchMode "RegEx"
  97.         if !(hWnd := WinExist("-|Spotify ahk_exe i)Spotify.exe"))
  98.             return
  99.  
  100.         msg := this._actions[Name] << 16
  101.         SendMessage(0x0319, 0, msg, , "ahk_id " hWnd)
  102.         hWnd := DllCall("User32\FindWindow", "Str","NativeHWNDHost", "Ptr",0, "Ptr")
  103.         ;PostMessage(0xC028, 0x0C, 0xA0000, , "ahk_id " hWnd)
  104.     }
  105. }
  106.  
  107. #n:: Run "ncpa.cpl"
  108.  
  109. #c:: Run("chrome.exe")
  110.  
  111. ^NumpadSub::{
  112.     Run("https://chatgpt.com/?temporary-chat=true")
  113. }
  114. #NumpadSub::{
  115.     Run("https://chatgpt.com/?temporary-chat=true")
  116. }
  117.  
  118. !NumpadSub::{
  119.     Run("https://grok.com/")
  120.     Sleep 4000
  121.     Send("^+j")
  122. }
  123.  
  124. !Numpad0::
  125. {
  126.     activeTitle := WinGetTitle("A")
  127.  
  128.     if (activeTitle ~= "i)^(Save As|Open)$")
  129.     {
  130.         SendText("C:\!Projects_GG\temp")
  131.     }
  132.     else
  133.     {
  134.         Run("C:\!Projects_GG\temp")
  135.     }
  136. }
  137.  
  138. $`::
  139. {
  140.     SendText("``")
  141.     ; Sends a literal backtick
  142. }
  143.  
  144. $´::
  145. {
  146.     SendText("``")
  147.     ; Sends a literal backtick
  148. }
  149.  
  150. ^+F11:: Run(UserProfile "\source\repos\AHK_Scripts\Basic Functions AHK\open mkdocs website.ahk")
  151.  
  152. ;====================
  153. ; Mouse Shortcuts
  154. ;====================
  155. ;DPI - Empfindlichkeit
  156. ;G604 - 3900
  157. ;MX Ergo - 72%
  158. ;====================
  159.  
  160. ^RButton:: Send("!{Up}")
  161.  
  162. ;====================
  163. ; Mouse G-Buttons (MX Ergo / G604)
  164. ;====================
  165. ; obendrauf
  166. ;[F23]
  167. ; seitlich
  168. ; [F21]
  169. ; [F22]
  170.  
  171. ;seitlich vorne
  172. F21:: {
  173.     if check_ifBrowser()
  174.         Send("^{PgUp}")
  175.     else
  176.         Send("^#{Right}")
  177. }
  178.  
  179. ^F22:: Send("^#{Right}")
  180.  
  181. ;seitlich hinten
  182. F22:: {
  183.     if check_ifBrowser()
  184.         Send("^{PgDn}")
  185.     else
  186.         Send("^#{Left}")
  187. }
  188.  
  189. +F22:: Send("{F5}")  ; Google-specific
  190.  
  191. ;obendrauf
  192. F23:: Send("^+l")  ; Divvy
  193. ^F23:: Send("!{Up}")
  194.  
  195.  
  196. ; Mouse Layout
  197. ;  obendrauf
  198. ; [F16]
  199. ; [F15]
  200. ;  seitlich
  201. ; [F13] [F14]
  202. ; [F17] [F18]
  203. ; [F20] [F19]
  204.  
  205. ^!+F23::
  206. {
  207.     if check_ifPDF() {
  208.             Send("^!{Home}")
  209.         } else {
  210.             Send("^{Home}")
  211.     }
  212. }
  213.  
  214. ^!+F24::
  215. {
  216.     if check_ifPDF() {
  217.             Send("^!{End}")
  218.         } else {
  219.             Send("^{End}")
  220.     }
  221. }
  222.  
  223. ;Obendrauf - vorne
  224. F16::{
  225.     if WinActive("ahk_exe msedge.exe")
  226.     {
  227.         MouseGetPos &x, &y
  228.         Click 1170, 606
  229.         MouseMove x, y
  230.     }
  231.     else
  232.         Send("{Enter}")
  233. }
  234.  
  235. ;Obendrauf - hinten
  236. F15:: {
  237.     if check_ifBrowser()
  238.         Send("{F5}")
  239.     else
  240.         Send("!{Up}")
  241. }
  242.  
  243. ;Seitlich - VorneUnten
  244. F13:: Send("^#{Left}")
  245.    
  246. ;Seitlich - VorneOben
  247. F14:: Send("^#{Right}")
  248. ^F14:: Send("!{F4}")
  249.  
  250. ;Seitlich - MitteUnten
  251. F17:: Send("^+l")  ; Divvy
  252.  
  253. ;Seitlich - MitteOben
  254. F18:: Send("^w")
  255. ;Tilde ~ is needed for combinations like these:
  256. ~F18 & F19:: Send("!{F4}")
  257.  
  258. ;Seitlich - HintenUnten
  259. #HotIf WinActive("ahk_exe hdevelop.exe")
  260. F20:: Send("s")
  261. #HotIf
  262. #HotIf WinActive("ahk_exe Adobe Bridge.exe")
  263. a:: {
  264.     Send("v")
  265.     Sleep(50)
  266.     Send("d")
  267.     Send("d")
  268.     Sleep(100)
  269.     Send("{Enter}")
  270. }
  271. #HotIf
  272. F20:: Send("^{PgUp}")
  273.  
  274. ;Seitlich - HintenOben
  275. #HotIf WinActive("ahk_exe hdevelop.exe")
  276. F19:: Send("m")
  277. #HotIf
  278. F19:: Send("^{PgDn}")
  279. ;====================
  280. ; Explorer View Toggle (Ctrl+Numpad8)
  281. ;====================
  282.  
  283. ; This script sets the view mode for Windows File Explorer
  284. ; https://www.autohotkey.com/boards/viewtopic.php?p=527250#p527250
  285.  /* View modes ------------------------------------------
  286.  1 = Icons
  287.  2 = Small icons
  288.  3 = List
  289.  4 = Details
  290.  5 = Thumbnails
  291.  6 = Tile
  292.  7 = Thumbnail strip
  293.  --------------------------------------------------------
  294.  */
  295.  
  296. #HotIf WinActive("ahk_class CabinetWClass")
  297. ^Numpad8:: {
  298.     extraLarge := 255
  299.     for window in ComObject("Shell.Application").Windows {
  300.         if WinActive("ahk_id" window.HWND) {
  301.             doc := window.Document
  302.             doc.CurrentViewMode := (doc.CurrentViewMode = 1 ? 4 : 1)
  303.             doc.IconSize := extraLarge
  304.         }
  305.     }
  306. }
  307. #HotIf
  308.  
  309. ;====================
  310. ;VisualStudio 2022 Navigation Switch between tabs with Mouse
  311. ;====================
  312. ^PgUp:: {
  313.     if WinActive("ahk_exe devenv.exe")
  314.         Send("^!{PgUp}")
  315.     else
  316.         Send("^{PgUp}")
  317. }
  318.  
  319. ^PgDn:: {
  320.     if WinActive("ahk_exe devenv.exe")
  321.         Send("^!{PgDn}")
  322.     else
  323.         Send("^{PgDn}")
  324. }
  325.  
  326. ;====================
  327. ; Numpad Utilities
  328. ;====================
  329. NumpadDot:: {
  330.     if (WinGetProcessName("A") = "ApplicationFrameHost.exe")
  331.         Send(",")
  332.     else
  333.         Send(".")
  334. }
  335.  
  336. ^Numpad0:: {
  337.     if check_ifPDF() || check_ifPhotos() {
  338.         Send("^0")
  339.     } else {
  340.         Run("notepad++.exe -multiInst")
  341.     }
  342. }
  343.  
  344. check_ifPDF() {
  345.     activeExe := WinGetProcessName("A")
  346.     activeClass := WinGetClass("A")
  347.  
  348.     return activeExe = "PDFXEdit.exe"
  349.         && activeClass = "PXE:{C5309AD3-73E4-4707-B1E1-2940D8AF3B9D}"
  350. }
  351.  
  352. check_ifPhotos() {
  353.     activeExe := WinGetProcessName("A")
  354.     activeClass := WinGetClass("A")
  355.  
  356.     return activeExe = "Photos.exe"
  357.         && activeClass = "WinUIDesktopWin32WindowClass"
  358. }
  359.  
  360. ;Numpad7
  361. ;NumpadHome:: Send("{Text}{")
  362. ;Numpad9
  363. ;NumpadPgUp:: Send("{Text}}")
  364.  
  365. /*
  366. Numpad0     / NumpadIns     0 / Ins
  367. Numpad1     / NumpadEnd     1 / End
  368. Numpad2     / NumpadDown    2 / ↓
  369. Numpad3     / NumpadPgDn    3 / PgDn
  370. Numpad4     / NumpadLeft    4 / ←
  371. Numpad5     / NumpadClear   5 / typically does nothing
  372. Numpad6     / NumpadRight   6 / →
  373. Numpad7     / NumpadHome    7 / Home
  374. Numpad8     / NumpadUp      8 / ↑
  375. Numpad9     / NumpadPgUp    9 / PgUp
  376. NumpadDot   / NumpadDel
  377. */
  378.  
  379. ;====================
  380. ;GUI
  381. ;====================
  382.  
  383. IconFolder := UserProfile "\source\repos\.ICO\New\"
  384.  
  385. img1 := IconFolder "Reload.png"
  386. img2 := IconFolder "PowerPoint.png"
  387. img3 := IconFolder "Character.png"
  388. img4 := IconFolder "mkdocs.png"
  389.  
  390.  
  391. +F1::ShowMyGui()   ; Shift-F1 opens the GUI
  392.  
  393. ShowMyGui() {
  394.     global myGui, img1, img2, img3, img4
  395.     if IsSet(myGui) {
  396.         myGui.Show()
  397.         return
  398.     }
  399.  
  400.     myGui := Gui("+AlwaysOnTop -SysMenu", "PNG Button GUI")
  401.     myGui.BackColor := "0x202020"  ; anthracite
  402.  
  403.     p1 := myGui.Add("Picture", "x20   y20 w100 h100 0x4"), p1.Value := img1, p1.OnEvent("Click", Btn1)
  404.     p2 := myGui.Add("Picture", "x140  y20 w100 h100 0x4"), p2.Value := img2, p2.OnEvent("Click", Btn2)
  405.     p3 := myGui.Add("Picture", "x260  y20 w100 h100 0x4"), p3.Value := img3, p3.OnEvent("Click", Btn3)
  406.     p4 := myGui.Add("Picture", "x380  y20 w100 h100 0x4"), p4.Value := img4, p4.OnEvent("Click", Btn4)
  407.  
  408.     myGui.Show("w500 h140")
  409. }
  410.  
  411.  
  412.  Btn1(*) {
  413. global myGui  
  414. myGui.Hide()
  415. Reload
  416. }
  417. Btn2(*) {
  418. global myGui  
  419. myGui.Hide()
  420. Run UserProfile "\source\repos\AHK_Scripts\Numpad5_-_Powerp._Translate_-_PixelSearch.ahk"
  421.  }
  422. Btn3(*) {
  423. global myGui  
  424. myGui.Hide()
  425. Run UserProfile "\source\repos\AHK_Scripts\SpecialCharacters.ahk"
  426.  }
  427. Btn4(*) {
  428. global myGui  
  429. myGui.Hide()
  430. Run UserProfile "\source\repos\AHK_Scripts\Basic Functions AHK\open mkdocs website.ahk"
  431.  }
  432.  
  433. ;====================
  434. ;Functions()
  435. ;====================
  436.  
  437. ; Helper to detect Chrome/Edge
  438. check_ifBrowser() {
  439.     class := WinGetClass("A")
  440.     process := WinGetProcessName("A")
  441.     return (class = "Chrome_WidgetWin_1") && (process = "chrome.exe" || process = "msedge.exe" || process = "brave.exe")
  442. }
  443.  
  444. ;====================
  445. ;=== WORK-STUFF ====
  446. ;====================
  447.  
  448. ::%HA:: SendText(EnvGet("HALCONROOT"))
  449.  
  450. ;=== Excel autoFit Column Width ===
  451. !^Numpad4:: {
  452.     if WinActive("ahk_class XLMAIN") {
  453.         Send("^a")
  454.         Sleep(200)
  455.         Send("!h")
  456.         Send("o")
  457.         Send("i")
  458.     } else {
  459.         Send("^{Numpad4}")
  460.     }
  461. }
  462.  
  463. ;=== Kill Photos.exe ===
  464. !^Numpad8:: RunWait("taskkill /im Photos.exe /f")
  465.  
  466. ;=== Open Temp.jpg ===
  467. +F11:: {
  468.     Run("C:\!Projects_GG\temp\temp.jpg")
  469.     Sleep(1500)
  470.     Send("^c")
  471.     Sleep(500)
  472.     Send("^w")
  473.     if WinExist("ahk_exe POWERPNT.exe")
  474.         WinActivate
  475. }
  476.  
  477. return ; End of auto-execute
  478.  
  479.  
  480. /** Open in paint
  481.  * @description Get array of selected path names.  
  482.  * If no paths are selected or explorer not active, a 0 is returned.  
  483.  * @param {Integer} var_hwnd - Provide the handle of a window to check.  
  484.  * If no handle is provided, the acvtive window is used.  
  485.  * @returns {Array} An array of strings is returned containing each selected path.  
  486.  * A 0 is returned if nothing is selected.
  487. */
  488. f_GetExplorerSelectionPath(var_hwnd := WinActive('A')) {
  489.     arr := []
  490.    
  491.     ; ✅ Correctly pair else with the WinActive check
  492.     if WinActive('ahk_class CabinetWClass') {
  493.         for var_Window in ComObject("Shell.Application").Windows
  494.             if (var_Window.hwnd == var_hwnd)
  495.                 for Items in var_Window.Document.SelectedItems
  496.                     arr.Push(Items.path)
  497.     } else {
  498.         ; 🚀 If NOT Explorer → run Paint
  499.         Run "mspaint.exe"
  500.         return
  501.     }
  502.  
  503.     ; ✅ Return if no selection
  504.     if (arr.Length = 0)
  505.         return 0
  506.  
  507.     ; ✅ Open selected images in Paint
  508.     for index, value in arr {
  509.         if RegExMatch(StrLower(value), "\.(jpg|jpeg|png|bmp|gif|HEIC)$") {
  510.             Run 'mspaint.exe "' value '"'
  511.         }
  512.     }
  513. }
  514.  
  515. Create_emptyPNG(var_hwnd := WinActive('A')) {
  516.    
  517.     if WinActive('ahk_class CabinetWClass')
  518.         for var_Window in ComObject('Shell.Application').Windows
  519.             If (var_Window.hwnd == var_hwnd)
  520.                 for Items in var_Window.Document.SelectedItems {
  521.                     ; get parent folder
  522.                     SplitPath Items.path, , &parentDir
  523.                     newFile := parentDir "\empty.png"
  524.                     FileAppend "", newFile  ; creates empty file
  525.                     return
  526.                 }
  527.             }
Advertisement
Add Comment
Please, Sign In to add comment