This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: PID -> WindowHandle (stop/restart processes)


On 03 January 2008 13:09, TAJTHY TamÃs wrote:

> Hi,  I wanted to stop and restart mencoder automatically under cygwin. 

  I'd like to stop your mailserver going crazy and sending this post again and again and again!  Is your sysadmin back from the christmas holiday yet?

> I
> have read that sending a STOP signal is not a proper solution and signal
> handling is not perfectily solved (I tried and this does not work on
> mencoder :-( ).

  Are you sure you're using a cygwin build of mencoder and not a win32/mingw build?  Signals *ought* to work between two cygwin apps, and if they don't it's a bug that could be fixed.  They certainly wouldn't be expected to work betwen a cygwin and a win32 app.

> So as a workaround I installed Win32::GutTest perl module
> which implements SendKeys function which can send a ctrl+S/ctrl+Q to the
> window. This work.  I would like to find the window handle to the specific
> PID in cygwin. Is there a way to do this? Now I use FindWindowLike function
> giving a list of window handle having matching window title. But it is not
> "nice". With ps (or /proc/<PID>) I can detect the windows PID of the
> process, but how can I find the window handle belonging to this WPID? Is it
> stored somewhere in window local memory content (GetWindowLong)?  

  I googled "HWND from pid" and found this advice:
http://mail.python.org/pipermail/python-list/2003-March/195226.html

  To summarize:  Use EnumWindows() to step through all the top-level windows on the desktop, then for each one call GetWindowThreadProcessId() and see if it's the PID you're looking for.

  <obiwan>This isn't the PID you're looking for</obiwan>

  If EnumWindows isn't convenient (for example if you don't want to or can't conveniently use callbacks), you can write a loop that calls FindWindow(0, 0) at the start to get the first window and uses GetWindow(old_hwnd, GW_HWNDNEXT) to advance to the next one.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]