Spy++ "hook" equivalent in Linux

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
wxNewbster
In need of some credit
In need of some credit
Posts: 6
Joined: Mon Sep 12, 2005 8:10 pm
Location: In a cube

Spy++ "hook" equivalent in Linux

Post by wxNewbster »

Is there one? Is there a tool for Linux which does the same thing as Spy++ (at least to see messages for foreign apps)?

I used MS Spy++ to see messages from foreign apps. Then I create a "hook" under MS VC++ to have my app monitor when that message is received. Is there an equivalent technique in Linux using signals and slots?

I fear that my code will not be portable to Linux due to this "hook" concept.
[Linker error] undefined reference to `wxNewbster'
ld returned 1 exit status
koderpat
Experienced Solver
Experienced Solver
Posts: 62
Joined: Tue Apr 05, 2005 5:04 am
Contact:

Post by koderpat »

I'm not really familer with Spy++..

but if you want message passing for IPC,

you could use sockets, or shared memory or pipes or unix sockets
wxNewbster
In need of some credit
In need of some credit
Posts: 6
Joined: Mon Sep 12, 2005 8:10 pm
Location: In a cube

Post by wxNewbster »

Spy++ is an app on MS Windows that allows you to select another app by pointing to its window, then monitor which messages are sent to that window. Such as painting or mouse clicking. It also provides the handle and class name, rectangle size, etc of the window you want to monitor.

Let's say there is an app with a button and a text box. When the button is clicked, it takes the text in the text box and changes the window title to have that text. Spy++ would say that the window received a WM_SETTEXT message. Or if you just passed the mouse over that window, it could report WM_MOUSEMOVE messages.

My app (a second app that I program) could send a message to the first app to set its title text directly (or even set the text box text and send a click message to the button) and it would be as if the first app set its own text.
[Linker error] undefined reference to `wxNewbster'
ld returned 1 exit status
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

You can check properties on the windows with the X11 tool called xprop.

You can get event spam from wxGTK by having a full debug build of GTK+, and launching the application with the --gtk-debug=events command line argument (or GDK_DEBUG="events" environment variable), and --gtk-debug=geometry might be useful too. There are more, --gdk-debug=all --gtk-debug=all showing all the stuff.

Not sure if that is helpful to you.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
koderpat
Experienced Solver
Experienced Solver
Posts: 62
Joined: Tue Apr 05, 2005 5:04 am
Contact:

Post by koderpat »

Spy++ sounds windows proprietary.

If you wanted to something similar in linux, I suggest you take a look at the wxEvtHandler and the ways you can manipulate it's events; to pass them to other windows.

with something like the following:

Code: Select all

nethandler = new netEvtHandler();
nethandler->SetEvtHandlerEnabled(true);

wxEvtHandler *mainhandler;
mainhandler = frame->GetEventHandler();
mainhandler->SetNextHandler(nethandler);
mainhandler->SetPreviousHandler(NULL);
nethandler->SetNextHandler(NULL);
nethandler->SetPreviousHandler(mainhandler);
netEvtHandler is an inherieted class of type wxEvtHandler.

Now events specified either statically (in BEGIN_EVENT_TABLE tables) or events processed by

Code: Select all

nethandler->ProcessEvent( P )
will first go to the nethandler window, but if that event object has specified

Code: Select all

event.Skip(true);
event.ResumePropagation(1);
then it will then hit mainhandler's event stack and be processed by that window (where you can tell it to change the title based on the event arguments)

custom events are a must if you take this route; however it only works for the same wx application, I'm not really sure what you use the 'hook' method for, but this will only work within the same application.
wxNewbster
In need of some credit
In need of some credit
Posts: 6
Joined: Mon Sep 12, 2005 8:10 pm
Location: In a cube

Post by wxNewbster »

Wow, I don't know why I didn't come back to this thread after the last two replies. the funny thing is I just visited http://www.wxwidgets.org/ and this forum and a lot of wx links today and I get a private message from someone.

leio,
Yes, "event spam" was what I was interested in.

koderpat,
Unfortunately I was interested in "outside" of an application I wrote, not "within" the same application I wrote. I believe that is why the term "hook" is used.

I just noticed my signature and that is exactly why I will be posting a new thread (and probably why I haven't touched wxWidgets in a while).
[Linker error] undefined reference to `wxNewbster'
ld returned 1 exit status
Post Reply