Page 1 of 1

Create new folder in Explorer?

Posted: 08 May 2019, 05:31
by Lee James
I've been struggling with this for a while…

In Explorer, I want to be able to delete files by pressing Ctrl+D, and create a new folder by pressing Ctrl+G.

The Script I made works fine for delete, but not for making a new folder:

Code: Select all

; *** Delete ***
#IfWinActive, Explorer
^d::
   Send, {delete}
Return

; *** New folder ***
#IfWinActive, Explorer
^g::
   Send, {control}{shift}n
Return
I also tried ^+n instead of {control}{shift}n but neither has any effect.

Something else I would love to be able to do (if it's possible?) is have a shortcut which moves the currently selected files into a new folder. Can that be done?

Re: Create new folder in Exploerer?  Topic is solved

Posted: 08 May 2019, 05:39
by elModo7
Change that to this:

Code: Select all

; *** New folder ***
#IfWinActive, ahk_exe explorer.exe
^g::
	Send, {LControl Down}{LShift Down}N{LControl Up}{LShift Up}
Return

Re: Create new folder in Exploerer?

Posted: 09 May 2019, 06:44
by Lee James
elModo7 wrote:
08 May 2019, 05:39
Change that to this:
FANTASTIC! :) Thank you elModo7! :)

Re: Create new folder in Exploerer?

Posted: 09 May 2019, 06:59
by Lee James
elModo7 wrote:
08 May 2019, 05:39
Change that to this:
I've just noticed something strange… Now that I've added your code to my script, none of my other keys work!

For example, this shortcut no longer works at all:

Code: Select all

#2::
   Send, ½
Return

Re: Create new folder in Explorer?

Posted: 09 May 2019, 12:16
by gregster
Strange? Depends on the structure of your script. My guess: you placed the other hotkeys behind the context-sensitive hotkey:

A context-sensitive hotkey definition section (started here with #IfWinActive, ahk_exe explorer.exe) needs to be closed with #IfWinactive or #If without any parameter to close the context-sensitive section, if there are other hotkeys after it, that should work anyway...
https://www.autohotkey.com/docs/commands/_If.htm wrote:To turn off context sensitivity, specify #If or any #IfWin directive but omit all the parameters.

Code: Select all

; some general hotkeys here
[...]

#IfWinActive, ahk_exe explorer.exe
[...]		; contect-sensitive hotkeys here
#If		; closes the context-sensitive section

; other general hotkeys here:
#2::
   Send, ½
Return
If that's not it - please show a code snippet that allows to reproduce the problem...

Re: Create new folder in Explorer?

Posted: 10 May 2019, 07:54
by jeeswg
- I would do it like this:

Code: Select all

#IfWinActive, ahk_exe explorer.exe
^g:: ;create new folder
SendInput, ^+n
return
#IfWinActive
- Note: I use n, not N, N is equivalent to shift+n. (I tested, and SendInput, ^N worked, although I prefer ^+n for clarity.)
- Note also (repeating gregster): #If and #IfWinActive affect all hotkey labels underneath them, until the next #If/#IfWinActive.

Re: Create new folder in Explorer?

Posted: 13 May 2019, 02:11
by elModo7
I myself had never used the #IfWinActive, I tend to do something like this:

Code: Select all

^g::gosub, SampleLabel


SampleLabel:
	IfWinActive, Untitled - Notepad
	{
	    WinMaximize  ; Maximizes the Notepad window found by IfWinActive above.
	    Send, Some text.{Enter}
	    return
	}
return
That way I find hotkeys easier to spot and labels help isolate their purpose.