Jump to content

Copy folder to the current active window (folder)


Recommended Posts

Hi all,

Totally new to autoit, so I beg you to be kind with my question. :-)

I would like to create a script to copy a specific folder (with subfolders and files within them) to the current Windows Explorer window whenever I press a hotkey. I've tried with DirCopy and @WorkingDir, but of course the latter makes the script copy the folder into the same location where the au3 file is. Is there any expression to refer to the current active window? Else does anyone have any suggestions? Thanks in advance!

Regards

Link to comment
Share on other sites

Welcome to the forums!

What you want to do isn't too bad as long as you're just trying to interact with the current active window. You can get the location of it to use with DirCopy by doing:

Sleep (3000) ; Sleep for 3 seconds to give you time to click on another window
$WinTitle = WinGetTitle ("") ; Get the Window Title of the current active window
$FolderLocation = ControlGetText($WinTitle, "", "Edit1") ; Get the text of the control Edit1 from that window
MsgBox (0, "", $FolderLocation) ; Display what you got

MsgBox (0, "", ControlGetText(WinGetTitle (""), "", "Edit1")) ; You can get the same thing from this combined command

Commands to look up:

WinGetTitle

ControlGetText

MsgBox

Sleep

Also, in SciTE, open up Tools --> AU3Info and put your mouse cursor on the address bar of any explorer window (the one you're using to browse the files, not Internet Explorer) and you'll see where I got the Edit1 from. If you don't have that option you may need to install the full SciTE package from here.

*Edit - mind you this is an example, I'd expect you'd take out the sleep and messageboxes when you utilize it in your script...

Edited by exodius
Link to comment
Share on other sites

Welcome to the forums!

What you want to do isn't too bad as long as you're just trying to interact with the current active window. You can get the location of it to use with DirCopy by doing:

Sleep (3000) ; Sleep for 3 seconds to give you time to click on another window
$WinTitle = WinGetTitle ("") ; Get the Window Title of the current active window
$FolderLocation = ControlGetText($WinTitle, "", "Edit1") ; Get the text of the control Edit1 from that window
MsgBox (0, "", $FolderLocation) ; Display what you got

MsgBox (0, "", ControlGetText(WinGetTitle (""), "", "Edit1")) ; You can get the same thing from this combined command

Commands to look up:

WinGetTitle

ControlGetText

MsgBox

Sleep

Also, in SciTE, open up Tools --> AU3Info and put your mouse cursor on the address bar of any explorer window (the one you're using to browse the files, not Internet Explorer) and you'll see where I got the Edit1 from. If you don't have that option you may need to install the full SciTE package from here.

*Edit - mind you this is an example, I'd expect you'd take out the sleep and messageboxes when you utilize it in your script...

Wow, that was quick! I have to read though the Help and your code to ensure I understand everything. Though it works already! Thanks so much.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...