Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

edit: nevermind, i figured it out myself!!

Humble Request
Problem:
My C or C++ is 20 years out of date and I don't really feel like brushing up on them or learning how Windows works right now. I'd like something to do this:

nielsm posted:

Possibly a hook: SetWindowsHookEx with WH_CALLWNDPROCRET, look for WM_CREATE and WM_DESTROY messages.

Basically, I'm looking to automate some stuff in python when different windows are opened and enumerating all windows in a loop is either slow or CPU intenstive. AFAICT, no one has done any work on getting SetWindowsHookEx to work in python.

Or I guess this?

Bonfire Lit posted:

SetWindowsHookEx has some requirements that make it unwieldy (like having the hook code in a DLL so it can be injected). If you only want to track windows getting created/destroyed, you can use the accessibility functions (SetWinEventHook).



Description and requirements:
At a minimum it would just sit there printing to stdout a message when any window was created or destroyed. Probably would be ideal if it printed the handle and possibly the title...not sure if this info is part of the payload of this hook.

I could just run this via python and watch the messages.

Nice to have features:
  • publish the info on a zmq socket. Zmq is easy to use.
  • some nice comments so I can make changes myself and maybe convince me to actually brush up on C and Windows programming!

Thermopyle fucked around with this message at 22:49 on Apr 8, 2019

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply