Been working on a short code for opening a program or file and getting the handle. So far this is the best Ive come up with. Not really short but works quite well. If you have something better please share. Thanks in advance.
Throw this into a button and add a label and see it work.
Throw this into a button and add a label and see it work.
Code:
Titles = Window.EnumerateTitles(true); File.Open("notepad.exe", "", SW_SHOWNORMAL); old = Table.Count(Titles); stop = 0; repeat -- Stalling until the program catches up. Application.Sleep(1); updateTitles = Window.EnumerateProcesses(); new = Table.Count(updateTitles); stop = stop + 1; until new > old or stop == 85; -- looks like a good even number if stop == 85 then -- seriously it shouldn't take this long Dialog.TimedMessage("Operation Timed Out","Operation is taking longer than usual", 500, MB_ICONINFORMATION); Application.ExitScript(); end for j,k in pairs(updateTitles) do next = false; for J,K in pairs(Titles) do if (String.Find(j, J, 1, false) ~= -1) then next = true; break; end end if not next then Label.SetText("Label1", "Window "..k.." Handle "..j); end end
Comment