PDA

View Full Version : Please help about the asterisk


phucasimo
08-19-2007, 12:18 AM
I want to close all opened windows that names are begin with "C:",so the windows name will be "C:\[folder name]"

windows = Window.EnumerateTitles();

window_name = "C:"..**
for handle, title in windows do

result = String.Find(title, window_name, 1, false);

if (result1 ~= -1) then
Window.Close(handle, CLOSEWND_SENDMESSAGE);
end

end

I tried to replace [folder name] by **,but it didn't work,please help

yosik
08-19-2007, 03:32 PM
If there is no chance of having a window title which includes C: except as directory path , just change:
window_name = "C:"..**
to
window_name = "C:"

And you have a mistake:
if (result1 ~= -1) then
it should be:
if (result ~= -1) then

Good luck
Yossi

phucasimo
08-19-2007, 10:23 PM
but it only close the drive C: window,how can i close all windows of folders in drive C:,ex: C:\Firefox, C:\Awasu,...with only one line code,i know about using asterisk as a certain path,maybe it's possible ???

Desolator
08-20-2007, 01:51 AM
-- enumerate all the open windows
local tblOpenWindows = Window.EnumerateTitles();

-- browse hrough the resulting table
for numWinHanlde, strWinTitle in tblOpenWindows do
-- if "C:" is found in the title
if String.Find(strWinTitle, "C:", 1, false) ~= -1 then
-- send it a message to close
Window.Close(numWinHanlde, CLOSEWND_SENDMESSAGE);
end
end

I added comments to make you notice what for loop does. It will loop through the list and close any windows that have "C:" anywhere in their titles.

phucasimo
08-21-2007, 03:22 AM
Thanks alot