Phantom Documentation

[Help Home] [Phantom Home]
TypeKeys

window.TypeKeys(sKeys);

Applicable Classes: MainWin

Parameters:
string sKeys - A formatted string containing the keystrokes to send to the window.
Return Value: None

Description:
TypeKeys sends key messages to a window as if a manual keyboard input occurred.  Care must be taken to use the function with the window that actually processes the keyboard input.

The text in sKeys can be formatted to allow for multiple keys to be pressed simultaneously.  Special keys can also be used in TypeKeys.  A list and description of these formats and special keys is as follows:

Regular Characters - Regular characters are input by simply placing them in quotes like a regular string.  All characters in the quotes are sent to the window in the order they are in placed in the quotes.

Special Characters - Special characters are input by placing the character name in open and close arrows ('<' and '>').  A list of Special character names are as follows:

 PGDN

 INS
 DEL
 END
 ESC - The Escape Key  
 BKSP - The Backspace Key  
 TAB  
 ENTER
 CTRL  
 SHIFT
 PRISC - The Print Screen Key
 ALT  
 SPACE
 CAPS   - The Caps Lock Key
 F1   
 F2   
 F3   
 F4   
 F5   
 F6   
 F7   
 F8   
 F9   
 F10  
 F11  
 F12  
 NUM   - The Num Lock Key
 SCROLL
 HOME  
 UP    - The Up arrow Key  
 PGUP  
 LEFT   - The Left arrow Key
 RIGHT - The Right arrow Key
 CENTER
 DOWN - The Down arrow Key
 LWIN    - The left Windows Key
 RWIN   - The right Windows Key     
 APPS  - The Application Key

Also, keys can be combined by adding a '-' between the characters within the carats. This is used when two or more characters are to be held down at the same time.

Example Code

#Start notepad and create window variables
System("c:\\windows\\system32\\Notepad.exe");
window Notepad = MainWin("*", "Notepad");
window Edit = MainWin("*", "Notepad").MainWin(1, "Edit");

# Enter some text in notepad
Edit.TypeKeys("Phantom");
Edit.TypeKeys("<ENTER><SHIFT-s>ome more text");

# Clear the text so notepad can exit
Edit.SetText("");

# Exits Notepad
Notepad.TypeKeys("<ALT-f>");
Notepad.TypeKeys("<UP>");
Notepad.TypeKeys("<ENTER>");



See Also: MainWin Functions


Copyright 2000-2011 Phantom Automated Solutions