Is possible to get file name path of file opened in active application?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MIRKOSOFT
Posts: 334
Joined: 23 Sep 2014, 14:29

Is possible to get file name path of file opened in active application?

19 Apr 2020, 19:17

Hi!

Simply:
1. I open any application
2. Select file and have application active
... I need for script to get file name path of file opened in active application.
Is it possible?

I'm using mainly in case of file and folders handling script function which was helped me in this forum earlier and works great, here is for help:

Code: Select all

getSelected(){
    cO:=clipboardAll
    ;clipboard:= ""
    send ^c
    clipWait,0.5
    ;if(errorlevel){
    ;    clipboard:=c0
    ;    return
    ;}
    path:=clipboard
    clipboard:=cO
    return path
Thank you for all - help, replies, suggestions or comments.
Miro
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is possible to get file name path of file opened in active application?

20 Apr 2020, 01:05

I guess it's much easier to get the file path if selected in Windows Explorer instead of ANY :shock: OPEN :crazy: application. :shifty:
Have a try in Explorer: press SHIFT + Right-click (on whatever file(s) you wanna select) + a (valid if your Windows is set with the English language setting, bc you wanna select "Copy as Path"). Afterwards you'll find the full path of that selected files at the clipboard.
MIRKOSOFT
Posts: 334
Joined: 23 Sep 2014, 14:29

Re: Is possible to get file name path of file opened in active application?

20 Apr 2020, 18:39

I know.
I write example of use.

I open assembler editor GUI and I need to generate also version by time and compile number to notes.
So, when I click compile (automated by AHK) it first add note to assembler source as text, then save it and compile.
Then I can get always actual compile attempt number (count) without adding it manually to source file.
I know that compile time is easiest to use in filename, even in file text, but want not to change filename, Ineed to modify assembler source text.
But I never saw number of compile attempt. I must to note it manually always.

For this reason I want to get file name path opened in compiler GUI and automate this part of work.

But this is only single example and it can be used in many programs this way to add for example saving count and many other reasons where I need time and <event> number or so.
Really AHK has big potential and I never got so many possibilities to get them automated. Many people think that AHK is only remapping tool and hotkeys manager, truth is that's much higher productivity tool.

Understandable?
Miro

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: just me, Rohwedder and 181 guests