1. Create a new Folder in explorer
This one is of high interest to me and other people, but seems difficult to do with 100% reliability and in a way that works on all languages. I think Tekl or someone else had an alternate way to do it, perhaps involving FileCreateDir and then having the script wait for the folder to appear. But I'm still on the lookout for a more seamless way to do it (I'm currently using Send !fwf).
!fwf is indeed specific to English... For me, it would be !fn{Enter} or even !fn{Enter}{Enter} if there is already files selected.
Well, the nice thing with AHK is that you don't necessarily need to write the scripts for all systems, but you can tweak them to fit your specific needs. Unless, of course, you manage hundred of heterogenous computers...
The case of
creating a new folder in the current view of Explorer has been solved in a way that seems quite system agnostic, as long as the option to display the full path in the title bar is activated.
7. Launch a file using an alternative action eg "edit script"
Run and RunWait support some of the standard verbs like "edit" and "print". For example: Run edit "C:\My Text File.txt"
The difficult part here is to get the name of the selected file, I think.
One can do it like this:
appName = Test AHK
WinGetClass winClass, A
If winClass != ExploreWClass
{
MsgBox 16, %appName%, Oops, wrong window...
return
}
WinGetActiveTitle currentPath
Send {F2}^C{Esc}
MsgBox 64, %appName%, %currentPath%\%Clipboard%
at the expense of loosing the clipboard content.
I tried to get the item name using SendMessage (first try at this command...), but I have no success. If somebody can explain what is wrong in the code below... (Edit: perhaps
I found it, it is harder than it seems, as Windows may not allow to get data from another process.)
LVM_FIRST = 0x1000
LVM_GETSELECTIONMARK := LVM_FIRST + 66
LVM_GETITEMTEXT := LVM_FIRST + 45
LVIF_TEXT = 0x1
; SendMessage LVM_GETSELECTIONMARK, 0, 0, FolderView, A
SendMessage LVM_GETSELECTIONMARK, 0, 0, SysListView321, A
itemIndex = %ErrorLevel%
VarSetCapacity(item, 13*4, 0)
VarSetCapacity(fileName, 257, 0)
InsertInteger(LVIF_TEXT, item, 0) ; mask
InsertInteger(11, item, 1*4) ; iItem
InsertInteger(0, item, 2*4) ; iSubItem
InsertInteger(&fileName, item, 5*4) ; pszText
InsertInteger(256, item, 6*4) ; cchTextMax
; MsgBox % StructureDump(item, 13)
SendMessage LVM_GETITEMTEXT, %itemIndex%, &item, SysListView321, A
MsgBox %ErrorLevel% - %fileName%
I made a StructureDump function to better check what I put in the buffer:
StructureDump(ByRef pSource, pSourceSize = 1)
{
intSize = 4
old_FormatInteger := A_FormatInteger
SetFormat Integer, hex
result = Dump:
Loop %pSourceSize%
{
intVal = 0
offset := (A_Index-1) * intSize
Loop %intSize%
{
intVal += *(&pSource + offset + A_Index-1) << 8 * (A_Index-1)
}
result = %result% %intVal%
}
SetFormat Integer, %old_FormatInteger%
return result
}
I added it to the file with ExtractInteger / InsertInteger...
I could have used ExtractInteger here, but I prefer to make it standalone (faster?).
BTW, why these useful functions are not built in AHK, since they are complementary of DllCall/SendMessage?