BeBits Information Developer Central Submit Application Your Account Web Links Contact Us
BeBits
HeY

hey version 1.2.6

Hey is a BeOS program that allows one to control BeOS GUI programs from a terminal or shell script. I know you can run GUI programs with either clicks of the mouse or hotkeys. Hey can access the gui and let the script control the gui just as if a user were to access a gui and run it. Not all applications support all BMessages. The old Hey app shows up on some old mirrors of Be and there are a few updates on bebits.com and maybe bezip.de. With all older beos apps you sometimes have to search or hope someone has it on beshare.

Related Links

http://bebits.com/app/2042 One of the original hey apps. Might be lost.

http://bebits.com/app/3332 An updated version thanks.

heymodule A way to run hey from python?

More to follow. Let's see how this shows up.

What is hey?

hey is a small public domain scripting utility which works with standard BeOS BMessages. 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 double clicking 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]  [  | name | "name" | '"name"'] 
       : index | '['index']' | '['-reverse_index']' | '['fromvalue to tovalue']' 
       : int | -int | '['int']' | '['-int']' | '['startint to end']' 
      <value> : "string" |  | <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 <a href="file:///boot/beos/documentation/Be%20Book/The%20Application%20Kit/PropertyInfo.html">BPropertyInfo</a> and <a href="file:///boot/develop/headers/be/app/PropertyInfo.h">PropertyInfo.h</a> for details. (Only on BeOS compatible systems.)

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 <sander@adamation.com> 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 <a href="mailto:pfolk@uni.uiuc.edu">Peter Folk</a> 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=<value> [and name=<value> [...]]
    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
  • First public release


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

How do I start an app from the UserBootScript in a minimized state?

Try hey, it's available on BeBits. Check out this excerpt from my UserBootscript:

 
# Workspaces
/boot/beos/preferences/Workspaces &
hey Workspaces set Look of Window 0 to 3
hey Workspaces set Minimize of Window 0 to true
# Workspaces

It starts Workspaces, removes the window tab and then minimizes it.

By Christian Corona

This is my one

#!/bin/sh
/boot/beos/preferences/Workspaces &
hey Workspaces set Look of Window 0 to 19 &
hey Workspaces set Feel of Window 0 to 6 &
It removes the border and sets it to on top on all workspaces. I have no idea why someone would want to remove the border from workspaces then minimize it, it just doesn't make sense.

-misza

Reply by Christian Corona: Misza, I remove the tab, NOT the border, because I don't need it. I have Workspaces open all the time and the tab is just useless. I'm keeping the border to drag it around though. And I hide it, because I only want to look at it when I'm switching workspaces. What you're doing makes sense, too. But personally, I wouldn't like to have the window open at all times and even worse: on top of everything! But that's just a matter of preference. There's no right or wrong way.

How to have BeOS remember all the positions and workspaces (arrangment) of apps?

One can use the almighty "hey" command for this. Launch all your apps and arrange the windows as you please. Then open a terminal and type the following for each app and each window:

 
hey AppName get Frame of Window 0
hey AppName get Workspaces of Window 0

Note the replied values and then write a simple Shell script:

#!/bin/sh

/boot/apps/AppName/AppName & hey AppName set Frame of Window 0 to BRect(333.0, 171.0, 908.0, 939.0); hey AppName set Workspaces of Window 0 to 3

Note that the numbers of the workspaces are organized in a very developer-style manner:

WS 1: 1 WS 2: 2 WS 3: 4 WS 4: 8 ..

(Note, those numbers are powers of two. So the formula is: 2^(workspace_number-1)

If you want a window to appear on multiple Workspaces, just add the numbers. Once finished, you can invoke this script using SpicyKeys.

By Christian Corona

Before this data gets lost I am going to copy it here.

From http://www.birdhouse.org/beos/byte/08-scripting/

"Hey, Do Something

Of course, cross-platform scripting languages don't know jack about BMessages by default. To speak to hooks in BeOS GUI apps from within bash scripts, all you have to do is invoke a command-line utility called hey, by Hungarian programmer Attila Mazei. With hey in your path, you can learn a given application's scriptable hooks by typing:

hey ApplicationName getsuites

hey will return a catalog of named scriptable suites. Digging through hey's documentation a little, and asking hey to tell you what you can do with the application's window frame, you find that you can change its position on-screen. So let's say you have a StyledEdit window open on a document called "lee" and you want that window to "walk" diagonally down across your screen (which might be useful for creating self-running BeOS demos). You'd use something like this:

#!/bin/sh

# Starting coordinates for top left and bottom right # corners of StyledEdit window: TopLeft=50 TopDown=50 BottomRight=300 BottomDown=300

# Loop until the bottom of the window is at the bottom of the screen

while [ $BottomDown -lt 768 ]; do

# Send a BMessage via hey. hey StyledEdit set Frame of Window "lee" to \ "BRect($TopLeft, $TopDown, $BottomRight, $BottomDown)"

# Add ten pixels to value of each variable TopLeft=$(expr $TopLeft + 10) TopDown=$(expr $TopDown + 10) BottomRight=$(expr $BottomRight + 10) BottomDown=$(expr $BottomDown + 10) done

A very simple bash construct is all it takes -- a "while" loop that continues until the window has reached the bottom of the screen (for a monitor set to 1024x768 resolution). And right smack in the middle of the loop, you shoot a BMessage off through the OS, to be intercepted by the StyledEdit application.

And if you want to use Perl rather than bash? No problem. You just invoke hey via Perl's built-in ability to send messages to the system. I'm currently in the process of writing a Perl-based system for controlling the BeOS audio application SoundPlay remotely. I use calls like this:

system "hey SoundPlay set pitch of track 0 to $pitch" if ($pitch ne "");

Where $pitch is a value trapped in the URL of a web page after selecting a pitch from a Web-based interface. Yes, of course you can do similar things on other OSes by sending system commands to command-line tools. But the cool thing is, SoundPlay is a GUI application without any kind of command-line interface. The possibilities are pretty inspiring. "


PAGE VISITS
5,278

LINKS HERE
TvHowTo
CrossPlatformDevelopmentTools
IndexPage
ScriptingBeOS
BeAppTips

NEW PAGES
CrosscompilingFirefox
BuildingCairo
StoringDataInBetweenOSes
ScriptingBeosRuby
ScriptingBeosPython
HaikuOS
QemUwinbe
MinimalBeos
XpMBRoverwrite
SteveSakoman

RECENT CHANGES
BuildingFirebird
FrontPage
BeAcademic
CrosscompilingFirefox
HowTo
BuildingCairo
BeCommunity
PlayGround
CorumIII
SupportForMachinesAndArchitectures
Edit Page | Front Page | BeBits
Site content is in the public domain. Unless otherwise noted, everything else is copyright © 1999-2009 BeBits. All Rights Reserved.
For more legal trivia, take a gander at our
Legal Stuff page and our Privacy Statement.