Same Hotkey differently in Explorer or SaveAs dialogue

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Same Hotkey differently in Explorer or SaveAs dialogue

21 Oct 2018, 05:19

I guess I'm doing this wrong, but could someone advise please?
I want to make Ctrl-Shift-d operate differently in Explorer (CabinetWClass) from in the SaveAs dialogue box (ahk_clas #32770).
I considered that a SaveAs box is essentially still explorer, but this shouldn't matter to AHK, since I've distinguished two classes.
Does anyone know in general how I can use a hotkey differently in two different apps, and how to distinguish Explorer from SaveAs please?

Code: Select all

#IfWinActive ahk_class CabinetWClass   ; Only process lines below here if CabinetWClass is in focus ?????? Not work, see ~
#if (A_ComputerName = "ASUS")
    ~^+d::Explorer_JumpTo("D:\")
#if 
#IfWinActive                           ; End context sensitivity for CabinetWClass


#IfWinActive ahk_class #32770
#if (A_ComputerName = "ASUS")
    ~^+d::SaveAs_Paste("D:\")
#if 
#IfWinActive                           ; End context sensitivity for CabinetWClass
CyL0N
Posts: 211
Joined: 27 Sep 2018, 09:58

Re: Same Hotkey differently in Explorer or SaveAs dialogue

21 Oct 2018, 14:43

Here's one of many ways...

Code: Select all

GroupAdd,  explorerHotkeys, ahk_class CabinetWClass
GroupAdd,  explorerHotkeys, ahk_class #32770

#IfWinActive ahk_group explorerHotkeys
~^+d::
SoundBeep
WinGetClass, activeClass, A
if (A_ComputerName = "ASUS" AND activeClass = "CabinetWClass" )
	SoundBeep, 1000
if (A_ComputerName = "ASUS" AND activeClass = "#32770" )
	SoundBeep, 2000
#IfWinActive
live ? long & prosper : regards
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Same Hotkey differently in Explorer or SaveAs dialogue

21 Oct 2018, 15:30

Code: Select all

#If active("ahk_class CabinetWClass") 
~^+d::Explorer_JumpTo("D:\")

#If active("ahk_class #32770") 
~^+d::SaveAs_Paste("D:\")

active(title) {
	return A_ComputerName = "asus" && WinActive(title)
}
CyL0N
Posts: 211
Joined: 27 Sep 2018, 09:58

Re: Same Hotkey differently in Explorer or SaveAs dialogue

22 Oct 2018, 00:14

I stand corrected swagfag,i totally forgot #If supports logical operators,late night... which begs the question,why the function...

Code: Select all

#If WinActive("ahk_class CabinetWClass") && A_ComputerName = "asus"
~^+d::Explorer_JumpTo("D:\")
#If WinActive("ahk_class #32770") && A_ComputerName = "asus"
~^+d::SaveAs_Paste("D:\")
#If
live ? long & prosper : regards
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Same Hotkey differently in Explorer or SaveAs dialogue

22 Oct 2018, 00:17

To avoid repeating the computer name bit. This may or may not be desired, but that depends entirely on what roysubs intends to do with the script.
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Re: Same Hotkey differently in Explorer or SaveAs dialogue

22 Oct 2018, 05:11

To explain what I intend to do:

- I have a common script that I deploy on 3 different computers and so some they have different resources and different paths to things. For example, I want a bunch of quick jump hotkeys for Dropbox (Ctrl-Shift-1), OneDrive (Ctrl-Shift-2), Google Drive (Ctrl-Shift-3), but on my TV NUC (with only a 128 GB drive), I don't have enough space to locally install this cloud storage, so the path on this computer instead points to a UNC path for the cloud folders (these are done by the Explorer_JumpTo function which does ^d if in Explorer and then shoves in the path and presses Enter to go there).

- Secondly, when I am in a SaveAs dialogue box, I want to be able to jump to those same folders, but there is no Address Bar in Save As boxes, so what I want to do is use the same hotkeys to instead enter the path into the Filename field and press Enter, so that I jump to that location and can save something in there (the SaveAs_Paste function).

The GroupAdd stuff is fascinating thanks (I'd seen that in the docs, but had not explored). These are great, I'll have a play with them thanks.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Same Hotkey differently in Explorer or SaveAs dialogue

22 Oct 2018, 10:10

I would do it like this. Cheers.

Code: Select all

#If WinActive("Save As ahk_class #32770 ahk_exe notepad.exe")
&& A_ComputerName = "asus"
q::
MsgBox, % "notepad save as"
return
#If

#If WinActive("Save As ahk_class #32770 ahk_exe wordpad.exe")
&& A_ComputerName = "asus"
q::
MsgBox, % "wordpad save as"
return
#If
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Joey5 and 226 guests