SendString

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > UI (User Interface) > Windows API >

SendString

 

Description

 

Send text to the current top-level window simulating keyboard keystrokes.

 

Syntax

 

n = SendString(TextToSend [, mSec_Char [, mSec_Final]])

 

Returns

 

Number

 

Parameters

 

Name

Type

Optional

Meaning

TextToSend

String

No

Text to send

mSec_Char

Number

Yes

Milliseconds to wait after each key text has been sent.

mSec_Final

Number

Yes

Milliseconds to wait at the end before control is passed back to script

 

Remarks

 

Special keys can be emulated using the following special codes. Note that pressing and releasing special keys is something the programmer must handle.

"{CTRL_DOWN}"

"{CTRL_UP}"

"{ALT_DOWN}"

"{ALT_UP}"

"{SHIFT_DOWN}"

"{SHIFT_UP}"

"{WIN_DOWN}"

"{WIN_UP}"

"{BACKSPACE}""{BS}"

"{ENTER}""{ENT}"

"{INSERT}""{INS}"

"{DELETE}""{DEL}"

"{RIGHT}""{ARROWRIGHT}"

"{LEFT}""{ARROWLEFT}"

"{UP}""{ARROWUP}"

"{DOWN"}, "{ARROWDOWN}"

"{HOME}"

"{END}"

"{TAB}"

"{ESCAPE}""{ESC}"

"{PGUP}"

"{PGDN}"

"{F1}"

"{F2}"

"{F3}"

"{F4}"

"{F5}"

"{F6}"

"{F7}"

"{F8}"

"{F9}"

"{F10}"

"{F11}"

"{F12}"

"{F13}"

"{F14}"

"{F15}"

"{F16}"

"{APPS}"

"{NUMLOCK}"

"{PRTSC}"

"{SCROLLLOCK}"

"{HELP}"

"{CAPITAL}"

 

Restrictions

 

See also

 

 SendKeys

 

Examples

 

Uses "UI"

 

Dim hWnd As Long

 

hWnd = Win_FindByTitle("...Notepad")

 

'---If found ...

If hWnd Then

  Sleep 1000

  Win_SetForeground(hWnd)

  Sleep 1000

  SendString "aaaaaaaaa bbbbbbbbbbb bbbbbbbbbb", 0, 1000

  SendString "{SHIFT_DOWN}{CTRL_DOWN}{LEFT}{LEFT}{LEFT}{SHIFT_UP}{CTRL_UP}{DEL}", 500, 1000

   

  hWnd = Win_FindByTitle("thinAir...")

  Win_SetForeground(hWnd)

End If

 

Beep