Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance Force ; Prevents multiple instances of the script
- #Requires AutoHotkey v2.0
- ;#NoTrayIcon
- ;Send, {AppsKey}
- ;InstallKeybdHook ; Installs the keyhook analyzing - doubleclick tray icon and then ^k shortcut
- ;Try ContextSensitive Input - Goal don't overwrite preestablished Hotkeys like Adobes ^e
- ;https://stackoverflow.com/questions/65527892/conditional-key-remapping-ahk?rq=3
- ;if (ergo)
- ; SendInput, {Blind}e
- ;====================
- ; System Tray Icon
- ;https://www.autohotkey.com/board/topic/121982-how-to-give-your-scripts-unique-icons-in-the-windows-tray/
- ;====================
- global UserProfile := EnvGet("UserProfile")
- I_Icon := UserProfile "\source\repos\.ICO\AHK_Ice.ico"
- if FileExist(I_Icon)
- TraySetIcon(I_Icon)
- Spotify := Spotify_Basic()
- ;====================
- ;temp Stuff
- ;====================
- ;RControl::AppsKey
- ;^g::Run "\\A02\BackUps\2026" ;Send("Pass")
- ;F1:: Send("{F2}")
- ;====================
- ;General
- ;====================
- ;Open Screenshot folder
- ^PrintScreen:: Run("C:\Users\" A_UserName "\Pictures\Screenshots")
- ;Opens image in paint
- #p::f_GetExplorerSelectionPath()
- ;Creates empty.png
- #^p::Create_emptyPNG()
- ;open current explorer window in Everything search
- !+e::OpenCurrentExplorerPathInEverything()
- ;Change Explorer View
- ~RButton & F17::ChangeWinExplorerViewThumbnailToDetails()
- ;SPOTIFY
- ;Spotify := Spotify_Basic()
- ^F10::Spotify.Previous()
- ^F11::Spotify.TogglePlay()
- ^F12::Spotify.Next()
- ;F10::Spotify.Pause()
- ;F11::Spotify.Play()
- ;open current explorer window in Everything search
- OpenCurrentExplorerPathInEverything()
- {
- if WinActive("ahk_exe explorer.exe") {
- A_Clipboard := ""
- Send("!{d}")
- sleep 50
- Send("^{c}")
- ClipWait(2)
- Send("!{e}")
- Sleep 250
- Send(A_Clipboard)
- }
- }
- ChangeWinExplorerViewThumbnailToDetails()
- {
- extraLarge := 255
- for window in ComObject("Shell.Application").Windows {
- if WinActive("ahk_id" window.HWND) {
- doc := window.Document
- doc.CurrentViewMode := (doc.CurrentViewMode = 1 ? 4 : 1)
- doc.IconSize := extraLarge
- }
- }}
- class Spotify_Basic {
- _actions := Map("Next",11, "Pause",47, "Play",46, "Previous",12, "TogglePlay",14)
- __Call(Name, Params) {
- if (!this._actions.Has(Name))
- throw Error("Invalid action: " Name)
- DetectHiddenWindows true
- SetTitleMatchMode "RegEx"
- if !(hWnd := WinExist("-|Spotify ahk_exe i)Spotify.exe"))
- return
- msg := this._actions[Name] << 16
- SendMessage(0x0319, 0, msg, , "ahk_id " hWnd)
- hWnd := DllCall("User32\FindWindow", "Str","NativeHWNDHost", "Ptr",0, "Ptr")
- ;PostMessage(0xC028, 0x0C, 0xA0000, , "ahk_id " hWnd)
- }
- }
- #n:: Run "ncpa.cpl"
- #c:: Run("chrome.exe")
- ^NumpadSub::{
- Run("https://chatgpt.com/?temporary-chat=true")
- }
- #NumpadSub::{
- Run("https://chatgpt.com/?temporary-chat=true")
- }
- !NumpadSub::{
- Run("https://grok.com/")
- Sleep 4000
- Send("^+j")
- }
- !Numpad0::
- {
- activeTitle := WinGetTitle("A")
- if (activeTitle ~= "i)^(Save As|Open)$")
- {
- SendText("C:\!Projects_GG\temp")
- }
- else
- {
- Run("C:\!Projects_GG\temp")
- }
- }
- $`::
- {
- SendText("``")
- ; Sends a literal backtick
- }
- $´::
- {
- SendText("``")
- ; Sends a literal backtick
- }
- ^+F11:: Run(UserProfile "\source\repos\AHK_Scripts\Basic Functions AHK\open mkdocs website.ahk")
- ;====================
- ; Mouse Shortcuts
- ;====================
- ;DPI - Empfindlichkeit
- ;G604 - 3900
- ;MX Ergo - 72%
- ;====================
- ^RButton:: Send("!{Up}")
- ;====================
- ; Mouse G-Buttons (MX Ergo / G604)
- ;====================
- ; obendrauf
- ;[F23]
- ; seitlich
- ; [F21]
- ; [F22]
- ;seitlich vorne
- F21:: {
- if check_ifBrowser()
- Send("^{PgUp}")
- else
- Send("^#{Right}")
- }
- ^F22:: Send("^#{Right}")
- ;seitlich hinten
- F22:: {
- if check_ifBrowser()
- Send("^{PgDn}")
- else
- Send("^#{Left}")
- }
- +F22:: Send("{F5}") ; Google-specific
- ;obendrauf
- F23:: Send("^+l") ; Divvy
- ^F23:: Send("!{Up}")
- ; Mouse Layout
- ; obendrauf
- ; [F16]
- ; [F15]
- ; seitlich
- ; [F13] [F14]
- ; [F17] [F18]
- ; [F20] [F19]
- ^!+F23::
- {
- if check_ifPDF() {
- Send("^!{Home}")
- } else {
- Send("^{Home}")
- }
- }
- ^!+F24::
- {
- if check_ifPDF() {
- Send("^!{End}")
- } else {
- Send("^{End}")
- }
- }
- ;Obendrauf - vorne
- F16::{
- if WinActive("ahk_exe msedge.exe")
- {
- MouseGetPos &x, &y
- Click 1170, 606
- MouseMove x, y
- }
- else
- Send("{Enter}")
- }
- ;Obendrauf - hinten
- F15:: {
- if check_ifBrowser()
- Send("{F5}")
- else
- Send("!{Up}")
- }
- ;Seitlich - VorneUnten
- F13:: Send("^#{Left}")
- ;Seitlich - VorneOben
- F14:: Send("^#{Right}")
- ^F14:: Send("!{F4}")
- ;Seitlich - MitteUnten
- F17:: Send("^+l") ; Divvy
- ;Seitlich - MitteOben
- F18:: Send("^w")
- ;Tilde ~ is needed for combinations like these:
- ~F18 & F19:: Send("!{F4}")
- ;Seitlich - HintenUnten
- #HotIf WinActive("ahk_exe hdevelop.exe")
- F20:: Send("s")
- #HotIf
- #HotIf WinActive("ahk_exe Adobe Bridge.exe")
- a:: {
- Send("v")
- Sleep(50)
- Send("d")
- Send("d")
- Sleep(100)
- Send("{Enter}")
- }
- #HotIf
- F20:: Send("^{PgUp}")
- ;Seitlich - HintenOben
- #HotIf WinActive("ahk_exe hdevelop.exe")
- F19:: Send("m")
- #HotIf
- F19:: Send("^{PgDn}")
- ;====================
- ; Explorer View Toggle (Ctrl+Numpad8)
- ;====================
- ; This script sets the view mode for Windows File Explorer
- ; https://www.autohotkey.com/boards/viewtopic.php?p=527250#p527250
- /* View modes ------------------------------------------
- 1 = Icons
- 2 = Small icons
- 3 = List
- 4 = Details
- 5 = Thumbnails
- 6 = Tile
- 7 = Thumbnail strip
- --------------------------------------------------------
- */
- #HotIf WinActive("ahk_class CabinetWClass")
- ^Numpad8:: {
- extraLarge := 255
- for window in ComObject("Shell.Application").Windows {
- if WinActive("ahk_id" window.HWND) {
- doc := window.Document
- doc.CurrentViewMode := (doc.CurrentViewMode = 1 ? 4 : 1)
- doc.IconSize := extraLarge
- }
- }
- }
- #HotIf
- ;====================
- ;VisualStudio 2022 Navigation Switch between tabs with Mouse
- ;====================
- ^PgUp:: {
- if WinActive("ahk_exe devenv.exe")
- Send("^!{PgUp}")
- else
- Send("^{PgUp}")
- }
- ^PgDn:: {
- if WinActive("ahk_exe devenv.exe")
- Send("^!{PgDn}")
- else
- Send("^{PgDn}")
- }
- ;====================
- ; Numpad Utilities
- ;====================
- NumpadDot:: {
- if (WinGetProcessName("A") = "ApplicationFrameHost.exe")
- Send(",")
- else
- Send(".")
- }
- ^Numpad0:: {
- if check_ifPDF() || check_ifPhotos() {
- Send("^0")
- } else {
- Run("notepad++.exe -multiInst")
- }
- }
- check_ifPDF() {
- activeExe := WinGetProcessName("A")
- activeClass := WinGetClass("A")
- return activeExe = "PDFXEdit.exe"
- && activeClass = "PXE:{C5309AD3-73E4-4707-B1E1-2940D8AF3B9D}"
- }
- check_ifPhotos() {
- activeExe := WinGetProcessName("A")
- activeClass := WinGetClass("A")
- return activeExe = "Photos.exe"
- && activeClass = "WinUIDesktopWin32WindowClass"
- }
- ;Numpad7
- ;NumpadHome:: Send("{Text}{")
- ;Numpad9
- ;NumpadPgUp:: Send("{Text}}")
- /*
- Numpad0 / NumpadIns 0 / Ins
- Numpad1 / NumpadEnd 1 / End
- Numpad2 / NumpadDown 2 / ↓
- Numpad3 / NumpadPgDn 3 / PgDn
- Numpad4 / NumpadLeft 4 / ←
- Numpad5 / NumpadClear 5 / typically does nothing
- Numpad6 / NumpadRight 6 / →
- Numpad7 / NumpadHome 7 / Home
- Numpad8 / NumpadUp 8 / ↑
- Numpad9 / NumpadPgUp 9 / PgUp
- NumpadDot / NumpadDel
- */
- ;====================
- ;GUI
- ;====================
- IconFolder := UserProfile "\source\repos\.ICO\New\"
- img1 := IconFolder "Reload.png"
- img2 := IconFolder "PowerPoint.png"
- img3 := IconFolder "Character.png"
- img4 := IconFolder "mkdocs.png"
- +F1::ShowMyGui() ; Shift-F1 opens the GUI
- ShowMyGui() {
- global myGui, img1, img2, img3, img4
- if IsSet(myGui) {
- myGui.Show()
- return
- }
- myGui := Gui("+AlwaysOnTop -SysMenu", "PNG Button GUI")
- myGui.BackColor := "0x202020" ; anthracite
- p1 := myGui.Add("Picture", "x20 y20 w100 h100 0x4"), p1.Value := img1, p1.OnEvent("Click", Btn1)
- p2 := myGui.Add("Picture", "x140 y20 w100 h100 0x4"), p2.Value := img2, p2.OnEvent("Click", Btn2)
- p3 := myGui.Add("Picture", "x260 y20 w100 h100 0x4"), p3.Value := img3, p3.OnEvent("Click", Btn3)
- p4 := myGui.Add("Picture", "x380 y20 w100 h100 0x4"), p4.Value := img4, p4.OnEvent("Click", Btn4)
- myGui.Show("w500 h140")
- }
- Btn1(*) {
- global myGui
- myGui.Hide()
- Reload
- }
- Btn2(*) {
- global myGui
- myGui.Hide()
- Run UserProfile "\source\repos\AHK_Scripts\Numpad5_-_Powerp._Translate_-_PixelSearch.ahk"
- }
- Btn3(*) {
- global myGui
- myGui.Hide()
- Run UserProfile "\source\repos\AHK_Scripts\SpecialCharacters.ahk"
- }
- Btn4(*) {
- global myGui
- myGui.Hide()
- Run UserProfile "\source\repos\AHK_Scripts\Basic Functions AHK\open mkdocs website.ahk"
- }
- ;====================
- ;Functions()
- ;====================
- ; Helper to detect Chrome/Edge
- check_ifBrowser() {
- class := WinGetClass("A")
- process := WinGetProcessName("A")
- return (class = "Chrome_WidgetWin_1") && (process = "chrome.exe" || process = "msedge.exe" || process = "brave.exe")
- }
- ;====================
- ;=== WORK-STUFF ====
- ;====================
- ::%HA:: SendText(EnvGet("HALCONROOT"))
- ;=== Excel autoFit Column Width ===
- !^Numpad4:: {
- if WinActive("ahk_class XLMAIN") {
- Send("^a")
- Sleep(200)
- Send("!h")
- Send("o")
- Send("i")
- } else {
- Send("^{Numpad4}")
- }
- }
- ;=== Kill Photos.exe ===
- !^Numpad8:: RunWait("taskkill /im Photos.exe /f")
- ;=== Open Temp.jpg ===
- +F11:: {
- Run("C:\!Projects_GG\temp\temp.jpg")
- Sleep(1500)
- Send("^c")
- Sleep(500)
- Send("^w")
- if WinExist("ahk_exe POWERPNT.exe")
- WinActivate
- }
- return ; End of auto-execute
- /** Open in paint
- * @description Get array of selected path names.
- * If no paths are selected or explorer not active, a 0 is returned.
- * @param {Integer} var_hwnd - Provide the handle of a window to check.
- * If no handle is provided, the acvtive window is used.
- * @returns {Array} An array of strings is returned containing each selected path.
- * A 0 is returned if nothing is selected.
- */
- f_GetExplorerSelectionPath(var_hwnd := WinActive('A')) {
- arr := []
- ; ✅ Correctly pair else with the WinActive check
- if WinActive('ahk_class CabinetWClass') {
- for var_Window in ComObject("Shell.Application").Windows
- if (var_Window.hwnd == var_hwnd)
- for Items in var_Window.Document.SelectedItems
- arr.Push(Items.path)
- } else {
- ; 🚀 If NOT Explorer → run Paint
- Run "mspaint.exe"
- return
- }
- ; ✅ Return if no selection
- if (arr.Length = 0)
- return 0
- ; ✅ Open selected images in Paint
- for index, value in arr {
- if RegExMatch(StrLower(value), "\.(jpg|jpeg|png|bmp|gif|HEIC)$") {
- Run 'mspaint.exe "' value '"'
- }
- }
- }
- Create_emptyPNG(var_hwnd := WinActive('A')) {
- if WinActive('ahk_class CabinetWClass')
- for var_Window in ComObject('Shell.Application').Windows
- If (var_Window.hwnd == var_hwnd)
- for Items in var_Window.Document.SelectedItems {
- ; get parent folder
- SplitPath Items.path, , &parentDir
- newFile := parentDir "\empty.png"
- FileAppend "", newFile ; creates empty file
- return
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment