delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/01/03/11:09:11

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
References: <NUTMEGEGKROptzzpYEz00000b14 AT mail DOT artimi DOT com>
Subject: RE: PID -> WindowHandle (stop/restart processes)
Date: Thu, 3 Jan 2008 16:03:35 -0000
Message-ID: <00b401c84e22$31c640b0$2e08a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
In-reply-to: <NUTMEGEGKROptzzpYEz00000b14@mail.artimi.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id m03G8q3F027205

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/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019