hey version 1.2.6
What is hey?
hey
is a small public domain scripting utility which works with standard BeOS scripting. It comes with source which you can modify as you wish. If you want your modification in the standard distribution, just drop me a line.
Use it at your own risk.
Installation
- unzip the archive by doubleclicking on
hey-YYYYMMDD.zip
or by dropping it on Expander
- open the right project file depending on the hardware platform and select 'Make' from the 'Project' menu to compile it
- you may want to move the executable (
hey
) to /boot/home/config/bin
Usage
hey should be used from Terminal. When you start it without parameters it will display the command line syntax it accepts:
hey v1.2.6, written by Attila Mezei (amezei@mail.datanet.hu)
usage: hey [-s] <app|signature> [let <specifier> do] <verb> <specifier_1> <of <specifier_n>>*
[to <value>] [with name=<value> [and name=<value>]*]
where <verb> : DO|GET|SET|COUNT|CREATE|DELETE|GETSUITES|QUIT|SAVE|LOAD|'what'
<specifier> : [the] <property_name> [ <index> | name | "name" | '"name"']
<index> : index | '['index']' | '['-reverse_index']' | '['fromvalue to tovalue']'
<index> : int | -int | '['int']' | '['-int']' | '['startint to end']'
<value> : "string" | <integer> | <float> | bool(value) | int8(value) |
int16(value) | int32(value) | float(value) | double(value) |
BPoint(x,y) | BRect(l,t,r,b) | rgb_color(r,g,b,a) | file(path)
options: -s: silent
The verb
The verbs send the following messages:
- DO: B_EXECUTE_PROPERTY
- GET: B_GET_PROPERTY
- SET: B_SET_PROPERTY
- COUNT: B_COUNT_PROPERTIES
- CREATE: B_CREATE_PROPERTY
- DELETE: B_DELETE_PROPERTY
- GETSUITES: B_GET_SUPPORTED_SUITES
- QUIT: B_QUIT_REQUESTED
- SAVE: B_SAVE_REQUESTED
- LOAD: B_REFS_RECEIVED
You can use your own verbs if you specify the value names and constants in the 'value_info' structure. See BPropertyInfo and PropertyInfo.h for details.
Note that the verb is not case sensitive but the specifier names (e.g. "Frame", "Label"...) are. You can use 'what' constants
directly, like
hey Application '_ABR'
will open the about window of the application.
LOAD and SAVE are actually not scripting commands, they are standard BeOS messages (B_REFS_RECEIVED and B_SAVE_REQUESTED). I included them for convenience. E.g. open a file in Application (the path can be relative or absolute):
hey Application load 'file(/boot/home/images/Be.jpg)'
or save it:
hey Application save Window "Be.jpg"
The specifier
The specifier can be direct, index, reverse index, range or named. Reverse range is
not supported. If you enter an index which consists of only digits, you can omit the square
brackets:
hey Application get Window 0
The value
It is easy to use the type names in front of the value but beware that the shell will throw a syntax error if you do this:
hey Application set .... to BPoint(100,100)
Instead use square brackets or quotes:
hey Application set .... to BPoint[100,100]
hey Application set .... to 'BPoint(100,100)'
If the value string contains only digits, it will be considered an int32. If it contains digits and a dot,
a float type is assumed. "true" or "false" can also be used as bools.
DEBUG mode
You can check the message to be sent to the application by setting the DEBUG_HEY preprocessor symbol to 1, and recompiling.
History
v1.2.6
- syntax extended by Sander Stoks to allow:
"hey Application let Specifier do ..."
allowing you to send messages directly to other handlers than the app itself.
In cooperation with the new Application defined commands (note that some
Be classes, e.g. BWindow, publish commands as well) this allows, for example:
"hey NetPositive let Window 0 do MoveBy BPoint[10,10]"
Note that this is partly redundant, since
"hey NetPositive let Window 0 do get Title"
duplicates "hey NetPositive get Title of Window 0"
But with the old system,
"hey NetPositive MoveBy of Window 0 with data=BPoint[10,10]"
couldn't work ("MoveBy" is not defined by the Application itself).
v1.2.5
- 'value_info' is supported in BPropertyInfo. This means when you send GETSUITES (B_GET_SUPPORTED_SUITES) the value info is printed after the property infos (name, kind, value, usage).
You can also use application defined commands (as the verb) with hey:
hey MyBackupApp Backup "Maui"
v1.2.4
- The syntax is extended by Peter Folk
to contain:
do the x of y -3 of z '"1"'
I.e. "do" => B_EXECUTE_PROPERTY, optional "the" makes direct specifiers
more like english, bare reverse-index-specifiers are now handled, and
named specifiers can contain only digits by quoting it (but make sure the
shell passes the quotes through).
- Hey(target,const char*,reply) was previously limited to 100 tokens.
It now uses a vector<> so it's only limited by available memory.
- Also, the archive name is now Y2K compliant =)
v1.2.3
- new option: -s for silent processing (no reply or errors printed) AM
v1.2.2
- Fixes by Marco Nelissen (marcone@xs4all.nl):
- fixed parsing of negative numbers
- fixed "with" syntax, which was broken (after a create, "with" would be taken as a specifier)
v1.2.1
- compiled for R4 with minor modifications of BPropertyInfo usage
v1.2.0
- the syntax is extended by Sander Stoks (sander@adamation.com) to contain
with name= [and name= [...]]
at the end of the command which will add additional data to the scripting message. E.g:
hey Becasso create Canvas with name=MyCanvas and size=BRect(100,100,300,300)
Also a small interpreter is included.
- Detailed printout of B_PROPERTY_INFO in BMessages. Better than BPropertyInfo::PrintToStream().
Also prints usage info for a property if defined.
v1.1.1
- minor change from chrish@qnx.com to return -1 if an error is
sent back in the reply message; also added B_COUNT_PROPERTIES support
- The range specifier sent to the target was 1 greater than it should've been. Fixed.
- 'hey' made the assumption that the first thread in a team will be the
application thread (and therefore have the application's name).
This was not always the case. Fix from Scott Lindsey (wombat@gobe.com).
v1.1.0
- flattened BPropertyInfo is printed if found in the reply of B_GET_SUPPORTED_SUITES
- 1,2,3 and 4 character message constant is supported (e.g. '1', '12', '123', '1234')
- alpha is sent with rgb_color
v1.0.0
Examples
For these examples you need to start the Network preferences application
(the classic way to demo scripting ;-)
Get the messenger of an application (not useful if you use 'hey'):
hey Network get Messenger
Get the suite of messages which the application can handle:
hey Network getsuites
(BApplication & BHandler suites printed)
Get the name of the application
hey Network get Name
Open the about window of the application
hey Network '_ABR'
Get a window of the application (actually a messenger for the window)
hey Network get Window [0]
or you can omit the square brackets when using an index:
hey Network get Window 0
or you can specify a window name (with or without quotes):
hey Network get Window "Network"
Get the suite of messages which the window can handle:
hey Network getsuites of Window "Network"
(for the description of suite/vnd.Be-window see the BeBook)
Get the title, frame or other properties of the window:
hey Network get Title of Window "Network"
hey Network get Frame of Window "Network"
Set the title, frame or other properties of the window:
hey Network set Title of Window "Network" to "hey is great"
hey Network set Frame of Window "Network" to 'BRect(0,0,300,300)'
or you can use square brackets to avoid the 's:
hey Network set Frame of Window "Network" to BRect[0,0,300,300]
Get a view from the window (actually a messenger for the view)
hey Network get View 0 of Window "Network"
Get the suite of messages which the view can handle:
hey Network getsuites of View 0 of Window "Network"
(for a description of suite/vnd.Be-view see the BeBook)
Get a view property:
hey Network get Frame of View 0 of Window "Network"
hey Network get Hidden of View 0 of View 0 of Window "Network"
hey Network get Label of View 5 of View 0 of Window "Network"
hey Network get Value of View 0 of View 2 of View 0 of Window "Network"
hey Network get Text of View 2 of View 2 of View 0 of Window "Network"
Set a view property:
hey Network set Frame of View 0 of Window "Network" to 'BRect(0,0,100,400)'
hey Network set Hidden of View 0 of View 0 of Window "Network" to true
hey Network set Label of View 5 of View 0 of Window "Network" to "Restart Something"
hey Network set Value of View 0 of View 2 of View 0 of Window "Network" to 1
hey Network set Text of View 2 of View 2 of View 0 of Window "Network" to "joe"
Close a window in an application
hey Network quit Window "Network"
Quit an application
hey Network quit