Created
August 16, 2011 00:00
-
-
Save aubricus/1148174 to your computer and use it in GitHub Desktop.
AutoHotkey script to create a new file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; create new file | |
; installation: | |
; 1. you must be running autohotkey: http://www.autohotkey.com | |
; 2. double click on script to run | |
; [pro-tip] add this script to your startup folder to run when windows start | |
; [pro-top] you can add this script to another .ahk script file. | |
; hotkey is set to control + alt + n | |
; more on hotkeys: http://www.autohotkey.com/docs/Hotkeys.htm | |
^!n:: | |
; script will automatically use its current directory as its "working directory" | |
; to get the file to appear in the active directory we have to extract | |
; the full path from the window(stupid!) | |
; get full path from open windows | |
WinGetText, FullPath, A | |
; split up result (returns paths seperated by newlines [also lame]) | |
StringSplit, PathArray, FullPath, `n | |
; get first item | |
FullPath = %PathArray1% | |
; clean up result | |
FullPath := RegExReplace(FullPath, "(^Address: )", "") | |
StringReplace, FullPath, FullPath, `r, , all | |
; change working directory | |
SetWorkingDir, %FullPath% | |
; an error occurred with the SetWorkingDir directive | |
if ErrorLevel | |
return | |
; display input box for file name | |
InputBox, UserInput, New File (example: foo.txt), , ,400, 100 | |
; user pressed cancel | |
if ErrorLevel | |
return | |
; success! output file with user input | |
else | |
FileAppend, ,%UserInput% | |
return |
Dave, Glad you found some use out of it! Would you mind posting a link to your version of it? Thanks!
Sure, I created it as a fork: https://gist.github.com/1965432
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this is really useful.
I also added
Run %UserInput%
to the end, to load the file in the appropriate editor.Also
#IfWinActive ahk_class CabinetWClass
before it, so it only tries to run when Explorer is active.