Page 1 of 1

System-wide monitoring or maybe integration of BB4W & AHK

Posted: Fri 25 Jan 2019, 10:32
by lettersquash
Hi, renewed greetings and thanks for these wonderful BBC BASIC projects! I hope you're well, Richard!

I want to write a diary-task-management program, and am trying to figure out how to do that with the languages I'm familiar with. These are (ones that bear mentioning, anyway) BBC BASIC and AutoHotkey. I'm not familiar with BBCSDL and don't particularly want to go there, at least not yet, and this is fine just for Windows (7 and above). My knowledge of the Windows API isn't great.

I need the program to run in the background most of the time, monitoring the time (for notifications of appointments, etc.) and either monitoring (hot)key and/or mouse events or having a tray menu (so that dialogue windows can be opened to create new reminders, etc.). The latter could be done by opening the main window and using features there, but it wouldn't be as neat as direct access to subroutines via a tray menu from the application's icon in the notification area (or, as I say, ideally, hotkeys). Can this be done in BB4W? From what I gather, it seems designed to write relatively self-contained programs operated via their own windows, and may lack system-wide access to things like hotkeys, or the notification area. If it lacks some of that, can a program at least be run with its window hidden, but opened somehow, and, if so, how?

I could do everthing I need to do in AutoHotkey, but its syntax is so irregular it drives me crazy. So another question would be whether I could accomplish the task with a hybrid - AHK doing what it's good at, monitoring system events, with an icon and menu in the tray, and using that to access the main BB4W routines, but I don't know how I'd go about that. The AHK exe could obviously run the BBC exe, but it would need to activate particular PROCs or FNs. I'm thinking this might take me into Windows messaging, which I've never done before, and/or the two would have to communicate via a file or something. Any help would be much appreciated.

Re: System-wide monitoring or maybe integration of BB4W & AHK

Posted: Sat 26 Jan 2019, 17:28
by Zaphod
It sounds to me like you could set up a Taskbar Icon and hide your program. Then you would have a callback from the tray icon click to open your background program. As there are examples of WIN32 code (using C++) doing this BB4W certainly could as well although I am not aware of any BB4W specific examples of this having ever been shared here or other previous fora.
A C++ example is here which you may be able to translate or get ideas from. The only difficult part (for me) is the callback function itself but Richard or others may be able to help on that if you decide to go along these lines.


Re: System-wide monitoring or maybe integration of BB4W & AHK

Posted: Sun 27 Jan 2019, 00:05
by lettersquash
Thanks Zaphod, it's great to know it's possible and you've given me a direction towards solving it too. (Someone else reminded me that BB4W is a general purpose programming language, so of course you can do it!). I'm looking into Shell_NotifyIconA function and the NOTIFYICONDATAA structure that's set up to call it, from the link you gave and other resources around that, but it looks like it'll take a while for me to translate it. I'll check out other calls in BB4W and compare them with the docs on the same at msdn, and do some actual programming with API calls to get more familiar with them. This looks like it would be a really useful function or library if it's not been written in bb4w yet. Minimizing programs to the "tray" is used so often.