Can AHK see these PDFs and reopen them after rebooting?

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Coldblackice
Posts: 20
Joined: 13 Nov 2013, 14:39

Can AHK see these PDFs and reopen them after rebooting?

16 Jun 2014, 00:36

Is there a way for AHK to see what PDF's are currently open and then reopen them after rebooting?

I currently have 12 Acrobat windows open with PDF's. I need to reboot, and I'm wondering if AHK can see and remember which PDF's are currently open, and then reopen them after rebooting.

Thoughts:

Even though there are 12 Acrobat windows, there's still just one "Acrobat.exe" running. I wonder if it's possible for AHK to poll or "ask" Acrobat.exe what files it currently has open? Or perhaps asking each window what file it's accessing?

Anyone have the know-how to do something like this?
Micha

Re: Can AHK see these PDFs and reopen them after rebooting?

16 Jun 2014, 09:36

Use Window Spy on each of the Acrobat windows and see if the filename and path are in available in there somewhere.

I'm not on a Windows computer atm so I can't check myself, put that'd be my starting point.
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Can AHK see these PDFs and reopen them after rebooting?

16 Jun 2014, 11:04

If you want to re-open the files after rebooting you will need to save the file paths to a file.
You can put a script to read that file and Run the saved file paths in the Windows Startup folder.

Here is a script that closes all open adobe windows and saves the paths to an array. (Win+C) Then it can re-open the files. (Win+O)
Tested with Adobe Reader 11.0.07

Code: Select all

global WindowArray := {}	; Stores the paths of closed windows

#c::CloseAdobe()	; Win+C to close all Adobe windows
#o::OpenAdobe()		; Win+O to open the stored files

CloseAdobe() {
	while ThisWin := WinExist("ahk_class AcrobatSDIWindow") {
		WinActivate, % "ahk_id " ThisWin
		WinWaitActive, % "ahk_id " ThisWin,, 1
		if (ErrorLevel) {
			MsgBox, Window activation timed out.
			return
		}
		Send, ^d	; Open "Document Properties"
		WinWaitActive, Document Properties,, 1
		if (ErrorLevel) {
			MsgBox, Could not detect Document Properties window.
			return
		}
		ControlGetText, Static2, Static2	; Get the file name
		if (ErrorLevel) {
			MsgBox, Could not get file name.
			return
		}
		ControlGetText, Static18, Static18	; Get the file path
		if (ErrorLevel) {
			MsgBox, Could not get file path.
			return
		}
		WindowArray.Insert(Static18 Static2)	; Store the file name and path
		ControlClick, Button5, Document Properties,,,, NA	; Close Document Properties
		WinWaitClose, Document Properties,, 2
		if (ErrorLevel) {
			MsgBox, Could not close Document Properties.
			return
		}
		WinClose, % "ahk_id " ThisWin	; Close the file
		WinWaitClose, % "ahk_id " ThisWin,, 2
		if (ErrorLevel) {
			MsgBox, Could not close file.
			return
		}
	}
}

OpenAdobe() {
	for key, val in WindowArray
		Run, % val
	WindowArray := {}
}
	
Esc::ExitApp

Return to “Ask For Help”

Who is online

Users browsing this forum: Ashrel, blue83, WOlfen and 53 guests