DonationCoder.com Software > Coding Snacks
Batch file,Use a special command to stop the application?
(1/1)
johnny09033:
Use a special command to stop the application?
Its about AlwaysUP application and i use it to run other tools As System, i would like to STOP IT only when the Output.txt content finds the word FINISHED.
http://imgur.com/a/4sy7f
Ath:
And you are asking here, instead of at the Core Technologies support-site, because....?
Seems like a decent feature request to me.
wraith808:
And you are asking here, instead of at the Core Technologies support-site, because....?
Seems like a decent feature request to me.
-Ath (May 31, 2017, 01:46 PM)
--- End quote ---
It seems pretty straightforward that he's asking for a coding snack to remove it because at the site, they might not make it a priority, unless I'm missing something?
skrommel:
ClosedBy closes a program when a file contains a word. :)
Batch file,Use a special command to stop the application?
Download and install AutoHotkey to run the script.
Save the script to ClosedBy.ahk and doubleclick to run.
10.07.2017: Added a timeout. Corrected a bug when selecting a file to watch.
Skrommel
--- ---;ClosedBy.ahk
; Closes a program when a file contains a word
;Skrommel @ 2017
#NoEnv
#SingleInstance,Force
Gosub,INILOAD
Gosub,GUI
Return
GUI:
;Menu,Tray,NoStandard
Menu,Tray,Add,&ClosedBy,SHOW
Menu,Tray,Add
Menu,Tray,Add,&Show...,SHOW
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Default,&ClosedBy
Menu,Tray,Tip,ClosedBy
Gui,1:Add,Text,,Program to close:
Gui,1:Add,Edit,XM Y+2 W300 Vprogram,% program
Gui,1:Add,Button,X+5 W50 GPROGRAM,&Browse
Gui,1:Add,Text,XM,File to search:
Gui,1:Add,Edit,XM Y+2 W300 Vfile,% file
Gui,1:Add,Button,X+5 W50 GFILE,&Browse
Gui,1:Add,Text,XM,Word to look for:
Gui,1:Add,Edit,XM Y+2 W300 Vword,% word
Gui,1:Add,Text,XM,Delay between searches:
Gui,1:Add,Edit,XM Y+2 W50 Vdelay Limit4,% delay
Gui,1:Add,UpDown,Range1-9999
Gui,1:Add,Text,X+5 W150,seconds
GuiControl,1:,delay,% delay
Gui,1:Add,Text,XM,Timeout before closing program:
Gui,1:Add,Edit,XM Y+2 W50 Vtimeout Limit4,% delay
Gui,1:Add,UpDown,Range1-9999
Gui,1:Add,Text,X+5 W150,seconds
GuiControl,1:,timeout,% timeout
Gui,1:Add,Button,X+100 W50 GRUN +Default,&Run
Gui,1:Add,StatusBar,GWEBPAGE,1HourSoftware.no
SB_SetIcon("1HourSoftware.ico")
Gui,1:Show,,ClosedBy
Gui,2:+AlwaysOnTop
Gui,2:Add,Progress,XM W300 Vcountdown Range0-%timeout%,% timeout
Gui,2:Add,Button,XM W100 +Default GCLOSE,&Close the program
Gui,2:Add,Button,X+5 W50 GABORT,&Abort
Return
RUN:
Gui,Submit
Gosub,INISAVE
Loop
{
abort=0
close=0
Process,Exist,%program%
If ErrorLevel>0
{
FileRead,lines,% file
IfInString,lines,% word
{
Gui,2:Show,NoActivate,ClosedBy
countdown:=timeout
Loop,% timeout
{
If close=1
Break
GuiControl,2:,countdown,% countdown
countdown-=1
Sleep,1000
}
If abort=1
Continue
Process,Close,% program
Gui,2:Hide
}
}
Sleep,% delay*1000
}
Return
CLOSE:
close=1
Gui,2:Hide
Return
ABORT:
abort=1
Gui,2:Hide
Return
PROGRAM:
Gui,1:Submit,NoHide
FileSelectFile,program,3,% program,Select a program,Programs (*.exe)
IfExist,% program
{
SplitPath,program,program
GuiControl,1:,program,% program
}
Return
FILE:
Gui,1:Submit,NoHide
FileSelectFile,file,3,% file,Select a text file,Text files (*.txt)
IfExist,% file
GuiControl,1:,file,% file
Return
SHOW:
Gui,1:Show
Return
INILOAD:
IniRead,program,ClosedBy.ini,Settings,program
IniRead,file,ClosedBy.ini,Settings,file
IniRead,word,ClosedBy.ini,Settings,word
IniRead,delay,ClosedBy.ini,Settings,delay
IniRead,timeout,ClosedBy.ini,Settings,timeout
If program=ERROR
program=Calc.exe
If file=ERROR
file=C:\Output.txt
If word=ERROR
word=FINISHED
If delay=ERROR
delay=10
If timeout=ERROR
timeout=30
Return
INISAVE:
IniWrite,% program,ClosedBy.ini,Settings,program
IniWrite,% file,ClosedBy.ini,Settings,file
IniWrite,% word,ClosedBy.ini,Settings,word
IniWrite,% delay,ClosedBy.ini,Settings,delay
IniWrite,% timeout,ClosedBy.ini,Settings,timeout
Return
WEBPAGE:
Run,http://www.1HourSoftware.no,,UseErrorLevel
Return
GuiClose:
EXIT:
Gosub,INISAVE
ExitApp
johnny09033:
thank you !!!
Navigation
[0] Message Index
Go to full version