View Full Version : LUA "win.KillWindow" not working for me???

October 14th, 2005, 06:26 AM

Is there a bug in the win.KillWindow function? or am I doing something wrong.

If I try to kill internet explorer windows using the LUA function it is not working, however if I use the Girder close window function (using same CLASS name for targetting) it works fine. Below is my LUA code extract, then below this the standard out. As the output shows I am getting the handle to the window OK, however the win.KillWindow function is not killing off the window. As I can't call out to the girder action that does work from within the LUA script I need to work this one out.

Any ideas?

function getIEhandle()
print ("DEBUG: Entering getIEhandle")
local h, err
h, err = [b]win.FindWindow[/b] ("IEFRAME",nil)
if (h == nil)
then print("ERROR: Finding IE, error = ", err, " h=", h);
print("DEBUG: Found IE window, h=", h);
return h


print ("DEBUG: Entering closeIE")
local h = getIEhandle()
while (not (h == nil)) do
print ("INFO: Killing window ", h)
win.KillWindow (h, 2000)
oldh = h
h = getIEhandle()
if (oldh == h) then
print ("ERROR: Found same handle again!")

Stardard output:
DEBUG: Entering closeIE
DEBUG: Entering getIEhandle
DEBUG: Found IE window, h= 1771250
INFO: Killing window 1771250
DEBUG: Entering getIEhandle
DEBUG: Found IE window, h= 1771250
ERROR: Found same handle again!

October 14th, 2005, 10:20 AM
did you try the win.CloseWindow ?

October 14th, 2005, 06:05 PM
Yes but as per the LUA win documentation this only MINIMISES the window.

I think this is inconsistent with the girder window close action and really should be aligned. The win.CloseWindow function would need to be adjusted to match this.

Once you've considered this would you be able to indicate what your recommendation is, and if a new release is required when you think you can get this out?

thanks again for such quick responses

October 14th, 2005, 07:02 PM
There naming is inconsistent but we feel it fits better with the level of user using the action tree vs. lua.

I wonder if you have enough user rights to kill the process.

The other function is TermintateProcess which might work better.

The killwindow tries to politely close the window.

October 14th, 2005, 08:14 PM

The TerminateProcess works, however it's a little inflexible in terms of being able to search for the instance of IE you want to "close". Probably OK for what I'm doing this time around.

Re the win.KillWindow issue, some thoughts:

a) regarding rights - seeing the girder "close" window function works fine I don't think this would be the case would it?

b) is it possible that the windows handle variable (as you have to find the windows handle to be able to use KillWindow) is holding a reference to the window such that it won't let the KillWindow function complete.

c) my guess is it may be a bug in KillWindow I think though (just guessing)

d) if there was a result returned from KillWindow this would be useful

e) It would be useful to have a win.FindWindow fucntion that returned a table of handles too, in the case you have more than one window which matches. For example in the girder CLOSE function you can effectively close multiple windows at a time via the targeting settings, however it seems we don't have this flexibility in LUA

Hope this is useful. I'm just wanting to get my little web page toggler working then I'll jump in and purchase the LITE version of girder 4 (I'm assuming this support the basic remote functions and the win.* functions I've been using)


October 14th, 2005, 10:23 PM
Some good points and ideas.

The killwindow tries to kill using a sendmessage and then using the terminate process. something must be going wrong there. I looked at the code and tested here on notepad.exe and it works....

i believe were are exporting the standard girder targeting stuff to lua. there is the enumerate windows functions for doing some of what you want. the win. stuff was mainly done to mimic the windows api with little fluff in the middle... it has evolved with time from there and shows some of those growing pains ...