Code: Select all
#F::
Send ^c
Sleep, 150
RunWait, %comspec% /c ftp %clipboard%
Return
Code: Select all
#F::
Send ^c
Sleep, 150
RunWait, %comspec% /c ftp %clipboard%
Return
Code: Select all
book := A_ScriptDir "\book1.xls" ; change this to the path of your excel file
cell = A1 ; change this to the cell containing the IP address
xlObj := ComObjGet( book )
ip := xlObj.Sheets( 1 ).Range( cell ).Value
RunWait, %comspec% /c ftp %ip%
;..............
Code: Select all
#F::
Send ^c
Sleep, 150
SetTimer, Kill_FTP, -3000 ; change 3000 to in/decrease the amount of time to wait.
RunWait, %comspec% /c ftp %clipboard%,, UseErrorLevel, ftpPID
; place the rest of your script here
Return
Kill_FTP:
If ( ErrorLevel != 0 )
WinKill % "ahk_pid " ftpPID
Return
Code: Select all
#F::
Send ^c
Sleep, 150
if !( clipboard ~= "^(\d{1,3}\.){3}\d{1,3}" )
{
Msgbox, 0x10, Whoops!, There is no IP Address on the clipboard! Please try again.
Return
}
SetTimer, Kill_FTP, -3000 ; change 3000 to in/decrease the amount of time to wait.
RunWait, %comspec% /c ftp %clipboard%,, UseErrorLevel, ftpPID
; place the rest of your script here
Return
Kill_FTP:
If ( ErrorLevel != 0 )
WinKill % "ahk_pid " ftpPID
Return
Code: Select all
#SingleInstance, Force
#Persistent
new RunWait( 3 ).run( "notepad" )
msgbox done
Return
class RunWait {
iTimeout := 10
__New( iTimeout=10 ) {
this.iTimeout := iTimeout
}
run( sCommand ) {
Run, % sCommand,, UseErrorLevel, _iPID
_func := ObjBindMethod( this, "closeProcess", _iPID )
SetTimer, % _func, % this.iTimeout ? this.iTimeout * -1000 : -1
Process, WaitClose, % _iPID, % this.iTimeOut
}
closeProcess( iPID ) {
Process, Close, % iPID
}
}
A_User wrote: ↑20 Nov 2017, 11:29Another approach I found is to use `Process, WaitClose`.
Code: Select all
#SingleInstance, Force #Persistent new RunWait( 3 ).run( "notepad" ) msgbox done Return class RunWait { iTimeout := 10 __New( iTimeout=10 ) { this.iTimeout := iTimeout } run( sCommand ) { Run, % sCommand,, UseErrorLevel, _iPID _func := ObjBindMethod( this, "closeProcess", _iPID ) SetTimer, % _func, % this.iTimeout ? this.iTimeout * -1000 : -1 Process, WaitClose, % _iPID, % this.iTimeOut } closeProcess( iPID ) { Process, Close, % iPID } }
The 2005 AHK version is not comparable to today's, by far - there are so many more things you can do nowadays.
Users browsing this forum: gongnl, Google [Bot] and 122 guests