Jump to content


Create new file shortcut (like ctrl+shift+n for folder)


  • Please log in to reply
5 replies to this topic

#1 Guests

  • Guests

Posted 19 July 2012 - 09:54 AM

Hello,
I'd like to create new empty file by pressing Ctrl+shift+F (it is something like create new folder by pressing Ctrl+shift+N), but I have some problems to do it right.

I have this so far:
#ifWinActive ahk_class CabinetWClass
^+F::
#ifWinActive ahk_class Progman
^+F::
{
	;How to get focus on window, not selected item?
	Send {AppsKey}
	Send wt
	Sleep 200
	;Delete selected name and extension
	Send {Del 5}
	;Confirm extension change
	;KeyWait Enter
	;Send {Enter}
}
return

Everything is nice except when some file is selected in the explorer window.
I tried to search for focus related topics, but nothing helped me.

Is there a possibility to do it 'create new folder' way?

#2 TheDewd

TheDewd
  • Members
  • 823 posts

Posted 19 July 2012 - 12:46 PM

^+F::
    FileAppend,, New File  ; create new file
return
You will need to combine this with more code to find the location of the currently active window, or else the new file will be created in the same directory as the script.

#3 Guests

  • Guests

Posted 20 July 2012 - 08:04 AM

Thanks for response.
I can't change focus to the window? Or do it simpler? It would be more windowish. ;P
I considered that way and if there aren't other possibilities I'll go with it.

#4 girlgamer

girlgamer
  • Moderators
  • 2039 posts

Posted 20 July 2012 - 08:54 AM

How would you create this same file if you were doing it by hand without a script? Exactly what steps and in what order would you need to accomplish what you want to do? Write those steps down in the exact order you would have to do them. That is the outline for the script you're thinking of. Once you have that then you can begin to create a script to do it.

#5 Guests

  • Guests

Posted 21 July 2012 - 11:32 AM

Steps should be based on the way of doing it. I didn't know how to do it right.
I found a workaround and now it works as I wanted. I guess it is not to good, though.

#ifWinActive ahk_class Progman
^+F::
{
	Send {Click -1, -1}
	Send {AppsKey}wt
	Sleep 200
	Send {Del 5}
}
return

#ifWinActive ahk_class CabinetWClass
^+F::
{
	Send {F10}fwt
	Sleep 200
	Send {Del 5}
}
return


#6 Guests

  • Guests

Posted 21 July 2012 - 11:45 AM

Send {Click -1, -1}

It works for me because I have two monitors. This script will work if there won't be any window in the way.

Normally it should be:
Send {Click 0, 0} ;No window in the top left corner