Announcement

Collapse
No announcement yet.

Get NEW Window Handle - perhaps someone has a better method?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get NEW Window Handle - perhaps someone has a better method?

    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.

    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

  • #2
    I'm not sure how viable this still is, but I released a DLL a very long time ago: https://www.imagine-programming.com/...n-prog-ex.html - try that, see if it suits your needs
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment


    • #3
      Thanks! Im trying to give it a whirl but either my brain isn't functioning properly right now or I need to look more up on using dll files. Right now Im just trying to get notepad to even open but I keep messing up somewhere and getting a wtf is sFile or your syntax sucks do it again message. I would be grateful for a nudge in the right direction. Thanks in advance.

      Comment


      • #4
        try this
        RunProgEx2.apz

        Comment


        • #5
          Thank you that was actually very helpful on how to run dlls. Unfortunately though it is not consistent with outputting the correct handle. I'm averaging around 75% effiency on closing that handle .

          Comment


          • #6
            Ok try this old V6 one I found for detecting all running windows,
            Window_Detect_Manipulate.apz

            Comment


            • #7

              Just happened to glance at this when I loaded the page and noticed the
              Code:
              updateTitles = Window.EnumerateProcesses();
              should be
              Code:
              updateTitles = Window.EnumerateTitles();
              previously I used processes and found titles was much more time efficient.

              Comment


              • #8
                Originally posted by colc View Post
                Ok try this old V6 one I found for detecting all running windows,
                [ATTACH]n303506[/ATTACH]
                This sort of what i was doing previously, I would compare the results in a listbox and found comparing the table returns was much faster. What I have is a spread of computers I monitor through VNC. I have a spread of buttons that represent those computers and when I hover over them using On Mouse Move takes my buttons in a table and decides whether or not the mouse is inside the boundaries of the button. If they are I have a timed script that declares the unit I have hovered on returns a ping, switch port it is connected to, then pops up a small VNC window that moves to my mouse location, which I can then either click the button and close the small window and open a large one or I can move my mouse off the button and the window will automatically close. What I have now is much more efficient than my previous setup in fact I had to retard the process because I wanted a delay that you could hover over the mouse at a normal rate from point A to point B and it wouldn't open up an unwanted VNC forget that it was opening it and open another. Now the one that accidentally opened wont close automatically. The problem still persist but not as bad but I am looking for a better way to get the window handle that requires less process. I was quite disappointed the dll didn't work because it was exactly what I am looking for which is not to have to slow the process down anymore but to make sure the full script cycles before the new one begins.

                Comment


                • #9
                  Originally posted by colc View Post
                  try this
                  [ATTACH]n303502[/ATTACH]
                  Nice example, thanks for sharing
                  Bas Groothedde
                  Imagine Programming :: Blog

                  AMS8 Plugins
                  IMXLH Compiler

                  Comment

                  Working...
                  X