' Set the Watchdog to 20 Seconds
%SetWatchdog 20
' After using the Watchdog, switch it off
%ClrWatchdog
'-----------------------------------------------------------
' Dictate
'-----------------------------------------------------------
:But_Dictate
%SetWatchdog 20
GSB.HiColor
GSB.Dictate
GSB.LoButton
%ClrWatchdog
RET.
'-----------------------------------------------------------
' Dictate
'-----------------------------------------------------------
:But_Dictate
%SetWatchdog 2
GSB.HiColor
GSB.Dictate
GSB.LoButton
%ClrWatchdog
RET.
'**********************************************
' PRR./PRE./PRV. - Watchdog
' This script demonstrates a simple watchdog timer
' using the $$TIM variable to monitor the main script.
'
' Usage:
' - Set $$TIM to a non-zero value to start the watchdog.
' - The watchdog monitors the elapsed time.
' - If $$TIM is zero, the watchdog is off.
' - If the elapsed time exceeds $$TIM, an action is taken.
'**********************************************
:Watchdog_Start
MOD.New|Watchdog
' Variables Initialization
VAR.$$MWH=#cbw#
' Default State is off
VAR.$$TIM=0
'-----------------------------------------------------------
' Parallel Robot Routine
PRR.0
MOD.Enter|Watchdog
' Print robot information
'PRT.I am (Parallel-)Robot-Nr. #pri#.
'PRT.I am Son #pri# of $$MWH.
:Loop
PRT.Watchloop A
' Wait for timer value to be set
WFV.$$TIM|3
JIZ.$$TIM|off
' Record the start datetime
$$STA=#dtime#
' Main watchdog loop
:WatchdogLoop
PRT.Watchloop B: $$TIM
' Pause for a short period
PAU.1
' Calculate the elapsed time
CAL.$$CUT=(#dtime#-$$STA)
PRT.Test: $$CUT>$$TIM
' Check if the elapsed time exceeds the timer value
IVV.$$CUT>$$TIM
' Print the elapsed time and the timer value
PRT.Watchdog-Timeout: $$CUT>$$TIM
' Get and execute the command
GDF.hp|$$MWH|$$PID
CPR.$$PID
EIF.
' Check if the timer is reset to zero (watchdog off)
JIZ.$$TIM|off
' Repeat the watchdog loop
JMP.WatchdogLoop
' Off condition handling
:off
' Pause for 1 second
PAU.1
' Jump back to the beginning of the loop
JMP.Loop
END.
' Set return value for the main program
PRE.$$WDG|0
MOD.Copy to Last|$$WDG
'-----------------------------------------------------------
MOD.Return
RET.
: %SetWatchdog 1
MOD.Enter|Watchdog
VIN.$$TIM=§§§01
PRV.$$WDG|$$TIM
MOD.Return
END%
: %ClrWatchdog
MOD.Enter|Watchdog
VIN.$$TIM=0
PRV.$$WDG|$$TIM
MOD.Return
END%
#COMPILE EXE
#DIM ALL
#INCLUDE "WIN32API.INC"
TYPE SHELLEXECUTEINFO
cbSize AS DWORD
fMask AS DWORD
hwnd AS DWORD
lpVerb AS ASCIIZ PTR
lpFile AS ASCIIZ PTR
lpParameters AS ASCIIZ PTR
lpDirectory AS ASCIIZ PTR
nShow AS LONG
hInstApp AS DWORD
lpIDList AS ANY PTR
lpClass AS ASCIIZ PTR
hkeyClass AS DWORD
dwHotKey AS DWORD
hIcon AS DWORD
hProcess AS DWORD
END TYPE
%SEE_MASK_NOCLOSEPROCESS = &H00000040
%SEE_MASK_NO_CONSOLE = &H08000000
%SW_HIDE = 0
FUNCTION ShellExecNoConsole (BYVAL Command AS STRING, BYVAL Params AS STRING) AS LONG
DIM sei AS SHELLEXECUTEINFO
DIM result AS LONG
sei.cbSize = SIZEOF(sei)
sei.fMask = %SEE_MASK_NOCLOSEPROCESS OR %SEE_MASK_NO_CONSOLE
sei.hwnd = %NULL
sei.lpVerb = VARPTR(STRPTR("open"))
sei.lpFile = VARPTR(STRPTR(Command))
sei.lpParameters = VARPTR(STRPTR(Params))
sei.lpDirectory = %NULL
sei.nShow = %SW_HIDE
result = ShellExecuteEx(sei)
IF result THEN
' Wait for the process to complete, if needed
WaitForSingleObject(sei.hProcess, %INFINITE)
CloseHandle(sei.hProcess)
END IF
FUNCTION = result
END FUNCTION
FUNCTION PBMAIN () AS LONG
DIM command AS STRING
DIM params AS STRING
command = "notepad.exe" ' Example command
params = "" ' Example parameters, if any
IF ShellExecNoConsole(command, params) THEN
MSGBOX "Process started successfully without a visible window.", %MB_OK, "Info"
ELSE
MSGBOX "Failed to start the process.", %MB_OK, "Error"
END IF
END FUNCTION
function ExecHide(string c, int wait=0) as int
==========================================
STARTUPINFO infs
PROCESS_INFORMATION infp
' [color=#0000ff]CREATE_NO_WINDOW [/color]= 134217728
CreateProcess null,c,0,0,0,134217728,0,0,@infs,@infp
if wait
WaitForMultipleObjects 1,@infp.hthread,1,-1
end if
GetExitCodeProcess(infp.hProcess,@function)
CloseHandle infp.hProcess
CloseHandle infp.hThread
return 0
end function
QuoteIf the landing had been false, can you believe for a moment that the Russians would have wasted the opportunity to ridicule the Americans?
Page created in 0.215 seconds with 13 queries.