You've enhanced the program to accept multiple folder drops at once - nice going!
Tip: when you add code to a forum post use the "code highlighting" dropdown to colorize the AutoHotkey code, like in my posts.
In my working version I have moved the box creation to the top which seems to work, but is there a reason not to do this?
No problem in this case. But with more complex GUIs putting Show first can result in the user first seeing a blank window and only later text, buttons, editboxes. Avoided by putting Show last. Just to illustrate that try what happens if you add in a delay, like so
Gui, Show, w300 h300
, Subfolder Creator
To me the logical progression is make a box, chose pen and ink, and write something with it.
Makes sense in the sketching/planning phase. But that can differ from what is later on the best code order. It often helps to comment (shown in green here) the code to make it more intuitive to read later. For example
;Main GUI window where user drops folders
Gui, Show, w300 h300
, Subfolder Creator
I created a gosub for folder creation and dropped it to the bottom with the appropriate entries for folder creation.
That works. Just for example, another way to do it without the gosub. Notice: continue instead of break.
Gui, Show, w300 h300
, Subfolder Creator
return
GuiDropFiles:
{
}
return
Or alternatively with a
function instead of gosub
Gui, Show, w300 h300
, Subfolder Creator
return
GuiDropFiles:
{
MakeFolders(folder)
}
return
MakeFolders(folder) {
}
One great thing with AutoHotkey is that it is relatively easy to get going with commands and make small programs. We can then gradually move from commands/gosub style coding to expressions, functions and objects as the programs get more complex.
If all your subfolder names will have an increasing pattern you can shorten code by replacing all the FileCreateDir lines with a loop
Simple example, but without padding so the folders get named p1, p2 ... rather than p01, p02 ...
This gives padding
This gives padding in a shorter way by using expressions and the Format() function.