PDA

View Full Version : WndHandle, Get a partial title


volt
04-13-2006, 08:38 AM
http://www.indigorose.com/forums/showthread.php?t=15400&highlight=WndHandle
For example, to close this window (indigorose forums), i used the following code and it worked:



windows = Window.EnumerateTitles();
window_name = "stopping a program - Indigo Rose Software Forums - Mozilla Firefox";
for handle, title in windows do result = String.Find(title, window_name, 1, false);
if (result ~= -1) then Window.Close(handle, CLOSEWND_SENDMESSAGE);
end
end


If you are using firefox, it should work perfectly with you


Is it possible for me just to search for just to have

window_name = "stopping a program - Indigo Rose Software Forums"


Because they may not use Firefox =P

playmenow
04-13-2006, 09:41 AM
Yes, it is. Just replace the string and it will work.

volt
04-13-2006, 10:21 AM
Still lost so how would I wildcard the title?

Roboblue
04-13-2006, 10:45 AM
do a string.replace action

windows = Window.EnumerateTitles();
window_name = "stopping a program - Indigo Rose Software Forums - Mozilla Firefox";
sWindowName = String.Replace(window_name, " - Mozilla Firefox", "", false);
for handle, title in windows do result = String.Find(title, sWindowName, 1, false);
if (result ~= -1) then Window.Close(handle, CLOSEWND_SENDMESSAGE);
end
end

Actually, the first word in the window title is all you neeed, the rest are redundant.

playmenow
04-13-2006, 10:45 AM
You don't need. The String.Find action will search for what you gave it.

Worm
04-13-2006, 10:46 AM
Volt, String.Find searches for any instance of the characters you feed it. If you want to omit the " - Mozilla Firefox" from your title, any window that has
"stopping a program - Indigo Rose Software Forums" in the title would close. Think of it as a substring search.

playmenow
04-13-2006, 10:48 AM
Worm, I was faster :p

Worm
04-13-2006, 10:52 AM
That'll teach not to actually try to explain why rather than blurting out the answer :rolleyes

volt
04-13-2006, 11:05 AM
Ok, I understand now!!

Thank You all!! :yes

Intrigued
04-13-2006, 08:11 PM
That'll teach not to actually try to explain why rather than blurting out the answer :rolleyes

Worm it was worth the extra minute (literally!).

:yes

Mina
04-14-2006, 07:14 AM
"Being fast and not very spatial doesn't make you any better in spatial kinds of things; you probably just get the wrong answer more quickly."
Howard Gardner