Jump to content

Restore folder after networked PC resumes from sleep?


Recommended Posts

Hi. I have a shared folder open on a PC that runs 24/7. The host PC that the folder resides on sleeps from 10PM to 7AM daily. On the PC the folder is open, the content changes to show my network once the host PC sleeps. Normally every morning I would then click the back button in Explorer to get the contents of the folder back, but I'd like to write a script and have AutoIt do that instead. Is that possible? I've tried a few different things like If $OpenExplorer = ("Network") Then Send, ("{ALT}{LEFT}") and FileSelectFolder but I have not been successful. Any tips would be greatly appreciated!

Link to post
Share on other sites

Try to make a replicable runable snippet of the code you are having issue with.  It would be easier for us to help you out this way.

Link to post
Share on other sites

@Nine This is what I'm currently trying, but I keep getting an "error parsing function call" message. Sorry if it's not in the correct format...

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5

 Restore folder after host resumes from sleep

#ce ----------------------------------------------------------------------------

WinActivate ("Network")


If WinActive ("Network") Then ControlSend, ("{ALT}{LEFT}")

Link to post
Share on other sites

This doesn't display an error, but it also doesn't appear to pass the ALT+Left arrow command, as my network is still displayed.

If WinExists("Network") Then
    WinActivate("Network")
Send ("{ALT}{LEFT}")
Else

EndIf

Link to post
Share on other sites
Link to post
Share on other sites

@Nine Thank you for the reply, but I can't get that to work either. I can manually click the Explorer back button and get back to the folder contents, and I can also use the back button on my mouse. However the script doesn't appear to do anything as the network structure remains listed in the window.

Link to post
Share on other sites

On which OS are you ?  Maybe this :

#RequireAdmin
Const $sTitle = "Réseau" ; "Network"
Local $hWnd
If WinExists($sTitle) Then
  $hWnd = WinActivate($sTitle)
  ConsoleWrite ("Handle " & $hWnd & @CRLF)
  ConsoleWrite ("Wait " & WinWaitActive($hWnd) & @CRLF)
  ConsoleWrite ("Send " & ControlSend ($hWnd, "", "", "!{LEFT}") & @CRLF)
EndIf

Cause it is working fine here.

Link to post
Share on other sites

I'm on Win 8.1 and there was no change with your latest script. I've tested it with the Explorer window minimized and opened. How are you testing it?

Also, when I have the Explorer window open and run the script from Documents, I don't see the network window become activated (it's displaying it's background color). Should I see that change when WinActivate is called?

Edited by paul1965
Link to post
Share on other sites

Ah.  Right click on the script and open/edit.  You should be in Scite then.  Make sure your Explorer is in Network.  Come back to Scite and press F5.   The console is at the bottom, enlarge to see all messages.  Select all info, copy it and paste it here.

Link to post
Share on other sites

Ok it seems it doesn't find the window Explorer in Network.  You MUST be in the network otherwise it will not work.  You could try to WinList() all your windows and _ArrayDisplay them all.  You should see what is the problem.  Please show all the Scite console with all version info (everything).

Edited by Nine
Link to post
Share on other sites

Paul, what version of Scite and AutoIt are you running.  The code is NOT finding the window otherwise it would be displayed in the console.  So do not tell me it does.  You need to show me all Scite info.

Link to post
Share on other sites

Download and install full version of Scite (4.2.0.0).  If you want to create scripts, you absolutely need to run full version of Scite, this is essential.

Link to post
Share on other sites
  • Developers
21 minutes ago, paul1965 said:

I've never used AHK before,

Me neither...why should we even when participating in this forum? ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
26 minutes ago, Jos said:

why should we even when participating in this forum? ;) 

lol. I really wanted to use AutoIt. I wrote some scripts for Thunderbird to use for custom email notifications and they work fantastic. But for some reason the script refused to see the network folder. AHK saw it right away, restored it, clicked the back button, then minimized it using it's restored network folder name. The script has been converted to an .exe file and a task created to run it every morning.

Edited by paul1965
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...