From 51c0cd271065867b9dc04f16a1808eefb7733d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 5 Feb 2021 12:42:06 +0100 Subject: jump: Open in existing window if already open, fix Win key issues --- tt.jump.ahk | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'tt.jump.ahk') diff --git a/tt.jump.ahk b/tt.jump.ahk index aa5232f..f1e62c1 100644 --- a/tt.jump.ahk +++ b/tt.jump.ahk @@ -15,20 +15,15 @@ JumpPaths := { s: env("Sync") #s:: ToolTip, ... -SendInput, {Blind}{LWin Up}{RWin Up} -Input, k, C L1 +Input, k, M C L1 if (JumpPaths[k] != "") { if (InStr(FileExist(JumpPaths[k]), "D")) - Run, % "explorer /n, """ JumpPaths[k] """" + OpenExplorer(JumpPaths[k]) else Run, % """" JumpPaths[k] """" } ToolTip -if (GetKeyState("LWin", "P")) - SendInput, {Blind}{LWin Down} -if (GetKeyState("RWin", "P")) - SendInput, {Blind}{RWin Down} return ;; -> library @@ -38,3 +33,14 @@ env(name) EnvGet, r, %name% return r } + +OpenExplorer(path) +{ + for window in ComObjCreate("Shell.Application").Windows { + if (window.Document.Folder.Self.path = path) { + WinActivate, % "ahk_id " window.hwnd + return + } + } + Run, % "explorer /n, """ path """" +} -- cgit v1.2.3