Hey jeeswg!
So sorry for my late reply, I didn't receive any email notifications from those posts...
Thanks for your answer to my question, I've finally got something that works, thank you so much!!
Here's my script:
Code: Select all
F3:: ; Show current active file in Explorer
oArray := {Notepad:" - Notepad", XLMAIN: " - Excel", OpusApp: " - Word", PPTFrameClass: " - Powerpoint", AcrobatSDIWindow: " - Adobe Acrobat Reader DC", SciTEWindow:" - SciTE4AutoHotkey"}
WinGetClass, vWinClass, A
WinGetTitle, vWinTitle, A
if oArray.HasKey(vWinClass){
vDName1 := SubStr(vWinTitle, 1, -StrLen(oArray[vWinClass]))
if(RegExMatch(vDName1, "Compatibility Mode")) ;This to make the script work in case file opened in "Compatibility mode" in Office
{
vDName1 := SubStr(vWinTitle, 1, -28) ;Shorten the window name to get rid of "[Compatibility mode]" and make following matching work. Ideally I could write StrLen("[Compatibility mode]") instead of 28 but it doesn't work...
}
vDir1 := A_AppData "\Microsoft\Windows\Recent" ; C:\Users\Thomas\AppData\Roaming\Microsoft\Windows\Recent\
vPath2 := ""
vOutput := "`n"
Loop, Files, % vDir1 "\*", F
{
vPathLnk := A_LoopFileFullPath
FileGetShortcut, % vPathLnk, vPath
VarSetCapacity(vDName, 260*2, 0)
DllCall("comdlg32\GetFileTitle", Str,vPath, Str,vDName, UShort,260, Short)
if !(vDName = vDName1)
|| InStr(vOutput, "`n" vPath "`n")
continue
vOutput .= vPath "`n"
if (vPath2 = "")
vPath2 := vPath ;first matching file
}
vOutput := SubStr(vOutput, 2, -1)
Clipboard := StrReplace(vOutput, "`n", "`r`n") "`r`n"
vComSpec := A_ComSpec ? A_ComSpec : ComSpec
Run, % vComSpec " /c explorer.exe /select, " Chr(34) vPath2 Chr(34),, Hide
}
return
* Probably not the most stable nore beautiful piece of code, but it works in most cases and that all that matters to me here
* Works for: Powerpoint, Word, Excel, Notepad, Adobe pdf Reader, SciTEWindow
* Doesn't work for: PHP Storm and Notepad++ (in both cases because of name of window, possible workarounds which I might do someday if really needed)
* Known limitations: for SciAutoHotkey, works only with one file open, if several files opens the name of window changes.
* Go to know: sometimes Office files are in "[Compatibility Mode]", which changes the name of the window, hence lines 20 to 23 to deal with that. (If you have an answer to my comment on line 22 regarding StrLen("[Compatibility mode]") which doesn't work, I'd be curious).
GEV thanks a lot for your contribution: it works like a charm as well! Doesn't work yet with Powerpoint nore PHPstorm but that could be added, and it does work with Notepad++ which is cool
You guys ROCK, this is awesome
Such a useful little trick don't you think?
Everytime you have to attach a document your working on, F3 and tada, ready to drag and drop !