Jump to content

Click on shared/network drive in (file) explorer


Recommended Posts

Hi,

Thank you for this great work. I'm new to this though and could do with a bit of help. I want to automate clicking on a mapped network drive in windows explorer. I found the 'Automating Windows Explorer' functions, but I'm not sure how to use them (or if that is the best way to do this?), despite some reading and searching. An example would be amazing.

Thank you,

A

Link to comment
Share on other sites

  • Moderators

@artyb what exactly are you trying to accomplish? Rather than just focusing on clicking on a mapped drive, what is the end goal (open a file, etc.)? By walking us through all of the steps you're trying to complete, we can better assist you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

21 minutes ago, artyb said:

I want to automate clicking on a mapped network drive in windows explorer.

..I guess "Welcome to AutoIt" :D
You don't have to and should not, click 
around. "Windows Explorer" is a user interface to work with files, but in programming you don't use a graphic interface, you run/call commands, like FileCopy() or _WinAPI_CopyFileEx().
Do read around the forum and included help file ( from the standard AutoIt installer ). Doing so will show you how to do code what you need. ;) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Thanks for the quick reply. The network drive connections get lost if the network is interrupted, or eg if the machine is put to sleep. I've got an existing batch script I made to ensure they reconnect, which I can run using AutoIt, but the explorer windows all show 'Computer' and that the network drives are not connected. Simply (single left) clicking on the network drive, then pressing the explorer 'back' button achieves the reconnection and the location being shown before the network was lost. I'm trying to automate this. I found a way to AutoIt the back button, but had to resort to mouse coordinates.

Edited by artyb
Typo
Link to comment
Share on other sites

1 minute ago, artyb said:

and the location being shown before the network was lost

..yeah, the icon may show as not connected in explorer until the path is explored, and only then it shows the proper icon. I never got to dig into that issue.
Do post the solution once you find it. I'm sure it will be a most welcomed piece of code.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

But if you do not know what are the mappings cause it can change from computer to computer (or from time to time) :

Local $hWnd = WinActivate("[CLASS:CabinetWClass]")
;MsgBox ($MB_SYSTEMMODAL,"",$hWnd)

Local $hCtrl = ControlGetHandle($hWnd,"","ToolbarWindow321")
;MsgBox ($MB_SYSTEMMODAL,"",$hCtrl)
Local $aPos = ControlGetPos ($hWnd, "", $hCtrl)
;_ArrayDisplay ($aPos)
ControlClick ($hWnd, "", $hCtrl, "left", 1, $aPos[0]+$aPos[2]/3, $aPos[1]+$aPos[3]/2)

 

Link to comment
Share on other sites

Thanks for suggestions. I don't know what to do with the code you've posted though, and I'm not sure it will acheive what I'm trying to do? I'm trying to update existing open Explorer windows which 'don't realise' that the drives have been mapped.

Thanks.

A

Edited by artyb
Typo
Link to comment
Share on other sites

  • 2 weeks later...

Could you give an example of how this could be modified to step through all shared drives? Would it mean clicking on all locations, not only shared drives? Also explain why /3 for x coordinates and /2 for y?

Thanks,
A

Link to comment
Share on other sites

This is simulating on Window Explorer a click to the back arrow.  Since the control is the whole navigation toolbar (not just the back arrow), I need to estimate the coordinates where to click. Works fine with me on Win7 (untested on Win10).  Use AutoIt info tool to get more information on Window Explorer controls.

Edit : if you got multiple Window Explorer instances, you will need to loop thru each window (use WinList for that).

Edited by Nine
Link to comment
Share on other sites

Ah. I'd already implemented that part in my script, my difficulty was simulating clicks on the shared drives which still show as disconnected in all of the explorer windows (and to some other software which checks for their presence before running backups), even though they are connected and the right hand side of the explorer window is showing the contents if the simulated click on back is to a shared drive. I need to click on each shared drive on the left hand side in order to get the windows to update the fact that they are reconnected.

Thanks,
A

Edited by artyb
Typo
Link to comment
Share on other sites

Ok, I see what you want to do.  If you had used AutoIt Info tool (as I already told you) for the left side of the Window Explorer screen, you would have seen that it is a TreeView control.  You can easily manipulate a TreeView control with GUITreeView UDF.  I know it can be done as I already have a script doing so.  Try using the UDF, put something together and if you have trouble, just post what you got in here.

Link to comment
Share on other sites

I had tried the AutoIt info tool and also the UI Spy before posting. I had also found the Automating Windows Explorer UDF but didn't know how to use it and thought that may be a good way of doing this as people have had issues with automating Explorer. I'm new to AutoIt though, and posted in the Automating Windows Explorer UDF announcement thread, and was redirected here for advice. From memory I didn't spot anything I thought I could use with the info tool in that region (the whole area not individual drives), which is why I searched further and found the Automating Windows Explorer post. Might that UDF be a good way to do this? Alternatively knowing it's called a TreeView may help me in searching for examples.

Thanks,
A

Edited by artyb
Clarification
Link to comment
Share on other sites

I never used Automating Windows Explorer UDF, so I cannot tell if it is working correctly or not.  What I was suggesting is to use a built-in UDF that comes with AutoIt.  GUITreeView UDF is totally fit to manipulate the left end side of Window Explorer.

Look at _GUICtrlTreeView_FindItem to get to the Computer tree

Then use _GUICtrlTreeView_GetFirstChild to get the first child of the Computer tree and loop thru with _GUICtrlTreeView_GetNextChild.

Start learning those functions, experiment, run the examples, and try it on Window Explorer TreeView control handle.

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...