notepad // txt file in same folder

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
derPat19
Posts: 4
Joined: 12 Oct 2019, 06:10

notepad // txt file in same folder

12 Oct 2019, 06:16

Hi

I have a very simple script:

^t::
InputBox, name, Please select file name
FileAppend,,% name% .txt
Run% name% .txt

I would like to create a txt file in my folder (which I have just opened) ...

but how can I address the current window?

Kind regards
User avatar
boiler
Posts: 17399
Joined: 21 Dec 2014, 02:44

Re: notepad // txt file in same folder

12 Oct 2019, 09:07

What do you want to do with the window that you just opened? Put text in it after you opened it? It would have been easier to put the text in it before you opened it with FileAppend. Is there a reason why you don't want to do that?

By the way, there are a few places where you have a space in the wrong place around a % character. Should be like this:

Code: Select all

^t::
InputBox, name, Please select file name
FileAppend,,%name% .txt ; removed space before "name"
Run %name%.txt ; added space after "Run" and removed the space before "name" and before ".txt"
return
(you should also have a return at the end)
derPat19
Posts: 4
Joined: 12 Oct 2019, 06:10

Re: notepad // txt file in same folder

12 Oct 2019, 12:08

I just want to create a txt file in the opened Explorer window
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: notepad // txt file in same folder

12 Oct 2019, 13:04

Some like this ?

Code: Select all

#if WinActive("ahk_class CabinetWClass ahk_exe explorer.exe")
^t::
InputBox, name, Please select file name
if ErrorLevel
   return
fname := Explorer_GetCurrentFolder() "\" name ".txt"
FileAppend,, % fname
Run % fname
return
#if

Explorer_GetCurrentFolder() {
   global hwnd
    WinGet, process, processName, % "ahk_id" hwnd:=WinExist("A")
    WinGetClass class, ahk_id %hwnd%
    if  (process = "explorer.exe") 
        if (class ~= "(Cabinet|Explore)WClass") {
            for window in ComObjCreate("Shell.Application").Windows
                if  (window.hwnd==hwnd)
                    path := window.Document.FocusedItem.path

            SplitPath, path,,dir
        }
        return dir
}

*Esc::
   ExitApp
return
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
derPat19
Posts: 4
Joined: 12 Oct 2019, 06:10

Re: notepad // txt file in same folder

13 Oct 2019, 04:39

wow thanks, now only code understand ^ ^

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Hugh Jars, Mateusz53, MrDoge, peter_ahk and 359 guests