Scripting the GUI with 'hey'

Haiku’s GUI is in principle entirely scriptable. You can change a window’s position and size and manipulate pretty much every widget in it. The tool to do this is hey. It sends BMessages to an application, thus emulating what happens if the user clicks on a menu, checkbox, or other widgets.


This is a companion discussion topic for the original entry at https://www.haiku-os.org/blog/humdinger/2017-11-05_scripting_the_gui_with_hey/
9 Likes

Definitely opens up the possibility of test automation against Haiku apps!

2 Likes

Thanks for this tutorial!

Like so many things in Haiku, I knew about it a little bit, but haven’t used it for a while, so it was a good reminder as well as teaching some finer points that I didn’t know. And it was a fun diversion to follow along with the examples!

1 Like

How would I go about changing screen brightness in Screen preferences?

hey Screen 'brig' 'be:value'='int32(255)' didn’t work.

I am also interested.

No idea (I don’t even have that slider in my Screen prefs, using VESA).
I’m not even sure hey’s syntax allows including e.g. a ‘be:value’ field in the BMessage you send. That would be a nice addition…

It would be nice to add scripting support to the Screen prefs (all prefs really), so you get all the valid commands with a hey Screen getsuites. Then setting would be easy as something like hey Screen set Brightness to 100.

Didn’t @owenca add scripting commands to MediaPlayer last GCI? Maybe as mentor this year, he’d like to supervise such tasks… :slight_smile:

Oh, dear… trying to find “The BeOS Bible” I ran into this:

Either Google has long forgotten BeOS existed, or searching for beer apparently is common these days. :smile:

Scripting with “hey” seems quite interesting. At first glance I though it would be a tool to create user interfaces, but then I found out it’s entirely different. It’s cool, although I’m not sure how it would be useful other than automating testing or demonstrations. Would it be possible to use this as an automated mouse clicker (inside windows)?

As for what I first thought this tool is, Zenity came to mind. It’s a tool that allows you to easily make dialogs and use them in scripts:

Does Haiku have something similar to Zenity?

1 Like

There are also some tools built into the system, like alert.

2 Likes

As KapiX says, there’s shanty. There’s also hdialog which has far fewer options, but makes it quicker to learn and use, I suppose. Both are in HaikuDepot.

Haiku comes with a few “built-in” commands, see the user guide’s Useful scripting commands. Hmm… I should add “notify” for notifications.

1 Like

hey is not a tool to send generic BMessages.
To be honest, instead of trying to hack your way around, why not add brightness setting to the command line screenmode app? It should be just a few lines of code.

4 Likes

Talking about screen brightness… since a lot of the current users are probably using the vesa driver, it would be great for our eyes to add some kind of way to set a lower brightness, even if it’s done in another way, by changing the colors, or something like that. My eyes hurt at night when using indoor lighting. :slight_smile:

IIRC VESA has at least two levels of brightness, and it should be possible to add support for that. Patches welcome! It may or may not work depending on the BIOS implementation.

4 Likes

Going with the above… could we add somehow (userland / kernerland) support to enable some kind of night-mode filter like the ones you have in android phones and using fl.ux software?

Should be just going red-dish in the final rgb screen outcome (well, probably something more complex)

2 Likes