OS4 DepotLogo by Alkaron 
(anonymous IP:,1032) 

   Bug tracker
   Locale browser

   o Audio (325)
   o Datatype (47)
   o Demo (179)
   o Development (522)
   o Document (21)
   o Driver (87)
   o Emulation (140)
   o Game (848)
   o Graphics (447)
   o Library (87)
   o Network (196)
   o Office (56)
   o Utility (794)
   o Video (59)

Total files: 3808

Full index file. Download
Recent index file. Download



Support the site

 Readme for:  Utility » Script » stringins.lha


Description: Insert keypresses into the input stream
Download: stringins.lha       (TIPS: Use the right click menu if your browser takes you back here all the time)
Size: 7kb
Version: 1.1
Date: 27 Aug 09
Author: Peter Gordon
Submitter: Peter Gordon
Email: pete/petergordon org uk
Homepage: http://www.petergordon.org.uk/
Category: utility/script
Replaces: utility/script/stringins.lha
License: Freeware
Distribute: yes
Min OS Version: 4.0
FileID: 5035
Comments: 2
Snapshots: 0
Downloads: 317  (Current version)
393  (Accumulated)
Votes: 0 (0/0)  (30 days/7 days)

Show comments Show snapshots Show content Show crashlogs Replace file 
StringIns v1.1

©2007-2009 Peter Gordon (pete()petergordon.org.uk)

MY PAYPAL ACCOUNT! (Use the email above)

1. Introduction

StringIns converts a string into keyboard events and adds them to the input
queue as if they were typed on the keyboard, with an optional delay. This
allows you to automate tasks in scripts which normally require user input
such as acknowledging requesters or typing in passwords.

StringIns takes two arguments "DELAY" and "KEYSTRING". "KEYSTRING" is the
string to 'type' onto the keyboard buffer, and "DELAY" is a length
of time to wait in 1/50ths of a second before processing the keystring.

For example, if you typed:

run <>NIL: stringins delay=50 keystring="hello world"

into the shell, after a second "hello world" would appear in the shell
as if you typed it.

One example use would be a script which called a program that required
a password, which stringins then typed in for you:

run <>NIL: stringins delay=100 keystring="mypassword\n"

(\n is a special code to say "hit enter")

2. Advanced usage

As you saw in the above example, you can use the backslash charactor '\' to
insert special keycodes into the keystring. Here are all the special codes:

 \\ = Insert a backslash
 \a = Press and hold the left-amiga key
 \A = Release left-amiga key
 \m = Press and hold the right-amiga key
 \M = Release right-amiga key
 \l = Press and hold the left-alt key
 \L = Release left-alt key
 \t = Press and hold the right-alt key
 \T = Release right-alt key
 \s = Press and hold the left-shift key
 \S = Release left-shift key
 \h = Press and hold the right-shift key
 \H = Release right-shift key
 \c = Press and hold the ctrl key
 \C = Release the ctrl key
 \n = Enter key
 \b = Tab key
 \^ = Cursor up
 \v = Cursor down
 \< = Cursor left
 \> = Cursor right
 \k = Press key associated with a rawkey value (see below)
 \d = Wait 1/10th of a second before continuing
 \D = Wait 1 second before continuing
The "\k" code is different to the others in that it requires an argument. It
must be immediately followed by a 2-digit hex code of the rawkey to press. For
example, to press F1 followed by escape, you would use:

stringins "\k50\k45"

Some other examples:

stringins "hello \Dworld"    -> Types "hello ", waits 1sec then types "world".
stringins "\mcq\Mhello\mv"   -> Types RAmiga-C, RAmiga-Q, "hello" then RAmiga-v

Note that the "press and hold" escape chars don't generate a key-down event
for the qualifier, they just set the corresponding qualifier bit in subsequent
keypresses. To actually generate a keydown for the Amiga, Alt, Shift or Ctrl
keys you would have to use '\k'. Note also that every keypress (including
those with \k) will automatically generate a key-up event, so trying
"\k63\k66\k67" to reboot the Amiga won't work ;-)

A final example is one that I use myself (well, I did, but now I use yae).
I often use the eval command to quickly do some maths in the CLI, but eval only
uses integer maths. The following script uses the calculator program to do
floating point sums from the CLI:

.bra {
.ket }

run <>NIL: stringins delay=10 "{CALCSTR}=\mcq\M\d;\mv\M\n"

First, it inserts your sum, then presses '=' to get the result in the
calculator window, then presses RAmiga-C to copy the result, and
RAmiga-Q to quit calculator. It then waits 1/10th of a second to let
calculator quit, and types ";" followed by RAmiga-V into the shell
and then hits return.

This leaves you the result both in the window and on the clipboard.
Nifty, eh? The only thing to remember with this script is that because
of the way AmigaOS handles argument passing in scripts, if you want to
do multiplication, you need to use "**" instead of "*".

2. History

1.1 (27/08/2009)

 - Special keys now respect qualifiers. Thanks for Severin for the
   bug report!

1.0 (04/05/2007)

 - First version

Copyright (c) 2004-2017 by Björn Hagström All Rights Reserved
Amiga OS and its logos are registered trademarks of Hyperion Entertainment