Opening - Monitoring External Windows

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Intrinsic
    Forum Member
    • Mar 2005
    • 21

    Opening - Monitoring External Windows

    I have attached an example of a method to:
    1. Browse for a file
    2. Get the selected files default viewer
    3. Launch and monitor the opening of the default viewer
    4. Get the window handle of the default viewer
    5. Hide the AMS window
    6. Set the title text of the default viewer
    7. Monitor the closing of that default viewer window
    8. Show the AMS window


    The application does an initial check after opening the selected file and runs a function to monitor if the files viewer is open checking every 1/2 second then hides the AMS application

    If the default viewer isn't in the table of enumerated processes (slow opening) then it waits 5 seconds and further checks if the window has been opened.

    On opening the files default viewer it changes the window title text (A prompt to close the window to return to the AMS application)

    On closing the default viewer window the AMS window shows

    I am sure many users could appreciate having such an example, (I know that I would have) please feel free to correct any code, error handling as you see fit.

    Hope this is useful to many users!
    Attached Files
    Last edited by Intrinsic; 03-31-2005, 07:33 PM.
  • csd214
    Forum Member
    • Oct 2001
    • 939

    #2
    Intrinsic, THANKS!

    I find your function very valuable. Your post/project should be moved the Examples section. :yes

    The only "problem" I noticed is that the file browse dialog is flickering when I start it the second time. I'm not able to use the combo box ("Look in:"), but I resolved this by adding Page.StopTimer() as the first command in Button.On Click.

    Previously I have used a while loop to enumerate windows, but your solution is nicer (but have to keep track of several On Timer functions).

    Code:
    -- wait for system to open the file
    local bHandleFound = false; local nRescueCounter = 0; local sHelpHandle;
    while not bHandleFound and nRescueCounter <= 60 do
    	nRescueCounter = nRescueCounter + 1; -- avoid an infinitive loop!
    	sHelpHandle = Get_hWind(sTitle)
    -- a user defined function with Window.EnumerateTitles()
    	if sHelpHandle then
    		Window.SetOrder(sHelpHandle, HWND_BOTTOM);
    		bHandleFound = true;
    	else
    		Application.Sleep(500);	-- wait 5/10 sec
    	end
    end
    I'll try to extend your function with restriction to the top level folder.

    Thanks for sharing!

    Comment

    Working...
    X