[Pharo-dev] How to listen for windows messages?

Torsten Bergmann astares at gmx.de
Tue Feb 28 03:33:05 EST 2017


Hi,

I guess what you want to achieve will not be an easy task for you if you are new to programming.
But it is always good to have a goal and if you have time to learn I'm pretty sure you will master
it.

Even when OS-Windows inspire you for automizing tasks in other Windows processes (like autoit) you
should not start with my OS-Windows project directly as contributing to it requires knowledge 
on your side on Smalltalk as well as Win32 C programming. 

First start with learning Smalltalk and Pharo
  - http://files.pharo.org/books/
  - http://pharo.pharocloud.com/pharobooks
  - http://stephane.ducasse.free.fr/FreeBooks.html

After having an idea about Smalltalk and Pharo you should try to learn UFFI which
is Pharos unified foreign function interface and ability to call C DLL's. 

https://ci.inria.fr/pharo-contribution/view/Books/job/PharoBookWorkInProgress/lastSuccessfulBuild/artifact/book-result/UnifiedFFI/

Sideways start learning about the Win32 API and C as this helps to better understand
how things are done on the Windows side. There are many, many tutorials out there.
Try to call or wrap some simple DLL functions on you own first.

There is a nice and tiny C compiler if you want to try out some C samples
http://www.pellesc.de/index.php?page=download&lang=en

With this initial knowledge you can try to understand why and how OS-Windows was done.
I wrote many tests - just add a breakpoint and run them to debug through the code to understand.
Google for the API descriptions of the Win32 functions that are called to get an understanding
how Pharo and C get connected.

Also check how you work with callbacks in UFFI (as this would be required for a hook).

If you are then still interested in interception windows messages you should start reading here
https://msdn.microsoft.com/en-us/library/windows/desktop/ms632589(v=vs.85).aspx
 
Primarily one has to wrap SetWindowsHookEx API function and friends and wrap a good API 
for them in Pharo.

Hope that helps to get started. 

Regards
Torsten

> Gesendet: Dienstag, 28. Februar 2017 um 06:04 Uhr
> Von: lw1990 <lukewallace1990 at gmail.com>
> An: pharo-dev at lists.pharo.org
> Betreff: [Pharo-dev] How to listen for windows messages?
>
> In the OS-Windows package, there exists the ability to use the windows api in
> Pharo.
> This is very powerful, and I intend to add more of the windows api into it
> (it's only partially implemented).
> 
> This appears to all have been done with DllCalls (FFI calls) so far.
> 
> A big part of interacting with windows is listening to/intercepting and
> responding to windows messages.
> For example, every time a user presses a key on the keyboard, a windows
> message will happen in the background for that key. If Pharo was aware of
> these messages, then Pharo could do things in response to hotkeys pressed on
> Windows (outside of a pharo window).
> 
> It would also make reacting to events potentially nicer. Like making a
> windows-desktop-manager in Pharo that can tell when a new window is created
> by windows (maybe they opened notepad). It would certainly be better than an
> infinite loop or timer of 'get active window and compare to last active
> window and see if it changed'. Instead it would be 'when receive the
> WM_MESSAGE for new window created, notify Pharo so it can react'.
> 
> How can I set up a windows message hook in Pharo?
> Please keep in mind I'm very new to programming, but I work from home and
> have lots of time to learn :-)
> 
> 
> 
> --
> View this message in context: http://forum.world.st/How-to-listen-for-windows-messages-tp4936285.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
> 
> 



More information about the Pharo-dev mailing list