Home

Naurtech CETerm Scripting Guide

image

Contents

1. Unknown Full power ULATION FOR WINDOWS CE AND WINDOWS MOBILE Functional at low power Partial power Partial power Unpowered Navigate Error HRESULT status codes See Microsoft SDK for documentation URL string is not valid var INET E INVALID URL 0x800C0002 No session found var INET E NO SESSION 0x800C0003 Unable to connect to server var INET E CANNOT CONNECT 0x800C0004 Requested resource is not found var INET E RESOURCE NOT FOUND 0x800C0005 Requested object is not found var INET E OBJECT NOT FOUND 0x800C0006 Requested data is not available var INET E DATA NOT AVAILABLE 0x800C0007 Failure occurred during download var INET E DOWNLOAD FAILURE 0x800C0008 Authentication required var INET E AUTHENTICATION REQUIRED 0x800C0009 Required media not available or valid var INET E NO VALID MEDIA 0x800C000A Connection timed out var INET E CONNECTION TIMEOUT 0x800C000B Request is invalid var INET E INVALID REQUEST 0x800C000C Protocol is not recognized var INET E UNKNOWN PROTOCOL 0x800C000D Failed due to security issue var INET E SECURITY PROBLEM 0 800 000 Unable to load data from the server var INET E CANNOT LOAD DATA 0x800C000F Unable to create an i
2. See Microsoft SDK for documentation var PLAYSOUND FLAG ASYNC 0x00000001 Play asynchronously var PLAYSOUND_FLAG NODEFAULT 0x00000002 No default sound var PLAYSOUND FLAG LOOP 0x00000008 Repeat play needs ASYNC var PLAYSOUND_FLAG NOSTOP 0x00000010 Don t stop current sound var PLAYSOUND FLAG NOWAIT 0x00002000 Don t play if driver busy REGISTRY CONSTANTS Registry constants See Microsoft SDK for documentation Root key names var HKEY CLASSES ROOT HKEY CLASSES ROOT var HKEY CURRENT USER HKEY CURRENT USER var HKEY LOCAL MACHINE LOCAL MACHINE var HKEY USERS HKEY USERS Data types var REG SZ REG SZ var DWORD DWORD var REG BINARY REG BINARY var REG MULTI SZ REG MULTI SZ var REG EXPAND SZ REG EXPAND SZ CETerm Scripting Guide Page 179 Returned Status var REGISTRY SUCCESS var REGISTRY FAIL var REGISTRY BAD HIVE var REGISTRY BAD KEYNAME var REGISTRY BAD DATATYPE var REGISTRY BAD VALUE var REGISTRY BAD VALUEFORMAT var REGISTRY OUTOFMEMORY SERVICE STATE CONSTANTS Service state for GPS and other devices See msdn microsoft com IOCTL SERVICE STATUS for var SERVICE STATE OFE 0 Service is
3. Symbolic Name Friendly Name Description IDA_AT IDA_A A IDA B B IDA Z Z IDA LEFT BRACKET IDA BACKSLASH IDA RIGHT BRACKET IDA CARET IDA UNDERSCORE IDA BACKTICK i IDA b b IDA z 7 IDA_LEFT BRACE IDA_PIPE IDA RIGHT BRACE IDA_TILDE IDA_DEL DEL C1 ASCII Controls IDA_IND Index IDA_NEL Next Line IDA_HTS Horiz Tab Set IDA RI Reverse Index IDA_SS2 Single Shift 2 IDA_SS3 Single Shift 3 IDA_DCS Device Ctrl Str IDA_PU1 Private Use One IDA_PU2 Private Use Two IDA_CSI Ctrl Seq Intro IDA_ST String Term IDA_OSC OS Command IDA_PM Private Msg IDA_APC App Prog Cmd Internal Actions TE only IDA UPDATE CURSOR Update Cursor CETerm Scripting Guide Page 147 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA_INHIBIT_UPDATE Inhibit Update Don t update display IDA UNINHIBIT UPDATE Uninhibit Update Allow display update IDA UPDATE Update Force display update IDA INHIBIT SEND Inhibit Send VT buffer characters IDA UNINHIBIT SEND Uninhibit Send VT stop buffering IDA SEND PENDING Send Pending Chars VT send buffered chars Program Actions IDA PROGRAM ABOUT Program About Display About dialog IDA PROGRAM EXIT Program Exit Exit program IDA PROGRAM EXITSILENT Program Exit Si
4. Property Description Values AcceptButtonText Text displayed on accept signature button text D Accept AcceptButtonKey Key code Appendix 5 to accept signature integer D 0x0d Enter BoxBackgroundColor Color of background in signature box integer D 0xe0e0e0 b g r grey BoxHeight Height of signature box D 300 pixels integer BoxLineColor Color of background in signature box integer D 0x000000 b g r black BoxLineWidth Width of line on signature box D 2 integer BoxWidth Width of signature box D 500 pixels integer ButtonHeight Height of buttons D 35 pixels integer ButtonsAtTop If true position dialog buttons at the top of true false the capture dialog D false CancelButtonText Text displayed on cancel button If empty text button is not displayed D Cancel CancelButtonKey Key code Appendix 5 to cancel dialog integer D 0x1b Escape CETerm Scripting Guide Page 91 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Description Values CapturePrompt User prompt text D Please sign and tap text Accept ClearButtonT ext Text displayed on clear button If empty text button is not displayed D Clear ClearButtonKey Key code Appendix 5 to clear signature integer D 0x43 C ConstrainToBox If true only strokes within box are true false displayed D false
5. var EV_RXCHAR 0x0001 Any Character received var EV RXFLAG 0x0002 Received certain character var EV TXEMPTY 0x0004 Transmitt Queue Empty var EV CTS 0x0008 CTS changed state var EV DSR 0x0010 DSR changed state var EV RLSD 0x0020 RLSD changed state var EV BREAK 0x0040 BREAK received var EV ERR 0x0080 Line status error occurred var EV RING 0x0100 Ring signal detected var EV PERR 0x0200 Printer error occured var EV RX80FULL 0x0400 Receive buffer is 80 full var EV EVENTI 0x0800 Provider specific event 1 var EV EVENT2 0x1000 Provider specific event 2 var EV POWER 0x2000 WINCE Power event var EVENT WAIT FAILED 0x01000000 Wait failed see LastError var EVENT WAIT CANCELED 0x02000000 Canceled by user Extended Functions codes var SETXOFF 1 Simulate XOFF received var SETXON 2 Simulate XON received var SETRTS 3 Set RTS high var CLRRTS 4 Set RTS low var SETDTR 5 Set DTR high var CLRDTR 6 Set DTR low Gap for NT code RESETDEV not supported on CE var SETBREAK 8 Set the device break line var CLRBREAK 9 Clear the device break line Some devices share a UART between an IRDA port and a serial port These escape functions allow control over the mode var SETIR 10 Set the port to IR mode var CLRIR 11 Set the port to non IR mode Purg
6. EET I ET 58 3 9 The ETP ObJ6Gb i rhet hte nte teta pe tete bead 59 ERST 59 P iOperiieey m 62 3 10 The GPS ObJect z rco t ecce rt nter t ite oae 63 pro m 63 HAS nit T 65 u 66 acta The Keyboard Objects u re re eren Pret reds 68 Methods dica itia e ad o od ee 68 22 diac adi ud a t t i d tae ER te 71 cse 71 3 12 The Message 73 ERE 73 eornm 73 3 13 The Network Object 74 Mo P 74 ioo EH 75 9 14 The Process Object u au u a nuyusqa haod ase epit ae hao 75 Methods EE 75 A a us ete db tns usa 77 STS Ihe Registry ODJSCt si a um eed ua U 77 Methods bombe dnbie t 78 e ELE 80 3 16 Thie Screen eet iae blab tu 80 Methods oerte bone it ee cami deed 80 Propo OS Tu m tse fa 81 3 17 The SerialPort ObjeCtu u a 82 Methods 5 5 nn bui idee 82 Prope oS LEE 86 3 18 The SESSION n estet eet 89 Me thiods is rie b 89 Propertles et 89 3 19 The Signatur
7. USER INTERACTIV User initia 0 08000 ted action caused this 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0x2A 0x2B 0 40 0 41 0 42 0 80 0 81 ECTION MANAGER PRIORITY ECT FLAGS D TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE User aborted connection Connection is ready but disabled No path found to destination Waiting for a path to destination Voice call is in progress Phone needed and phone is off No connection exclusive conflict Resource allocation failure Connection link disconnected early Failed to authenticate user Attempting to connect Resource is in use Network in use or device is roaming Connection is being brought down Aborting connection attempt No proxy HTTP Proxy WAP Proxy gateway SOCKS4 Proxy SOCKS5 Proxy Suspended connections supported Only dial if on the home network Don t show errors for failed connections USE THIS VALUE FOR request and UL is currently pending on the creation of this connection IBACKGROUND LOWPRIBACKGROUND Only connects if higher priority client is connected Network GUIDs CONN ECTION MANAGE 0 00200 0 00008 Re INTE RNET 43 CETerm Scrip
8. ieee bete renda Appendix Symbology LabelTypes a CETerm Scripting Guide NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 4 Z ree y e eee tate e aa gaa qaa hq 170 Battery and Power Management Constants 170 Browser Error 8 aede 171 172 ConnectionManager Constants pressis arainn 172 File Attribute Constants cette o tite e estre o t i 176 IBM Stat s GCOonstahts eret te rete eiae etus ce e i cta ep Et d on e te e haku 177 Keyboard Gonstants teet ete xt t eter a be teda 177 MessageBox Constants s xot Ux D e uv pe t eed Da b e 178 PlaySound GoristantS ret neto ptite a deste o t p i bes eta viel n tr then e deed ede 179 Registry Constat i cec on e te e Beate 179 Service State Consta MSi oet eae rho ep vied n rece aska due 180 Serial Port Gonstants pp t edet et De ibi o a erogare or be PER dada 180 System Parameter Constant d e ere ep Dd n nare a pe Ed ES 183
9. enne nnns 5 8 Controlling a Serial Port from CETerm eee 5 8 1 SerialPort epe diuo tele redis 5 8 2 Setting the 5 8 3 Configuring SerialPort 5 8 4 Using WaitForEvent to Detect Data and State Changes 5 8 5 Using Single Byte 5 5 9 Writing Efficient Scripts U enne 5 91 Use Local Variables is oi eee ete aeo ob Ee RR 5 9 2 Encapsulate Code in Functions 5 9 3 Limit Execution u u m u Shu nnne nnn nnne nenne 5 10 Debugging Scripts U 5 10 1 Show Script Errors edie eee 5 10 2 OS Alert uu ini eec d a Ee E eadera ne Appendix 1 IDA Action 5 Appendix 2 Application Properties Device Properties csi ene reed deese pee pa ated da e Dore Dae Session Properties isti deep dude bes aqha Scanner Properties etin tee ade bee e Eee ep zd dier q EY Common Symbology Properties Codabar Symbology Properties Code39 Symbology Properties Code 128 Symbology Properties UPC EAN General Symbology Properties symbology
10. CodePage The contents of read write and append operations are Unicode strings in JavaScript The file contents must be converted from bytes to the Unicode string upon read Conversly a Unicode string must be converted to bytes before appending or writing to a file The conversions are performed using the CETerm Scripting Guide Page 58 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE File Codepage property to specify the desired codepage for conversion You may specify any that is already installed on the device by setting the numeric value The default conversion using the ANSI codepage is specified by the value 0 The special conversion UTF 8 can be specified with codepage value of 65001 A special value 1 will perform a raw conversion where only the lower byte of each Unicode value corresponds to each byte in the file with no terminating null byte The raw conversion is useful when reading or writing a binary file See Appendix 4 for additional special codepage values 3 9 THE FTP OBJECT The FTP object provides access to the File Transfer Protocol FTP operations You must use the Login method prior to using the other methods The FTP object is a property of the Network object OS Network FTP Methods The following methods are available Method Action CreateDirectory Create a new directory on the remote host
11. erroraccept Allow format error T F CODE 128 SYMBOLOGY PROPERTIES Code 128 specific symbology properties are unique for each session Symbology properties begin with sessionX scanner code128 where X is 1 through For example session4 scanner code128 ISBT If no X value is found the currently active session number is used NOTE If you are changing the symbology properties for the currently active session you must call CETerm PostIDA IDA SCAN 0 for the changes to take effect WARNING Not all properties are applicable to all hardware devices Different devices may use different names to refer to the same parameters You should look at the settings available in the CETerm configuration dialogs to determine if the property is appropriate and what values it may accept Last Property Level Description FNC1char FNC1 character 0 255 CIP Enable CIP labels T F ISBT Enable ISBT 128 labels T F other Enable other 128 labels T F UCCEAN Enable UCCEAN 128 labels T F UPC EAN GENERAL SYMBOLOGY PROPERTIES UPC EAN general symbology properties are unique for each session Symbology properties begin with sessionX scanner upc ean where X is 1 through For example session4 scanner upc ean bookland If X value is found the currently active session number is used NOTE If you are changing the symbology properties for the
12. 3 0 CETerm Automation Objects a 3 1 The CE Term Object orare cat vr ce Fee ee tease alsin ovis Methods EC arenis 3 2 The Device Object eu erri et nuege ace dae hela ave Methods SEL arenam 3 9 The OS Object Gila sad ela ieee Methods DLE u acted a 3 4 The Browser Object cac rc a E EP E EE RE vede M86052 PrOperligp abl S u Sakaq 3 5 ConnectionManager Object M86052 suu saved aunar akar RE E EEEE A E 3 6 The Display Objetu e e CETerm Scripting Guide Page 3 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 3 7 The Event Object a a ay aa cp e 50 Methods i ep bt aio eine ibe 50 Properties 54 3 8 55 M80605 E T 55
13. 5 1 status SetPostion left top Set the position of the SIP window if un dockable and undocked Returns 0 on success or non zero for error status SetDefaultRectangle left top right bottom Set the initial coordinates of the SIP window if un dockable and undocked Returns 0 on success or non zero for error The coordinates take effect when a new Input Method is loaded but they may be ignored by the Input Method rectangle GetSIPRectangle Get the coordinates of the current SIP window Returns a JSON string in the form left 0 top 206 right 240 bottom 286 Return null if function fails Use the SIP property LastError to get additional error information Properties The SIP object has the following properties Property Description Values LastError Returns the last error value associated with unsigned integer any SIP operation Docked Docked state of SIP true false Locked Locked state of SIP true false Status Returns the availability of the SIP read only 0 unavailable 1 available Visible Visiblility of SIP true false CETerm Scripting Guide Page 96 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 3 21 THE TEXTINPUT OBJECT The Text Input object provides user input a script This object displays a dialog with a text message an input field a Cancel button and an OK button
14. Appendix 2 Properties The properties listed in this appendix may be accessed via the GetProperty and SetProperty methods on the CETerm object Properties marked RO are read only and may not be set with SetProperty The symbol T F indicates a true or false value APPLICATION PROPERTIES Property Name Description app buildid RO Program build identifier app clockinfo displayed True if digital clock is displayed app clockinfo format Format for digital clock display app display hidekeybar RO Hide key bar Windows CE only app display hidemenubar Hide menu bar Windows CE only app display hidetoolbar RO Hide tool bar Windows CE only app display hidestartbar RO Hide Windows Start bar app display hidestartmenu RO Hide Disable Windows Start button app display disablestartmenu app commandline RO Commandline starting program app name RO Program name app processidacharacters Process IDA commands sent as characters app script NN Script NN contents NN is 1 64 app session active RO Currently active session app usertext NN User text NN contents NN is 1 64 app version RO Program version DEVICE PROPERTIES Property Name Description device batterystatus RO Current battery status string device battery statustext RO device battery status RO Current battery status 1 unknown 0 critical 1 warning 2
15. Initialize state this state 0 this checkCount 0 this Check CETerm Scripting Guide Page 129 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE function ExpectMonitor Abort Stop any timer this timer null if ETerm ClearTimeout this timer this timer null Set state to beyond reasonable range this state 1000 Method definitions ExpectMonitor prototype Check ExpectMonitor Check ExpectMonitor prototype Schedule ExpectMonitor Schedule ExpectMonitor prototype Start ExpectMonitor Start ExpectMonitor prototype Abort ExpectMonitor Abort ExpectMonitor prototype OnDone null Check every 200 milliseconds ExpectMonitor prototype checkDelta 200 About 10 seconds for each text check ExpectMonitor prototype maxCheckCount 50 Allow messages ExpectMonitor prototype silent false Class statics ExpectMonitor Instances 5 1 3 Automating Tasks with Expect Any routine prompt and response task can be automated with expect Examples may be navigating through a hierarchy of menus or closing an order for shipping In any case you identify text to find on the screen and the user input to take you to the next screen Here is a simple menu traversal Traverse menu expect ETerm ActiveSession 8000 3 Applications 3 r 2 Invent
16. 115 tia dieta eni A Dade tte faves hu 115 4 13 The OnSessionConnect 116 Mcr PEE 116 LEN 116 4 14 The OnSessionDisconnect Event 116 SYNTAX es igh EP 117 cj q Mh 117 4 15 The OnSessionDisconnected Event 117 SYNTAX EIE 117 117 4 16 The OnSessionReceive 118 nu C CE ha a a ua 118 T 118 4 17 The OnSessionSwitch Event 119 cra T 119 cue 119 CETerm Scripting Guide Page 5 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE je aa WOR oA edie dn OA eee en dnd 5 1 Expect and ExpectMonitor for Automating Tasks BA AM Expect SCHIDE CL Chagas 5 1 2 ExpectMonitor Class L 5 1 3 Automating Tasks with Expect 5 2 Presenting Visual Feedback During Script Execution 5 3 Getting User Input to a 5 4 Running an External Program U 5 5 Using Timers to Run Scripts 5 6 ACCESSING a File ied tiae d etiatn 5 7 Accessing the Registry
17. var x session 1 195 10 var y session 1 10 100 b AddMetaItem Battery x X b AddMetaItem Battery CETerm PostIDA IDA INFO REFRESH 0 4 18 THE ONSMARTCARDEVENT EVENT The OnSmartCardEvent event is fired when the smart card reader changes state The state change may be due to the arrival of data or due to the change of the RF power state This event is available only on devices with integrated CETerm Scripting Guide Page 119 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE support for the smart card reader See device specific documentation for more details Syntax function OnSmartCardEvent status type status status of an operation type type of card for valid read operation Example This example shows the skeleton of the handler OnSmartCardEvent function OnSmartCardEvent status Lype if status 0 0 amp amp type 0 1 ISO IEC14443 MIFARE Ultralight Send card data to session CETerm SendText Device SmartCard GetCardResponse 0 4 19 THE ONSTYLUSDOWN EVENT The OnStylusDown eventis fired when the user taps a terminal emulation screen with a stylus or finger This event is only fired if the tap does not activate a standard touch feature All touch features can be disabled in the CETerm configuration This handler can be used to activate u
18. low medium 4 high 5 charging device battery level RO Current battery strength 0 100 1 unknown device bluetoothaddress RO Bluetooth address device deviceid RO Device ID string device ipaddress RO IP Address of handheld NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Name Description device macaddress RO MAC Address of handheld device oeminfo RO OEM information text device platformid RO Windows CE Platform ID device presetid RO Windows CE Preset ID device rf ssid RO RF SSID of associated AP device rf strength RO 1 unknown RF signal strength 0 100 2 not associated with AP device rf status RO RF status 1 unknown 0 unassociated 1 poor 2 fair 3 good 4 very good 5 excellent device serialnumber RO Device serialnumber SESSION PROPERTIES Session properties begin with sessionX where X is 1 through 4 For example session4 connection host If no X value is found the currently active session number is used Property Name Description sessionX connection host Session host or home URL sessionX connection port TE session port sessionX connection ibmdevice sessionX connection lunumber IBM TE device a k a logical unit number lunumber session
19. status SimulateKeyDown vkCode Simulate the press of a hardware key The vkCode is an integer virtual key code between 1 and 254 See Appendix 5 for virtual key values This key event will be received by the current active foreground window which may not be CETerm The key down action may also generate text input to the application Typically SimulateKeyDown is followed by a SimulateKeyUp Return 0 on success 1 for invalid VK code status SimulateKeyUp vkCode Simulate the release of a hardware key The vkCode is an integer virtual key code between 1 and 254 See Appendix 5 for virtual key values This key event will be received by the current active foreground window which may not be CETerm Scripting Guide Page 70 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE CETerm Typically SimulateKeyUp follows a SimulateKeyDown call Return 0 on success 1 for invalid VK code status SimulateKeyPress vkCode keyStateFlags text Simulate the press and release of a key and specify generated text The vkCode is an integer virtual key code between 1 and 254 See Appendix 5 for virtual key values The keyStateFlags indicate the simulated state of modifier keys See Appendix 4 for key state flag values The text is an arbitrary text string that will be sent to the application together with the key events This key event will be received by the current active foreground
20. The TextInput object is a property of the CETerm object CETerm TextInput Methods The following methods are available Method Action Getlnput Get input from the user result GetInput Getlnput displays the user input dialog Returns 1 for successful input O if input is canceled by the user or 1 if there was an error A default response may be set in the Input property prior to calling Getlnput If no default is desired be sure to clear Input prior to calling Getlnput Properties The TextInput has the following properties Property Description Values Input Can be pre set with default response text before calling Getlnput If Getlnput returns 1 contains the user input PasswordMode If true input is shown as characters true false Prompt Text prompt message for user text Title Text in message box title bar text CETerm Scripting Guide Page 97 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 3 22 THE WINDOW OBJECT The Window object provides access to the displayed windows of running processes This object can be used to find applications and send messages to those applications This feature allows CETerm to control and cooperate with other applications The window object is a property of the os object OS Window WARNING Altering window visibility and input states can make your device unusable and require a device reset
21. function OnSessionConnect session Set login information var myusername inigo var mypassword montoya var waittime 8000 Milliseconds waiting for each text Only login session 1 if session 1 NOTE You must load the expect function and ExpectMonitor NOTE class scripts for this example to work Look for login then password expect session waittime Login myusername r Password mypassword r NOTE You must load the expect function definition and ExpectMonitor class scripts listed in Section 5 1 for the previous example to work The expect arguments are session for the session index waittime for the milliseconds waiting for each expected text followed by pairs of expected text prompt and corresponding action response If the action is text it is simply sent to the host when appropriate There can be any number of expected text action pairs as arguments The expected text can be plain text or a regular expression For a case insensitive match of Login an appropriate regular expression could be login i Regular expressions use the slash character as a delimiter rather than double quote characters The indicates a case insensitive match A more complex action can contain an anonymous function definition such as var beepMe function session CETerm SendIDA IDA BEEP LOUD 0 CETerm Scripting Guide Pa
22. status Reset eventHandleOrName Reset an event to the non signaled state The eventHandle is obtained from a Create call If you use eventName the event must have been previously created within Windows by Create or by another program Returns 0 on success or 1 if no matching event to reset status Set eventHandleOrName Set an event to the signaled state The eventHandle is obtained from a Create call If you use an eventName the event must have been previously created within Windows by Create or by another program Return 0 on success or 1 if no matching event to set status SetListener eventHandleOrName handlerScript timeout Assign a handler script to an event The eventHandle is obtained from a Create call If you use an eventName the event must have been previously created within Windows by Create or by another program The handlerScript will be queued for execution if the event is signaled within timeout milliseconds The handler script is not invoked if the listener times out The special timeout value of OXFFFFFFFF will never timeout The special timeout value 0 will cause an immediate check of the event state NOTE The currently running script which invoked SetListener must finish before any handler can be executed CETerm Scripting Guide Page 53 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Return 0 if a listener is set or a negative value on er
23. Delete fileName Delete an existing file Return true for success false for failure Use the File properties LastError or LastErrorMessge to get additional error information attributes GetAttributes fileName Return the attributes of the file Use the File properties LastError or LastErrorMessge to get additional error information See Appendix 4 for attribute definitions list GetList pattern Return a list of files with names that match a pattern The pattern specifies a valid directory or path and file name which can contain wildcard characters such as an asterisk or a question mark You may use forward slashes to delimit directories The returned list is in the form of a JavaScript array literal which contains JavaScript object literals containing information about every matching file See Section 2 8 for details about handling JavaScript literals Return null if no matching files found Use the File properties LastError or LastErrorMessge to get additional error information For example the following array literal shows two files and a directory name myApp cab attributes 0x21 creationTime new Date 2006 11 15 11 51 41 480 lastAccessTime new Date 2007 7 27 3 27 41 0 lastWriteTime new Date 2008 6 15 0 29 50 0 size 2455494 name myconfig ini attributes 0x21 lastAccessTime new Date 2007 7 27 3 27 18 0 lastWriteTime new Date 2008 6 15 0 29 48 0 size 1256
24. DeleteFile Delete a file on the remote host DeleteDirectory Delete a directory on the remote host GetFile Get a file from the remote host GetDirectory Get the current directory on the remote host ListFiles List files on the remote host Login Login to the FTP service of the remote host Logout Logout of the FTP service PutFile Put a local file onto the remote host RenameFile Rename a file on the remote host SetDirectory Set the current directory on the remote host CETerm Scripting Guide Page 59 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status CreateDirectory directoryName Create a new directory on the remote host Return 0 on success or non zero otherwise Use the FTP properties LastError and LastErrorText to get additional error information status DeleteFile fileName Delete the named file on the remote host Return 0 on success or non zero otherwise Use the FTP properties LastError and LastErrorText to get additional error information status DeleteDirectory directoryName Delete the named directory on the remote host Return 0 on success or non zero otherwise Use the FTP properties LastError LastErrorText to get additional error information status GetFile localName remoteName Copy the named remote file to the given local name Return 0 on success or non zero otherwise Use the FTP prop
25. IDA OIA HIDE OIA Hide Hide IBM OIA bar IDA OIA VISIBLE OIA Show Show IBM OIA bar IDA OIA TOGGLEHIDE OIA Toggle Toggle OIA bar visibility General IBM and VT Actions IDA PF1 F1 Not VT PF1 IDA PF2 F2 Not VT PF2 IDA F3 Not VT PF3 IDA PF4 F4 Not VT PF4 IDA PF24 F24 IDA HOME Home IDA DOWN Down IDA UP Up IDA LEFT Left IDA RIGHT Right CETerm Scripting Guide Page 150 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA_ENTER Enter IBM Actions IDA_IBM_HOME IBM Home IDA_DELETE Delete IDA INSERT ON Insert On IDA INSERT OFF Insert Off IDA INSERT TOGGLE Insert Toggle IDA ATTN Attn IDA CLEAR Clear IDA CURSOR SELECT Cursor Select IDA DUP DUP IDA ERASE EOF Erase EOF IDA ERASE INPUT Erase Input IDA FIELD MARK Field Mark IDA NEWLINE Newline IDA PA1 PA1 IDA PA2 PA2 IDA PA3 IDA RESET Reset IDA_SYSREQ Sys Request 5250 Specific Actions IDA FIELD EXIT Field Exit IDA FIELD PLUS Field 4 IDA FIELD MINUS Field IDA FIELD ADVANCE Field Advance IDA FIELD BACKSPACE Field Backspace IDA FIELD SUB Field SUB IDA HELP IBM Help IDA ROLL DOWN Roll Down IDA ROLL UP Roll Up IDA ROLL LEFT Roll Left IDA ROLL RIGHT Roll Right IDA BACKSPACE Backspace IDA PRINT IBM Print VT Actions IDA ANSWERBACK Answerbac
26. NAUR TECH CORPORATION CETerm Scripting Guide Naurtech Industrial Web Browser And Terminal Emulation Clients CETerm CE3270 CE5250 CEVT220 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Copyright Notice This document may be reproduced in full in part or in any form without prior written permission of Naurtech Corporation Naurtech Corporation makes no warranties with respect to the contents of this document and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose Further Naurtech Corporation reserves the right to revise this publication and referenced software without any obligation to notify any person or organization of such revision or changes Trademarks CETerm CE3270 CE5250 CEVT220 are trademarks of Naurtech Corporation Other product names mentioned in this manual may be trademarks or registered trademarks of their respective companies and are hereby acknowledged Software Version This document is for Version 5 7 0 or later of Naurtech Industrial Web Browser and Terminal Emulation clients CETerm Scripting Guide Page 2 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Table of Contents Copyright Noticeu tial A asia ha d iTrademarks Sata tania aa S ftWare VerSiO Ns Table of Conte
27. NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Workflow Automation Scripts be used to automate routine tasks The task may be a simple login process or a complex set of steps in your host application Event Activated Scripts There are several events within CETerm that will run associated scripts For example when a barcode is read the script OnBarcodeRead will execute and will allow arbitrary processing of the barcode data before it is submitted to the TE or web browser session Key Button and Menu Activated Scripts Like most other CETerm actions scripts can also be tied to any key combination a toolbar button or a context menu Timer Activated Scripts Scripts can be scheduled to run at a future time or run periodically Host Activated Scripts Host applications can also invoke scripts using special commands within the TE data stream CETerm Scripting Guide Page 12 2 0 Getting Started This section describes some common ways that scripting features can be used within CETerm Here we describe the JavaScript engine in CETerm and show how to load and edit a script We also show sample scripts which 1 handle scanner input 2 auto login a terminal emulation session and 3 provide user specified hot spots on the screen Only small code snippets are shown For complete details see the later sections of this manual 2 1 JAVASCRIPT ENGINE The CETerm JavaScript engi
28. R 110 R 300 R 600 R 1200 R 2400 R 4800 R 9600 R 14400 R 19200 R 38400 R 56000 R 57600 R 115200 R 128000 var CB R 256000 Error Flags var E RXOVER Var ERRUN Var E pr lt PARITY var var Var FULL var o Var Var Var G O GO y Gy Gy Cy Ch Cy G FJ Dr D D E O zo 9 02 var Access var GENERIC READ var GENERIC WRIT Events CETerm Scripting Guide 0x02 0x03 0x04 0 00 0 01 0 02 110 300 600 1200 2400 4800 9600 14400 19200 38400 56000 57600 115200 128000 256000 0 0001 Receive Queue overflow 0x0002 Receive Overrun Error 0x0004 Receive Parity Error 0x0008 Receive Framing error 0x0010 Break Detected 0x0100 TX Queue is full 0x0200 LPTx Timeout 0x0400 LPTx I O Error 0x0800 LPTx Device not selected 0x1000 LPTx Out Of Paper 0x8000 Requested mode unsupported 0x80000000 0x40000000 Page 181 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE
29. if eventMask amp EV RXCHAR Data is available read and process MyReadAndProcess portIndex if eventMask amp EV DSR DSR state changed Devic ntered sleep MyCloseAndReopen portIndex else if portIndex 3 Do something different for port 3 DoPort3Actions eventMask This sample is just a template It shows that there is only one OnSerialPortEvent handler for all serial ports and that you must further direct the event to your own processing routines depending on the port signaling the event The event handler may be very complex Some rich examples are available on our website or through Naurtech Support After your handler is defined and the port opened you call SerialPort WaitForEvent when you are ready to handle events This enables an event listener for the port If the event is signaled by the port the event handler OnSerialPortEvent is invoked The event handler is invoked only once for each call of WaitForEvent but the handler parameters may indicate multiple event conditions Within the OnSerialPortEvent handler or other helper routines a common pattern is to schedule the next SerialPort WaitForEvent Although they share a common handler function you must call WaitForEvent separately for each port each time you want to enable events for that port To cancel an active event listener use SerialPort CancelWaitForEvent CETerm Scripting Guide Page 140 NAURTECH WEB BROWSE
30. CETerm Scripting Guide Page 30 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE CETerm Scripting Guide Page 31 3 1 THE CETERM OBJECT The top level CETerm object gives access to CETerm features settings and session state This section documents the methods and properties of the CETerm object Methods The following methods are available Method Action AbortScript Abort the currently running script ClearAllTimers Clear all SetTimeout and Setlnterval timers Clearlnterval Clear a recurring interval timer ClearTimeout Clear a one time timer GetProperty Get a property value GetlDADescription Get the description friendly name of an IDA value GetlDAName Get the symbolic name of an IDA value GetlDAValue Get the numeric value for an IDA name PostIDA Send a command to a session asynchronous RunScript Run a script called from a web browser only Send to session synchronous SendText Send text to a session Session Get a session object Setlnterval Create a recurring interval script execution timer SetProperty Set a property value SetScriptTimeout Set the current script execution timeout SetTimeout Create a one time script execution timer AbortScript Stop the currently executing script ClearAllTimers Clear all recurring interval timers and one time timers ClearInterval intervalTimerID Cl
31. Failed to get password CETerm Scripting Guide Page 132 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 5 4 RUNNING AN EXTERNAL PROGRAM It is possible to start an external program from the CETerm script engine You can wait for the program to finish or allow it to run independently Often you will run a program then return to CETerm when it exits The Process object allows you to manage running processes The Fvent object can be used to schedule a script to run when a process exits Here is an example to start the stylus calibration Note that the arguments depend on whether your device is Window CE or Windows Mobile Stylus Calibration TODO Uncomment the lines for your device For Windows CE 5 0 devices OS Process ExecuteAction Windows ctlpnl exe colmain cpl 9 1 open For Windows Mobile 5 devices OS Process ExecuteAction Windows ctlpnl exe cplmain cpl 7 0 open 5 5 UsiNG TIMERS TO RUN SCRIPTS Script execution timers are useful for several tasks They can be used to Defer an action which is not possible in an event handler Perform an action periodically Provide an asynchronous script execution Split up a long running task cod m We have already shown how the timer is used with the ExpectMonitor class and task automation in Section 5 1 Event handlers should be limited to a small amount of processing If more pro
32. Open the GPS device and enable operations This action will supply power to the GPS device if it is not already operational To minimize power consumption the GPS device should remain closed until data is required CETerm Scripting Guide Page 63 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Before opening the device you may want to set the event properties if events are used to monitor location changes Return 0 for success non zero for error Use the GPS property LastError to get additional error information status Close Close the GPS device Return 0 for success non zero for error Use the GPS property LastError to get additional error information position GetPosition Read the current GPS position The returned position is a JavaScript object literal containing information about the current position See Section 2 8 for details about handling JavaScript literals Return null if error Use the GPS property LastError to get additional error information The returned literal contents will depend on the capabilities of the GPS hardware If successful the contents should at least contain latitude and longitude values The GPS property MaximumAge also affects the returned values Any position data older than MaximumAge milliseconds will not be reported Satellite data is only included if the GPS property IncludeSatelliteData is true Here is a sample position o
33. Ox4A 14 48 2527 254 2565 257 258 259 260 261 262 for more details Width of screen in pixels Height of screen in pixles Width of vertical scroll bar Height of arrow bitmap Width or arrow bitmap Height of horizontal Scroll bar Special window handle for broadcast var HWND BROADCAST var WINDOW RELATIONS HWNDFIRST 0x0 the specified window is a topmost window the specified window is a child window OxFFFFFFFF The window of the same type that is highest in the z order the handle identifies the topmost window that is highest in the z order the handle CETerm Scripting Guide Page 183 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE identifies the sibling window that is highest in the z order HWNDLAST The window of the same type that is lowest in the z order the specified window is topmost window the handle identifies the topmost window that is lowest in the z order the specified window is a child window the handle identifies the sibling window that is lowest in the z order HWNDNEXT 0x2 The window below the specified window in the z order If the specified window is a topmost window the handle identifies the topmost window below the specified window If the specified window is a child window the handle identifies
34. PromptFontSize Size of capture prompt font D 16 pt integer PromptFontWeight Weight of capture prompt font D 500 integer medium SignaturePenColor Color of pen in signature box D 0x000000 integer b g r black SignaturePenWidth Width of pen in signature box D 2 integer LastError Returns the last error value associated unsigned with any SignatureCapture operation integer Example The following example shows how signature capture can be performed from a web page This page will save a new signature image each time the capture is invoked The most recent image will be displayed in the web page when the capture is complete To run this example put the contents in a file and copy the file to the device to use as a static page i e file signandshow htm html head lt title gt Signature Capture Demo lt title gt lt head gt lt body gt lt b gt Signature Capture Demo lt b gt lt br gt lt form name forml lt input type button name signme value Capture Signature onclick mycapture gt lt table border 1 width 100 style background color darkgray gt lt tr gt lt td gt lt input type image name testl id sigimage onclick alert ok alt Tap Capture Signature to continue value Testbutton src signature bmp gt lt td gt lt tr gt lt table gt lt br gt lt form gt lt script language javascript gt CETerm Scripting Guide Page 92 NAURTECH WEB BROWSER
35. SignatureCapture AcceptButtonText 91 SignatureCapture BoxBackgroundColor 91 SignatureCapture BoxHeight 91 SignatureCapture BoxLineColor 91 SignatureCapture BoxLineWidth 91 SignatureCapture BoxWidth 91 SignatureCapture ButtonHeight 91 SignatureCapture ButtonsAtTop 91 SignatureCapture CancelButtonKey 91 SignatureCapture CancelButtonText 91 SignatureCapture CancelDialog 90 SignatureCapture Capture 90 SignatureCapture CapturePrompt 92 SignatureCapture ClearButtonKey 92 SignatureCapture ClearButtonText 92 SignatureCapture ClearSignaturePoints 90 SignatureCapture ConstrainToBox 92 SignatureCapture Display 90 SignatureCapture GetSignaturePoints 90 SignatureCapture LastError 92 SignatureCapture PromptFontSize 92 SignatureCapture PromptFontWeight 92 SignatureCapture SetSignaturePoints 91 SignatureCapture SignaturePenColor 92 SignatureCapture SignaturePenWidth 92 SignatureCapture WriteBMPImage 91 SignaturePenColor 92 SignaturePen Width 92 SimulateKeyDown 70 SimulateKeyPress 71 SimulateKeyUp 70 SIP object 42 95 SIP Docked 96 SIP GetInputMethod 95 SIP GetInputMethodList 95 SIP GetSIPRectangle gt 96 SIP LastError 96 SIP Locked 96 SIP SetDefaultRectangle 96 SIP SetInputMethod 95 SIP SetPostion 96 SIP Status 96 SIP Visible 96 Sleep 41 132 SmartCard object 39 Speech object 39 Status SIP 96 Page 196 NAURTECH W
36. accepting input or false if the window is not accepting input Use the window property LastError to get additional error information status IsVisible windowHandle Check the visibility state of the specified window Return true if the window may be visible or false if the window is hidden A window in the visible state may still be hidden from view by other windows Use the window property LastError to get additional error information CETerm Scripting Guide Page 100 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status IsWindow windowHandle Check if the specified window handle is valid Return true if the window handle identifies an existing window or false if the window does not exist Use the Window property LastError to get additional error information status PostMessage windowHandle message wParam IParam Post a message to the specified window Return the status of the posting not the status of processing the message This feature is primarily intended to work with applications that document public messages that may be used for control or communication Valid message values and parameters are not documented in this manual Use the window property LastError to get additional error information WARNING Posting ill formed message may cause the receiving application to fail There are very few messages that are valid from this method status SendMessage windowHand
37. if data length 8 data 000 data Send barcode to emulator CETerm SendText data session Return 0 to handle barcode normally Return 1 if handled data here return 1 If the OnBarcodeRead handler is defined it will override any ScannerNavigate handler defined in a web page META tag The following OnBarcodeRead CETerm Scripting Guide Page 19 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE handler will pass the scan on to the ScannerNavigate handler for a web browser in session 2 OnBarcodeRead function OnBarcodeRead session data source date Lime Don t process for browser session if session 2 Return 0 to handle barcode with ScannerNavigate return 0 Prefix zeros to short barcodes if data length 8 data 000 data Send barcode to emulator CETerm SendText data session Return 1 if handled data here return 1 The following OnBarcodeRead handler will split any barcode containing an ASCII Linefeed LF 0x0A character and terminated with an ASCII ENQ ENQ 0x05 into two parts The first part is put into the current IBM 5250 field and the second part into the next field and then submitted to the IBM host This technique is used to login a user with a Code39 barcode full ASCII mode All other barcodes are passed on for normal input OnBarcodeRead function OnBar
38. is disconnected If there are no other connected sessions then CETerm will exit OnSessionDisconnect function OnSessionDisconnect session Switch to next connected session CETerm SendIDA IDA SESSION NEXTLIVE 0 if CETerm ActiveSession session Still on current session no others connected C ETerm PostIDA IDA PROGRAM 0 4 15 THE ONSESSIONDISCONNECTED EVENT The onSessionDisconnected event is fired when a terminal emulation TE session is disconnected by the remote host The handler can be used to attempt to reconnect to the host or perform other cleanup tasks Syntax function OnSessionDisconnected session session index of session which was disconnected by remote host Example This example will check for RF coverage and attempt to reconnect if RF is detected OnSessionDisconnected function OnSessionDisconnected session CETerm Scripting Guide Page 117 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Check RF status var status CETerm GetProperty device rf status if status lt 0 OS Alert signal detected Nn Return to RF coverage and reconnect return Attempt to reconnect to host CETerm PostIDA SESSION CONNECT session 4 16 THE ONSESSIONRECEIVE EVENT The OnSessionReceive event is fired when a terminal emulation sessio
39. sc ClearButtonText Erase sc ClearButtonKey 8 charCodeAt 0 VK codes for 0 9 and A Z are ASCII values CETerm Scripting Guide Page 93 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE sc AcceptButtonText OK sc AcceptButtonKey 0x0D Default is VK RETURN Rotate screen display before capture if originalRotation captureRotation display SetOrientation captureRotation Capture signature sc Capture Restore original display rotation if originalRotation captureRotation display SetOrientation originalRotation Save signature as a BMP file filename signature count bmp sc WriteBMPImage filename imagePenWidth imagePenColor imageBackgroundColor imageConstrainToBox Update signature image in page document getElementById sigimage src filename Increment count for next signature count lt script gt lt body gt lt html gt CETerm Scripting Guide Page 94 3 20 THE SIP OBJECT The 51 object controls the Soft Input Panel SIP displayed the screen This object can be used to select the desired Input Method and control the SIP visibility The SIP object is a property of the OS object OS SIP NOTE The SIP object may not work on some Windows CE devices depending on the support included in the OS by the hardware vendor Methods The following methods are
40. All command line arguments are processed and auto connect sessions are connected before this event CETerm Scripting Guide Page 114 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Syntax function OnProgramStart This handler has no arguments and any return value is ignored Example This example makes sure Session 3 is active when CETerm starts OnProgramStart function OnProgramStart Allways switch to Session 3 CETerm PostIDA SESSION 53 0 4 12 THE ONSERIALPORTEVENT EVENT The OnSerialPortEvent event is fired when a serial port changes state The state change may be due to the arrival of data or due to the change of a signal line state See Chapter 5 for details about OnSerialPortEvent Syntax function OnSerialPortEvent portIndex eventMask index of serial port object signaling the event eventMask mask indicating event s that occurred Example This example shows the skeleton of the handler See Chapter 5 for details OnSerialPortEvent function OnSerialPortEvent portIndex eventMask var 0 0001 Any Character received if portIndex 3 amp amp eventMask amp EV RXCHAR Read data from port 3 MyReadData portIndex CETerm Scripting Guide Page 115 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 4 13 THE ONSESSIONCO
41. Be sure you understand the effect of changing values Methods The following methods are available Method Action Enablelnput Enable or disable input to a window Find Find a named window if it exists GetDesktop Get the handle for the desktop window GetList Get a list of top level windows GetParent Get the parent of the specified window GetRelative Get a relative child or sibling of the specified window GetSelf Get the handle of the top level CETerm window GetText Get the text of the specified window GetTopmost Get the window with which the user is working IsEnabled Check if window is enabled for input IsVisible Check if window is visible IsWindow Check if window handle is valid PostMessage Post a message to a window SendMessage Send a message to a window SetTopmost Set a window as the current working window Show Show or hide a window CETerm Scripting Guide Page 98 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status Enablelnput windowHandle enabled Enable or disable input to a window If enabled is true then mouse and keyboard input is enabled Return true if window was previously disabled or false if window was previously enabled Check the Window property LastError to determine the success of the method windowHandle Find windowClass windowName Find the handle of the top level window
42. CE AND WINDOWS MOBILE status ClearAllListeners Clear all handler scripts that have been assigned to events ClearAllListeners will also clear handler scripts waiting for processes Return 0 for success or a negative value for failure status ClearListener event Clear the handler script for the specified event The event may be specified by the integer event handle or the event name Return 0 for success or a negative value for failure eventHandle Create eventName manualReset Create an eventHandle for the named event The eventName cannot be empty If manualReset is true the event will not be reset after waiting for a listener If manualReset is false the event is automatically reset after waiting for a listener If the named event already exists within Windows the manualReset value is ignored and a handle to the existing event is returned Otherwise the event is created within Windows Create is typically used when a new event is created for use exclusively within CETerm Create may also be used to create a handle within CETerm to access an event which is normally created within Windows by another program or driver Return the eventHandle for success 0 for failure Use the Event property LastError to get additional error information status Delete eventHandle Delete the specified eventHandle from management The Create method must have been used to create the eventHandle For convenience you may s
43. DeleteValue Delete an existing value Delete Value2 Delete an existing value deprecated EnumerateKeys Get all sub key names of a specified key EnumerateValues Get all value names of a specified key FlushKey Issue the RegFlushKey command GetValueType Get the data type of a value ReadValue Read a value from a key ReadValueVBArray Read a value from a key and return as a Visual Basic array WriteValue Write a value to a key status DeleteKey keyname Deletes an existing key and all values Returns 0 for success or non zero for an error Delete will fail if a key has sub keys status DeleteValue valuename Deletes the specified value in an existing key Use a fully qualified value name that starts with a root key Returns 0 for success or non zero for an error status DeleteValue2 keyname valuename deprecated Deletes the specified value in an existing key Returns 0 for success or non zero for an error CETerm Scripting Guide Page 78 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE keylist EnumerateKeys keyname Return a JSON array of sub keys of the specified key See Appendix 4 for key names and definitions If StringSeparator is not empty returns a string with the sub key names separated by the current StringSeparator property value keylist EnumerateValues keyname Return a JSON array of values of the specified key See Appendix 4 for key names an
44. Disable scanner if keyboard is locked IBM KEYBOARD NORMAL UNLOCKED if state if PreviousKeyboardState session CETerm Scripting Guide Page 108 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE IBM KEYBOARD NORMAL UNLOCKED CETerm PostIDA IDA SCAN RESUME 0 if PreviousKeyboardState session IBM KEYBOARD NORMAL UNLOCKED CETerm PostIDA IDA SCAN SUSPEND 0 Save new state PreviousKeyboardState session state 4 6 THE ONKEYMESSAGE EVENT The OnKeyMessage event is fired only when the CETerm property InterceptKeyMessages is true This event is rarely used but does permit full capture of key messages to allow features such as a device un lock key sequence All arguments in the handler contain integer values The handler must return true if it processes the message or false to allow normal processing Syntax function OnKeyMessage hwnd message wparam lparam time x y hwnd window handle for message message message type e g keydown keyup etc wparam wparam of the message e g vk code of the message time time of the message x coordinate if a stylus input y y coordinate if a stylus input The handler function must return true if it processed the key message and no further action is needed for this message CETerm Scripting Guide Page 109 NAURT
45. If false GetFile will report an error if a file with the same name exists Default is false PassiveMode If true use passive FTP semantics for true or the connection This must be set prior false to login Default is false CETerm Scripting Guide Page 62 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Description Values Port Specifies the TCP IP port used on the unsigned server for the FTP connection Default integer is 21 ServerListsUTCFiletimes If true ListFiles assumes that the true or server sends UTC based file false timestamps and converts these to local times before output If false assumes that timestamps are in local times Default is false UserName User name of the current active string session read only 3 10 THE GPS OBJECT The GPS object provides access to GPS operations The GPS object is a property of the Device object Device GPS The GPS object provides direct access to the GPS functionality Some devices do not support the GPS object but GPS data can be read from a serial port using the Device SerialPort object Consult your device documentation for details Methods The following methods are available Method Action Open Open the GPS device and enable operations Close Close the GPS device GetPosition Read the current GPS position GetDeviceState Query the GPS device state status Open
46. Locked HTML Actions IDA DOM SUBMIT DOM Submit Submit the first form in the page Used in scanner postamble IDA URL URL Defines start of URL Used in UserText and terminated with IDA URL HOME URL Home IDA URL BACK URL Back IDA URL FORWARD URL Forward IDA URL REFRESH URL Refresh IDA URL STOP URL Stop Special Actions IDA 100 Vibrate 100ms IDA VIBRATE 200 Vibrate 200ms IDA VIBRATE 500 Vibrate 500ms IDA VIBRATE 1000 Vibrate 1sec IDA VIBRATE 2000 Vibrate 2sec IDA VIBRATE 5000 Vibrate 5sec IDA_BEEP_OK Beep IDA_BEEP_WARN Beep Warn IDA_BEEP_LOUD Beep Loud IDA_KBD_ALPHA KeyMode Alpha IDA KBD NUMERIC KeyMode Numeric IDA KBD ALPHANUM KeyMode AlphaNum IDA KBD UPPERALPHA KeyMode Upper Alpha IDA KBD LOWERALPHA Keymode Lower Alpha IDA KBD FUNCMODE KeyMode Func CETerm Scripting Guide Page 154 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA KBD CYCLEMODE KeyMode Cycle Cycle to next mode IDA POPUP IPADDRESS Show IP Address IDA POPUP MACADDRESS Show MAC Address IDA POPUP BATTERY Show Battery IDA POPUP TIME Show Time IDA POPUP SERIALNUMBER Show Serial IDA POPUP DEVICEID Show Device ID IDA POPUP RFINFO Show RF info CETerm Scripting Guide Page 155
47. MessageBox 41 OS Network 42 74 OS PlaySound 41 OS PlayTone 41 OS Process 42 75 OS Registry 42 77 OS SIP 42 95 OS Sleep 41 OS StopSound 42 OS TickCount 42 43 OS Version 42 43 OS Window 43 98 OutputContinueOnXOFF 87 P ParityMode 87 PasswordMode 97 Ping 74 PlaySound 41 125 PlaySound Constants 179 PlayTone 41 143 PortIndex 86 PortName 86 PostIDA 33 PostMessage 101 PowerStateRequest 38 Process object 42 75 Process ExecuteAction 76 Process GetList 76 Process Kill 77 Process LastError 77 Process LastExecuteProcess 77 Process WaitForExit 77 ProcessMetaKey 45 Progress 73 ProgressRate 73 ProgressRunning 73 ProgressVisible 73 Prompt 97 PromptFontSize 92 PromptFontWeight 92 Pulse 53 PurgeQueues 84 PutFile FTP 61 R Read File 57 Read SerialPort 84 ReadByte 84 ReadIntervalTimeout 88 CETerm Scripting Guide ReadTillByte 84 ReadTotalTimeoutConstant 88 ReadTotalTimeoutMultiplier 88 ReadValue 79 135 ReadValueVBArray 79 Registry Constants 179 Registry object 42 77 Registry DeleteKey 78 Registry DeleteValue 78 Registry EnumerateKeys 79 Registry EnumerateValues 79 Registry FlushKey 79 Registry GetValueType 79 Registry ReadValue 79 Registry ReadValueVBArray 79 Registry StringSeparator 80 Registry WriteValue 80 RemoveDirectory 57 RenameFile FTP 62 Re
48. MessageBox Display a standard Windows MessageBox PlaySound Play a wave file on the device PlayTone Play a tone on the device Sleep Pause the script execution StopSound Stop an asynchronous playing PlaySound sound Alert message Show the user a simple text message and wait for them to press OK Sound the default Windows beep tone text GetErrorMessage error Return a descriptive text message for the specified Windows error If the value is unknown return the error hexadecimal value as text NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE value GetSystemMetric id Return an integer system metric value for the specified id System metrics are dimensions widths and heights of Windows display elements and system configuration settings See Appendix 4 for a list of id values Returns 0 for an uknown id value GetSystemParameter type Returns a string value for the specified type The return value may represent an integer or a JSON literal See Appendix 4 for a list of type values Returns null for an unknown type Not all devices will return valid values for all types value MessageBox message title flags Display a standard Windows message box The title is displayed in the message box title bar The flags are used to specify the icon and buttons that are visible Return a value corresponding to the button pushed to close the dialog See Appe
49. Process operation read only integer LastExecuteProcess Returns the process ID of the last unsigned process created by ExecuteAction integer read only 3 15 THE REGISTRY OBJECT The Registry object provides access to the Windows registry The registry is form of database on Windows devices which holds the device configuration The registry has a hierarchical structure The keys are similar to file folders and the values inside a key are similar to files in a folder For a better understanding of the Windows registry you can search for information at msdn microsoft com with the keywords using registry ce Several methods require a fully qualified value name which contains the full key hierarchy begins with a root key and ends with the value name This fully CETerm Scripting Guide Page 77 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE qualified value name is similar to a file name with the full path The Registry object is a property of the OS object OS Registry WARNING Altering the registry can make your device unusable Be sure you understand the effect of changing values NOTE The Registry object now returns multiple values in the JSON format If you want the legacy format set the StringSeparator to the value lt gt Methods The following methods are available Method Action DeleteKey Delete an existing key
50. RFID readers into CETerm See Chapter 5 for additional details about using the SerialPort object Methods The following methods are available Method Action CancelWaitForEvent Stop listening for a serial port event ClearBreak Clear the break condition ClearError Clear any error conditions and return status information Close Close the serial port and terminate communications Open Open the serial port for communication PurgeQueues Discard content of input and output queues Read Read up to a maximum number of bytes ReadByte Read one byte ReadTillByte Read up to a maximum number of bytes or a specified byte value SetBreak Set the break condition SetQueueSizes Set the size of input and output queues CETerm Scripting Guide Page 82 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE WaitForEvent Start listening for a serial port event Write Write a string of characters WriteByte Write a single byte value WriteNULL Write a number of NULL 0 bytes WriteUrgent Write a single urgent byte at the front of the output queue status CancelWaitForEvent Cancel the active event listener for the port If canceled changes in port status will not be reported through the event handler OnSerialPortEvent Return 0 on success non zero for failure status ClearBreak Clear the break condition on the port Return 0 on suc
51. System Metric Constants U 183 Window Constants ete Chan 183 Appendix 5 Microsoft Virtual Key 185 GIOSS EDS 190 LAX PE 191 CETerm Scripting Guide Page 7 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Preface All of us at Naurtech Corporation constantly strive to deliver the highest quality products and services to our customers We are always looking for ways to improve our solutions If you have comments or suggestions please direct these to Naurtech Corporation e mail support naurtech com Phone 1 425 837 0800 Assumptions This manual assumes you have a working knowledge of Microsoft Windows user interface metaphor and terminology Stylus based touch screen navigation terminology Basic programming and scripting concepts Dynamic HTML the browser DOM and JavaScript Basic operations and requirements of the host applications you want to access with the Naurtech web browser and terminal emulation clients Conventions used in this Manual This manual uses the following typographical conventions User actions and interactions with the application are in bold as in Session Configure Precautionary notes or tips are presented as follows TIP Text associated with a specific tip 57 represents new version specific information Text associated with sampl
52. a CETerm action to a global hot key The vkCode is an integer virtual key code between 1 and 254 See Appendix 5 for virtual key values The keyModifiers specify if the Alt Ctrl Shift or Windows key must also be pressed with the activating key See Appendix 4 for key modifier values The idaCode is a CETerm IDA Action Code symbolic name as a text string Each hot key must use a unique IDA Action Code Often the IDA code will activate a CETerm script to perform multiple operations If multiple hot key combinations must perform the same action you can use separate but identical scripts See Appendix 1 for IDA values Return 0 for success 1 if replaced an existing hot key or a negative value for failure Use the Keyboard property LastError to get additional error information A global hot key is recognized regardless of the foreground application so it can be used to activate CETerm actions even when another program is visible WARNING On Windows Mobile devices the CETerm setting Disable Windows Action Keys will also disable all hot keys in CETerm status DeleteHotKey idaCode Delete the global hot key with the specified IDA action Return 0 if deleted the hot key 1 if the key was not found other negative value for failure Use the Keyboard property LastError to get additional error information status DeleteAllHotKeys Delete all global hot keys Return 0 status Enable enabled Enable or disable t
53. as data collection validation and automation All Naurtech Clients include one or more Terminal Emulations TE and a Web Browser for a natural migration path from legacy text based TE applications to newer Web based applications We will refer to the clients collectively as CETerm although the scripting features apply fully to the single emulation products CE3270 CE5250 and CEVT220 Scripting features can help the transition to web applications and add capabilities to older TE applications Newer web based applications can be presented in a familiar single purpose locked down configuration which uses keys the touch screen or both for user interactions Please see our Web Browser Programming Guide for detailed information on using the Web Browser features The Naurtech Scripting features automate and extend our clients We use the industry standard JavaScript language with Microsoft JScript additions JavaScript is the language underlying the most capable and complex functionality in web applications today This class of web applications is sometimes referred to as Web 2 0 using Asynchronous JavaScript and XML AJAX CETerm brings this rich language to the TE user to provide more productive TE applications Scripting can also interact with web browser sessions to extend existing web applications on the mobile device Scripts can be as simple as editing barcode data before sending to a host or as complex as parsing an externa
54. available Method Action GetlnputMethod Get CLSID of current Input Method SetlnputMethod Set the current Input Method GetlnputMethodL ist Get a list of available Input Methods SetPostion Set the position of the SIP if un dockable and undocked SetDefaultRectangle Set the default SIP size May be adjusted by the Input Method GetSIPRectangle Get the current SIP window rectangle clsid GetInputMethod Returns the CLSID string of the current Input Method status SetInputMethod clsid Set the current Input Method The CLSID is a string in the form var keyboardIMclsid 42429667 AE04 11D0 A4F8 00AA00A749B9 var status OS SIP SetInputMethod keyboardIMclsid Returns zero on success non zero for error inputmethodList GetInputMethodList Return a list of the available Input Methods The returned list is in the form of a JavaScript array literal which contains JavaScript object literals 1 containing information about each Input Method See Section 2 8 for details about handling JavaScript literals Return null if error Use the SIP property LastError to get additional error information NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE The returned literal has the following format name Keyboard clsid 42429667 AE04 11D0 A4F8 00AA00A749B9 15 0 4149 9306 105
55. configuration dialogs to determine the correct name Symbology Name Description ames Ames auspostal Australian Postal aztec Aztec bpo British Postal canpostal Canadian Postal chinapostal China Postal codabar Codabar codablock Codablock code1 1 Code 11 code16k Code 16k code32 Code 32 code39 Code 39 code49 Code 49 code93 Code 93 code128 Code 128 composite Composite AB and C couponcode Coupon Code d2of5 Discrete standard 2 of 5 datamatrix Datamatrix delta Delta Code dutchpostal Dutch Postal ean8 EAN 8 3 EAN 13 i20f5 Interleaved 2 of 5 iata25 IATA 2 of 5 idtag ID Tag isbt ISBT japanpostal Japan Postal koreapostal Korea Postal label45 Label 45 m2of5 Matrix 2 of 5 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Symbology Name Description maxicode Maxicode mesa Mesa micropdf Micro PDF msi MSI pdf PDF 417 pdf417 PDF 417 pharma39 Pharma 39 planet Planet plessey Plessey posicode Posicode postnet Postnet qrcode QR Code rss RSS 14 GS1 Databar rss14 RSS 14 GS1 Databar rssexp RSS Expanded GS1 Databar Expanded rsslim RSS Limited GS1 Databar Limited rssitd RSS Limited GS1 Databar Limited telepen Telepen 39 TLC 39 trioptic39 Trioptic 39 ukpostal British UK Postal
56. currently active session you must call CETerm PostIDA IDA SCAN 0 for the changes to take effect WARNING Not all properties are applicable to all hardware devices Different devices may use different names to refer to the same parameters You should look at the settings available in the CETerm configuration dialogs to determine if the property is appropriate and what values it may accept Last Property Level Description bookland Enable Bookland labels T F coupon Enable Coupon labels lineardecode Enable linear decode T F supplemental2 Enable 2 digit supplemental or add on barcode T F supplemental5 Enable 5 digit supplemental or add on barcode T F supplementalretry Supplemental decode retry count 2 10 randomweightcheckdigit Enable random weight check digit T F supplementalmode Supplemental mode none always auto securitylevel Decode security level none all ambiguous SYMBOLOGY NAMES Symbology properties begin with sessionX scanner SSS where X is 1 through 4 and SSS represents a symbology name and may be 3 or more characters long The following table lists all available symbology names WARNING Not all symbologies are applicable to all hardware Different devices may use different names to refer to similar symbologies e g upce and upceO You should look at the symbologies available in the CETerm
57. line of script but the error is detected as the compiler reaches column 8 of this line and encounters the O Be sure to look around the indicated location to identify the source of the error A runtime error may be seen at startup if a script is performing some initialization or it may be seen while using CETerm It can be difficult to identify the source of the error if the script was fired by an event or timer Most often a runtime error can be prevented by defensive coding where you are sure to check the validity of arguments and object references The runtime error looks like this Microsoft JScript runtime error CETerm Scripting Guide Page 144 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Line 14 Col 9 Object doesn t support this property or method Unfortunately the JScript engine does not return the source code line for a runtime error You must manually examine your scripts at the specified location for a clue about the problem 5 10 2 OS Alert Because there is no JScript debugger on the Windows CE device the tried and true debugging tool is OS Alert message Experienced programmers will recognize this as the write 6 100 print or MessageBox technique The basic idea is to sprinkle OS Alert calls through your code to track program flow and variable values It can be tedious but it s easy to do and easy to remove the OS Alert calls by preceding t
58. new Date 2008 8 8 8 8 0 driverPrefix COM4 multiplexPrefix GPD1 friendlyName ACME GPS Card version 1 23 Properties The GPS object has the following properties Property Description Values DeviceStateChangeEvent Event ID of event signaled when GPS eventID device state changes If needed you must set this value before calling Open The eventlD must be obtained by calling OS Event Create IncludeSatelliteData Include satellite data with position true false results if true Default is false IsOpen Indicates GPS device is open and true false enabled read only LastError Returns the last error value associated unsigned with the GPS object integer LastPosition Return last position data obtained by object GetPosition literal MaximumAge Maximum age in milliseconds of position unsigned results returned by GetPosition Default integer value is 180000 CETerm Scripting Guide Page 65 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Description Values NewLocationDataEvent Event ID of event signaled when GPS eventlID position changes If needed you must set this value before calling Open The eventID must be obtained by calling OS Event Create Example The following example shows how the GPS device can be monitored and the current location displayed This example also uses the OS Event methods
59. number of bytes written for success negative value for failure Use the SerialPort property LastError to get additional error information Where needed this method may be used to wakeup an attached device prior to sending commands status WriteUrgent byteValue Write a single byte with integer value byteValue to the port This places the byte ahead of any pending data in the output buffer Return 1 for success negative value for failure Use the SerialPort property LastError to get additional error information More details can be found by searching msdn microsoft com with the keyword transmitcommchar CETerm Scripting Guide Page 85 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Properties Many ofthe SerialPort properties correspond directly to Windows serial port configuration values More details can be found by searching msdn microsoft com with the keywords commtimeouts structure ce and DCB structure ce In general you should set all necessary properties before opening the serial port However you may alter the properties of an open port by assigning new values See Chapter 5 for additional details about using the SerialPort object The SerialPort object properties are listed in the following tables The first table contains general purpose properties the second contains device control DCB properties and the third contains timeout properties Values marked D ind
60. object For example var valuename HKLM Comm PY21BG1 Parms TcpIp DhcpDNS var vbarray new VBArray OS Registry ReadValueVBArray valuename var jsarray vbarray toarray CETerm Scripting Guide Page 79 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status WriteValue valuename valuedata datatype Write the specified value Use a fully qualified value name that starts with a root key WriteValue will create the containing key if it does not exist Values may be specified in a JSON format or as a simple string Simple binary value strings can be submitted as a list of comma separated hexadecimal digits MULTI SZ strings can be separated with the current StringSeparator property value Returns 0 for success non zero for error See Appendix 4 for root key names and datatype definitions Common datatypes are REG_ SZ for a string and REG DWORD for a DWORD value var name HKLM Test MultiString ValueName var data valuel value2 value3 r JSON format var status OS Registry WriteValue name data REG MULTI SZ Properties The Registry object has the following property Property Description Values StringSeparator Text string that separates MULTI SZ text values Default empty uses JSON formats 3 16 THE SCREEN OBJECT The Screen object gives access to a session terminal emulation screen The Screen Object is a property o
61. starts with CETerm startup or when Re Initialize has been pressed on the General tab After importing or editing a script you may want to tap the Test Load button Doing so will start the following actions e If the script engine was previously enabled the script will be executed If the current script contains function definitions they will be checked for correct syntax and will be made available to the script engine If the current script contains executable statements such as function calls and variable assignments they will be processed immediately In general you do not want to use Test Load for scripts with executable statements that are usually invoked by key bindings or other activations Remember to tap Test Load or Re Initialize with Load at Startup checked after making changes to a script if you want those changes loaded into the script engine Also Test Load will not work if you have just checked Enable but not yet accepted the configuration changes to enable the script engine The Template button displays a list of script templates which correspond to the scripting event handlers Select a template and tap OK to have it replace the current contents of the script being edited The template scripts show some of the ways to use CETerm Automation Objects Load Script Template fok Select template and tap OK OnBarcodeRead Process barcode read a OnDocumentDone Run after web docu lOnNavigateError Run i
62. that matches the given window class or window name Either argument may be an empty string Return the non zero window handle or 0 if not found Use the Window property LastError to get additional error information windowHandle GetDesktop Get the handle of the desktop window windowList GetList Return a list of current top level windows The returned list is in the form of a JavaScript array literal which contains JavaScript object literals containing information about each window See Section 2 8 for details about handling JavaScript literals Return null if error Use the Window property LastError to get additional error information The returned literal has the following format hwnd 0x7c010680 processID 0x0 text CursorWindow hwnd 0x7c012d70 processID 0xf79f79aa text hwnd 0x7cOlcf20 processID 0x77452dda text Edit Script 6 hwnd 0x7cOlbb70 processID 0x77452dda text Scripting hwnd 0x7c0189c0 processID 0x77452dda text S1 Configure hwnd 0x7c015c50 processID 0x77452dda text CETerm 51 hwnd 0x7c012320 processID 0xb7f67176 text Input Panel hwnd 0x7c011d40 processID 0xb79f7e32 text WinCENotify 1 E windowHandle GetParent windowHandle Get the handle of the parent window If the window is a child window the return value is a handle to the parent window If the window is a top level windo
63. to the serial port the default timeouts wait for all the data to be written In most cases this will be instantaneous because the data are placed in the output buffer If flow control is enabled and transmission is blocked the buffer may fill and the write may block You should use write timeouts if blocking is possible so that CETerm is not fully blocked waiting for the write to complete var portIndex 5 var sp Device SerialPort portIndex sp WriteTotalTimeoutConstant 100 sp WriteTotalTimeoutMultiplier 10 5 8 3 2 Configuring Common SerialPort Properties In addition to the timeout properties discussed above there are a couple of other properties which must often be configured These include the baud rate flow control and the EventMask Here is a sample function used to configure and open a port function OpenPort portIndex CETerm Scripting Guide Page 138 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE var sp Device SerialPort portIndex Port configuration sp EventMask EV RXCHAR EV DSR sp XOFFOutputFlowControl false sp XOFFInputFlowControl false See Appendix 4 for contants sp BaudRate CBR 9600 sp DataBits 8 sp StopBits ONESTOPBIT sp ParityMode NOPARITY Set read timeouts sp ReadTotalTimeoutConstant 100 Sp ReadIntervalTimeout 50 sp ReadTotalTimeoutMultiplier 10 Set write timeouts sp WriteTotalTimeoutConsta
64. var SERVICE STATE ON 1 Service is var SERVICE STATE STARTING UP 2 Service is var SERVICE STATE SHUTTING DOWN 3 Service is var SERVICE STATE UNLOADING 4 Service is var SERVICE STATE UNINITIALIZED 5 Service is var SERVICE STATE UNKNOWN Oxfffffftf Constan DTR Con SERIAL PORT CONSTANTS trol Flow Values NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE documenta tion turned off turned on starting up shutting down ts for SerialPort control object var DTR_CONTROL DISABLE 0x00 var CONTROL ENABLE 0x01 var DTR CONTROL HANDSHAKE 0x02 RTS Control Flow Values var RTS CONTROL DISABLE 0x00 var RTS CONTROL ENABLE 0x01 var RTS CONTROL HANDSHAKE 0x02 var RTS CONTROL TOGGLE 0x03 Parity Modes var NOPARITY 0x00 var ODDPARITY 0x01 CETerm Scripting Guide unloading not unini tialized Page 180 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE var FV ENPARITY var MA RKPARITY var SPACEPARITY Stop Bit Counts var ON var ON ESTOPBIT ESSTOPBITS var TWOSTOPBITS Baud rates var CB var CB var CB var CB var CB var CB var CB var CB var CB var CB var CB var CB var CB var CB
65. verb Run a program using the specified action verb The file specifies either an executable program that will be run or a general document file that will be processed according to the specified verb The arguments are specified as a text string and are passed to the program that is run Arguments are separated by spaces Use quotes if an argument contains spaces If you want to include double quotation marks as part of an argument these must be enclosed by two sets of double quotation marks For example the argument string var args first arg with spaces quotes part of arg last specifies 4 arguments first arg with spaces quotes part of arg and last Normally the verb is open for executable files but it may be edit or print to invoke those actions on a document file Return 0 on success or non zero otherwise Use the Process property LastError to get additional error information Use the property LastExecuteProcess to get the process ID of the last process started processList GetList Return a list of currently running processes The returned list is in the form of a JavaScript array literal which contains JavaScript object literals containing information about each process See Section 2 8 for details about handling JavaScript literals Return null if error Use the Process property LastError to get additional error information The returned literal has the following format proc
66. write The new File Append method should be used to append data to files but this example still illustrate how to use the File object AppendToFile function AppendToFile filename addedContent var status false var F OS File Check if file exists var attributes F GetAttributes filename if attributes OxFFFFFFFF var content F Read filename status F Write filename content addedContent else CETerm Scripting Guide Page 134 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status F Write filename addedContent return status 5 7 ACCESSING THE REGISTRY The registry on a Windows CE device is a form of database which contains most of the device configuration The Registry automation object allows you to read write and delete registry keys and values WARNING Altering the registry can make your device unusable Be sure you understand the effect of changing values and accept the responsibility The registry has a hierarchical structure The keys are similar to file folders and the values inside a key are similar to files in a folder Several Registry methods require a fully qualified value name which contains the full key hierarchy begins with a root key and ends with the value name This fully qualified value name is similar to a file name with the full path The following example creates a new k
67. 0 CONNSTATUS 0x00000100 LASTCONNECT 0x00000200 SIGNALQUALITY 0 00000400 IPADDR 0 00000800 be Connection status flags CONNECTION MANAGER STATUS FLAGS BILLBYTIME 0 00000001 Connection is billed by time ALWAYSON 0x00000002 Connection is always on SUSPENDRESUME 0x00000004 Connection is suspend resume capable be FILE ATTRIBUTE CONSTANTS File attribute flags CETerm Scripting Guide Page 176 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE See Mi var var var var var var var var var var FI FI Pu E FI FI EL FI FI FI EJ Ed El Ed Ed Ed IBM STATUS CONSTANTS Constants used by DisplayStatus var var Var var var var var var var var IBM IBM IBM 5 STAT STAT STAT STAT STAT STAT STAT IBM STAT IBM STAT ENDIN AITIN YSTE US UNKNOWN G G TED UMERI S W S PROTEC N F 2 NSERT n K n Q C 02 CA 2 D H U rC LI EAR KEYBOARD CONSTANTS OF 40 s 40 xs N P 0x0000000
68. 0 EV RXFLAG event OutputContinueOnXOFF Continue output when XOFF has true D false been sent to restrict input ParityMode Parity scheme to use when parity integer see checking is enabled Default is Appendix 4 none 0x0 RTSControlMode RTS signal mode Default is integer see enable when open 0x1 Appendix 4 StopBits Number of stop bits to use integer see Default value is one stop bit Appendix 4 D 0x0 XONCharacter Value of XON character D 0x11 integer XONLowerLimit Consumed space threshold in integer D 100 input buffer below which flow control is relaxed to allow additional input Input flow control may be XON XOFF RTS or DTR XOFFCharacter Value of XOFF character integer D 0x13 XOFFInputFlowControl Enable XON XOFF control for reception Send XOFFCharacter when XOFFUpperCushion is reached Send XONCharacter when XONLowerLimit is reached true D false XOFFOutputFlowControl Enable XON XOFF control for transmission Stop transmission when XOFFCharacter is received re start when XONCharacter is received true D false XOFFUpperCushion Minimum available space in input buffer allowed before flow control is activated to stop additional integer D 100 CETerm Scripting Guide Page 87 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE DCB Description Values Property input Input flow control may b
69. 1 0x00000002 0x00000004 0x00000010 0x00000020 0x00000040 0x00000040 0x00000080 0x00000100 0x00000800 0x00001000 0x00002000 icrosoft SDK for documentation _ATTRIBUTE READONLY _ATTRIBUTE HIDDEN _ ATTRIBUTE SYSTEM ATTRIBUTE DIRECTORY ATTRIBUTE ARCHIVE ATTRIBUTE INROM ATTRIBUTE ENCRYPTED ATTRIBUTE NORMAL ATTRIBUTE TEMPORARY ATTRIBUTE COMPRESSED ATTRIBUTE ROMSTATICRE ATTRIBUTE ROMMODULE Constants used by OnKeyboardStateChange Var Var Var Var Var Var Var Var Var Var Keyboard Ho EY MODIFIERS Var ALT IBM IBM IBM IBM IBM IBM IBM IBM VT VT ROL KEYBOARD HARD KEYBOAR KEYBOAR KEYBOAR KEYBOARD PRE KEYBOAR KEYBOAR KEYBOAR EYBOARD LOCKE EYBOARD UNLOC D POWE D NORMAL UN WARE E RRO D NORMAL LOCKED OCK ED RRO D POST 0x1 0x2 CETerm Scripting Guide H D SS MES D SYSTEM I tkey Constants RROR ST S a 0 Either ALT key must be held down Either CTRL key must be held down Page 177 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE MOD SHIFT 0x4 MOD WIN 0 8 MOD KEYUP 0x1000 he Key state flags var Keys KEY STATE FLAGS K
70. 2 description The Internet secure true status GetDetailedStatus Returns the detailed status of all current connections The list is in the form of a JSON literal see Section 2 8 See Appendix 4 for type flag and status values Following is the partial output from a Windows Mobile 6 5 device version 0xl parameterflags 0x36f type 0x6 subtype 0xl1 securitylevel 0x0 status 0x20 destination A1182988 0D73 439E 87AD 2A5B369F808B source 18AD9FBD F716 ACB6 FD8A 1965DB95B814 description null corp 18AD9FBD F716 ACB6 FD8A 1965DB95B814 lastconnecttime new Date 0 0 0 0 0 0 version 0xl parameterflags 0x36f type 0x6 subtype Oxl securitylevel 0x0 status 0x20 CETerm Scripting Guide Page 47 NAURTECH WEB BROWSER AND TERM destination 436 NAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE EF144 B4FB 4863 A041 8F905A62C572 source ADBOB001 10B5 3F39 27C6 9742E785FCD4 description HTTP ADBOB001 10B5 3F39 27C6 9742 lastconnecttime new Date 0 0 0 0 0 0 version 0xl parameterflags Oxff7 type 0x2 subtype 0x2 tylevel 0x0 status 0x10 signalquality Oxff flags 0x2 securi destination 436 EF144 B4FB 4863 A041 8F905A62C572 description lwifi2 adaptername AR6K 5 1 lastconnecttime new Date 2010 2 1 18 52 43 ipaddress 192 168 1 207 guid MapNameToNetwork name Map a network name to the corres
71. 4 attributes 0x10 lastWriteTime new Date 2008 2 11 12 29 49 0 size 1024 1 Note that the lastAccessTime are always present and should be checked for existence before using them Their existence depends on the type of Windows filesystem holding the files See any standard JavaScript reference for details on the Date constructor arguments See Appendix 4 for attribute definitions CETerm Scripting Guide Page 56 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE filename GetOpenFileName title filter Return the name of a file specified by the user in an Open file dialog The title of the dialog should contain descriptive information for the user For example Please select a datafile The filter is a list of filter pairs Each pair represents the description of a filter and the file selector wildcards For a JavaScript file it may look like this JScript File js x00 js x00 x00 Each element of the pair is followed by as a separator character The last pair has an additional trailing xoo Here is a multiple filter example JScript File js Nx00 3s8Nx00A11 Files x00 x00 x00 filename GetSaveFileName title filter Return the name of a file specified by the user in a Save file dialog The title of the dialog should contain descriptive information for
72. 73 Message Title 73 MessageBox 41 MessageBox Constants 178 MinimumReceiveBandwidth 49 CETerm Scripting Guide ModemStatus gt 86 Move File 57 N Navigate 45 Network object 42 74 Network ConnectionManager 46 Network DNSLookup 74 Network FTP 59 75 Network LastDNSError 75 Network LastPingError 75 Network LastPingHostName 75 Network LastPingIP Address 75 Network LastWSAError 75 Network MaximumPingTimeout 75 Network Ping 74 NewLocationDataEvent 66 O OnBarcodeRead 12 18 20 104 OnConnectionManagerEvent 105 OnDocumentDone 106 133 OnIBMCommand 107 OnKeyboardStateChange 108 OnKeyMessage 109 OnNavigateError 110 OnNavigateRequest 112 OnNetCheckFailed 113 OnProgramExit 114 OnProgramStart 114 OnSerialPortEvent 115 OnSessionConnect 22 116 OnSessionDisconnect 116 OnSessionDisconnected 117 OnSessionReceive 118 OnSessionSwitch 119 OnSmartCardEvent 119 OnStylusDown 23 120 OnTriggerEvent 121 OnVTCommand 122 OnWakeup 123 Open GPS 63 Open SerialPort 83 OS object 28 40 42 OS Alert 40 OS Beep 40 OS ClipboardData 42 OS Event 42 50 OS File 42 55 OS GetErrorMessage 40 OS GetSystemMetric 41 OS GetSystemParameter 41 OS LastError 42 Page 194 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE OS LastOSError 42 OS MasterVolume 42 OS MemoryStatus 42 43 OS
73. AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE var count 1 var ext null global variable not declared in a function if typeof external object Windows external is already defined in global namespace ext external else Windows Mobile Create CEBrowseX for object access ext new ActiveXObject Cebrowsex IdaCtl function mycapture filename var sc ext Device SignatureCapture var display ext Device Display var originalRotation display Orientation Capture parameters Set desired screen rotation during capture var captureRotation 90 Rotate display before capture var imagePenWidth 2 var imagePenColor Oxff bbggrr hex color specification var imageBackgroundColor Oxffffff white var imageConstrainToBox false shrink image to signature sc CapturePrompt Your purchase totals 15 34 n Please sign and tap Accept sc PromptFontSize 20 ConstrainToBox is false allow writing anywhere on screen sc ConstrainToBox false true sc SignaturePenWidth 2 sc BoxLineWidth 2 sc ButtonHeight 35 sc ButtonsAtTop true Shrink box height or width NOTE If too large will be shrunk to fit screen sc BoxHeight 50 sc BoxWidth 100 Set cancel button text empty to hide button sc CancelButtonText sc CancelButtonKey 0 Don t allow key activation
74. E NETWORK OBJECT The Network object provides access to the network features such as hostname resolution ping and FTP The Network object is a property of the os object OS Network Methods The following methods are available Method Action DNSLookup Lookup the IP address of a given hostname Ping Test whether a host is reachable across an IP network ipAddress DNSLookup hostname Return the IP address corresponding to the hostname as a string Returns null if cannot resolve the IP address Use the Network property LastDNSError to get additional error information status Ping hostname timeout Sends an ICMP packet to the hostname and waits timeout milliseconds for a reply The hostname may be a text name or an IP address Return the round trip response time in milliseconds Return 0 for no response or a negative value on error Use the Network property LastPingError to get additional error information The Ping command is synchronous so no other CETerm operations occur while itis active You should minimize the timeout value The property MaximumPingTimeout limits the timeout you can specify in the Ping command CETerm Scripting Guide Page 74 Properties The Network object has the following properties Ping command The default value is 3000 milliseconds Use caution when increasing this value due to the delays it may produce Property Description Val
75. EB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE StopBits 87 StopSound 42 StringSeparator 80 SystemMetric Constants 183 SystemParameter Constants 183 T Text 73 TextInput 36 132 TextInput object 97 TextInput GetInput 97 TextInput Input 97 TextInput PasswordMode 97 TextInput Prompt 97 TextInput Title 97 TickCount 43 Timeout 73 Title 73 97 Trigger object 39 V Vibrate 38 Virtual Key Codes 185 VisibleColumns 82 VisibleRows 82 VK Codes 185 W WaitForEvent 85 WaitForExit 77 Window Constants 183 Window object 43 98 CETerm Scripting Guide Window EnableInput 99 Window Find 99 Window GetDesktop 99 Window GetList 99 Window GetParent 99 Window GetRelative 100 Window GetSelf 100 Window GetText 100 Window GetTopmost 100 Window IsEnabled 100 Window IsVisible 100 Window IsWindow 101 Window LastError 102 Window PostMessage 101 Window SendMessage 101 Window SendMessageTimeout 102 Window SetTopmost 101 Window Show 101 Write File 58 Write SerialPort 85 WriteBMPImage 91 WriteByte 85 WriteNULL 85 WriteTotalTimeoutConstant 88 WriteTotalTimeoutMultiplier 88 WriteUrgent 85 WriteValue 80 135 X XOFFCharacter 87 XOFFInputFlowControl 87 XOFFOutputFlowControl 87 XOFFUpperCushion 87 XONCharacter 87 XONLowerLimit 87 Page 197
76. ECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE The handler function must return false if the key message should be processed as usual Example See the Naurtech website for an example using this feature 4 7 THE ONNAVIGATEERROR EVENT The OnNavigateError event is fired if the browser fails to complete a navigation Typically the error handler will redirect the web browser to a file URL on the device for error recovery This event may fire if the device loses RF coverage during a navigation or the web server crashes It is a good practice to use the CETerm Check Network Before Send feature to validate RF coverage prior to submitting the navigation request and use the OnNavigateError for additional error handling Syntax function OnNavigateError session params session index of browser session which failed to navigate params navigation error parameters including the error number and URL The params argument is formatted as URL parameters and has the form error 0x800C0005 amp url http 192 168 1 20 application exe state 3 amp scan 0 Everything after url the params argument is the URL that failed to navigate along with all the parameters of that URL The error values are standard Microsoft browser status codes and are defined in Appendix 4 Example for Windows CE 5 0 devices This example shows how to redirect a web browser to a static URL on the device OnNavigat
77. EP if needed CETerm SetTimeout RFWakeupSoundPlay 100 RFWakeupSoundContinue 0 se if RFWakeupSoundCount gt RFWakeupSoundCountMaximum cripting Guide Page 124 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Failed to get RF show failure message OS Alert Failed to detect RF signal n Return to coverage area RFWakeupSoundContinue 0 if RFWakeupSoundContinue if RFWakeupSoundCount 5 Play tick sound while check is running CETerm PlaySound MenuPop Schedule next RF check RFWakeupSoundTimerID CETerm SetTimeout RFWakeupSoundOnTimer RFWakeupSoundInterval function RFWakeupSoundPlay Select any wave file on device for notification CETerm PlaySound infbeg CETerm Scripting Guide Page 125 5 0 Scripting Techniques and Tips This section describes ways that scripting can extend the capabilities of CETerm Tips for script development are also presented 5 1 EXPECT AND EXPECTMONITOR FOR AUTOMATING TASKS The expect script and ExpectMonitor class provide a general purpose prompt and response tool Using expect for automated login was described in Section 2 6 Here we provide the complete listing of the scripts and discuss other options for use 5 1 1 Expect Script The expect script illustrates a couple of powerful JavaScript constructs Even though t
78. FID reader As with all CETerm scripting features we provide as much direct access to the hardware as possible while hiding un needed complexity The SerialPort object usage can be complex and the developer will need a good programming foundation with event driven concepts Much of the SerialPort object corresponds directly to the Windows Win32 serial port APIs General information can be found by searching msdn microsoft com with the keywords basic serial communication 5 8 1 SerialPort Objects CETerm provides access to ten 10 SerialPort objects By default these correspond to through COM9 however any SerialPort object can be configured to control any named port such as BSP1 for a virtual Bluetooth port The SerialPort objects can be used from both the CETerm script engine and the browser scripting environment When a SerialPort objectis first accessed within CETerm it begins with all default settings and will maintain all updated settings while CETerm is running CETerm Scripting Guide Page 136 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE The SerialPort objects are obtained from the root Device object by specifying the desired index var index 0 var sp Device SerialPort index where sp is the reference to the SerialPort object It is a good practice to use a local variable to hold the reference inside a function when multiple port operations must be per
79. NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Value O 0x4F P 0x50 Q 0x51 R 0x52 S 0x53 T 0x54 U 0x55 V 0x56 W 0x57 X 0x58 Y 0x59 Z 0x5A VK LWIN 0x5B VK_RWIN 0x5C VK APPS 0x5D VK SLEEP Ox5F VK_NUMPADO 0x60 NUMPAD1 0x61 VK NUMPAD2 0x62 VK NUMPAD3 0x63 NUMPAD4 0x64 VK NUMPAD5 0x65 VK NUMPAD6 0x66 VK NUMPAD7 0x67 VK NUMPADS 0x68 VK NUMPAD9 0x69 VK MULTIPLY Ox6A VK_ADD 0 6 VK_SEPARATOR 0 6 VK_SUBTRACT 0x6D VK DECIMAL Ox6E VK DIVIDE Ox6F VK F1 0x70 VK F2 0x71 VK F3 0x72 VK_F4 0x73 VK_F5 0x74 VK_F6 0x75 VK_F7 0x76 VK_F8 0x77 VK F9 0x78 CETerm Scripting Guide Page 187 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Value VK_F10 0x79 VK F11 Ox7A VK_F12 0x7B VK_F13 0x7C VK_F14 0 70 VK F15 Ox7E VK F16 Ox7F VK F17 0x80 VK F18 0x81 VK F19 0x82 VK F20 0x83 VK F21 0x84 VK F22 0x85 VK F23 0x86 VK F24 0x87 VK NUMLOCK 0x90 VK SCROLL 0x91 VK LSHIFT 0 0 VK_RSHIFT OxA1 VK LCONTROL OxA2 VK_RCONTROL VK_LMENU 4 VK RMENU 5 VK_BROWSER_BACK 0 6 VK BROWSER FORWARD OxA7 VK BROWSER REFRESH 0xA8 VK BROWSER STOP 0 9
80. NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE EDGE 6 Not distinct from GPRS UMTS Shy Not distinct from GPRS VOICE 29 9 Push to Talk not supported HSDPA 2210 High Speed Downlink Packet Access 3 56 MAX ET NIC UNKNOWN 0 ETHERNET 1 WIFI 22 23 BLUETOOTH UNKNOWN 0 sly PAN 2 MAX 53 UNKNOWN 2 CSD sl OOB CSD PA Derived from unimodem device types NULL MODEM 37 Direct Cable Connect DCC EXTERNAL MODEM 4 Serial port attached modem INTERNAL MODEM 5 PCMCIA MODEM 6 i1 DCC over Irda DYNAMIC MODEM 8 Bluetooth modem DYNAMIC PORT 9 DCC over Bluetooth MAX 10 VPN UNKNOWN 0 L2TP els PPTP 22 23 PROXY UNKNOWN 0 CETerm Scripting Guide Page 175 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE NULL WAP SOCKS4 SOCKS5 MAX 5 Q N P PC NKNOWN SKTOPPASSTHROUGH MODEM LINK HP Connection status parameters CONNECTION MANAGER STATUS PARAMETERS TYPE 0x00000001 SUBTYPE 0x00000002 DESTNET 0x00000004 SOURCENET 0x00000008 FLAGS 0x00000010 SECURE 0x00000020 DESCRIPTION 0x00000040 ADAPTERNAME 0x0000008
81. NNECT EVENT The onSessionConnect event is fired when a session initially connects to the specified host The handler can be used to initiate an automated login using the expect script and ExpectMonitor class Syntax function OnSessionConnect session session index of session which connected Example An example using OnSessionConnect to start the automated login was shown above in Section 2 6 and is repeated below Please refer to Section 2 6 for details The expect script is discussed in Section 5 1 OnSessionConnect function OnSessionConnect session Set login information var myusername joeuser var mypassword secret var waittime 8000 Milliseconds waiting for each text Only login session 1 if session 1 Look for login then password expect session waittime Login myusername r Password mypassword r 4 14 THE ONSESSIONDISCONNECT EVENT The OnSessionDisconnect event is fired when a session is disconnected by a user action The handler can be used to switch to another session exit or perform other cleanup tasks CETerm Scripting Guide Page 116 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Syntax function OnSessionDisconnect session session index of session which was disconnected by user Example This example will switch to the next connected session when the current session
82. OWS CE AND WINDOWS MOBILE default if responseState DATA Save character responseData push String fromCharCode break if responseState DONE Process message Maybe schedule another data detection after processed MyProcessMessage responseData responseState PRE STX else Schedule another data detection to complete message sp WaitForEvent 5 9 WRITING EFFICIENT SCRIPTS Good programming practices should be used when developing scripts for CETerm In general it is important to conserve memory minimize script compilations and limit execution times Please refer to a JavaScript programming book for more information We recommend JavaScript The Definitive Guide 5th Edition by David Flanagan The following URL is an excellent starting point for in depth details about JavaScript and good programming practices http javascript crockford com 5 9 1 Use Local Variables Whenever possible use local variables within functions and declare them with the var keyword like this var status var message hello var 1 1 k If you fail to use the var keyword then JavaScript automatically creates a global variable with that name if it has not already been declared outside a function CETerm Scripting Guide Page 142 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE JavaScript uses garbage
83. ProgressVisible true ProgressRate 20 IsVisible true Sse You may want to update the progress bar directly while processing data Here is an example Update progress and message during processing var m CETerm Message m Text Processing data please wait m Timeout 0 m AbortButtonVisible false m ProgressRunning false Do some work CETerm Scripting Guide Page 131 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE m Progress 0 m IsVisible true OS Sleep 2000 Simulate work delay Update m Progress 20 m Text Finding addresses please wait OS Sleep 2000 Simulate work delay Update m Progress 50 m Text Sorting addresses please wait OS Sleep 2000 Simulate work delay Update m Progress 90 m Text Almost done please wait OS Sleep 2000 Simulate work delay Done m IsVisible false 5 3 GETTING USER INPUT TO A SCRIPT The Textlnput object can get user input for a script Here is an example for getting a password Get password from user var t CETerm TextInput t Title Warehouse Management t Prompt Pleas nter your password t PasswordMode true t Input Clear current password var s t GetInput if s 1 OS Alert Password is t Input t Input Clear password else OS Alert
84. R AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 5 8 5 Using Single Byte Reads One pattern which often works well for handling serial port data is to read a single byte at a time and to accumulate data until a complete message can be processed Your application and peripheral device will define what a complete message contains but often messages are terminated by special characters such as ASCII ETX When using single byte reads you can keep read timeouts short and optimize responsiveness To use this pattern you would use WaitForEvent with the EV_RXCHAR event and process the data within your handler Here is a template for a single byte read handler Serial port data handler var responseData var responseStat PRE STX function MyReadAndProcess portIndex var var readTries 4 var sp while responseStat readTries gt 0 c sp ReadByte if lt 0 Read error OS Sleep 20 readTries continue Res readTries 4 switch case ASCII STX DONE amp amp try again t tries after successful Start of response responseStat break case ASCII ETX End of content responseStat break CETerm Scripting Guide DONE DATA x responseData Device SerialPort portIndex read Page 141 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WIND
85. Receives special command in VT data stream OnWakeup Device resumes after a suspend 4 1 THE ONBARCODEREAD EVENT The onBarcodeRead event is fired when a barcode is successfully read The handler can pre process the data or check other conditions prior to passing it on to a TE or browser session Syntax function OnBarcodeRead session data source type date time session index of currently active session data barcode data source source of barcode Typically a constant scanner name type labeltype of barcode See Appendix 3 for values date date of barcode read time time of barcode read The handler function must return 1 if it processed the barcode data and sent it to the session as needed or discarded the barcode If the handler function does the processing and returns 1 then it must also perform any needed pre amble or post amble actions such as simulating a trailing TAB or Enter key The handler function must return 0 if the barcode is not processed by the handler and should be sent to the session by the internal processor If the internal processor handles the barcode then it will perform any stripping that is configured and will apply the pre amble and post amble as configured CETerm Scripting Guide Page 104 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Example Several samples for OnBarcodeRead were given in Section 2 5 Following is an example
86. S versions They may also vary with different CETerm versions You should review the raw form of the returned values on the devices you plan to use and program defensively to allow for variations See the example below for details 2 8 1 Array Literals Here is a simple JavaScript statement that uses an array literal to create an array and assign it to a JavaScript variable var myArray 2 4 6 myArray 2 now has the value 6 If a CETerm object returned the same array literal then you would use the JavaScript eval function to assign the array to a JavaScript variable var arrayResult 2 4 6 var myArray eval arrayResult myArray 0 now has the value 2 2 8 2 Object Literals Here is a simple JavaScript statement that uses an object literal to create an object and assign it to a JavaScript variable var myObject name fred attributes 0x21 size 12341234 myObject attributes has the value 0x21 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE If a CETerm object returned the same object literal then you would again use the JavaScript eval function to assign the object to a JavaScript variable Because the curly bracket operator may delimit either a block of statements or an object literal you must add parenthesis before the conversion or use the syntax Preferred syntax var objectResult name fred attributes 0x21 size 12341234 eval var myObj
87. SSAGE OBJECT The Message object provides feedback to the user while a script is running The Message object is a property of the CETerm object CETerm Message This object displays a dialog with a text message an optional progress bar and an optional script cancellation button The progress value can be set by the script as tasks are completed or it can run at a constant rate to show activity to the user Methods The Message object has no methods Properties The Message object is controlled through read write properties Setting a property will change the message dialog appearance Property Description Values AbortButtonVisible If true a script abort button is visible true false Taping this button will abort the current script execution IsVisible If true message dialog is visible true false Progress Current progress value in percent 0 to 100 ProgressRate Rate of change of progress bar In units 1 to 100 of percent per second ProgressRunning If true Progress increases at true false ProgressRate ProgressVisible If true progress bar is shown true false Text Text of message text Title Text in message box title bar text Timeout Visibility timeout for dialog After this 0 to 9999 interval message dialog is closed A value of 0 disables this timeout CETerm Scripting Guide Page 73 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 3 13 TH
88. Text match target Found match var action this args this state 1 this checkCount 0 if action null Check action if typeof action function Run function action Pass session number as argument action this session else if typeof action string Send text to session CETerm SendText action Lhis session else if this silent OS Alert Unknown action type for expect Check if another match expected this state 2 target this args this state if target null Schedule next check this Schedule else Done with this expect CETerm Scripting Guide Page 128 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Run any post execution actions if typeof this OnDone function this OnDone true No match schedule again if this checkCount lt this maxCheckCount this Schedule else if this silent OS Alert Expect failed to find text target if typeof this OnDone function Done but failed this OnDone false function ExpectMonitor Schedule Schedule next check var script ExpectMonitor Instances this session Check this timer CETerm SetTimeout script this checkDelta function ExpectMonitor Start Cleanup first in case restarted this Abort
89. UID for a named network MapURLToNetworks Find networks which can reach the URL SetPriority Set the priority of an established connection NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status Connect flags priority exclusive guid timeout Establish a connection to provide network access The flags priority and exclusive arguments can be used to specify a proxy connection or other connection attributes See Appendix 4 for supported values The guid specifies the desired network The timeout in milliseconds can be 0 to attempt an asynchronous connection The return value of 0 indicates that a connection was established non zero timeout or the request is valid zero timeout A non zero value is returned on error status Disconnect Disconnect a network connection established by a Connect Returns 0 on success or non zero on error list GetA vailableNetworks Returns a list of all available networks on the device The list is in the form of a JSON literal see Section 2 8 Following is the partial output from a Windows Mobile 6 5 device guid 18AD9FBD F716 ACB6 FD8A 1965DB95B814 description My Work Network secure true guid ADBOB001 10B5 3F39 27C6 9742E785FCD4 description My ISP secure true guid F28D1F74 72BE 4394 A4A7 4E296219390C description Secure WAP Network secure true guid 436EF144 B4FB 4863 A041 8F905A62C57
90. VK BROWSER SEARCH OxAA VK BROWSER FAVORITES OxAB VK BROWSER HOME OxAC VK VOLUME MUTE OxAD VK VOLUME DOWN OxAE VK VOLUME UP OxAF VK MEDIA NEXT TRACK 0xBO VK MEDIA PREV TRACK OxB1 VK MEDIA STOP 0xB2 VK_MEDIA_PLAY_PAUSE 0xB3 VK LAUNCH MAIL OxB4 VK LAUNCH MEDIA SELECT 0 5 VK LAUNCH APP1 0xB6 VK LAUNCH APP2 0 7 CETerm Scripting Guide Page 188 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Value VK 1 VK PLUS 0xBB VK_OEM_COMMA 0xBC MINUS 0xBD PERIOD VK 2 OxBF VK OEM 3 0xCO VK OEM 4 OxDB VK OEM 5 OxDC VK OEM 6 OxDD VK OEM 7 OxDE VK OEM 8 OxDF VK OEM AX OxE1 VK OEM 102 OxE2 VK PROCESSKEY OxE5 VK PACKET OxE7 VK DBE ALPHANUMERIC OxFO VK DBE KATAKANA OxF1 VK DBE HIRAGANA OxF2 VK DBE SBCSCHAR OxF3 VK DBCSCHAR OxF4 VK DBE ROMAN OxF5 VK ATTN OxF6 VK CRSEL OxF7 VK EXSEL OxF8 VK EREOF OxF9 VK PLAY OxFA VK ZOOM OxFB VK NONAME OxFC VK PA1 OxFD VK OEM CLEAR OxFE CETerm Scripting Guide Page 189 Glossary Automation Objects Objects internal to CETerm that provide access to device application and session features from the script engine CEBrowseX A Naurtech ActiveX control which provides access to the CETerm Automation Objects from a Windows Mobile PIE browser external This is the name of a
91. X connection type Session type 3270 5250 VT220 HTML sessionX connection networkcheck interval Network check interval ms sessionX connection networkcheck timeout Network check timeout sec sessionX connection networkcheck beforesend Network check beforesend sessionX connection networkcheck host Network check host sessionX connection networkcheck action Network check action sessionX display hidemenubar RO Hide CETerm menu bar WM only sessionX display hideallbars RO Hide all CETerm bars Windows CE only sessionX display hidekeybar RO Hide CETerm keybar WM sessionX display hidetoolbar RO Hide CETerm toolbar WM sessionX display hideoia RO Hide IBM OIA bar CETerm Scripting Guide Page 157 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Name Description sessionX display hidehorizontalscrollbar RO Hide horizontal scroll bar sessionX display hideverticalscrollbar RO Hide vertical scroll bar sessionX display scroll column Scroll lock column sessionX display scroll row Scroll lock row sessionX display scroll mode Scroll mode sessionX hidden Hide session on menu true false sessionX printer network queue Network printing queue sessionX printer serial port Serial printing port CETerm Scripting Guide Page 158 SCANNER PROPERTIES Scanner propert
92. _M VT CSI ESC M IDA VT CSI VT CSIN ESC N IDA_VT_CSI_O VT CSIO IDA VT CSI P VT CSIP IDA VT CSI Q VT CSI Q IDA VT CSI R VT CSI R IDA VT CSI S VT CSI 5 IDA VT CSI T VT CSIT Windows App Keys IDA APPKEY K1 App Key 1 IDA APPKEY K2 App Key 2 IDA APPKEY K16 App Key 16 IDA SCROLL UPPERLEFT Scroll Upper Left IDA SCROLL UPPERRGHT Scroll Upper Right IDA SCROLL LOWERLEFT Scroll Lower Left IDA SCROLL LOWERRGHT Scroll Lower Right IDA SCROLL CENTER Scroll Center IDA SCROLL CURSOR CENTER Scroll Cursor Center IDA SCROLL CURSOR VISIBLE Scroll Cursor Visible IDA COPYALL Copy All Copy screen to clipboard IDA PASTE Paste Past clipboard IDA USTRING 1 Text 1 Send user text 1 IDA USTRING 2 Text 2 Send user text 2 IDA USTRING 64 Text 64 Send user text 64 IDA SCRIPT 1 Script 1 Run Script 1 IDA SCRIPT 2 Script 2 Run Script 2 IDA SCRIPT 64 Script 64 Run Script 64 IDA SIP HIDE SIP Hide IDA SIP SHOW SIP Show IDA SIP TOGGLEHIDE SIP Toggle IDA SIP LOCKDOWN SIP Lockdown CETerm Scripting Guide Page 153 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA_SIP_UNLOCK SIP Unlock IDA_SIP_UP SIP Up IDA SIP DOWN SIP Down IDA SIP FORCEDOWN SIP Forcedown IDA IM KEYBOARD IM Keyboard IDA IM LOCKED IM
93. ach line segment is an array of points and each point is an array of x and y values Returns null if there are no current points Here is an abbreviated point output 65 25 3 25 5 1 231 30 191 31 17 13 ene 27 9 I 25 419 822 ep 22779 5 7401 16 3611 L75 533 4 175 7281 87723 ses 9r l8 87 712 CETerm Scripting Guide Page 90 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status SetSienaturePoints points Set the current signature points for re display The format of the points is the same as is returned by GetSignaturePoints Returns the number of points in the signature or 1 on error Check the property LastError for additional error information status WriteBMPImage filename penWidth penColor backgroundColor boxAreaOnly Write the last captured signature points as a BMP image The image is an efficient 1 bit per pixel representation and is typically about 5Kb in size The penWidth may be in the range 1 5 and colors are specified as a hexadecimal triplets of B G R byte values e g 0x0000ff Red Oxff0000 Blue Oxffffff White 0x606060 Grey If boxAreaOnly is true then the signature output is clipped by the box area displayed during capture Returns 0 on success or 1 on error Check the property LastError for additional error information Properties The SignatureCapture object has the following properties
94. and CETerm PostIDA IDA session You may have noticed by now the use of Post IDA in some cases and SendIDA in other cases SendIDA is a synchronous activation of an action whereas PostIDA is an asynchronous or deferred activation In general it is always better to use Post IDA unless the script must wait for the action to complete before proceeding The post action is similar to the PostMessage function in Windows programming and the send is similar to the SendMessage function See the CETerm automation object for more details CETerm Scripting Guide Page 24 2 8 HANDLING JAVASCRIPT LITERAL VALUES JSON LITERAL The Automation Objects described in Chapter 3 often return JavaScript literal values when the results are complex For example JavaScript literals are returned when the results are lists of files lists of processes or memory information A JavaScript literal is a text string which describes the contents of an array or an object These literals are easily converted into true JavaScript arrays or objects for use by your scripts This concept of data representation is similar to the highly popular JavaScript Object Notation JSON www json org data interchange used by web applications The results in CETerm do not follow the strict JSON format but are handled in nearly identical ways WARNING The format and content of JavaScript literals returned by various CETerm object may vary depending on hardware types or O
95. and tapping the Edit button an Edit Script dialog will appear The edit dialog allows Import and Export of scripts For initial script development it may be easier to edit on your desktop PC copy the script to the device and Import the script You can use any programming editor that does not insert text formatting commands Even Notepad will work fine but do not edit scripts with Microsoft Word Smaller editing changes are easily made on the device TIP We often edit and test scripts by viewing the device on a PC with a remote control program so we can use the PC keyboard to edit If editing a function be sure to tap Test Load to test syntax and load the changes into the scripting engine Edit Script OnBarcodeRead K OnBarcodeRead Function OnBarcodeRead session data 17 Manipulate barcode data here 11 Send barcode to emulator CETerm SendText data session Load at Startup The checkbox Load at Startup should be checked for all scripts that contain function definitions that you want to have available in the script engine The checkbox should not be checked for slots that contain scripts that are bound to keys or other activations Load at Startup should be checked for all event handler function definitions All scripts marked Load at Startup will be loaded CETerm Scripting Guide Page 15 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE into the script engine when it
96. args linel split Activate FTP if FTP args 1 var ftp OS Network FTP if 0 ftp Login args 2 ftpuser secret CETerm Scripting Guide Page 107 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE ftp PutFile args 3 ftp Logout args 4 Submit screen to move to next action CETerm PostIDA IDA ENTER session 4 5 THE ONKEYBOARDSTATECHANGE EVENT The OnKeyboardStateChange event is fired when the state of the keyboard is changed by a user or host action Typically this event is only used with IBM sessions A VT session may generate this event only if custom escape sequences lock the keyboard Syntax function OnKeyboardStateChange session state session index of currently active session state new keyboard state Example This example disables the scanner when the keyboard enters the locked mode OnKeyboardStateChange var IBM KEYBOARD HARDWARE ERROR 0 var IBM KEYBOARD NORMAL LOCKED 1 var IBM KEYBOARD NORMAL UNLOCKED 2 var IBM KEYBOARD POWER ON 3 var IBM KEYBOARD PRE HELP ERROR 4 var IBM KEYBOARD POST HELP ERROR 5 var IBM KEYBOARD SS MESSAGE 6 var IBM KEYBOARD SYSTEM REQUEST 7 var PreviousKeyboardState 0 0 0 0 0 0 function OnKeyboardStateChange session state
97. ate The Session object is obtained from a CETerm object method CETerm Session i This section documents the methods and properties of the Session object Methods The Session object has no methods Properties The Session object has several read only properties Property Description Values Browser Returns browser object read only object IsConnected Returns true if session is connected true false read only Screen Returns screen object read only object 3 19 THE SIGNATURECAPTURE OBJECT The SignatureCapture object provides signature capture capabilities to both TE and web sessions The SignatureCapture object is a property of the Device object Device SignatureCapture The signature may be stored as an image or as a sequence of coordinates There are many properties to control the appearance and behavior of the capture operation Methods The following methods are available Method Action Capture Display the capture window CancelDialog Cancel a current capture operation Display Display a recorded signature ClearSignaturePoints Clear the last captured signature points GetSignaturePoints Get the last captured signature points SetSignaturePoints Set the array of signature points for re display CETerm Scripting Guide Page 89 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE WriteBMPImage Write a BMP image of th
98. bject literal See Section 2 8 for information on handling JSON literal values For example the following object literal shows results from a Windows CE 5 0 device utilization 22 totalRAM 58613760 availableRAM 46153728 totalStorage 29061120 availableStorage 17583852 Not all devices will return all values so you should check for the existence of a value before use See Section 2 8 for details TickCount The return value is the number of milliseconds since the device booted excluding any time that the system was suspended TickCount starts at zero on boot and then counts up from there The count will rollover to zero if the system is run continuously for 49 7 days The maximum value is OXFFFFFFFF When using TickCount beware that rollover may occur Comparing tick values directly does not always yield the correct results By design TickCount may have a drift of 1 second per 2 hours Do not use TickCount for drift sensitive applications Version The Windows CE version value is in the form of a JSON literal see Section 2 8 Following is an example result from a Windows Mobile 6 5 device majorVersion 5 minorVersion 2 buildNumber 23101 platformID 3 extraData CETerm Scripting Guide Page 43 3 4 THE BROWSER OBJECT The Browser object gives access to a web browser session The Browser object is a property of the Session object CETerm Session i Browser This section documents the methods and properties of the Bro
99. bleUPCA Using the later approach the function is only compiled once not each time the key is pressed In general separating the function definitions from the invocation is a good practice CETerm Scripting Guide Page 143 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 5 9 3 Limit Execution Time Because the script engine acts like a virtual user when a script is executing CETerm will seem unresponsive You cannot have a script running continuously However using events and timers you can accomplish any task Do not disable the Script Timeout unless you are sure your script will not enter an infinite loop 5 10 DEBUGGING SCRIPTS All but the most trivial script will require some amount of debugging 5 10 1 Show Script Errors The first step is to enable Show Script Errors This will enable a popup message for compilation and runtime errors Compilation errors will usually be seen when new scripts are added or upon script engine startup It may not be clear which script loaded at startup contains the error In this case you may need to open the edit dialog for each script and tap the Test Load button to identify the bad script The compilation error looks like this Microsoft JScript compilation error Line 15 Col 8 Expected OS Alert message Notice that the line of script presented looks OK In this case the missing y should be on the previous
100. cess non zero for failure Use the SerialPort property LastError to get additional error information status ClearError Clear the error condition and re enable I O operations Return information about the error condition and current port status as a JavaScript literal object Return null if the port is not open or other failure More details can be found by searching msdn microsoft com with the keyword clearcommerror The general format of the status is errorType 1 CTSHold false DSRHold false RLSDHold false XOFFHold false XOFFSent false EOF false TXIM false inputQueue 0 outputQueue 0 status Close Close the serial port Any active event listener is canceled Return 0 on success non zero for failure Use the SerialPort property LastError to get additional error information status Open access Open the serial port for communications The access parameter code specifies read and or write access Return 0 on success non zero for failure Use the SerialPort property LastError to get additional error information See Appendix 4 for access definitions CETerm Scripting Guide Page 83 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status PurgeQueues mode Discard content from input and output queues Return 0 on success non zero for failure Use the SerialPort LastError to get additional error information See Appendix 4 for mode de
101. cessing is needed it is best to schedule that processing with SetTimeout and allow the event handler to exit The following example will save data from memory to a flash file whenever a particular URL is loaded OnDocumentDone function OnDocumentDone session var b CETerm Session session Browser if b Document URL match InventorySave CETerm Scripting Guide Page 133 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Resume online inventory and save cached data to file in background CETerm SetTimeout BackgroundSave session 10 BackgroundSave function BackgroundSave session var d new ActiveXObject Microsoft XMLDOM d loadXML lt xml version 1 0 gt lt Books gt lt Book QTY 10 gt lt Title gt Beginning XML lt Title gt lt Book gt lt QTY 2 gt lt Title gt Mastering XML lt Title gt lt Book gt lt Books gt if OS File Write FlashDisk inventory xml d xml OS Alert Failed to save inventory 5 6 ACCESSING A FILE The File automation object provides basic access to the Windows CE filesystem It supports whole file read and write but does not support the concept of an open file with piecewise read or write You can also create and delete file directories This example shows how to append to an existing file by using a combination of read and
102. cluded in the results if specified in a Create call The manualReset is included if the Create call actually created the corresponding Windows CE event Here is a sample event list output id 0xFE490034 name MyPrivateEvent manualReset false id 0xF345DE00 name ExistingEvent 0 546902 script GetName eventHandle Return the of the event associated with the specified eventHandle Return null if no event found status IsExistingEvent eventHandleOrName Return the status of the event with the given eventHandle or eventName Return 0 if the event does not exist 1 if the eventName exists within Windows 2 if the event was created within Windows by the Create method or 1 on error CETerm Scripting Guide Page 52 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status IsListenerSet eventHandleOrName Return the status of the listener with the given eventHandle or eventName Return 0 if a listener is not set 1 if a listener is set or 1 on error status Pulse eventHandleOrName Pulse the state of an event This signals all listeners that an event is set then resets the event to the non signaled state The eventHandle is obtained from a Create call If you use eventName the event must have been previously created within Windows by Create or by another program Return 0 on success or 1 if no matching event to pulse
103. codeRead session data source type date time Look for Full ASCII Code 39 LF 0x0A to mark Field Exit var lflndex data indexOf x0A if lfIndex gt 0 var passwordStart lfIndex 1 Look for Full ASCII Code 39 ENQ 0x05 var enqIndex data lastIndexOf x05 if enqIndex gt 0 NOTE Using substr to extract user Send User CETerm SendText data substr 0 lfIndex session CETerm Scripting Guide Page 20 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Send field exit to advance cursor CETerm SendIDA IDA FIELD EXIT session Send Password NOTE Using substring to extract password CETerm SendText data substring passwordStart engIndex session Submit form CETerm SendIDA IDA ENTER session All scan data handled here return 1 Handle scan data in normal way return 0 The type argument to OnBarcodeRead contains the labeltype of the barcode This labeltype is related to the barcode symbology but is usually a little more informative The values are dependent on the hardware manufacturer but for most devices are the same as the Symbol LABELTYPE The type is a small integer value representing a printable ASCII character See Appendix 3 The source argument is the name of the scanner that read the barcode and is typically unused The date and tim
104. collection to reclaim memory no longer in use Memory occupied by global variables may never be reclaimed whereas local variable memory can be reclaimed after a function call completes Because the JavaScript engine in CETerm is not reset frequently like a browser JavaScript engine it is more likely that poor programming practices could exhaust memory 5 9 2 Encapsulate Code in Functions Whenever possible put multiple script actions within a function This should minimize compilations and make it easier to use local variables as described above For example the following actions could be in a script which is bound to a key combination ETerm SetProperty sessionl scanner upca enabled true ETerm SetProperty sessionl scanner msi enabled false ETerm SetProperty sessionl scanner pdf417 enabled false ETerm PlayTone 8 2000 200 ETerm PlayTone 8 1500 200 ETerm PostIDA IDA SCAN APPLYCONFIG 0 aaaaaa Or the actions could be in a function which is loaded with Load at Startup function enableUPCA ETerm SetProperty sessionl scanner upca enabled true ETerm SetProperty sessionl scanner msi enabled false ETerm SetProperty sessionl scanner pdf417 enabled false ETerm PlayTone 8 2000 200 ETerm PlayTone 8 1500 200 ETerm PostIDA IDA SCAN APPLYCONFIG 0 aaaaaa and the function call in a separate script could be bound to the key combination ena
105. d 064 e 06 Australian Postal 9g 067 _ Canadian Post 1 2 00 2 89 01 0880 4 CETerm Scripting Guide Page 169 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Appendix 4 Constants This appendix contains various constants that are used by CETerm Automation Objects Many of these constants are a direct representation of the equivalent values from the Windows CE system APIs and constants These constants are mostly presented as global JavaScript variables for direct inclusion in scripts For simple scripts a few extra global variables are not harmful but good programming practices seek to minimize globals to prevent accidental name collisions Some constants below are represented more appropriately as properties of constant objects For efficiency you should not include constant definitions that are not used by your scripts One good pattern is to re express the needed constants as members of a single CONSTANTS object Here is a brief example showing how a single CONTANTS object might contain multiple categories of constants Express constants as object properties var CONSTANTS MESSAGEBOX FLAG OK 0x00000000 FLAG OKCANCEL 0x00000001 FILE ATTRIBUTE READONLY 0x00000001 HIDDEN 0x00000002 SERIAL PORT NOPARITY 0x00 ODDPARITY 0x01 0 02 va
106. d definitions If StringSeparator is not empty returns a string with the value names separated by the current StringSeparator property value status FlushKey keyname Performs a Windows RegFlushKey on the specified key Some older devices use this to trigger a save of the current registry to persistent memory Do not use FlushKey unless directed by the device manufacturer Returns 0 for success non zero for error type GetValueType valuename Gets the data type for the specified value Use a fully qualified value name that starts with a root key Returns 0 for success or non zero for an error data ReadValue valuename Read the data from the specified value Use a fully qualified value name that starts with a root key Returns a JSON array of either integers or strings If StringSeparator is not empty returns a single string binary values are returned as a list of comma separated hexadecimal digits MULTI SZ strings are separated with the current StringSeparator property value data ReadValueVBArray valuename Read the data from the specified value Return the data as a Visual Basic array Use a fully qualified value name that starts with a root key It is usually best to use the ReadValue method and parse the JSON value In rare circumstances a true array may be needed It is not possible to return a JavaScript array but it is easy to convert a Visual Basic array into a JavaScript array using the VBArray
107. d on to the static page without using a User Text variable OnNavigateError function OnNavigateError session params Navigate to static error page var b CETerm Session session Browser b Navigate file error htm params The error page can access the failed URL parameters using normal techniques to re attempt the navigation or decide on other error recovery var params document location search CETerm Scripting Guide Page 111 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 4 8 THE ONNAVIGATEREQUEST EVENT The onNavigateRequest event is fired before the browser begins a navigation Normally all navigation control should be done within the HTML of a page In rare cases when the pages cannot be modified this handler can be used to control navigations This handler can cancel a navigation or request an alternative navigation Syntax function OnNavigateRequest session url session index of browser session url target URL of navigation request The return value of OnNavigateRequest is used to control the navigation A return value of 0 will allow the navigation to continue a value greater than 0 will cancel the navigation Example This example shows how to control navigation OnNavigateRequest function OnNavigateRequest session url Prevent unwanted URL if url match forbidden htm return 1 Require password
108. de Page 57 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Use the File properties LastError LastErrorMessge to get additional error information status SetAttributes fileName attributes Set the attributes of the file Return true for success false for failure Use the File properties LastError LastErrorMessge to get additional error information See Appendix 4 for attribute definitions status Write fileName contents Write contents to the named file Return true for success false for failure Any current contents are first deleted The write is an atomic operation which opens the file writes all contents and closes the file The File object does not support the concept of an open file or writing parts of a file To append to a file use Append See the description of the CodePage property for details on how the content is converted before writing Use the File properties LastError or LastErrorMessge to get additional error information Properties The File object has the following properties Property Description Values CodePage Specifies the codepage used for data integer conversion in read and write operations See comments below Default 0 ANSI LastError Returns the last error value associated unsigned with the File object integer LastErrorMessage Returns a text message of the last error text associated with the File object read only
109. display m IsVisible false Remove event listener e ClearListener GPSPositionUpdateEvent Delete event e Delete GPSPositionUpdateEvent Remove hot key assignment k DeleteHotKey IDA SCRIPT 50 Function which initializes demo function GPSDemo var s status var g Device GPS var m CETerm Message var e OS Event var k Device Keyboard Create event for GPS position update var ep e Create GPSPositionUpdateEvent false Assign initial listener script for GPS position event S e SetListener ep UpdateGPSPosition 300000 Assign event to GPS object g NewLocationDataEvent ep g MaximumAge 5000 Open GPS device S g Open Prepare message display m AbortButtonVisible false m Title GPS Demo m Text Initializing please wait m IsVisible true Create global hot key to run Script 50 for cleanup k AssignHotKey VK RETURN 0 IDA SCRIPT 50 CETerm Scripting Guide Page 67 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Put cleanup script invocation into slot 50 CETerm SetProperty app script 50 CleanupGPS Invoke GPSDemo function to start demo GPSDemo 3 11 THE KEYBOARD OBJECT The Keyboard object provides access to keyboard operations The Keyboard object is a property of the Device object D
110. e XON XOFF RTS or DTR D 0x0 Timeout Description Values Property ReadlntervalTimeout Maximum milliseconds allowed integer between the arrival of two bytes If this time is exceeded the read call will return A value of 0 means not used With the special value Oxffffffff the read operation will return immediately with all bytes already received if the ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier are both zero D 0xffffffff ReadTotalTimeoutConstant Constant milliseconds time added to compute total timeout integer D 0 ReadTotalTimeoutMultiplier Milliseconds factor multiplied times the number of bytes requested in the read request This is added to the ReadTotalTimeoutConstant to yield the total read timeout integer 0 0 WriteTotalTimeoutConstant Constant milliseconds time added to compute total timeout integer D 0 WriteTotalTimeoutMultiplier Millisecond factor multiplied times the number of bytes to be written This is added to the WriteTotalTimeoutConstant to yield the total write timeout integer D 0 See a complete discussion of timeout properties special values and special behaviors by searching msdn microsoft com for commtimeouts structure ce CETerm Scripting Guide Page 88 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 3 18 THE SESSION OBJECT The Session object gives access to session st
111. e are text strings representing the time of the read 2 6 AUTOMATED LOGIN Automating the host login process is a common task to speed workflow CETerm contains a simple Macro record and playback that can be used for this task One limitation of the Macro feature is that it will only support a single session auto connecting when CETerm starts The scripting feature allows much more power and flexibility for automating the login or any complex or repetitive process Most auto login features are based on a prompt and response mechanism that waits for text from the host the prompt and then sends some text the response The expect script and ExpectMonitor class provide the prompt and response mechanism within CETerm The response is usually some simple text but with the ExpectMonitor it can be a script itself The ExpectMonitor is also a good example of using script timers to perform long tasks The full listing of the expect script and ExpectMonitor can be found in Section 5 1 CETerm Scripting Guide Page 21 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE NOTE You must load the expect function definition and ExpectMonitor class scripts listed in Section 5 1 for the following example to work When expect is used for auto login it is activated within the OnSessionConnect event handler Here is a simple example of an OnSessionConnect handler OnSessionConnect
112. e corresponding SerialPort object Valid index values are 0 through 9 See Chapter 5 for details on how to use the SerialPort object status Vibrate durationMillisec Activate the device vibrator for the specified duration in milliseconds Return 0 on success or 1 otherwise For most devices this method is synchronous and will not return until the vibration is complete CETerm Scripting Guide Page 38 Properties The Device object has the following properties Property Description Values Display Returns the Display object This object provides access to hardware display actions read only object GPS Returns the GPS object This object provides access to GPS actions read only object Keyboard Returns the Keyboard object This object provides access to keyboard actions read only object RFID Returns the RFID object This object provides access to the RFID device The RFID object is available only in select builds of CETerm and is documented separately read only object SignatureCapture Returns the SignatureCapture object This object can be used for signature capture from both TE and web sessions read only object SmartCard Returns the SmartCard object This object provides access to the Smart Card Reader Writer a k a Near Field Communication NFC features The SmartCard object is available only in select builds of CETerm and is documented sepa
113. e length Not supported by all symbologies See configuration dialogs for ranges maxlength Maximum barcode length Not supported by all symbologies See configuration dialogs for ranges stripleading Strip characters from start of barcode 0 32 striptrailing Strip characters from end of barcode 0 32 customid Custom symbology ID 4 character string NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE SYMBOLOGY PROPERTIES Codabar specific symbology properties are unique for each session Symbology properties begin with sessionX scanner codabar where X is 1 through For example session4 scanner codabar clsiediting If no X value is found the currently active session number is used NOTE If you are changing the symbology properties for the currently active session you must call CETerm PostlDA IDA SCAN APPLYCONFIG 0 for the changes to take effect WARNING Not all properties are applicable to all hardware devices Different devices may use different names to refer to the same parameters You should look at the settings available in the CETerm configuration dialogs to determine if the property is appropriate and what values it may accept Last Property Level Description clsiediting CLSI editing is enabled T F notisediting NOTIS editing is enabled T F startstop Start Stop digit modes Not all modes apply to all devices See CETerm configu
114. e m T E A 107 4 5 The OnKeyboardStateChange Event 108 108 AS ou E 108 4 6 OnKeyMessage Event 109 109 ccs S 110 4 7 OnNavigateError 110 SICH OMS 110 Example for Windows CE 5 0 110 Example for Windows Mobile devices 111 4 8 The OnNavigateRequest Event eene nennen nnns nennen nes 112 Soo RS 112 ccs e 112 4 9 The OnNetCheckFailed 113 epee a 113 n mu een T A du 113 4 10 The 114 C ada c MA ADEL 114 dieto nea ide ta dp det teas 114 4 11 The OnProgramStart Event 114 o Le Ds A T eto eit M ee eM AD ete 115 Example imam tuti eldest mu 115 4 12 The OnSerialPortEvent nennen nnns trenes 115 VIX ien pi D e MALE DL EL MILLE
115. e mode flags var PURGE TXCLEAR 0 0004 Kill the transmit queue var PURGE RXCLEAR 0 0008 Kill the receive queu Modem Status Flags var MS CTS ON 0x0010 var MS DSR ON 0x0020 var MS RING ON 0x0040 var MS RLSD ON 0x0080 CETerm Scripting Guide Page 182 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE SYSTEM PARAMETER CONSTANTS Constants for OS GetSystemParameter Search for MSDN SystemParametersInfo var SPI GETSHOWSOUNDS var SPI GETWHEELSCROLLLINES var SPI GETFONTSMOOTHINGCONTRAST var SPI GETFONTSMOOTHING var SPI GETSCREENSAVETIMEOUT var SPI GETWORKAREA var SPI GETBATTERYIDLETIMEOUT var SPI GETEXTERNALIDLETIMEOUT var SPI GETWAKEUPIDLETIMEOUT var SPI GETPLATFORMTYPE var SPI GETOEMINFO var SPI GETPROJECTNAME var SPI GETPLATFORMNAME var SPI GETBOOTMENAME var SPI GETPLATFORMMANUFACTURER SYSTEM METRIC CONSTANTS Constants for OS GetSystemMetric GetSystemMetrics CE Search for var var var var var var MSDN I SM CXSCREEN SM CYSCREEN SM CXVSCROLL SM CYVSCROLL SM CXHSCROLL SM CYHSCROLL ll WNNNEF CO WINDOW CONSTANTS for more details 56 104 0x200C
116. e signature status Capture Perform a signature capture operation This operation is modal and will display a capture window Be sure to set all desired property values before calling Capture The dimensions requested in the properties may be adjusted to fit the screen dimensions Return 0 for success or 1 if canceled Check the property LastError for additional error information status CancelDialog Cancel a current capture operation Return 0 for success non zero for error This function can only be used from a timer if a capture operation is in progress Check the property LastError for additional error information status Display Display the last captured signature The display is read only and cannot be modified Return 0 for success non zero for error Check the property LastError for additional error information The display is based on the last captured signature points or the points loaded with SetSignaturePoints There is no mechanism to re display a saved signature image in the SignatureCapture object but the image can be displayed in a web page in a CETerm session status ClearSienaturePoints Clear the last captured signature points Return 0 for success non zero for error Check the property LastError for additional error information points GetSienaturePoints Returns the last captured signature points The points are returned as a JSON literal which is an array of line segments E
117. eCapture Object enne nennen nnn nnne nnne 89 uris m 89 gren EE 91 lj i L 92 3 20 The SIP Object a R eger eee A ee cg 95 Methods inima eR in en dede ine 95 Properties edd eli edad pen 96 3 21 The Objects ss qhu 97 ID EE 97 Propertie S y u 97 22 The Window aap ede de 98 plor m 98 isi 102 4 0 CGET rm Script Events cerro o eder ede e adea rere 103 CETerm Scripting Guide Page 4 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 4 1 The OnBarcodeRead 104 crc 104 105 4 2 The OnConnectionManagerEvent 105 SVMUAK S M 105 EX AIM PIC uu a Vj 105 4 3 The OnDocumentDone Event 0 106 SYMUAK d 106 s R M M 106 4 4 The OnIBMCommand 107 107 Exampl
118. eError function OnNavigateError session params Save params text where x is session index This is required by CE 5 0 devices which do not pass CETerm Scripting Guide Page 110 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE parameters to a file URL CETerm SetProperty app usertext 3 session params Navigate to static error page var b CETerm Session session Browser b Navigate file error htm Note the CETerm SetProperty call This method saves the params in persistent memory for later use by the error htm web page The reason to do this is because the parameters are discarded by the Windows CE browser when navigating to a file resource The error web page can retrieve the params using var property app usertext 3 external sessionindex var params external CETerm GetProperty property Using the URL the error page can re attempt the navigation or decide on other error recovery Please note that the User Text x is used for several purposes in CETerm including key remapping Be sure that this use does not collide with other uses in your configuration Example for Windows Mobile devices Handheld devices using Windows Mobile can use a different technique to pass on the params URL For these devices the parameters of a file URL are available within the browser The error parameters can simply be passe
119. ead only object Textlnput Return text input object read only object CETerm Scripting Guide Page 36 3 2 THE DEVICE OBJECT The top level Device object provides access to device components such as the keyboard and serial ports This section documents the methods and properties of the Device object Not all features of the Device object will be available on all devices For example GPS RFID Speech and Trigger functionality will depend on the hardware make model and operating system version Methods The following methods are available Method Action GetBatterylnfo Get the battery charge information GetPowerState Get the current power state for a device component PowerStateRequest Request a change of the power state of a device component ResetldleTimer Reset the Windows idle timer to prevent a suspend SerialPort Return the requested SerialPort object Vibrate Activate the vibrator batteryStatus GetBatteryInfo Get the battery charge information Returns a JavaScript object literal with the information in the form ACLineStatus 0xl main flags 0x1l lifePercent 100 lifeTime 4294967295 fullLifeTime 4294967295 voltage 4178 current 0 averageCurrent 0 averageInterval 0 mAHourConsumed 0 temperature 3 8 chemistry 0x4 backup flags 0xl lifePercent 100 lifeTime 4294967295 fullLifeTime 4294967295 voltage 2797 See Section 2 8 for detai
120. ear the specified recurring interval timer ClearTimeout timerID Clear the specified one time timer NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE description GetIDA Description IDA Value Return the friendly name for the IDA numeric value If there is no friendly name it will return a string in for form OxEF01 for an IDA value U D001 for other Unicode values name GetIDAName IDA Value Return the symbolic name e g IDA SESSION S1 for the IDA numeric value Returns null if there is no corresponding symbolic name value GetIDA Value name Return the numeric value for the IDA name Returns 1 if the name is not found This numeric value is rarely used but may be needed by an external application or wedge which is sending a command to CETerm value GetProperty propertyName Return the named property value This may be a device property application property or session property See Appendix 2 for a list of available properties Returns the JavaScript undefined value if the requested property cannot be found PostIDA IDASymbolicName session PostIDA submits an IDA action command and directs it to the specified session Valid session values are 1 to MaxSession The special session value of 0 will send the command to the current session Some IDA commands act at a global level and ignore the session variable See Appendix 1 for IDA Symbolic Na
121. ect objectResult OF Syntax with added parenthesis var objectResult name fred attributes 0x21 size 12341234 var myObject eval objectResult note parenthesis in either case myObj ect now has the value fred 2 8 3 Complex Literals A complex literal may consist of nested array and object literals but it is treated in the same manner In general you should use the eval syntax shown for the object literal for all types of array object or complex literals 2 8 4 Optional Object Properties The object literal returned as a result may not always contain all possible properties This is true for the File GetList method The various file timestamps are not always present Your JavaScript code must check these values or be prepared to handle the undefined value that can result When first developing your application it can be helpful to display the literal within a message box using OS Alert in order to review the contents that are returned in your environment You can then tailor your JavaScript to process the contents var getListResult OS File GetList System OS Alert GetList results n getListResult Following is a sample of one technique to test for a property before using the property This technique uses the JavaScript Object hasOwnProperty method to check for existence The File GetList method may return a result which is missing the
122. edgeenabled Allow wedge if scanner disabled in CETerm Intermec T F sessionX scanner focusnear Imager focus near if true T F sessionX scanner enhanced1d Improved decode for poor quality barcodes sessionX scanner negativelabel Improved decode negative barcodes T F sessionX scanner picklistmode Decode barcode under cross hairs T F sessionX scanner preamble Barcode preamble sessionX scanner postamble Barcode postamble sessionX scanner grid Barcode grid filter Intermec Use NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Name Description OnBarcodeRead for more features sessionX scanner beamtimeout Scan beam timeout milliseconds sessionX scanner aimertimeout Aimer timeout milliseconds sessionX scanner aimmode Aim mode none dot slab reticle sessionX scanner redundancy Linear security redundancy 0 5 CETerm Scripting Guide Page 160 COMMON SYMBOLOGY PROPERTIES Symbology properties are unique for each session Symbology properties begin with sessionX scanner SSS where X is 1 through 4 and SSS represents symbology name and may be 3 or more characters long For example session4 scanner upca enabled If no X value is found the currently active session number is used See the Symbology Names table below for SSS values NOTE If you are changing the scanner prope
123. een CETerm Session session Screen var text screen GetTextLine row if text match beep i OS PlaySound default wav 0 This hot spot will play a sound if the line touched contains the word beep The following hot spots will activate VT function keys if the user touches in the CETerm Scripting Guide Page 23 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE specified rows and columns In this case the screen can show a box drawn with VT line drawing characters and text inside each box With such a display you can effectively create large glove friendly on screen buttons in TE OnStylusDown function OnStylusDown session row column Buttons are on rows start through end var buttonrowstart 9 var buttonrowend 13 var IDA IDA NONE Buttons are buttonwidth columns wide Leftmost button is 1 var buttonwidth 5 var button Math floor column buttonwidth 1 buttonwidth if row gt buttonrowstart amp amp row lt buttonrowend switch button case 1 IDA IDA VT_PF1 break case 2 IDA IDA VT_PF2 break case 3 IDA IDA break case 4 IDA IDA break DEBUG Uncomment next two lines for testing OS Alert row row col column button button IDA IDA if IDA match IDA NONE Send comm
124. eger SendMessageTimeout Timeout in milliseconds of integer SendMessage method Default value is 5000 CETerm Scripting Guide Page 102 4 0 CETerm Script Events This section describes the script events within the CETerm script engine These events provide ways to trigger event handlers when various conditions occur in CETerm The event handlers are just user defined functions The event model in CETerm uses specific event handler names to bind events to handler functions If the event handler function e g OnBarcodeRead is defined in the script engine it will be executed when the event occurs There is no special command required to register or bind the function to the event Event handlers can be re defined at any time If the handler is no longer needed the function can be re defined as empty Normally the return value of an event handler function is ignored A few events such as OnBarcodeRead require the function to return a value to control further actions The documentation below will indicate if the event handler must return a value Events play a very important role for scripting in CETerm Just as in the standard web browser a script cannot run continuously or it will prevent user interaction and other program actions The script engine acts like a virtual user When script is executing CETerm will seem unresponsive Typically a script will do a little bit of work and then exit This way CETerm is alway
125. ent wp lp OS Alert Event nwp 0x wp toString 16 0 lp toString 16 4 3 THE ONDOCUMENTDONE EVENT The OnDocumentDone event is fired when a new webpage has completed loading into a web browser session The handler can add META tag definitions examine or alter the Document Object Model DOM or add JavaScript methods to the page This event allows CETerm to enhance a web page for mobile data collection that was not originally designed for such Syntax function OnDocumentDone session session index of browser session which completed page load Example This example shows how several META tags can be added to a web page We will add a PowerOn handler a key remapping and information item tags to position the RF indicator at a special location The handler is often used to navigate to a specific page such as a login page when the device resumes The RF indicator tags will restore a specific location but could be used to alter the RF indicator location depending on the current page OnDocumentDone function OnDocumentDone session var b CETerm Session session Browser Do not process the initial about blank page if b Document URL match about blank Add PowerOn META handler b AddMetaltem PowerOn Javascript alert My PowerOnN Insert new JavaScript function b RunScript function myfl alert N Fl Func
126. erm ClearTimeout 32 CETerm GetIDADescription 33 CETerm GetIDAName 33 CETerm GetIDAValue 33 CETerm GetProperty 33 CETerm MaxSession 36 CETerm Message 36 73 CETerm PostIDA 33 CETerm RunScript 33 CETerm SendIDA 34 CETerm SendText 34 CETerm Session 34 89 CETerm SetInterval 35 CETerm SetProperty 35 CETerm SetScriptTimeout 35 CETerm SetTimeout 35 CETerm TextInput 36 97 CheckParity 86 ClearAllListeners 51 ClearAllTimers 32 ClearBreak 83 ClearButtonKey 92 ClearButtonText 92 ClearCache 44 ClearError 83 ClearInterval 32 35 ClearListener 51 ClearSignaturePoints 90 ClearTimeout 32 35 124 130 ClipboardData 42 Close GPS 64 Close SerialPort 83 CodePage File 58 CodePage Constants 172 Connect 47 ConnectionManager Constants 172 ConnectionManager object 46 ConnectionManager Connect 47 ConnectionManager ConnectionStatus 48 ConnectionManager Disconnect 47 ConnectionManager GetA vailableNetworks 47 ConnectionManager GetDetailedStatus 47 ConnectionManager LastError 48 ConnectionManager ManagerReady 48 ConnectionManager MapNameToNetwork 48 ConnectionManager MapURLToNetworks 48 ConnectionManager MaximumCost 48 ConnectionManager MaximumLatency 48 ConnectionManager MinimumReceiveBandwidth 49 ConnectionManager ReportStatusEvents 49 ConnectionManager SetPriority 48 ConnectionStatus 48 ConstrainT
127. erties LastError LastErrorText to get additional error information directory GetDirectory Return the name of the current working directory on the host Returns null on failure Use the FTP properties LastError and LastErrorText to get additional error information filelist ListFiles pattern Return a list of remote files with names that match a pattern The pattern specifies a valid directory path or file name on the remote host which can contain wildcard characters such as an asterisk or a question mark but may not contain spaces An empty pattern will list all files in the current working directory The returned list is in the form of a JavaScript array literal which contains JavaScript object literals containing information about every matching file See Section 2 8 for details about handling JavaScript literals CETerm Scripting Guide Page 60 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Return an empty array literal if no matching files are found Use the FTP properties LastError or LastErrorText to get additional error information The returned object literals will depend on the remote host and may not contain all possible properties See Section 2 8 for dealing with missing properties For example the following array literal shows two files and a directory name myApp cab attributes 0x21 creationTime new Date 2006 11 15 11 51 41 480 lastAcces
128. es is presented as follows alert OS Alert Script done CETerm Scripting Guide Page 8 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Additional Documentation Naurtech Scripting is an integral feature of Naurtech Web Browser and Terminal Emulation Clients Please refer to the CETerm User s Manual for detailed installation and configuration information The User s Manual be downloaded from the Support section of www naurtech com Online Support Wiki Although we strive to keep this manual up to date you may find our online Support Wiki useful for the latest features sample scripts and troubleshooting tips You can access the Support Wiki from our website www naurtech com gt Support Support Wiki CETerm Scripting Guide Page 9 1 0 Introduction The Naurtech CETerm Clients provide a robust and flexible environment for Terminal Emulation and Web based applications on a mobile device Our Clients are available for most Windows CE platforms including CE NET 4 2 Windows CE 5 0 Windows CE 6 0 Windows Mobile 2003 Windows Mobile 5 and Windows Mobile 6 Device tailored versions of our Clients are available for most industrial terminals These versions integrate the peripherals on each device such as the barcode scanner magnetic stripe reader RFID reader and Bluetooth printer Naurtech Scripting features provide additional control of these peripherals and simplify tasks such
129. essID 0x17fdf002 threads 2 0 17 266 threads 6 name filesys exe processID 0xb7f67176 threads 85 name device exe processID 0x97a5a6e6 threads 10 name gwes exe processID 0xf79f79aa threads 4 name explorer exe processID 0xb79f7e32 threads 7 name services exe processID 0x77452dda threads 2 1 CETerm Scripting Guide Page 76 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status Kill processID Terminates a currently running process identified by the process ID Return 0 on success or non zero otherwise Use the Process property LastError to get additional error information exitvalue WaitForExit processID timeout Wait timeout milliseconds for a currently running process to terminate Return the exit value of the process Use the Process property LastError to determine if the call timed out there was an error or the process terminated normally While waiting for the process CETerm is prevented from performing any other actions Keep the timeout to less than a couple of seconds It is better to use the Event SetProcessListener method to detect the termination of a process Properties The Process object has the following properties Property Description Values LastError Returns the last error value associated unsigned with any
130. evice Keyboard The Keyboard object can be used to simulate hardware keyboard actions to other applications or to CETerm if required Simulated key events should not be used if CETerm Action codes can achieve the same result The Keyboard object can also create global hot keys which can be used to activate CETerm actions or scripts Global hot keys are recognized regardless of which program is active and in the foreground Global hot keys can be an important feature when using CETerm as a lock down shell and program launcher Methods The following methods are available Method Action AssignHotKey Assign a global hot key DeleteHotKey Delete a global hot key DeleteAllHotKeys Delete all global hot keys Enable Enable or disable the keyboard IsEnabled Check the keyboard enabled state IsHotKey Check if a global hot key has been assigned IsKeyDown Check if a state key was down for the last key input IsKeyDownNow Check if a key is currently down IsKeyToggled Check if a state key is toggled on SimulateKeyDown Simulate the press of a hardware key SimulateKeyUp Simulate the release of a hardware key SimulateKeyPress Simulate the press and release of a key and specify generated text CETerm Scripting Guide Page 68 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status AssignHotKey vkCode keyModifiers idaCode Assign
131. ey and value and confirms that it can be read NewRegistryDWORD function NewRegistryDWORD keyname valuename valuedata var status false var R OS Registry Check if file exists var fullyQualifiedKey HKEY LOCAL MACHINE keyname valuename if R WriteValue fullyQualifiedKey valuedata REG DWORD Check if can read value var readdata R ReadValue fullyQualifiedKey if readdata valuedata status true if status CETerm Scripting Guide Page 135 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE OS Alert Failed to confirm write of fullyQualifiedKey return status NewRegistryDWORD be used as follows Write a new value NewRegistryDWORD SOFTWARE Naurtech Test TestDword 510 5 8 CONTROLLING A SERIAL PoRT FROM CETERM This section describes how to control serial ports with scripting in CETerm Both real e g COM1 and virtual e g BSP1 serial ports can be fully controlled and accessed from emulation or browser sessions Serial ports can be opened for read access write access or both All serial port settings can be configured and events can be generated when data is available or when signal lines change state The SerialPort object can be used to integrate any serial device into CETerm such as a tethered scanner scale printer Bluetooth scanner or R
132. eys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys Keys tateToggledFlag tateGetAsyncDownFlag tatePrevDownFlag tateDownFlag hiftAnyCtrlFlag hiftAnyShiftFlag hiftAnyAltFlag hiftCapitalFlag hiftLeftCtrlFlag hiftLeftShiftFlag hiftLeftAltFlag hiftLeftWinFlag hiftRightCtrlFlag hiftRightShiftFlag hiftRightAltFlag hiftRightWinFlag hiftDeadFlag hiftNoCharacterFlag Dt Cb Db GP Lec BE Lh hiftNumLockFlag hiftScrollLockFlag MESSAGEBOX CONSTANTS MessageBox flags See Microsoft SDK for documentation var var var var var var var var CETerm S cripting Guide Either SHIFT key must be held down Either WINDOWS key was held down Both key up events and key down events generate a WM HOTKEY message 0x0001 Key is toggled 0x0002 Key went down since last GetAsyncKey call 0x0040 Key was previously down 0x0080 Key is currently down 0x40000000 1 R control is down 0x20000000 Lor R shift is down 0x10000000 Lor R alt is down 0x08000000 VK CAPITAL is toggled 0x04000000 L control is down 0x02000000 L shift is down 0x01000000 L alt is down 0x00800000 Win key is down 0x00400000 control is down 0x00200000 shift is down 0x00100000 alt is d
133. f navigation Failg ionNetCheckFailed Run after network T OnSessionConnect Run after connect 4 OnSessionDisconnect Run after discon CETerm Scripting Guide Page 16 2 3 CETERM AUTOMATION OBJECTS The CETerm Automation Objects provide access to the running CETerm application session screens device hardware the Windows CE operating system and other features For example the command CETerm PostIDA SESSION 51 0 within script would switch CETerm to Session 1 if another session was currently active Automation Objects can give access to the browser Document Object Model DOM of connected web sessions and the text on terminal emulation sessions The IDA action codes are described briefly in Section 2 4 and listed in Appendix 1 The CETerm Automation Objects are similar to ActiveX controls that are used in web pages but they do not require any special creation prior to use In fact the same CETerm Automation Objects are accessible from both the CETerm JavaScript engine and the web browser JavaScript engines 2 3 1 Top Level Automation Objects The automation objects are accessed in a parent child manner The three top level objects are CETerm Device 05 These objects are available directly in the CETerm Script engine The CETerm object provides access to application specific features The Device object provides access to device hardware such as keyboards and serial ports The os ob
134. f the Session object CETerm Session i Screen This section documents the methods and properties of the Screen object To access text in a browser page use the Browser Document reference and read the text directly from the desired page element Methods The following methods are available CETerm Scripting Guide Page 80 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Method Action GetText Get all text from start location to end location GetTextLine Get all text on a line GetTextRect Get a rectangle of text text GetText startRow startColumn endRow endColumn Return the requested range of text Each line will be separated by the TextLineSeparator property value If the session is not connected the JavaScript null value is returned End coordinates of 1 will use the maximum valid value text GetTextLine row Return the requested row of text If the session is not connected the JavaScript null value is returned The row range is from 1 to the maximum row number text GetTextRect startRow startColumn endRow endColumn Return the requested rectangle of text Each line fragment will be separated by the TextLineSeparator property value If the session is not connected the JavaScript null value is returned End coordinates of 1 will use the maximum valid value Properties The Screen object has the following properties Property Descriptio
135. finitions data Read maxCount Read up to maxCount bytes from the port Return data as a string Return null if no data or error This method blocks until the maximum bytes are read or the read timeout expires Data are converted from bytes to a wide character string by mbstowcs using the current locale Use the SerialPort property LastError to get additional error information data ReadByte Read a single byte from the port Return data as an integer value between 0 and 255 Return negative number if failure 1 failure 2 timeout This method blocks until the byte is read or the read timeout expires Use the SerialPort property LastError to get additional error information data ReadTillByte maxCount byteValue Read up to maxCount bytes from the port Return data as a string Return null if no data or error This method blocks until the maximum bytes are read or a byte with the specified integer value is read or the read timeout expires The suggested technique to use ReadTillByte is to call it after the RXFLAG event is signaled through OnSerialPortEvent with desired character as the event character Use the SerialPort property LastError to get additional error information status SetBreak Set the break condition on the port Suspends character transmissions and enters the break state Return 0 on success non zero for failure Use the SerialPort property LastError to get additional error information s
136. formed 5 8 2 Setting the PortName By default the SerialPort objects correspond to the ports If you plan to control COM1 then you should use Device SerialPort 1 Ina few cases you may need to control a non COM port such as a virtual serial port BSP1 for a Bluetooth device In this case you can use any SerialPort object that is not being used for a COM port and set the PortName as needed var bluetoothPortIndex 5 var bluetoothPortName BSP1 var sp Device SerialPort bluetoothPortIndex Sp PortName bluetoothPortName It is also possible to specify COM ports with numbers greater than 9 Following the Windows convention prepend the string device to the name The double backslash is required in JavaScript literal strings to specify a single backslash character For example to open COM123 use the name device COM123 You must set the name before opening the port 5 8 3 Configuring SerialPort Properties All serial port settings can be controlled through SerialPort object properties Please refer to Section 3 15 for a complete list of properties In general you will set needed properties before opening the port for the first time but most properties can be changed at any time Some properties are intuitive and control well known settings such as the baud rate Other properties such as timeouts and handshaking can be more complex and confusing It can be helpful to search for informat
137. g Guide Page 148 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA SESSION_S3 Session 3 Switch to session 3 IDA SESSION_S4 Session 4 Switch to session 4 IDA SESSION_S5 Session 5 Switch to session 5 IDA_TOOLBAND_HIDE Hide ToolBar Hide full Toolbar IDA TOOLBAND TOGGLEHIDE Toggle ToolBar Toggle Toolbar visibility IDA KEYBAR HIDE Hide KeyBar Hide KeyBar IDA KEYBAR TOGGLEHIDE KeyBar Toggle Toggle KeyBar visibility IDA KEYBAR LEFT Prev KeyBar Switch to previous KeyBar IDA KEYBAR RIGHT Next KeyBar Switch to next KeyBar IDA KEYBAR SEPARATOR Separator Separator for KeyBar IDA KEYBAR NONE Empty No action placeholder IDA HSCROLL HIDE HScroll Hide IDA HSCROLL VISIBLE HScroll Show IDA HSCROLL TOGGLEHIDE HScroll Toggle IDA HSCROLL PLUSON HScroll Right One IDA HSCROLL MINUSONE HScroll Left One IDA HSCROLL PLUSHALF HScroll Right Page IDA HSCROLL MINUSHALF HScroll Left Page IDA HSCROLL PLUSEND HScroll Right End IDA HSCROLL MINUSEND HScroll Left End IDA VSCROLL HIDE VScroll Hide IDA VSCROLL VISIBLE VScroll Show IDA VSCROLL TOGGLEHIDE VScroll Toggle IDA VSCROLL PLUSONE VScroll Up One IDA VSCROLL MINUSONE VScroll Down One IDA VSCROLL PLUSHALF VScroll Up Page IDA VSCROLL MINUSHALF VScro
138. ge 22 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE CETerm SendText meNr session Combining these changes into the expect call would give expect session waittime login i beepMe Password mypassword r You might wonder why the SendIDA call in beepMe has a session index of 0 whereas SendText has the actual session argument In this case we know that the beep action is not session specific and does not need to be sent to a specific session In general it is always OK to specify a session and it will be ignored for actions that do not require a value 2 7 CUSTOM SCREEN HOT SPOTS A hot spot is an area on a terminal emulation screen that is activated by taping with your finger or the stylus CETerm supports several pre defined hot spots for TE sessions With scripting it is possible to define custom hot spot behaviors Custom hot spots use the OnStylusDown event handler Browser sessions do not support the OnStylusDown event because equivalent behavior can be implemented in HTML You may need to disable the pre defined hot spots in CETerm because they will be triggered before a custom hot spot The hot spot action can depend on the screen contents in an area or simply be tied to a screen area The following OnStylusDown handler can be loaded from the script templates OnStylusDown function OnStylusDown session row column Look for custom hot spot var scr
139. ggled 70 IsListenerSet 53 IsOpen GPS 65 IsOpen SerialPort 86 IsVisible Message 73 IsVisible Window 100 IsWindow 101 J JavaScript Literal Values 25 JavaScript Object Notation JSON 25 K Keyboard Constants 177 Keyboard object 39 68 71 Page 193 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Keyboard AssignHotKey 69 Keyboard DeleteAllHotKeys 69 Keyboard DeleteHotKey 69 Keyboard Enable 69 Keyboard IsEnabled 70 Keyboard IsHotKey 70 Keyboard IsKeyDown 70 Keyboard IsKeyDownNow 70 Keyboard IsKeyToggled 70 Keyboard LastError 71 Keyboard SimulateKeyDown 70 Keyboard SimulateKeyPress 71 Keyboard SimulateKeyUp 70 Kill Process 77 L LastDNSError 75 LastError 65 71 77 86 102 LastErrorText FTP 62 LastExecuteProcess 77 LastPingError 75 LastPingHostName 75 LastPingIPAddress 75 LastPosition 65 LastWS AError 75 ListFiles FTP 60 Load at Startup 15 16 143 Locked SIP 96 Login FTP 61 Logout FTP 61 M ManagerReady 48 MapNameToNetwork 48 MapURLToNetworks 48 MaximumAge 65 MaximumCost 48 MaximumLatency 48 MaximumPingTimeout 75 MaxSession 36 Message 36 Message AbortButtonVisible 73 Message Is Visible 73 Message Progress 73 Message ProgressRate 73 Message ProgressRunning 73 Message ProgressVisible 73 Message Text 73 Message Timeout
140. global hot key and CETerm Message The event is signaled by the GPS device and used to update the display The hot key is used to terminate the demo To run this demo simply load the full script into an available script slot and tap Test Load GPS Demo Script WARNING This demo overwrites the contents of Script 50 WARNING This demo does not contain any error checking and WARNING may not work on all devices Constants var VK RETURN 0x0D Enter key Function to update position display when position event is signaled function UpdateGPSPosition var var Device GPS GetPosition Parse position literal object eval p pl OS Beep Update display message CETerm Message Text Lat and Long will display values when GPS obtains a location fix Initial fix may take several minutes nPress ENTER when done NMnLat p latitude nLong p longitude Reschedul vent listener var s OS Event SetListener GPSPositionUpdateEvent UpdateGPSPosition 300000 Function to cleanup GPS display when done function CleanupGPS CETerm Scripting Guide Page 66 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE var g Device GPS var m CETerm Message var OS Event var k Device Keyboard Close GPS device g Close Hide
141. he expect function has 4 defined arguments in the function declaration it is possible to pass an unlimited number of arguments All arguments are accessible through the special arguments variable This script also shows the object oriented aspects of JavaScript by creating a new ExpectMonitor class expect This script will expect a text prompt on the screen and respond with text or action Syntax expect session timeout xpectedText respons expectedText2 response2 session is the session index timeout is the wait interval for each text in milliseconds expectedText can be a string or regular expression Response can be a text response or a function function expect session timeout expectedText response Build array from arguments This technique will accumulate any number of expect response pairs var TargetResponseArray for var 1 2 i lt arguments length i TargetResponseArray push arguments i Create an ExpectMonitor class that manages the actions var EM new ExpectMonitor session timeout TargetResponseArray Set optional ExpectMonitor behaviors EM silent true NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE EM OnDone function success OS Alert Done Start check EM Start 5 1 2 ExpectMonitor Class The Ex
142. he hardware keyboard If enabled is true the keyboard is enabled if false it is disabled Not all devices support this action Return the new keyboard state WARNING If the keyboard is disabled it may render the device unusable and require a system reset Design your scripts defensively to prevent unwanted conditions CETerm Scripting Guide Page 69 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status IsEnabled Check the keyboard enabled state Returns true if enabled false if disabled Not all devices support this action status IsHotKey idaCode Check if a global hot key has been assigned with the specified IDA code Return true if hot key was assigned false otherwise status IsKeyDown vkCode Check the status of the specified key Return true if key was down false if up Note that this state is updated by Windows only when key events are processed Use IsKeyDownNow to check the instantaneous state of a key See Appendix 5 for VK values status ISKeyDownNow vkCode Check the current status of the specified key Return true if key is down false if up This instantaneous check is useful to detect when a user releases a key See Appendix 5 for VK values status ISKeyToggled vkCode Check the toggle status of the specified key Return true if key is toggled on false if toggled off This check is used for VK CAPITAL 0x14 and VK NUMLOCK 0x90 keys only
143. hem with comment characters Alternatively you can define a Debug method and sprinkle it through your code This makes it easier to enable or disable debugging var globalDebugLevel 0 function Debug message if globalDebugLevel 0 OS Alert message CETerm Scripting Guide Page 145 Appendix 1 IDA Action Codes Many IDA codes apply only to a Terminal Emulation session Some IDA codes can only be used in restricted circumstances such as IDA URL Symbolic Name Friendly Name Description IDA_BEL Bell IDA_BS Backspace IDA HT Horizontal Tab IDA_TAB Tab IDA_LF Linefeed IDA_VT Vertical Tab IDA_FF Form Feed IDA_CR Carriage Return Printable ASCII IDA_SPACE lt Space gt IDA_EXCLAMATION_MARK IDA_DOUBLE_QUOTE IDA NUMBER SIGN IDA_DOLLAR_SIGN IDA PERCENT IDA_AMPERSAND amp IDA_SINGLE_QUOTE IDA LEFT IDA RIGHT PAREN x IDA_ASTERISK IDA_PLUS IDA_COMMA IDA HYPHEN IDA PERIOD IDA SLASH IDA 0 IDA 1 IDA 9 IDA_COLON IDA_SEMICOLON IDA LESS THAN IDA_EQUAL IDA_GREATER_THAN IDA_QUESTION MARK NPV H NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE
144. icate the default setting General Description Values Property EventMask Events monitored by WaitForEvent integer flags see Default is none Appendix 4 IsOpen Returns true if port is open read true false only LastError Returns the last error value unsigned integer associated with any SerialPort operation read only ModemStatus Modem status read only integer flags see Appendix 4 Portlndex Index of this SerialPort object read integer only PortName Name of the serial port device text Default value is COMx where x is the PortIndex DCB Description Values Property BaudRate Baud rate of device Default integer see 115200 Appendix 4 CheckParity Perform parity checking true false D CTSOutputFlowControl Monitor CTS signal for output flow true false D control CETerm Scripting Guide Page 86 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE DCB Description Values Property DataBits Bits per byte integer D 8 DiscardReceivedNULL Discard any null bytes received true false D DSRInputControl Monitor DSR signal for input flow true false D DSROutputFlowControl Monitor DSR signal for output flow true false D control DTRControlMode DTR signal mode Default is integer see enable when open 0 1 Appendix 4 EventCharacter Character that triggers integer D 0x
145. ies are unique for each session Scanner properties begin with sessionX scanner where X is 1 through 4 For example session4 scanner enabled If no value is found the currently active session number is used We use the name scanner for all types of barcode readers including laser scanners and imagers If a hardware vendor is listed the property is specific to barcode readers made by that vendor NOTE If you are changing the scanner properties for the currently activesession you must call CETerm PostlDA IDA SCAN APPLYCONFIG 0 for the changes to take effect WARNING Not all properties are applicable to all hardware devices Different devices may use different names to refer to the same parameters You should look at the settings available in the CETerm configuration dialogs to determine if the property is appropriate and what values it may accept Property Name Description app scanner allowscanwhennotconnected Allow scan when session is not connected to a host T F D F app scanner deinitscannerwhennotactive Deinit release scanner when CETerm is not the active application T F D F app scanner suspendscannerwhennotactive Suspend scanner operation when CETerm is not the active application T F D T Property Name Description sessionX scanner enabled Scanner is enabled T F sessionX scanner aimerenabled Aimer is enabled T F sessionX scanner w
146. if url match protected htm var t CETerm TextInput t Title Administrator Login t Prompt Pleas nter your password t PasswordMode true t Input Clear current password var s t GetInput if s 1 t Input secret Bad password cancel return 1 t Input Clear password CETerm Scripting Guide Page 112 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Continue all other navigations return 0 4 9 THE ONNETCHECKFAILED EVENT The onNetCheckFailed event is fired if a Network Check on Send fails to detect the host system and the Network Check Action is ida IDA SCRIPT ON NETCHECKFAILED Other Network Check Actions are possible including direct naming of an error URL See the User Manual for more information Typically this error handler will redirect the web browser to a file URL on the device for error recovery Syntax function OnNetCheckFailed session pendingURL session index of browser session attempting navigation pendingURL pending URL for navigation The pendingURL is the destination that the user requested but which has been deferred because the host was not contacted The event handler can re try the navigation Example This example is nearly identical to the onNavigateError handler except that there is no error number in the pendingURL This handler shows how to redirect a Windows CE web browse
147. ion at msdn microsoft com with the keywords serial communications reference ce to learn additional details about Windows CE serial port control and behavior CETerm Scripting Guide Page 137 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 5 8 3 1 Configuring SerialPort Timeouts When reading from the serial port the default timeouts prevent blocking of the read operation Most reads should be performed in response to an EV_RXCHAR event indicating that data is available from the attached device Often however some timeout is needed to allow a complete data message to be received In these cases we recommend a small ReadTotalTimeoutConstant and perhaps a small ReadTotalTimeoutMultiplier Beware of a read request with a large maxCount parameter because this can result in a large total timeout if ReadTotalTimeoutMultiplier is non zero var portIndex 5 var sp Device SerialPort portIndex sp ReadTotalTimeoutConstant 100 sp ReadTotalTimeoutMultiplier 0 Sp ReadIntervalTimeout 0 You should review the Microsoft documentation mentioned above and may need to experiment with timeouts to configure the behavior that works best with your peripheral and software architecture For example if you do not seem to get a complete message during your read you may need a larger timeout or may need to save the partial data and perform another read at a later time When writing
148. isec Set a one time timer to execute the scriptExpression after a delay of delayMillisec This method returns an ID that should be saved in a global variable for later use with ClearTimeout if needed Other scripts may run while waiting for this timer The scriptExpression is a string containing the script but is commonly a function invocation such as myTimerFunction 3 alert Timers are especially useful with complex or long running scripts Timers can also be used to defer an operation which is not possible within an event handler One time timers should be used in preference to interval timers In general CETerm Scripting Guide Page 35 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE scripts should perform a short action and exit With a complex script such as a state machine the state can be maintained in global variables and the script re activated periodically to check for state transitions and perform actions See the expect script and ExpectMonitor in Section 5 1 for an example of the use of a timer Properties The CETerm object has the following properties Property Description Values ActiveSession Current active session read only 1 MaxSession InterceptKeyMessages When true all key messages can be true false processed in OnKeyMessage handler D false MaxSession Maximum session index read only 5 Message Returns message object r
149. ject provides access to generic Operating System OS features such as files events processes the network and the Windows registry For more details see Chapter 3 2 3 2 Accessing Top Level Objects in Web Pages Most automation objects and features can also be used directly by the JavaScript engine within web page The technique to get a top level reference is different for Windows Mobile and Windows CE devices Under the Windows CE browser the top level objects can be referenced from the pre defined externa1 object Under Windows Mobile you must create an ActiveX object which can return the top level objects To make top level access easier the following bit of code will work on either platform and will provide the ext reference for access to the top level objects The ext reference can be used anywhere the web page after including the following script in the lt head gt element of the page NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE NOTE The external and ActiveXObject techniques are only needed within web pages Within the CETerm JavaScript engine the top level objects are pre defined and directly accessible lt script language javascript gt Script to provide access to CETerm Automation Objects Put this lt script gt element in the lt head gt of the page Resolve ext reference one time when page loads WARNING Make sure ext not already used by your scri
150. k IDA FIND Find CETerm Scripting Guide Page 151 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA_INSERT_HERE Insert Here IDA NEXT Next IDA PREVIOUS Previous IDA REMOVE Remove IDA SELECT Select IDA VT PF1 VT PF1 Numpad PF1 key IDA VT PF2 VT PF2 Numpad PF2 key IDA VT PF3 VT PF3 Numpad PF3 key IDA VT PF4 VT PF4 Numpad key IDA VT COMMA Numpad Comma IDA NUMPAD 0 Numpad 0 IDA NUMPAD 1 Numpad 1 IDA NUMPAD 2 Numpad 2 IDA NUMPAD 3 Numpad 3 IDA NUMPAD 4 Numpad 4 IDA NUMPAD 5 Numpad 5 IDA NUMPAD 6 Numpad 6 IDA NUMPAD 7 Numpad 7 IDA NUMPAD 8 Numpad 8 IDA NUMPAD 9 Numpad 9 IDA VT ENTER Numpad Enter IDA VT MINUS Numpad Minus IDA VT PERIOD Numpad Period IDA UDK F6 UDK F6 VT User Defined Key F6 IDA UDK F7 UDK F7 VT User Defined Key F7 IDA UDK F20 UDK F20 VT User Defined Key F20 IDA_VT_HELP VT Help IDA_VT_DO VT Do IDA_ADD Add IDA_MULTIPLY Multiply IDA_DIVIDE Divide Custom VT Sequences IDA VT BS VT Backspace Send BS character IDA VT 5 0135 VT SAP0135 0x00 0x35 CETerm Scripting Guide Page 152 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA_VT_CSI
151. l XML document applying an XSLT transformation and returning the result to the host through the TE session CETerm Automation Objects are provided to give scripts access to the state of CETerm the TE session hardware components and access to Windows CE operating system functions such as network file and registry operations This guide is intended to describe the steps for writing and running scripts and the features provided through the CETerm Automation Objects Please consult the standard references for details on JavaScript or JScript syntax and XML You may also need to consult standard references for HTML syntax the browser NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Document Object Model DOM and other aspects of Dynamic HTML if you are scripting web browser features Please refer to the Naurtech User s Manual for details on basic usage and configuration of the Naurtech clients We hope that our Scripting features will enrich and extend the capabilities of your TE and browser applications Explore a little deeper and we think you will be amazed the possibilities for building powerful business applications 1 1 FEATURE HIGHLIGHTS Following are some of the special features in Naurtech Scripting JavaScript Naurtech uses the industry standard JavaScript scripting language This powerful language is familiar to programmers and non programmers world wide as the core of rich web application
152. lastAccessTime for directory entries CETerm Scripting Guide Page 26 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Sample GetList literal result name myApp cab attributes 0x21 creationTime new Date 2006 11 15 11 51 41 480 last last name last last name last AccessTime new Date 2007 7 27 3 27 41 0 WriteTime new Date 2008 6 15 0 29 50 0 size 2455494 myconfig ini attributes 0x21 AccessTime new Date 2007 7 27 3 27 18 0 WriteTime new Date 2008 6 15 0 29 48 0 size 12564 AppDirectory attributes 0x10 WriteTime new Date 2008 2 11 12 29 49 0 size 1024 var getListResult OS File GetList System eval var fileArray getListResult var i var file var time for 1 0 i fileArray length i file fileArray il if file hasOwnProperty lastAccessTime time file lastAccessTime OS Alert Last Access time getFullYear CETerm Scripting Guide Page 27 3 0 CETerm Automation Objects This section describes the Automation Objects available to the CETerm script engine These objects provide access to the running CETerm application TE session screens the Windows CE operating system hardware device components and other features for developing rich applications The automation objects are accessed in a hierarchical manner similar to the Document Object Model DOM of a
153. ld read data and respond to a host Windows event objects should only be used when synchronization with external programs or device services is required For a better understanding of Windows event objects you can search for information at msdn microsoft com with the keywords createevent ce Methods The following methods are available Method Action ClearAllListeners Clear all assigned handler scripts ClearListener Clear an assigned handler script for a single event Create Create a handle for a named event If the named event does not yet exist within Windows it is created Delete Delete an event handle DeleteAllEvents Delete all event handles open in CETerm GetHandlerScript Returns the handler script for an active listener GetList Returns list of managed events GetName Returns name of an event handle IsExistingEvent Returns status of an event handle IsListenerSet Returns status of a listener on a single event Pulse Signals all listeners that an event is set then resets the event to the non signaled state Reset Reset an event to the non signaled state Set Set an event to the signaled state SetListener Assign a handler script to an event The handler is run when the event is signaled SetProcessListener Assign a handler script to a running process The handler is run when the process exits NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS
154. le The OnBarcodeRead event handler is called every time a barcode is successfully decoded The handler function can intercept and pre process CETerm Scripting Guide Page 18 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE barcode scan data using the full power of JavaScript before sending the data on to the TE or browser session The OnBarcodeRead handler could do something simple such as pre pending zero digits for short barcodes or something complex such as splitting an Automotive Industry Action Group AIAG B 10 barcode and putting different parts into different fields on an IBM 5250 emulation screen Here is the OnBarcodeRead template that can be loaded in the script edit dialog OnBarcodeRead function OnBarcodeRead session data source type date Lime Manipulate barcode data here Send barcode to emulator CETerm SendText data session Return 0 to handle barcode normally Return 1 if handled data here return 1 This handler simply passes the barcode data on to the current session using the SendText method The return value of 1 tells CETerm not to pass on the barcode data with the usual wedge technique The following OnBarcodeRead handler will prefix 3 zeros to any 8 digit barcode and pass other barcodes unchanged OnBarcodeRead function OnBarcodeRead session data source type date time Prefix zeros to short barcodes
155. le message wParam IParam Send a message to the specified window Return the integer status of the message execution This feature is primarily intended to work with applications that document public messages that may be used for control or communication Valid message values and parameters are not documented in this manual Use the Window property LastError to get additional error information WARNING Sending an ill formed message may cause the receiving application to fail There are very few messages that are valid from this method Beware that some messages return complex results and these are not returned to the caller and may cause CETerm to fail status SetTopmost windowHandle Set the specified window to be the topmost and active window This is also called the foreground window Return true on success or false on failure status Show windowHandle visible Set the visibility state of the specified window If visible is true the window is set to the visible state If visible is false the window is hidden Return true if the window was previously visible or false if the window was previously hidden CETerm Scripting Guide Page 101 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Properties The Window object has the following properties Property Description Values LastError Returns the last error value associated unsigned with any Window operation int
156. lent Exit program silently IDA PROGRAM HELP Program Help Display Help IDA PROGRAM MINIMIZE Program Minimize Hide program window IDA SUSPEND DEVICE Suspend Device Enter suspend state IDA BLUETOOTH DISCOVERY Bluetooth Discovery Start discovery IDA WARMBOOT Warm Boot Warm boot device IDA COLDBOOT Cold Boot Cold boot device IDA MENU TOPBOTTOM Menu Top Bot Toggle menu location IDA MENU TOGGLEHIDE Menu Toggle Toggle menu visibility IDA TOOLBAR TOGGLE ToolBar Toggle Toggle toolbar visibility IDA START TOGGLEHIDE Start Menu Toggle Toggle Start visibility IDA MENUBAR TOGGLEHIDE MenuBar Toggle Toggle menubar visibility IDA SESSION TOGGLECON Connect Disconnect Toggle session connection IDA SESSION CONFIGURE Configure Configure session IDA SESSION CONNECT Connect Connect session IDA SESSION DISCONNECT Disconnect Disconnect session IDA SESSION NEXT LIVE Next Live Session Switch to next live session IDA SESSION PASSWORD Password Session password dialog IDA SESSION PREV Prev Session Switch to previous session IDA SESSION NEXT Next Session Switch to next session IDA SESSION DISCON ALL Disconnect All Disconnect all sessions IDA SESSION S1 Session 1 Switch to session 1 IDA SESSION S2 Session 2 Switch to session 2 CETerm Scriptin
157. ll Down Page IDA VSCROLL PLUSEND VScroll Up End IDA VSCROLL MINUSEND VScroll Down End IDA FONT PLUS Font Inc Increase font size IDA FONT MINUS Font Dec Decrease font size IDA TOGGLE FONT BOLD Font Bold IDA SMARTPAD OPEN SmartPad Show IDA SMARTPAD CLOSE SmartPad Hide IDA SMARTPAD TOGGLEHIDE SmartPad Toggle CETerm Scripting Guide Page 149 NAURTECH WEB BROWSER AND TERMINAL EMULAT ON FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Friendly Name Description IDA SLEEP 10 Sleep 10msec IDA SLEEP 50 Sleep 50msec IDA SLEEP 200 Sleep 200msec IDA SLEEP 1000 Sleep 1sec IDA SLEEP 5000 Sleep 5sec IDA SLEEP 20000 Sleep 20sec IDA SLEEP 100000 Sleep 100sec IDA SCAN RESUME Scan Resume Allow scanning IDA SCAN SUSPEND Scan Suspend Suspend scanning IDA SCAN TRIGGER Scan Trigger Soft trigger scanner IDA SCAN APPLYCONFIG Scan Apply Config Apply current settings IDA MACRO OPEN Macro Show Show Macro Tool IDA MACRO CLOSE Macro Hide Hide Macro Tool IDA MACRO TOGGLEHIDE Macro Toggle Toggle Macro Tool hiding IDA MACRO RECORD Macro Record Start Macro record IDA MACRO STOP Macro Stop Stop Macro record IDA MACRO PLAY Macro Play Replay Macro IDA PRINT SCREEN Print Screen Print current screen
158. lly to indicate the check This sample is more complex than needed but it illustrates how to use global variables RFSoundO and timers to periodically check state nConnect CETerm Scripting Guide Page 123 NAURTECH G func RF func if E func RF RF va if el CETerm S WEB BROWSER AND TERMINAL EMULATION FOR WiNDOWS CE AND WiNDOWS MOBILE lobal control variables RFWakeupSoundTimerID 0 RFWakeupSoundContinue 0 RFWakeupSoundInterval 200 milliseconds RFWakeupSoundCountMaximum 50 50 200 10 seconds RFWakeupSoundCount 0 tion OnWakeup Start with wakeup event WakeupSoundStart unction to start RF check tion RFWakeupSoundStart RFWakeupSoundContinue RFWakeupSoundContinue 1 if RFWakeupSoundTimerID 0 Stop and clear any previous check CETerm ClearTimeout RFWakeupSoundTimerID RFWakeupSoundTimerID 0 RFWakeupSoundCount 0 Schedule first RF check RFWakeupSoundTimerID CETerm SetTimeout RFWakeupSoundOnTimer RFWakeupSoundInterval unction to check RF and notify user tion RFWakeupSoundOnTimer WakeupSoundTimerID 0 WakeupSoundCount t Get and check info r rfStatus CETerm GetProperty device rf status rfStatus gt 0 RF detected Delayed playsound increase delay for W
159. ls about handling JavaScript literals See Appendix 4 for status and flag definitions Times are in seconds voltages are in millivolts and currents are in milliamperes Depending on the device some values may be invalid When a battery is under charge ACLineStatus 0x1 some values may be invalid Return null if battery information is not available Search msdn microsoft com with keyword SYSTEM POWER STATUS EX for more details NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status GetPowerState deviceName Get the power state of the specified device component The valid device names depend on the hardware Common devices are serial ports and the backlight BKL1 Return values are 0 full on 1 low on 2 standby 3 sleep 4 off 1 if unknown Check the Device property LastError for more error information status PowerStateRequest deviceName powerState Request the OS to set the power state of a device component The state is one of the 5 values listed under GetPowerState See Appendix 4 for state constants Return 0 for success non zero for failure Check the Device property LastError for more error information ResetIdleTimer Resets the system idle timer The idle timer is used to determine when to enter a suspended state Resetting the timer will typically prevent the device from suspending object SerialPort index Return th
160. mand argl arg2 arg3 arg4 if command Format PM text ST or ESC 7 text ESC N argl contains a text string Other args are undefined if argl charAt 0 1 CETerm Scripting Guide Page 122 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE else if 77 else if py Reply with special text CETerm SendText TDT 001 038 n session command ESCBangS Format ESC 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 Format only two specified args ESC 1 2 16 arguments are defined Arguments unspecified in the data stream have value 99 You can put more argX arguments in the function definition or use the special JavaScript arguments array to access the values nn argl arguments 2 arg2 arguments 3 argl6 arguments 17 Process command command ESCTilda Format ESC E or ESC S argl is 69 E or 83 S Process command 4 22 THE ONWAKEUP EVENT The OnWakeup event is fired when the device resumes after suspending The handler can be used to perform any action such as waiting for RF coverage or switching to a specific session Syntax function OnWakeup Example This example will wait for RF coverage to resume and sound a tone when it is available While waiting a tic sound will be made periodica
161. mes The PostIDA command will return before the action executes In general the IDA action will not be applied until after the current script execution ends TIP We recommend using PostIDA rather than SendIDA There are only rare situations when SendIDA must be used for a synchronous action status RunScript script Run the specified script in the CETerm engine This method must only be used when the CETerm object is referenced from the web browser script engine In CETerm Scripting Guide Page 33 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE general it is better to use PostIDA with an IDA SCRIPT xx action to run a pre defined script from the web browser To execute a script contained in a string from the CETerm engine use the JavaScript eval method SendIDA IDASymbolicName session SendIDA sends an IDA action command and directs it to the specified session Valid session values are 1 to MaxSession The special session value of 0 will send the command to the current session See Appendix 1 for IDA Symbolic Names TIP We recommend using PostIDA rather than SendIDA There are only rare situations when SendIDA is needed for a synchronous action The SendIDA method will attempt to complete the action before returning There are only rare situations when SendIDA must be used For example SendIDA will be needed if you need to invoke IBM field actions such as Field Exit between
162. n receives data from the connected host The handler can be used to detect screen content such as an error message and perform a desired action Syntax function OnSessionReceive session count session index of session which received data count count of bytes received Example This example will check the screen content on line 24 looking for an error message If found the error is displayed as a popup message OnSessionReceive function OnSessionReceive session count Get line of text var s CETerm Session session Screen var line s GetTextLine 24 Do a regular expression case insensitive match if line match error i OS Alert Error line CETerm Scripting Guide Page 118 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 4 17 THE ONSESSIONSWITCH EVENT The onSessionSwitch event is fired when the active session changes The handler can be used to perform a session specific action Syntax function OnSessionSwitch session previousSession session index of session which became active previousSession index of session which was previously active Example This example will reposition the battery information item depending on which browser session is active OnSessionSwitch function OnSessionSwitch session previousSession var CETerm Session session Browser if b DocLoaded
163. n Values Rows Number of rows in screen read only 1 50 Columns Number of columns in screen read only 1 132 CursorRow Current row containing cursor Setting 1 to Rows this value will change the cursor location CursorColumn Current column containing cursor Setting 1 to this value will change the cursor location Columns DisplayStatus IBM display status read only integer see Appendix 4 KeyboardState Keyboard state This applies to VT and integer IBM emulation only VT state can only be see CETerm Scripting Guide Page 81 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Description Values locked or unlocked read only Appendix 4 ScrollLeftColumn Left most visible column 1 to Columns ScrollTopRow Top most visible row 1 to Rows TextLineSeparator Text which separates every line in Default GetText methods nothing VisibleColumns Number of columns visible on the screen 1 to Columns VisibleRows Number of rows visible on the screen 1 to Rows 3 17 THE SERIALPORT OBJECT The SerialPort object gives access to serial port functionality The SerialPort objects are obtained from a Device object method Device SerialPort i where i is 0 through 9 This section documents the methods and properties of the SerialPort object The SerialPort object has been used to integrate devices such as tethered scanners Bluetooth scanners and
164. nction OnTriggerEvent flags id var index CETerm ActiveSession var Session CETerm Session index CETerm Scripting Guide Page 121 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE if Session Browser Document null Current session is browser session Hand off processing to web page var script flags id Wwe Session Browser RunScript script 4 21 THE ONVTCOMMAND EVENT The OnVTCommand event is fired when a special command format is received by a VT emulation session from the server The command includes a variable number of arguments that depends on the received command The handler script may perform any desired actions The screen text may contain additional information used by the handler Syntax function OnVTCommand session command argl arg2 arg3 arg4 session index of session receiving the command command activating command ESCBangS ESCTilda APC OSC PU1 PU2 arg1 command argument a Terminating character for ESCTilda b Up to 16 arguments with values which range between 0 and 99 for ESCBangS Unspecified ESCBangS arguments have the value 99 String with content for other commands APC OSC PM PU1 PU2 Example This example shows how to process the various possible arguments OnVTCommand function OnVTCommand session com
165. ndix 4 for flag definitions Search msdn microsoft com with keywords messagebox ce for more details PlaySound sound flags Play a wave file on the device This PlaySound is not the same as the CETerm PlaySound Use the complete absolute file path if the wave file is not in the Windows directory The flags control the way the sound is played See Appendix 4 for flag definitions Returns true on success false otherwise Search msdn microsoft com with keywords playsound for more details PlayTone volume frequency duration Play a tone if supported by the handheld hardware New applications should use this method and avoid CETerm Playtone volume is the volume 00 10 0 is off 10 is loudest frequency is the frequency in Hz duration is the duration in milliseconds Sleep delay Delay script execution for specified milliseconds CETerm Scripting Guide Page 41 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status StopSound Stop any currently playing sound Returns 0 on success Properties The os object has the following properties Property Description Values ClipboardData Provides access to the current Windows _ string clipboard cut and paste buffer Assigning to this property will set the clipboard contents Event Returns the Event object This object object provides access to the Window
166. ne is a full JavaScript environment running in CETerm that provides all the power and familiarity of JavaScript for automating and extending your data collection process Strictly speaking CETerm contains the Microsoft JScript engine which has additional capabilities but we will refer to it as JavaScript The CETerm JavaScript engine is separate from the JavaScript engines which are available in web browser sessions but the two engines can communicate exchange data and send commands Unlike the web browser engine the CETerm engine runs independently of any TE or browser session and can interact with all sessions This persistence allows the CETerm engine to maintain state throughout a data collection workflow The CETerm script engine runs as part of the CETerm user interface and when processing a script the device keys and screen may be unresponsive Think of the script engine as a virtual user which can examine the screen and send input There are several techniques to write asynchronous scripts and to show feedback to the user and get user input while a script is running 2 2 ENABLING SCRIPTING AND EDITING SCRIPTS Scripting is disabled by default To enable scripting open the configuration dialog Session gt Configure gt Options gt Configure Scripting General Settings On the General tab check the Enable box and check Show Script Errors You may also want to enable file and registry access permission or program launchi
167. ng if you need these features The Re Initialize button on this tab can be used if you have made changes to the permissions or your scripts and you wish to load the changes The re initialization does not take place until the dialog is closed by tapping OK General Scripts Olena Script Timeout sec 300 E Show Script Errors Allow File Registry Read Allow File Registry Write Allow Program Launch The Script Timeout variable limits the duration of script execution This limit is useful when developing new scripts and as a safeguard against a script with an infinite loop A value of 0 will disable the timeout During execution a script can modify the timeout value and reset the timer to allow additional execution time Editing Scripts Scripts are edited on the Scripts tab There are 64 script slots The size of the script in each slot is limited to about 260 000 characters about one half megabyte under Windows CE Scripts can also be loaded dynamically from files A script slot will usually contain function definitions which will be loaded into the engine or executable statements such as function calls which may be bound to a key toolbar or menu NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Scripting General Scripts Name Flags Script OnDocumentDor OnSessionConne I OnStylusDown ON C C C0 P9 After selecting a script slot
168. nstance of the object var INET E CANNOT INSTANTIATE OBJECT 0x800C0010 CETerm Scripting Guide auto wake manual wake Page 171 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Attempt to redirect the navigation failed var INET FAILED 0x800C0014 Navigation redirected to a directory var INET 0x800C0015 Unable to lock request with the server var INET LOCK REQUEST 0x800C0016 Reissue request with extended binding var INET F USE EXTEND BINDING 0x800C0017 Binding is terminated var INET F TERMINATED BIND 0x800C0018 Permission to download is declined var INET CODE DOWNLOAD DECLINED 0x800C0100 Result is dispatched var INET RESULT DISPATCHED 0x800C0200 Cannot replace a protected SFP file var INET E CANNOT REPLACE SFP FILE 0x800C0300 CODEPAGE CONSTANTS Special file conversion codepage values var var var Ver var CP_RAW CP ANSICOD UTF7 UTF8 1 CONSTANTS tted notation Special file conversion codepage values Constants for To reference values
169. nt 100 sp WriteTotalTimeoutMultiplier 0 Open port return sp Open GENERIC READ GE Z ERIC WRITE 5 8 4 Using WaitForEvent to Detect Data and State Changes Section 4 0 describes why scripts cannot run continuously within CETerm While a script is blocking on SerialPort Read command waiting for data CETerm cannot respond to user input or perform other actions Because of this you must keep read timeouts short to maintain a responsive program Although you could poll the serial port frequently to read newly arrived data this is an inefficient technique The better technique is to use the SerialPort WaitForEvent method to run an event handler when data arrives or other states change To use WaitForEvent you first configure the types of events you want to detect These are set as flag values in the EventMask property For example to report events for the arrival of data and a change of the DSR state you would use var portIndex 5 var sp Device SerialPort portIndex sp EventMask EV RXCHAR EV DSR See Appendix 4 CETerm Scripting Guide Page 139 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE You must also define OnSerialPortEvent handler that will be called when the event occurs Here is a sample handler Serial port event handler function OnSerialPortEvent portIndex eventMask if portIndex 5
170. nts i re m Conventions used in this Manual Additional Online Support 1 0 Introd iste eet Ie et pe 1 1 Feature Highlights 2 0 Getting Started suu ulus 2 SAVASCHIPUEM GING L 2 2 Enabling Scripting and Editing Scripts General Settilgs ct ed ies a asus uum tunai Suasana tima een Edilirig SOripIST Sim n ETE 2 3 Automation Objects 2 3 1 Top Level Automation 2 3 2 Accessing Top Level Objects in Web Pages ZA IDA Action CodeS 2 5 OnBarcodeRead Script 2 6 Automated Logi uu ia 2 7 Custom Screen Hot Spots 2 8 Handling JavaScript Literal Values JSON Literal 2 8 1 ku Sasak 2 8 2 Object Literals cnc 2 8 3 eau Aes 2 8 4 Optional Object Properties
171. nts i topindex i break Find next application index var nextindex topindex 1 arguments length DEBUG OS Alert topindex topindex nextindex nextindex 4 arg arguments nextindex Find next window var wa eval OS Window GetList for i20 i lt wa length i DEBUG OS Alert text wa i text if wa i text match arguments nextindex OS Window SetTopmost wa i hwnd The next step is to define the script that is run when the is pressed This script invokes ToggleApplications Lets assume this script is in Script 8 Switch between CETerm Calculator and Media Player ToggleApplications ceterm i calc i Media Player The last step is to assign the hot key to run Script 8 This can be placed in any script slot It may be marked Load at Startup or the key could be assigned as part of other initialization scripts For this example Shift Right_Arrow is the hot key combination Assign hot key var vk _ rightarrow 0x27 var modifier shift 0x4 var k Device Keyboard var result k AssignHotKey vk_rightarrow modifier shift SCRIPT 8 if result 0 OS Alert AssignHotKey failed e k LastError CETerm Scripting Guide Page 72 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 3 12 THE ME
172. oBox 92 Page 191 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Copy File 55 Create Event 51 CreateDirectory File 55 CreateDirectory FTP 60 CTSOutputFlowControl 86 CursorColumn 81 CursorRow 81 D DataBits 87 Delete Event 51 Delete File 56 DeleteAllEvents 52 DeleteAllHotKeys 69 DeleteDirectory FTP 60 DeleteFile FTP 60 DeleteHotKey 69 DeleteKey 78 DeleteValue 78 Device object 28 37 Device Display 39 49 Device GetBatteryInfo 37 Device GetPowerState 38 Device GPS 39 63 Device Keyboard 39 68 Device LastError 39 Device PowerStateRequest 38 Device ResetIdleTimer 38 Device RFID 39 Device SerialPort 38 82 Device SignatureCapture 39 89 Device SmartCard 39 Device Speech 39 Device Trigger 39 Device Vibrate 38 DeviceStateChangeEvent 65 DiscardReceivedNULL 87 Disconnect 47 Display SignatureCapture 90 Display object 39 49 Display LastError 49 Display Orientation 49 Display SetOrientation 49 DisplayStatus 81 DNSLookup 74 Docked SIP 96 DocLoaded 46 Document 46 DSRInputControl 87 DSROutputFlowControl 87 DTRControlMode 87 CETerm Scripting Guide E Enable Keyboard 69 EnableInput 99 EnumerateKeys 79 EnumerateValues 79 Event object 42 50 Event ClearAllListeners 51 Event ClearListener 51 Event Create 51 Event Dele
173. ory 2 r 2 5 Put Back 2NE CETerm Scripting Guide Page 130 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE This script can be entered into any script slot and bound to a key combination for activation You must also load the expect ExpectMonitor in a script slot which is marked Load at Startup so that the functions are available for use 5 2 PRESENTING VISUAL FEEDBACK DURING SCRIPT EXECUTION The Message object can be displayed during script execution when you want to provide a visual indication of script progress The Message object is asynchronous and a script can continue running while it is displayed This is unlike the OS Alert message which stops script execution and requires user confirmation There is only one Message object within CETerm and you can change the Message properties within any script WARNING You must exercise caution when using the Message box to avoid leaving it visible after a script is done You may want to provide a cleanup script that can be activated by the user to be sure the message is hidden Following is an example of using the Message box This message will display itself for 5 seconds and then disappear Show message for 5 seconds var m CETerm Message Text Processing data please wait Timeout 5 AbortButtonVisible true does nothing because script exits Progress 0 ProgressRunning true
174. own 0x00080000 Win key is down 0x00020000 Char is dead char 0x00010000 No corresponding char J D VDE 0x00001000 NumLock toggled state 0x00000800 ScrollLock toggled state MESSAGEBOX FLAG 0x00000000 MESSAGEBOX FLAG OKCANCEL 0x00000001 MESSAGEBOX FLAG ABORTRETRYIGNORE 0x00000002 MESSAGEBOX FLAG YESNOCANCEL 0x00000003 MESSAGEBOX FLAG YESNO 0x00000004 MESSAGEBOX FLAG RETRYCANCEL 0x00000005 MESSAGEBOX FLAG ICONERROR 0x00000010 MESSAGEBOX FLAG ICONQUESTION 0x00000020 MESSAGEBOX FLAG ICONWARNING 0x00000030 Page 178 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE var MESSAGEBOX FLAG ICONINFORMATION 0 00000040 var MESSAGEBOX FLAG DEFBUTTON1 0x00000000 var MESSAGEBOX FLAG DEFBUTTON2 0x00000100 var MESSAGEBOX FLAG DEFBUTTON3 0x00000200 var MESSAGEBOX FLAG DEFBUTTON4 0x00000300 var MESSAGEBOX FLAG APPLMODAL 0x00000000 var MESSAGEBOX FLAG SETFOREGROUND 0x00010000 var MESSAGEBOX FLAG TOPMOST 0x00040000 MessageBox returned values var MESSAGEBOX IDOK 1 4 var MESSAGEBOX IDCANCEL 2 var MESSAGEBOX IDABORT 37 var MESSAGEBOX IDRETRY 4 var MESSAGEBOX IDIGNORE 57 var MESSAGEBOX IDYES 6 var MESSAGEBOX IDNO 7 PLAYSOUND CONSTANTS PlaySound flags
175. pecify the eventName used in the Create call rather than the eventHandle Delete will clear the event listener if it exists After deleting an eventHandle it can no longer be used for any event operations If Delete closes the last open handle to the Windows event the named event will no longer exist within Windows Return 0 for success or a negative value for failure Use the Event property LastError to get additional error information CETerm Scripting Guide Page 51 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status DeleteAllEvents Delete all eventHandles obtained with Create All event listeners associated with the events are cleared DeleteAllEvents will not clear event listeners that have been assigned by name to Windows events created by other programs Return 0 if any events are deleted or a negative value if none deleted script GetHandlerScript eventHandleOrName Return the handler script associated with the specified eventHandle or eventName Return null if no listener found script GetList Return a list of events from Create calls and active SetListener handlers The returned list is in the form of a JavaScript array literal which contains JavaScript object literals containing information about each event See Section 2 8 for details about handling JavaScript literals Return empty array or null if no events found Names of events are in
176. pectMonitor class illustrates the use of a prototype in JavaScript This class also manages all instances of itself to restrict the number of objects that can be created ExpectMonitor ExpectMonitor class The ExpectMonitor class manages the expect action sequence for a session Only one ExpectMonitor is allowed per session function ExpectMonitor session timeout targetactions Validate session if session lt 1 session gt 4 return null this session session this timeout timeout this args targetactions this state 0 this timer null this checkCount 0 this totalCheckCount 0 this maxCheckCount this timeout this checkDelta Abort any existing object if ExpectMonitor Instances this session null ExpectMonitor Instances this session Abort Record this instance in the global array ExpectMonitor Instances this session this CETerm Scripting Guide Page 127 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE function ExpectMonitor Check Clear timer id this timer null something to check for check it var target this args this state if targ et null Get all screen text var C xf screenText ETerm Session this session Screen GetText 1 1 1 1 ScreenText null amp amp screen
177. ponding GUID Returns a string with the GUID or null if not matched list MapURLToNetworks URL Returns a list of network GUIDs that can reach the specified URL Typically only one network is returned Returns null if no network path found status SetPriority priority Sets the priority of a connection established with Connect See Appendix 4 for valid values Returns 0 for success non zero for failure Properties The ConnectionManager object has the following properties E785FCD4 Property Description Values ConnectionStatus Returns the current connection status unsigned read only integer LastError Returns the last error value associated unsigned with the ConnectionManager object integer ManagerReady Returns true if Connection Manager is true ready for use read only false MaximumCost Specifies the maximum cost for a unsigned connection Set before Connect integer Default 0 unspecified MaximumLatency Specifies the maximum latency for a unsigned connection Set before Connect integer CETerm Scripting Guide Page 48 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Description Values Default 0 unspecified MinimumReceiveBandwidth Specifies the minimum bandwidth fora unsigned connection Set before Connect integer Default 0 unspecified ReportStatusEvents If true OnConnec
178. portStatusEvents 49 Reset Event 53 ResetIdleTimer 38 RFID object 39 RTSControlMode 87 RunScript 33 45 106 S SaveSource 45 ScannerNavigate 19 Screen object 80 Screen Columns 81 Screen CrosorRow 81 Screen CursorColumn 81 Screen DisplayStatus 81 Screen GetText 81 Screen GetTextLine 81 Screen GetTextRect 81 Screen KeyboardState 81 Screen Rows 81 Screen ScrollLeftColumn 82 Screen ScrollTopRow 82 Screen TextLineSeparator 82 Screen VisibleColumns 82 Screen VisibleRows 82 ScrollLeftColumn 82 ScrollTopRow 82 34 117 SendMessage 101 SendMessageTimeout 102 SendText 19 34 128 Serial Port Constants 180 SerialPort object 38 82 SerialPort BaudRate 86 SerialPort CancelWaitForEvent 83 SerialPort CheckParity gt 86 SerialPort ClearBreak 83 Page 195 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE SerialPort ClearError 83 SerialPort Close 83 SerialPort CTSOutputFlowControl 86 SerialPort DataBits 87 SerialPort DiscardReceivedNULL 87 SerialPort DSRInputControl 87 SerialPort DSROutputFlowControl 87 SerialPort DTRControlMode 87 SerialPort EventCharacter 87 SerialPort EventMask 86 SerialPort IsOpen 86 SerialPort LastError 86 SerialPort ModemStatus 86 SerialPort Open 83 SerialPort OutputContinueOnXOFF 87 SerialPort ParityMode 87 SerialPort PortIndex 86 SerialPort Por
179. predefined object in the DOM of the Windows CE 5 0 browser that gives access to the CETerm Automation Objects IDA Action Code An IDA Action Code defines a special device application or emulation action within the Naurtech clients IDA codes can be tied to keys or KeyBars and invoked via META tags or JavaScript See the Appendix for a list of values NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS AND WINDOWS MOBILE Index A AbortButtonVisible 73 AbortScript 32 AcceptButtonKey 91 AcceptButtonText 91 ActiveSession 36 ActiveXObject 18 93 AddMetaltem 44 106 107 119 Alert 40 Append File 55 AssignHotKey 69 B Battery Constants 170 BaudRate 86 Beep 40 BoxBackgroundColor 91 BoxHeight 91 BoxLineColor 91 BoxLineWidth 91 BoxWidth 91 Browser Error Constants 171 Browser object 44 Browser AddMetaltem 44 Browser ClearCache 44 Browser DocLoaded 46 Browser Document 46 Browser GetMetaKeyContent 45 Browser Navigate 45 Browser ProcessMetaKey 45 Browser RunScript 45 Browser SaveSource 45 ButtonHeight 91 ButtonsAtTop 91 C CancelButtonKey 91 CancelButtonText 91 CancelDialog SignatureCapture 90 CancelWaitForEvent 83 Capture 90 CapturePrompt 92 CEBrowseX 190 CETerm object 28 32 CETerm AbortScript 32 CETerm ActiveSession 36 CETerm Scripting Guide CETerm ClearAllTimers 32 CETerm ClearInterval 32 CET
180. pts Examples which reference top level objects ext CETerm PostIDA IDA SIP SHOW 0 show SIP ext OS File Append NNmyfile txt content spl ext Device SerialPort 1 Get a SerialPort object var ext null global variable not declared in a function if typeof external object Windows CE external is already defined in global namespace ext external else Windows Mobile Create CEBrowseX for top level object access ext new ActiveXObject Cebrowsex IdaCtl lt script gt 2 4 IDA ACTION CODES An IDA Action Code is a special value that is used to invoke a device action program action or emulator action within the Naurtech Web Browser and Terminal Emulation Clients IDA Action Codes can invoke special keys under terminal emulation sound a tone connect a session or show the SIP There are many IDA codes and these are documented in Appendix 1 of this manual Almost any action which can be invoked by a KeyBar or assigned to a hardware key can be invoked by an IDA code IDA codes can be submitted to CETerm in several different ways under both scripting and the web browser 2 5 ONBARCODEREAD SCRIPT EVENT CETerm generates several script events during operation If there is a corresponding event handler function defined within the CETerm script engine then that handler be invoked The OnBarcodeRead event is a good examp
181. r myparity Refer to constants using normal JavaScript syn CONSTANTS SERIAL PORT ODDPARITY BATTERY AND POWER MANAGEMENT CONSTANTS Power Management and Battery Constants var AC LINE OFFLINE 0x00 var AC LINE ONLINE 0x01 var AC LINE BACKUP POWER 0x02 var AC LINE UNKNOWN OxFF var BATTERY FLAG HIGH 0x01 var BATTERY FLAG LOW 0x02 var BATTERY FLAG CRITICAL 0x04 var BATTERY FLAG CHARGING 0x08 var BATTERY FLAG NO BATTERY 0x80 var BATTERY FLAG UNKNOWN OxFF var BATTERY PERCENTAGE UNKNOWN var BATTERY LIFE UNKNOWN OxFFFFFFFF var BATTERY CHEMISTRY ALKALINE 0x01 CETerm Scripting Guide 170 NAURTECH WEB BROWSER AND TERMINAL EM BAT BAT BAT var var var var var var rg O z var var var var var POW POW POW POW POW POW TERY CHEMISTRY NICD 0x02 TERY CHEMISTRY NIMH 0x03 TERY CHEMISTRY LION 0x04 TERY CHEMISTRY LIPOLY 0x05 TERY CHEMISTRY ZINCAIR 0x06 TERY CHEMISTRY UNKNOWN OxFF r State ER STATE UNKNOWN 1 2 7 ER STATE FULL 0 ER STATE LOW POWER ON 1 ER STATE STANDBY 2 STATE SLEEP 3 ER STATE OFF a Age off BROWSER ERROR CONSTANTS
182. r to a static URL on the device OnNetCheckFailed function OnNetCheckFailed session pendingURL Save pendingURL text where x is session index This is required by CE 5 0 devices which do not pass parameters to a file URL CETerm SetProperty app usertext 3 session pendingURL Navigate to static error page var b CETerm Session session Browser b Navigate file error htm See the onNavigateError example above for additional details CETerm Scripting Guide Page 113 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE 4 10 THE ONPROGRAMExiT EVENT The OnProgramExit event is fired just before CETerm exits This handler can abort the exit to keep CETerm running Syntax function OnProgramExit This handler has no arguments The function returns 0 to continue with the exit or 1 to abort the exit Example This example prevents the CETerm exit if any session is connected OnProgramExit function OnProgramExit Don t exit if any session is connected for var 1 1 i CETerm MaxSession i if CETerm Session i IsConnected Switch to first connected session CETerm PostIDA IDA SESSION S adus 0 Abort exit return 1 OK to exit return 0 4 11 THE ONPROGRAMSTART EVENT The OnProgramStart event is fired just before CETerm starts processing user input
183. rately read only object Speech Returns the Speech object This object provides access to the Speech features The Speech object is available only in select builds of CETerm and is documented separately read only object Trigger Returns the Trigger object This object provides access to hardware trigger features The Trigger object is available only for limited devices and is documented separately read only object LastError Returns the last Windows error related to the Device object unsigned integer 3 3 THE OS OBJECT The top level os object provides access to operating system resources such as files processes windows and the registry Many of the automation objects on the OS hierarchy give direct access to low level Windows CE features Although powerful caution should be exercised when using these features We provide the basic API documentation in this document More information and useful discussion can be found by searching the Microsoft msdn microsoft com website Below we suggest such searches and provide relevant keywords Methods The following methods are available Method Action Alert Show the user a text message synchronous Beep Play a default beep tone GetErrorMessage Get a text error message for a Windows CE error value GetSystemMetric Get a system metric value GetSystemParameter Get a system parameter value
184. ration for values on a specific device discard none abcd dc1 dc4 lowerabcd abcd tn e aa bb cc dd any CETerm Scripting Guide Page 162 CODE39 SYMBOLOGY PROPERTIES Code 39 specific symbology properties are unique for each session Symbology properties begin with sessionX scanner code39 where X is 1 through For example session4 scanner code39 clsiediting If no X value is found the currently active session number is used NOTE If you are changing the symbology properties for the currently active session you must call CETerm PostlDA IDA SCAN APPLYCONFIG 0 for the changes to take effect WARNING Not all properties are applicable to all hardware devices Different devices may use different names to refer to the same parameters You should look at the settings available in the CETerm configuration dialogs to determine if the property is appropriate and what values it may accept Last Property Level Description asciimode Select ASCII mode Not all modes apply to all devices See CETerm configuration for values on a specific device base full mixedfull fullascii Enable Full ASCII mode T F verifycheck39 Check digit validation mode 0 255 reportstartstop Report start stop with barcode T F convertocode32 Convert to Code 32 format T F reportcode32prefix Report Code 32 prefix with barcode T F concatenation Enable concatenation T F stripAlIAG Remove AIAG codes
185. rmation CETerm Scripting Guide Page 61 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE status RenameFile existingName newName Rename an existing remote file to the newName Return 0 on success or non zero otherwise Use the FTP properties LastError and LastErrorText to get additional error information status SetDirectory newWorkingDirectory Set the current working directory on the remote host to the specified directory Return 0 on success or non zero otherwise Use the FTP properties LastError and LastErrorText to get additional error information Properties The FTP object has the following properties Property Description Values ASCIIMode Use ASCII mode for file transfers if true true or Use binary mode if false ASCII mode false may change the line termination characters in files This setting may be changed while a session is connected Default is false HostName Hostname of the current active session string read only LastError Returns the last error value associated unsigned with any FTP operation read only integer LastErrorText Returns a text description of the last string FTP error as reported by the remote host read only Loggedin True if FTP session is currently true or established read only false OverwriteExistingLocalFile If true GetFile will overwrite an true or existing file with the same local name false
186. ror status SetProcessListener processID handlerScript timeout The SetProcessListener method assigns a handler to the special event that occurs when a process exits The processlD is the process id number assigned when the process is created by Windows You can find process id values using the Process object methods The handlerScript will be queued for execution if the process exits within timeout milliseconds The handler script is not invoked if the listener times out The special timeout value will never timeout The special timeout value 0 will cause an immediate check of the event state NOTE The currently running script which invoked SetProcessListener must finish before any handler can be executed Return 0 if a listener is set or a negative value on error Properties The Fvent object has the following properties Property Description Values LastError Returns the last error value associated unsigned with the Event object integer CETerm Scripting Guide Page 54 3 8 THE FILE OBJECT The File object provides access to the Windows file system The File object is a property of the OS object OS File Methods The following methods are available Method Action Append Append content to a file Copy Create a copy of an existing file CreateDirectory Create a new directory Delete Delete an existing file GetAttributes Get the attrib
187. rties for the currently activesession you must call CETerm PostlDA IDA SCAN APPLYCONFIG 0 for the changes to take effect WARNING Not all properties are applicable to all hardware devices or all symbologies Different devices may use different names to refer to the same parameters You should look at the settings available in the CETerm configuration dialogs to determine if the property is appropriate and what values it may accept This is also true for the symbologies that a device supports You may be able to successfully change a parameter that is not supported on a device Last Property Level Description enabled Symbology is enabled T F verifycheck Require check digit validation T F redundancy Scan redundancy flag T F Symbol reportcheck Report the check digit with the data T F reportnumbersystem Report UPC number system T F reportcountry Report UPC country code T F reportstartstop Report start stop digits with barcode data T F converttoupca Convert barcode output to UPCA T F converttoean13 Convert barcode output to EAN 13 T F supplemental2 Enable 2 digit supplemental or add on barcode T F supplemental5 Enable 5 digit supplemental or add on barcode T F supplementalrequired Require supplemental on UPC T F supplementalseparator Insert supplemental separator T F addendum Supplemental mode none optional required minlength Minimum barcod
188. s With JScript the Microsoft version of JavaScript additional features are available such as the ability to use ActiveX objects in scripts On device Script Editing Scripts are saved within the CETerm configuration and can be edited and tested right on the mobile device Scripts can be imported and exported via text files on the device as well as loaded dynamically from files Cross Session Scripting All Naurtech clients allow up to 5 simultaneous sessions Scripts can access and control any or all sessions For example you could extract text from one TE session and insert it into a different TE session or into a Web application Automation Objects CETerm Automation Objects are available to access and control the state of CETerm the state of a TE or web browser session the mobile device and the Windows CE Operating System Together these objects provide features to simplify routine steps or build complex applications For example you can use an automation object to examine the current screen contents to trigger special actions or to capture a signature and FTP the the saved image to a host Enriched Web Browser Applications Naurtech Scripting can interact with a web browser session to enrich existing web applications that were not written for a mobile device For example key bindings can be added to activate items in the page and scanned barcode or RFID data can be directed to input elements CETerm Scripting Guide Page 11
189. s events used for synchronization read only File Returns the File object This object object provides access to the Windows file systems read only LastError Returns the last Windows error related to integer the OS object LastOSError Returns the last Windows OS error read integer only MasterVolume Read or set the master audio volume 0 100 96 MemoryStatus Returns a summary of the Windows JSON literal memory available read only Network Returns the Network object This object object provides access to Windows network features read only Process Returns the Process object This object object provides control of running Windows programs read only Registry Returns the Registry object This object object provides access to the Windows registry read only TickCount Returns the current tick count from unsigned Windows This provides a millisecond integer 0 resolution time source read only OxFFFFFFFF SIP Returns the SIP object This object object controls the Soft Input Panel read only Version Returns Window CE version read only JSON literal CETerm Scripting Guide Page 42 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Property Description Values Window Returns the Window object This object object provides access to current windows of running programs read only MemoryStatus The return value is in the form of a JavaScript o
190. s ready to respond to the user or host actions Events and timers are used to start or re start a script to do the next bit of work The expect script described in Section 2 6 is a good example of using a timer to automate multiple steps The events described in this section are the second major technique for running a script when needed Event Fired when OnBarcodeRead Barcode read OnConnectionManagerEvent Connection Manager status change OnDocumentDone New web page loads OnIBMCommand Receives special command in IBM data stream OnKeyboardStateChange Keyboard state changes in TE session OnKeyMessage Any key input is received if enabled OnNavigateError Web navigation fails OnNavigateRequest Web navigation begins OnNetCheckFailed Fails to complete network check to host OnProgramExit CETerm exits OnProgramStart CETerm first starts OnSerialPortEvent Serial port status changes OnSessionConnect Session connects to host OnSessionDisconnect User disconnects session from host NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE OnSessionDisconnected Session disconnected by host OnSessionReceive TE session receives data from host OnSessionSwitch Active session changes OnSmartCardEvent Smart Card reader event OnStylusDown Stylus tap on screen OnTriggerEvent Hardware trigger status changes OnVTCommand
191. sTime new Date 2007 7 27 3 27 41 0 lastWriteTime new Date 2008 6 15 0 29 50 0 size 2455494 name myconfig ini attributes 0x21 lastAccessTime new Date 2007 7 27 3 27 18 0 lastWriteTime new Date 2008 6 15 0 29 48 0 size 12564 name AppDirectory attributes 0x10 lastWriteTime new Date 2008 2 11 12 29 49 0 size 1024 1 Note that the creationTime and lastAccessTime are not always present should be checked for existence before using them Their existence depends on the type of remote host See any standard JavaScript reference for details on the Date constructor arguments See Appendix 4 for attribute definitions status Login hostname userName password Establish an FTP connection to the remote named host The userName and password are used for authentication If the default values are not correct you must configure the Port and PassiveMode properties before Login Return 0 on success or non zero otherwise Use the FTP properties LastError and LastErrorText to get additional error information status Logout Close an open FTP connection Return 0 on success or non zero otherwise Use the FTP properties LastError and LastErrorText to get additional error information status PutFile localName remoteName Copy the named local file to the remote name Return 0 on success or non zero otherwise Use the FTP properties LastError and LastErrorText to get additional error info
192. sending text to an IBM session with SendText SendText text session SendText sends a text string to the specified terminal emulation session Valid session values are 1 to MaxSession The special session value of 0 will send the command to the current session This command is synchronous and CETerm will act on each character before this method returns SendText will not send text to a browser session To set text in a browser page use the Browser Document reference and assign the text directly to the desired page element The text string may include IDA symbolic names between backslash characters V The IDA codes will be interpolated as the text is sent For example username IDA_ FIELD EXITNNsecretpassword Note that each backslash has a preceding backslash because it is the JavaScript escape character To put a single literal backslash in a string you precede it with another backslash object Session index Return the corresponding Session object Valid index values are 1 to MaxSession The object is returned even if the session is not connected CETerm Scripting Guide Page 34 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE intervalTimerID SetInterval scriptExpression delayMillisec Set a recurring interval timer to execute the scriptExpression after each delay of delayMillisec This method returns an ID that should be saved in a global variable for later use with Clearlnter
193. ser defined hot spots Syntax function OnStylusDown session row column session index of currently active session row row of screen tap column column of screen tap CETerm Scripting Guide Page 120 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Example Several samples for OnStylusDown were given in Section 2 7 Following is an example that starts a barcode scan if the row contains the word scan Not all hardware devices support a scan trigger by script If tapping on an IBM screen you must tap on an input field in the row or the focus will not be in an input field when the scan is sent to the session Of course the OnBarcodeRead handler could be used to force the scanned data into a preferred input field OnStylusDown function OnStylusDown session row column var screen CETerm Session session Screen Get row of text var text screen GetTextLine row Look for scan as case insensitive match if text match scan i CETerm PostIDA IDA SCAN TRIGGER 0 4 20 THE ONTRIGGEREVENT EVENT The OnTriggerEvent event is fired when the hardware trigger state changes Syntax function OnTriggerEvent flags id flags flags describing state change id trigger id Example This example activates a corresponding trigger handling function in the current browser session OnTriggerEvent fu
194. t of cache entry types The value 0 will match all cache entries the value 1 will match normal cache entries Returns the number of entries deleted NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE content GetMetaKeyContent vkCode Return the OnKey content string for the vkCode Returns null if no OnKey is assigned for the vkCode The vkCode is an integer virtual key code between 1 and 254 See Appendix 5 for virtual key values The vkCode value of 1 will return the OnAllKeys content if any status Navigate URL Navigate the browser session to the specified URL Return 0 for success non zero for failure status ProcessMetaKey vkCode Process the OnKey content if defined If no content is specified for the vkCode the OnAllKeys content will be processed if it is defined Returns true if processed or false otherwise See Appendix 5 for virtual key values status RunScript script Execute the specified script in the browser JavaScript engine Return 0 for success non zero for failure status SaveSource filename Windows CE browser only Save the source of the current page Even if you specify a file name on most devices you will be prompted to enter a file name in a file selection dialog Return 0 for success non zero for failure TIP To save most of a source on a Windows Mobile device you can use the innerHTML at
195. tName 86 SerialPort PurgeQueues 84 SerialPort Read 84 SerialPort ReadByte 84 SerialPort ReadIntervalTimeout 88 SerialPort ReadTillByte 84 SerialPort ReadTotalTimeoutConstant 88 SerialPort ReadTotalTimeoutMultiplier 88 SerialPort RTSControlMode 87 SerialPort SetBreak 84 SerialPort SetQueueSizes 84 SerialPort StopBits 87 SerialPort WaitForEvent 85 SerialPort Write 85 SerialPort WriteByte 85 SerialPort WriteNULL 85 SerialPort WriteTotalTimeoutConstant 88 SerialPort WriteTotalTimeoutMultiplier 88 SerialPort WriteUrgent 85 SerialPort XOFFCharacter 87 SerialPort XOFFInputFlowControl 87 SerialPort XOFFOutputFlowControl 87 SerialPort XOFFUpperCushion 87 SerialPort XONCharacter 87 SerialPort XONLowerLimit 87 Service State Constants 180 Session object 34 89 Session Browser 44 89 Session IsConnected 89 Session Screen 80 89 Set Event 53 SetAttributes 58 SetBreak 84 SetDefaultRectangle SIP 96 SetDirectory FTP 62 SetInputMethod 95 SetInterval 35 SetListener 53 SetOrientation 49 SetPostion SIP 96 SetPriority 48 CETerm Scripting Guide SetProcessListener 54 SetProperty 35 156 SetQueueSizes 84 SetScriptTimeout 35 SetSignaturePoints 91 SetTimeout 35 124 125 129 133 134 SetTopmost 101 Show 101 Show Script Errors 14 SignatureCapture object 39 89 91 SignatureCapture AcceptButtonKey 91
196. tatus SetQueueSizes inputQueueSize outputQueueSize Set the size of input and output queues Return 0 on success non zero for failure Use the SerialPort property LastError to get additional error CETerm Scripting Guide Page 84 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE information More details can be found by searching msdn microsoft com with the keyword setupcomm status WaitForEvent Enable an event listener for the port The listener waits for events that are specified in the property EventMask If the event is signaled by the port the event handler OnSerialPortEvent is invoked The event handler is invoked only once for each call of WaitForEvent but the handler parameters may indicate multiple event conditions Return 0 on success non zero for failure status Write data Write the data string to the port Data are converted from wide characters to bytes with wcstombs using the current locale Return number of bytes written for success negative value for failure Use the SerialPort property LastError to get additional error information status WriteByte byteValue Write a single byte with integer value byteValue to the port Return 1 for success negative value for failure Use the SerialPort property LastError to get additional error information status WriteNULL nullCount Write NULL 0 bytes to the port Write nullCount NULL bytes to the port Return
197. te 51 Event DeleteAllEvents 52 Event GetHandlerScript 52 Event GetList 52 Event GetName 52 Event IsExistingEvent 52 Event IsListenerSet 53 Event LastError 54 Event Pulse 53 Event Reset 53 Event Set 53 Event SetListener 53 Event SetProcessListener 54 EventCharacter 87 EventMask 86 ExecuteAction 76 133 ExpectMonitor 21 36 116 126 ExpectMonitor Class 127 external 17 190 F File Attribute Constants 176 File object 42 55 86 File Append 55 File CodePage 58 File Copy 55 File CreateDirectory 55 File Delete 56 File GetAttributes 56 File GetList 56 File GetOpenFileName 57 File GetSaveFileName 57 File LastError 58 File LastErrorMessage 58 File Move 57 File Read 57 File RemoveDirectory 57 File SetAttributes 58 File Write 58 Find Window 99 FlushKey 79 75 FTP object 59 FTP HostName 62 FTP LastError 62 Page 192 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE FTP ASCIIMode 62 FTP CreateDirectory 60 FTP DeleteDirectory 60 FTP DeleteFile 60 FTP GetDirectory 60 FTP GetFile 60 FTP LastErrorText 62 FTP ListFiles 60 FTP LoggedIn 62 FTP Login 61 FTP Logout 61 FTP OverwriteExistingLocalFile 62 FTP PassiveMode 62 FTP Port 63 FTP PutFile 61 FTP RenameFile 62 FTP ServerListsUTCFiletimes 63 FTP SetDirectory 62 FTP UserName 63 G GetAt
198. that checks the RF connection before submitting the data to the host This notifies the user that the barcode was not received by the host and instructs the user to return to RF coverage OnBarcodeRead function OnBarcodeRead session data source Lype date Ltime Check RF status var status CETerm GetProperty device rf status if status lt 0 OS Alert No RF signal detected n Barcode discarded n Return to RF coverage Discard barcode return 1 Send barcode to emulator CETerm SendText data session Return 1 if handled data here return 1 4 2 THE ONCONNECTIONMANAGERE VENT EVENT The OnConnectionManagerEvent event is fired when the Connection Manager changes state The handler can inform the user connect or disconnect a session or otherwise control user interaction Syntax function OnConnectionManagerEvent wparam lparam wparam wparam of event usually connection status of event usually 0 Example This example just displays the event arguments When using a synchronous connection request these events can be ignored To obtain more details about CETerm Scripting Guide Page 105 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE the connection changes use the ConnectionManager GetDetailedStatus method OnConnectionManagerEvent function OnConnectionManagerEv
199. the sibling window below the specified window HWNDPREV 0x3 The window above the specified window the z order the specified window is topmost window the handle identifies the topmost window above the specified window the specified window is a child window the handle identifies the sibling window above the specified window OWNER 0 4 The specified window s owner window if any This flag will not retrieve a parent window CHILD 2 0 5 The child window at the top the z order if the specified window is a parent window otherwise the retrieved handle is NULL CETerm Scripting Guide Page 184 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Appendix 5 Microsoft Virtual Key VK Codes This appendix lists the standard Microsoft Virtual Key codes These codes are sent to applications when keys are pressed Most devices generate only a small subset of these codes depending on the hardware keyboard Some VK codes are not applicable to Windows CE but are listed for completeness Many hardware vendors use unassigned values between 0x01 and 0xFF for custom behaviors For additional details search msdn microsoft com with the keywords virtual key codes and see your hardware documentation WARNING The keys on some devices do not send standard VK values Often the printed keycap label does not reflect the
200. the user For example Save file as The filter is list of filter pairs Each pair represents the description of a filter and the file selector wildcards For a JavaScript file it may look like this JScript File js x00 js x00 x00 Each element of the pair is followed by x00 as a separator character The last pair has an additional trailing x00 Here is a multiple filter example JScript File js x00 js x00A11 Files Nx00 Nx00Nx00 status Move existingFilename newFileName Move or rename an existing file Returns true for success false for failure Use the File properties LastError or LastErrorMessge to get additional error information contents Read fileName Read entire file and return as contents The read is an atomic operation which opens the file reads all contents and closes the file The File object does not support the concept of an open file or reading parts of a file There must be sufficient memory to hold the entire file contents Use GetAttributes to validate a filename and ensure read access prior to a read See the description of the CodePage property for details on how the content is converted after reading Returns null if failed to read or convert the file Use the File properties LastError or LastErrorMessge to get additional error information status RemoveDirectory directoryName Delete an existing directory Return true for success false for failure CETerm Scripting Gui
201. ting Guide NETWORK GUID High priority background Lowest priority 6EF144 B4FB 4863 A041 8F905A62C572 Page 173 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE CORPORATE A1182988 0D73 439e 87AD 2A5B369F808B I Cache constan CS CONNECTION MANAGER DI SCONNECT CACH E TIME NOCACHE 0 0 Do not cache DEFAULT CACHE 0x1 Use default system cache time CACHE 10 SECONDS 10 10 seconds CACHE 60 SECONDS 60 60 seconds CACHE 10 MINUUTES 600 600 seconds F Connection referenc NAP 0x0 PROXY 0 1 be ER CONN types ECTION REFERENCE TYPE Connection status types CONNECTION MANAG NKNOWN ELLULAR 0 T C 2 UETOOTH 35 IMODEM 4 25 6 7 8 rtf ER CONN ECTION TYP ll Ethernet WiFi Activesync pass through Connection status subtypes CONNECTION MANAG UNKNOWN 0 CELLULAR UNKNOWN 0 CSD 1 GPRS 2 1XRTT 3 1XEVDO 4 1XEVDV 5 CETerm Scripting Guide ER CONN ECTION SUBTYP Not distinct from CSD Not distinct from CSD Not distinct from CSD Page 174
202. tion CETerm Scripting Guide Page 106 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Add Key mapping to inserted function b AddMetaltem OnKey Fl Javascript myfl Position RF signal indicator b AddMetaItem Signal x 195 b AddMetaItem Signal 100 Update information items for location to take effect CETerm PostIDA IDA INFO REFRESH session 4 4 THE ONIBMCOMMAND EVENT The OnIBMCommand event is fired when a special extended command format is received in an IBM emulation session screen Extended commands are documented elsewhere but basically this event requires the two characters X starting in the second column of the first row The CETerm configuration option Extended Commands must be enabled for this event to fire The handler script may perform any desired actions Typically the screen text contains additional information used by the handler Syntax function OnIBMCommand session command session index of session receiving the command command specified command e g X Example This example looks at the data following the command and activates an FTP file transfer OnIBMCommand function OnIBMCommand session command Get full line from screen Expect X FTP myserver localfilename remotefilenam var linel CETerm Session session Screen GetTextLine 1 var
203. tionManagerEvent will true be called false 3 6 THE DISPLAY OBJECT The Display object provides access to the device display The Display object is a property of the Device object Device Display Methods The following methods are available Method Action SetOrientation Set the display orientation status SetOrientation angle Set the display orientation Returns 0 on success or non zero on failure The angle may be one of 0 90 180 or 270 Properties The Display object has the following properties Property Description Values Orientation Returns the current display orientation integer read only LastError Returns the last Windows error related to unsigned the Display object read only integer CETerm Scripting Guide Page 49 3 7 THE EVENT OBJECT The Event object provides access to the Windows event objects The Event object is a property of the OS object OS Event Windows event objects are used to synchronize operations between processes and signal special conditions Normally Windows event objects are used within a single program or between programs designed to work together By providing access to event objects through scripting CETerm makes a rich environment to control and interact with separate applications For example a custom utility program written to control a special device peripheral can signal an event to inform CETerm that it shou
204. tribute Some headers may be unavailable var d CETerm Session 1 Browser Document OS File Write myfile txt d all O innerHTML CETerm Scripting Guide Page 45 Properties The Browser object has the following properties Property Description Values Document Document object of the current web page object The DOM of the page may be examined and altered via this object WARNING Use local variable to hold this reference to minimize memory usage read only DocLoaded Returns true if document is loaded read true only false 3 5 THE CONNECTIONMANAGER OBJECT The ConnectionManager object gives access to the Windows CE Connection Manager for establishing network connections The ConnectionManager object is a property of the Network object OS Network ConnectionManager The ConnectionManager is primarily used to establish a GPRS connection and is only available on devices with Windows Mobile and on some newer Windows CE 6 0 devices There is no need to use the ConnectionManager for WiFi networks because Windows forces WiFi networks to stay connected Methods The following methods are available Method Action Connect Establish a connection for network access Disconnect Disconnect a network connection GetAvailableNetworks List available network connections GetDetailedStatus Get current connection status details MapNameToNetwork Find the network G
205. tributes 56 57 134 GetAvailableNetworks 47 GetBatteryInfo 37 GetDesktop 99 GetDetailedStatus 47 GetDeviceState GPS 65 GetDirectory FTP 60 GetErrorMessage 40 GetFile FTP 60 GetHandlerScript 52 GetIDADescription 33 GetIDAName 33 GetIDAValue 33 GetInput 97 132 GetInputMethod 95 GetInputMethodList 95 GetList Event 52 GetList File 56 GetList Process 76 GetList Window 99 GetMetaKeyContent 45 GetName Event 52 GetOpenFileName 57 GetParent 99 GetPosition 64 GetPowerState 38 GetProperty 33 124 156 GetRelative 100 GetSaveFileName 57 GetSelf Window 100 GetSignaturePoints 90 GetSIPRectangle 96 GetSystemMetric 41 GetSystemParameter 41 GetText Screen 81 CETerm Scripting Guide GetText Window 100 GetTextLine 81 118 121 GetTextRect 81 GetTopmost 100 GetValueType 79 GPS object 39 49 63 65 GPS GetDeviceState 65 GPS GetPosition 64 GPS Close 64 GPS DeviceStateChangeEvent 65 GPS IncludeSatelliteData 65 GPS IsOpen 65 GPS LastError 65 GPS LastPosition 65 GPS MaximumAge 65 GPS NewLocationDataEvent 66 GPS Open 63 H hasOwnProperty 26 I IBM Status Constants 177 IDA Action Codes 18 146 IncludeSatelliteData 65 Input 97 IsConnected 89 IsEnabled Keyboard 70 IsEnabled Window 100 IsExistingEvent 52 IsHotKey 70 IsKeyDown 70 IsKeyDownNow 70 IsKeyTo
206. ues ConnectionManager Returns the ConnectionManager object object This object provides access to ConnectionManager operations read only FTP Returns the FTP object This object object provides access to FTP operations read only LastDNSError Returns the last error value associated unsigned with the DNSLookup method read only integer LastPingError Returns the last error value associated unsigned with the Ping method read only integer LastPingHostName Returns the hostname used in the last string Ping operation read only LastPinglPAddress Returns the IP address used in the last string Ping operation read only LastWSAError Returns the last error value associated unsigned with any Windows socket operations integer read only MaximumPingTimeout Controls the maximum timeout for the integer 3 14 THE PROCESS OBJECT The Process object provides access to running Windows processes Processes can be started killed and listed The Process object is a property of the os object OS Process Methods The following methods are available Method Action ExecuteAction Run a program or open a file via the specified action GetList Get a list of the running processes NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Kill Stop Kill a running process WaitForExit Wait for a running process to exit status ExecuteAction file arguments
207. upca UPC A upce UPC E upce0 UPC E0 UPC E1 upc ean UPC EAN General Settings usplanet US Planet uspostnet US Postnet usps4cb USPS 4CB CETerm Scripting Guide Page 167 Appendix 3 Symbology LabelTypes This appendix contains a list of symbology labeltypes that are returned the type argument of OnBarcodeRead These are also available to a ScannerNavigate META tag handler Please note that not all hardware devices return these values You may need to test scan a known barcode to find the labeltype value for that barcode Character Value eee C eee 8 094 2 j CodalckF 2 EMEN 0 050 j UPCEorUPCEO Cd x 1 oct JUPCE 2 032 J UPCA 3 09 11 4 094 88 1 5 095 2 6 0946 7 8 058 Discrete20f5 Cd 9 0592 Interleaved 20f5 RW NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Character Value B 042 39 D 04 Bookland 045 MicroPDF x F 046 Code3 4 8G 047 jMaroPDF 048 jMaxcode 20 1 049 J OA jQRCoe 2 _ 048 jMacoMiroPDE E cds de HsSd4 M OdD jRSSlimted 2 N 04 jRSSExanded Gl a 06 jUSPoset C 0202 b 0x2 US Planet UK British Postal p
208. use do var wifi CONN var CONNECTION MANAGER Connection Sta CONNECTION MANAGE UNKNOWN CUS CONN SUSE ECT END ED ED DISCONNECTED CONNECTIONFAILE CETerm Scripting Guide R CONNECTION STATUS ECTION MANAGER CONNECTION _ 0 00 0 10 0x11 Connection Connection 0x20 0x21 Connection Connection conversion Raw binary 0 Default ANSI conversion 11 Default codepage 65000 UTF 7 conversion 65001 UTF 8 conversion the ConnectionManager object eau SUBTYPE NIC WIFI Unknown status is up is up but suspended is disconnected failed Page 172 NAURTECH WEB BROWSER A CONNECTIONCANCELED CONNECTIONDISABLED NOPATHTODESTINATION WAITINGFORPATH WAITINGFORPHONE PHONEOFF EXCLUSIVECONFLICT NORESOURCES CONNECTIONLINKFAILED AUTHENTICATIONFAILED WAITINGCONNECTION WAITINGFORRESOURCE WAITINGFORNETWORK WAITINGDISCONNECTION WAITINGCONNECTIONABORT Connect Flags CONNECTION PROXY NONE 0 0 voxi PROXY WAP 202 50 54 0 4 PROXY SOCKS5 0 8 SUSPEND AWARE 0 10 REGISTERED HOME 0x20 NO ERROR MSGS 0x40 jon Priority Levels CONN
209. utes of an existing file GetList Get list of files with names that match a pattern GetOpenFileName Select a filename with a file Open dialog GetSaveFileName Select a filename with a file Save dialog Move Move or rename a file Read Read file contents RemoveDirectory Remove delete an existing directory SetAttributes Set the attributes of an existing file Write Write contents to a new or existing file status Append fileName content Append content to the file The content is specified as a text string Return true for success false for failure If the file does not exist it is created See the description of the CodePage property for details on how the content is converted before writing Use the File properties LastError or LastErrorMessge to get additional error information status Copy existingFile newFile overWrite Copy an existing file to a new file If a file already exists with the new file name copy will fail unless overWrite is true Return true for success false for failure Use the File properties LastError or LastErrorMessge to get additional error information status CreateDirectory newDirectory Create a new directory Return true for success false for failure NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Use the File properties LastError LastErrorMessge to get additional error information status
210. utput flags 0x0 timeUTC year 2008 month 8 day 8 hour 8 minute 8 second 0 millisecond 0 latitude 47 64000000 10ngitude 122 13000000 speed 0 0 heading 0 0 magneticVariation 0 0 altitudeSeaLevel 30 123 altitudeEllipsoid 50 00 fixQuality 1 fixType 1 fixSelection 1 positionalDOP 0 0 horizontalDOP 0 0 verticalDOP 0 0 satellites usedCount 4 usedPRN 0 0 0 0 inViewCount 8 inViewPRN 0 0 0 0 0 0 0 0 inViewElevation 0 0 0 0 0 0 0 0 inViewAzimuth 0 0 0 0 0 0 0 0 inViewSNR 0 0 0 0 0 0 0 0 The speed is in knots and altitudes are in meters If GetPostion is called when the GPS object is closed it may return a cached position reading from the device but will not apply power If the reading was cached but is older than MaximumAge it will not be returned You should check timeUTC to determine if the returned values were cached CETerm Scripting Guide Page 64 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE state GetDeviceState Read the GPS device state The returned state is a JavaScript object literal containing information about the current device state See Section 2 8 for details about handling JavaScript literals Return null if error Use the GPS property LastError to get additional error information The returned literal contents will depend on the GPS hardware Here is a sample state output serviceState 0x1 deviceState 0x0 timeLastDataReceived
211. val if needed Other scripts may run while waiting for this timer The scriptExpression is a string containing the script but is commonly a function invocation such as myTimerFunction 3 alert Timers are especially useful with complex or long running scripts Interval timers can be used to perform simple update tasks One time timers should be used in preference to interval timers In general scripts should perform a short action and exit With a complex script such as a state machine the state can be maintained in global variables and the script re activated periodically to check for state transitions and perform actions See the expect script and class in Section 5 1 for an example of the use of a timer status SetProperty propertyName property Value SetProperty will assign the given value to the named property See Appendix 2 for a list of available properties The returned status is 0 for success non zero for failure SetScriptTimeout millisec Set the maximum script execution time This value may be updated during a running script If updated the new timeout will apply starting at the time of the change A value of 0 will disable the timeout The script timeout prevents a faulty script from locking up CETerm For example if a script enters an endless loop the timeout will eventually force the script to abort timeoutTimerID SetTimeout scriptExpression delayMill
212. value sent to applications If your keys are not working as expected you may need to refer to device documentation or the Trap feature in the CETerm New Key remapping configuration dialog to identify the correct value Symbolic Name Value VK_LBUTTON 0x01 VK_RBUTTON 0x02 VK_CANCEL 0x03 VK_MBUTTON 0x04 VK_XBUTTON1 0x05 VK_XBUTTON2 0x06 VK_BACK 0x08 VK_TAB 0x09 VK_CLEAR 0x0C VK_RETURN 0x0D VK_SHIFT 0x10 VK_CONTROL 0x11 VK_MENU 0x12 VK_PAUSE 0x13 VK_CAPITAL 0x14 VK_KANA 0x15 VK_JUNJA 0x17 VK_FINAL 0x18 VK_HANJA 0x19 VK_ESCAPE 0x1B VK_CONVERT 0x1C VK_NONCONVERT 0x1D VK ACCEPT Ox1E CETerm Scripting Guide Page 185 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE Symbolic Name Value VK MODECHANGE 0x1F VK SPACE 0x20 VK PRIOR 0x21 VK NEXT 0x22 VK END 0x23 VK_HOME 0x24 VK_LEFT 0x25 VK_UP 0x26 VK RIGHT 0x27 VK DOWN 0x28 VK SELECT 0x29 VK PRINT 2 VK Ox2B VK SNAPSHOT 0 2 VK_INSERT 0x2D VK_DELETE Ox2E VK_HELP Ox2F 0 0x30 1 0x31 2 0x32 3 0x33 4 0x34 5 0x35 6 0x36 7 0x37 8 0x38 9 0x39 A 0x41 B 0x42 C 0x43 D 0x44 E 0x45 F 0x46 G 0x47 H 0x48 0x49 J Ox4A K Ox4B L 0x4C M 0x4D N 0x4E CETerm Scripting Guide Page 186
213. w the CETerm Scripting Guide Page 99 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE return value is a handle to the owner window If the window is a top level unowned window or if the method fails the return value is 0 Use the Window property LastError to get additional error information and differentiate between failure and a top level unowned window windowHandle GetRelative windowHandle relation Get the handle of a window with the relation to the specified window The relation values are integers and are listed in Appendix 4 Return the window handle or zero if no such window or method fails Use the Window property LastError to get additional error information and differentiate between failure and no such window windowHandle GetSelf Get the handle of the top level CETerm window text GetText windowHandle Get the text of the specified window Return the text of the window s title bar or the text contents if the window is a control Return null if function fails Use the Window property LastError to get additional error information windowHandle GetTopmost Get the window with which the user is working This is also called the foreground window May return 0 if no window is currently active Use the window property LastError to get additional error information status IsEnabled windowHandle Check the input status of the specified window Return true if the window is
214. webpage The three top level objects are CETerm Device 05 The CETerm object provides access to application specific features The Device object provides access to device hardware such as keyboards and serial ports The os object provides access to generic Operating System OS features such as files events processes the network and the Windows registry Automation objects provide some of the same functionality provided by the Window object in the web browser For example the familiar Window methods alert and setTimeout are provided by the 0S Alert CETerm SetTimeout methods Many of the automation objects on the OS hierarchy give direct access to low level Windows CE features Although powerful caution should be exercised when using these features We provide the basic API documentation in this document More information and useful discussion can be found by searching the Microsoft msdn microsoft com website Below we suggest such searches and provide relevant keywords The top level CETerm objects are described in the first 3 sections below followed by all other objects in alphabetical order The following figures show the hierarchy of the objects Note that some objects are not available for all mobile devices NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE CETerm Scripting Guide Page 29 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS AND WINDOWS MOBILE
215. window which may not be CETerm SimulateKeyPress should be used when you need to simulate text sent to an independent application Return 0 on success 1 for invalid VK code Properties The Keyboard object has the following properties Property Description Values LastError Returns the last error value associated unsigned with the Keyboard object integer Example The following example shows how a global hot key may be assigned to cycle between several running programs This example also shows the use of several OS Window methods The hot key invokes a CETerm script that will check which application is visible and switch to the next The script is shown first It must be imported into CETerm script slot and marked Load at Startup Switch between multiple applications Each appX name can be a regular expression or string Can be any number of applications named in arguments function ToggleApplications appl app2 Find current application var i var top OS Window GetTopmost var toptext OS Window GetText top var topindex 1 DEBUG OS Alert toptext toptext Find argument that matches current foreground application no match will switch to appl CETerm Scripting Guide Page 71 NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE for i 0 i lt arguments length i if toptext match argume
216. wser object Methods The following methods are available Method Action AddMetaltem Add a CETerm element to the current web page ClearCache Clear the browser cache GetMetaKeyContent Get the OnKey content for the current web page Navigate Navigate to specified URL ProcessMetaKey Invoke the OnKey content RunScript Run a script in the web browser JavaScript engine SaveSource Save the source of the current page to a file Windows CE browser only status AddMetaltem target content Add a CETerm tag element to the current web page This is typically used to add custom elements which define key mappings or other custom behaviors See the Naurtech Web Browser Programming Guide for documentation on custom tags Return 0 for success non zero for failure After adding META elements that change the values of information icons you may need to use CETerm PostIDA IDA INFO REFRESH 0 to apply the changes AddMetaltem can be used to supplement or override the tags in a page For example it can be used to replace a key mapping on a device with unique requirements status ClearCache pattern type Remove the cache entries that match the pattern and type The pattern will match all entries A pattern of cookie or visited will match the cookie or history entries See Appendix 4 for a lis

Download Pdf Manuals

image

Related Search

Related Contents

  Anleitung - Velodyne  Agilent Technologies 82357B Computer Drive User Manual  Ficha - Pegomax SA  User Manual (pdf format)  user mAnuAl - Purple Haze  

Copyright © All rights reserved.
Failed to retrieve file