
61
2.0 Getting Started
Inserts the current time in the specified format
WLinq 3.x
Link*One
Time( “%H:%M” )
os.date( “%H:%M” )
Concatenations of expressions
WLinq 3.x
Link*One
“X” + Left( 2 ) + Right(
2 )
“X” .. string.sub( data, 1, 2 ) .. string.sub(
data, -2 )
Control characters
WLinq 3.x
Link*One
“<cr><tab>”
“{13}{9}”
“\x09”
“{9}”
“\d013”
“{13}
Combining text and key presses
WLinq 3.x
Link*One
Input() + “<tab>1<cr>” data .. “{Tab}1{Enter}”
Reboot Windows
WLinq 3.x
Link*One
Reboot()
app.exitWindows( exitWindowsOpts[“REBOOT”] )
Reboot Windows (forced)
WLinq 3.x
Link*One
RebootForced()
app.exitWindows( exitWindowsOpts[“FORCE”] )
Starts the specified program
WLinq 3.x
Link*One
RunApp( “notepad.
exe” )
h = app.run( “notepad.exe” )
closeAppHandle( h )
Please note that the Link*One sample code below more realistically
demonstrates what is needed when switching to another application. A
small delay is needed before sending input to the activated window or
characters may be lost. Also the example avoids an unnecessary delay
when the target window already is the foreground window.
Activates the first window that has a caption that matches
the window caption pattern
WLinq 3.x
Link*One
SetFocus( “*Notepad” )
There is no direct equivalent function for the WLinq 3.x WaitForWin-
dow. Below is a full example of a script which waits for a Notepad win-
dow to appear, activates the window, and after a small delay sends the
data to the window.
Some common situations where you need to wait for a window are when
waiting for an Open dialog to appear (after sending Ctrl+O) or when
you have launched an application with app.run() and need to wait for it
to be ready to receive input.
Wait for a window to appear
WLinq 3.x
Link*One
WaitForWindow(
“*Notepad”,
3000 )
No direct equivalent function for WaitForAppExit() exists in Link*One.
The same result can be achieved by using app.isAppRunning().
Even though the sample below demonstrates a script that pauses until
you exits Notepad, Link*One is not intended to have a script that inter-
act with the user (except for app.messageBox()) since there may be side
effects.
app.isAppRunning() is intended to be used to synchronize the script
with an external application that does its job and then exits.
Wait for a window to appear
WLinq 3.x
Link*One
WaitForAppExit(
30000 )
If a script calls
app.closePort()
, the script can start an external ap-
plication that uses the same serial port. When that external application
is exited, the script can re-open the serial port by calling
app.open-
Port()
.