Re: [Pywinauto-users] CloseClick; force termination; locate window by coordinates
Status: Alpha
Brought to you by:
mcmahon_m
From: Mark Mc M. <mar...@gm...> - 2006-04-15 13:48:09
|
Hi Sergey, On 4/15/06, Sergey A. Lipnevich <se...@op...> wrote: > Hi All, > > I'd like to offer a tiny patch and ask two questions. The patch is for > CloseClick() method not to complain about unassigned variable. The > variable "waited" is not used, but it looks like there are plans for it := -). I hope this is a warning from pylint/pychecker rather than a runtime error! In fact the watied variable should be going away! (changed from adding the time and counting to measuring it. I haven't looked at the patch yet - I will on Monday. > > My first question is about forcing a process to terminate. In > application.py, the "quadruple" resulting from CreateProcess call is not > saved anywhere. If it were, it would be trivial to call TerminateProcess > on the handle returned from CreateProcess (in a more elaborate scenario, > I'd probably send an exit event, waited on the process handle for some > time, and then terminated it). What is the best way to implement this > (I'd like to try; I didn't look at how the same would be possible if > connect_() was used instead of start_()). Or maybe there's already an > easier way to terminate a process? A scenario I'm facing is a process > that is not responding to events. Yes I had looked into various ideas related to this. I don't know about saving the information from CreateProcess (not that I think it is a bad idea - I just have no idea how to use it :-). On my reading of the docs for Terminate process and the various other ways of killing a process I hadn't found any way that I was really happy with. Maybe I should look at implementing app.Close() (which would more or less keep sending ALT+F4 until there are no windows - and fail otherwise), app.Terminate() which would be a bit more forceful, and app.Kill() which would do whatever is necessary to kill the app. > > The second question is if it's possible to find a window by proximity to > certain coordinates? In some situations, there are way too many controls > with the same class and without any text distinguishing them, so now I > have to use for example app.dlg['2'] to get to the third of such > controls. I would prefer instead to say something like "control with > class X in the center" or "control with class Y in the north-west > corner). The find_windows() function would accept one more argument > (coordinates, or some presets such as "south-east") and use it as one > more criterion for eliminating windows from the list. The idea here is > to use the same proximity approach, but for location instead of the > text. If there is no such feature, what would be the right approach to > implementing it? > There is one easy way to do it WindowFromPoint and RealWindowFromPoint API methods. Otherwise you could look at passing in a predicate function to find_windows() e.g. find_windows(predicate_func) =3D=20 your_function_which_returns_true_or_false_and_recieves_a_window_handle > Thank you for a very useful tool :-)! Glad you are finding it useful! > > Sergey. > Mark > > |