Try
ReOpen!
It closes a file when it becomes unavailable, and opens the file again when it becomes available.
FINISHED: Reopen file after Wifi reconnectsDownload and install
AutoHotkey to run the script.
Save the script as ReOpen.ahk and doubleclick to run.
Skrommel
;ReOpen.ahk
; Closes a file when it becomes unavailable, opens the file again when it becomes available
; The filename is saved to ReOpen.ini
;Skrommel @ 2017
#NoEnv
#SingleInstance,Force
Gosub,INIREAD
Gosub,GUI
Return
INIREAD:
IniRead,file,ReOpen.ini,Settings,file
If (file="ERROR")
file=Spreadsheet.xlsx
Return
INIWRITE:
IniWrite,%file%,ReOpen.ini,Settings,file
IniWrite,%window%,ReOpen.ini,Settings,window
Return
GUI:
Gui,Add,Text,XM,File:
Gui,Add,Edit,XM Y+3 W300 Vfile,%file%
Gui,Add,Button,X+5 W50 GBROWSE,&Browse
Gui,Add,Button,XM+250 W50 GSTART,&Start
Gui,Add,Button,X+5 W50 GEXIT,E&xit
Gui,Show,,ReOpen
Return
START:
Gui,Hide
closed=1
IfWinNotExist,%title%
{
Run,%file%,,UseErrorLevel,pid
If (ErrorLevel=1)
Return
closed=0
}
Loop
{
If closed=0
IfNotExist,%file%
{
WinClose,Ahk_pid %pid%
closed=1
}
If closed=1
IfExist,%file%
{
Run,%file%,,UseErrorLevel,pid
If (ErrorLevel=1)
Return
closed=0
}
Sleep,1000
}
BROWSE:
FileSelectFile,file,3,,Select a file,All files (*.*)
If (ErrorLevel=1)
{
MsgBox,No file selected
Return
}
GuiControl,,file,%file%
Return
EXIT:
Gosub,INIWRITE
ExitApp
Return