Home Image-Pro Automation (Macros, Apps, Reports)

How can an APP close an IMAGE without interaction from the user?

All --

I've investigated several methods to close an intermediate image in an APP including:

-------------
    ThisApplication.ActiveImage.Close
-------------
and
-------------
        Dim window1

        With application.windowcommands.Active(Nothing)
            .Run(window1)
        End With

        With Application.WindowCommands.Close(Nothing)
            .Run(window1)
        End With
-------------

Unfortunately all of the methods I've tried prompt the USER before the image will close.

Is there a way for an APP to close an image without prompting the user?

Thanks.

-- Matt

Best Answers

  • Accepted Answer
    Matt,

    The easiest way is to reset Modified flag before closing the image.

        Public Sub CloseModifiedImage()
            ThisApplication.ActiveImage.Modified=False
            ThisApplication.ActiveImage.Close
        End Sub
    

    Yuri
  • edited August 2013 Accepted Answer
    Hi Matt,

    Now I can see the problem, I tested with filters and the image was closed without prompt. Measurements seem to behave differently. I will check how it can be fixed.
    For now you can use this macro to close image with measurements without prompt:

        Public Function CloseImage3() As SimpleScript
            CloseImage3 = New SimpleScript
    
            With Measure.MeasurementsCommands.DeleteAll(CloseImage3)
                .Run(ThisApplication.ActiveImage)
            End With
    
            With Adjust.ImageCommands.Close(CloseImage3)
                .Run(ThisApplication.ActiveImage)
            End With
        End Function
    
    

    Yuri

Answers

  • Yuri --

    Thank you for the suggestion.  I tagged this as ANSWERED before trying your code but . . .

    I copied your SUB into my project and then called it at the appropriate place and I still get the prompt before the image closes.

    If you have any other suggestions, that would be super.

    Perhaps something like

        ThisApplication.ActiveImage.CloseNoPrompt
        and
        Application.Windowcommands.CloseAllNoPrompt

    could be added to the IPP9 WISH LIST.

    Thanks again.

    -- Matt
  • Another way is to use a Command, the same way as it was recorded. Note that the macro is passed to the command's constructor (if you use Nothing then the prompt is shown):
        Public Function CloseModifiedImage2() As SimpleScript
            CloseModifiedImage2 = New SimpleScript
    
            With Adjust.ImageCommands.Close(CloseModifiedImage2)
                .Run(ThisApplication.ActiveImage)
            End With
        End Function
    

    Yuri
  • Yuri --

    I've put your

        Public Function CloseModifiedImage2

    into my project inside IPP904.

    My APP calls

        CloseModifiedImage2

    at the appropriate time and the prompt is still displayed.

    -- Matt
  • Can you try calling this macro manually as it is, from the menu? 
    Both macros work properly in my tests.

    Yuri
  • Yuri --

    Since your

        CloseModifiedImage2

    is a FUNCTION, I created a SUB to test it.

    -----
    Public Sub testclosemodifiedimage2()

        CloseModifiedImage2

    End Sub
    -----

    When I

        -- Start IPP904,
        -- Open an image
        -- Manually run a bright count on the the image
        -- Run testclosemodifiedimage2 from the MACRO EXPLORER

    I get a prompt during the close.

    -- Matt
  • Yuri --

    I've put your

        Public Function CloseImage3

    into my APP and it succeeds in closing the current image that has experienced a count without any prompts.

    Thanks for looking into this.

    -- Matt

       
Sign In or Register to comment.