How get 'Filename.ext' from Explorer

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
Dimmak
Junior Coder
Posts: 25
Joined: Tue Jan 24, 2012 4:57 pm

How get 'Filename.ext' from Explorer

Post by Dimmak » Thu Jan 26, 2012 5:00 pm

How from Explorer get 'Filename.ext' of selected file
I'm trying to use code:

GetCursorPos>Xpos,Ypos
GetTextAtPoint>%Xpos%,%Ypos%,strText,nCharPos

But I get much more information than I need.
Please advice! :wink:

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 26, 2012 5:28 pm

First, may I ask why on earth you would need to do this? I ask because whenever people ask about automating explorer to do things with files there is nearly always a much easier/faster/more reliable way. Pretty much anything you can do in Explorer can be done in script code without having to simulate a user.

Second, if you really, really must do as you ask, how about this:

Code: Select all

//adjust accordingly to Explorer's title, or use some other means to focus Explorer 
SetFocus>My Documents

Press F2
Press CTRL
Send>ac
Release CTRL
Wait>0.2
GetClipBoard>filename

MessageModal>filename
This works because F2 makes the filename editable, ctrl-a selects all, ctrl-c copies to the clipboard. You now have the filename in the clipboard. GetClipBoard gets it to a variable.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Dimmak
Junior Coder
Posts: 25
Joined: Tue Jan 24, 2012 4:57 pm

Post by Dimmak » Thu Jan 26, 2012 6:34 pm

Thanks Marcus! :idea:

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts