4 Replies Latest reply on Oct 28, 2009 8:41 PM by kendall_hiles

    Question about popup menus

    wes_cessnun

      i am currently automating our DXF procedures for exporting files for mechanical team. I have every thing working except for the popup menu when a file exist.

       

      Example of menu

       

      "Expedition PCB" is the name of the popup.

       

      vbQuestion, The File "C:\Temp\Test.dxf" exists. Overwrite this file?

       

      Yes Button  No Button

       

      This is the Piece of code that works and then not able to get rid of the Popup menu without using the mouse or pressing enter on the keyboard. I have tried to use sendkey "~" but it does not work as well

       

      pcbAppObj.Gui.ProcessCommand("File->Export->DXF...")


      Dim dlgObj

      Dim OKButton

      Dim YesButton


      Set dlgObj = pcbAppObj.Gui.FindDialog("DXF Export")


      Set OKButton = dlgObj.FindButton("OK")


      Call OKButton.Click

       

      'code that doesn't work

       

      pcbAppObj.Gui.ProcessCommand("Expedition PCB", True)

      Set pcbYesapp = pcbAppObj.Gui.FindDialog("Expedition PCB")

       

      Set YesButton = pcbYesapp.FindButton("Yes")

      YesButton.Click

       

       

      How do I get the menu to say Yes and go away. I have tried many different things but none work. It seems like my script stops after Okbutton and doen't move forward until I manually  click the yes or no button.

        • 1. Re: Question about popup menus
          wes_cessnun

          I have noticed that Print Setup and Print are the same way as the example below. When I run a script to try and automate the Print setup menu I get the menu to come up but am unable to do anything in it. I also can not  use sendkeys to find a menu does anyone know how to find  Print setup through sendkeys? Here is the code I am trying to use to do this.

           

          '(Declarations)
          Option Explicit


          Scripting.AddTypeLibrary("MGCPCB.FablinkXEApplication")

          Dim app
          Dim doc

           

          Set app = GetObject(,"MGCPCB.FablinkXEApplication")
          Set doc = app.ActiveDocument

           

          'Main Loop
          '-----------------------------------------------------------------------------------

           

          Call ValidateServer(doc)

           

          Call Print_Setup

           

          '-----------------------------------------------------------------------------------

           

          Sub Print_Setup()

           

             Dim oWShell

             Set oWShell = CreateObject("wscript.shell")


              oWShell.SendKeys "%F"

              scripting.sleep 500

              oWShell.SendKeys "%r"

           

          End Sub

           

           

          '-----------------------------------------------------------------------------------


          Private Function ValidateServer(doc)
              Dim key, licenseServer, licenseToken

              ' Ask Expedition’s document for the key
              key = doc.Validate(0)

              ' Get license server
              Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")

              ' Ask the license server for the license token
              licenseToken = licenseServer.GetToken(key)

              ' Release license server
              Set licenseServer = Nothing

              ' Turn off error messages.  Validate may fail if the token is incorrect
              On Error Resume Next
              Err.Clear

              ' Ask the document to validate the license token
              doc.Validate(licenseToken)
              If Err Then
                  ValidateServer = 0  
              Else
                  ValidateServer = 1
              End If
          End Function

           

          I am able to Bring the Menu Print Setup by deleting the above Print_Setup() code and adding the code below into the Print_Setup() subroutine.

           

          Sub Print_Setup()

              Dim ret
              ret = app.Gui.ProcessCommand("File->Print Preview")

          End Sub

           

          But not able to do anything in the menu after calling this function because the script stops until you say ok or close the Print setup bar manually. Anyone know how make this menu active in a script and change settings?

          • 2. Re: Question about popup menus
            kendall_hiles

            What are you trying to do with this command?  i.e. what do you expect to happen when it is run?

             

            pcbAppObj.Gui.ProcessCommand("Expedition PCB", True)

            • 3. Re: Question about popup menus
              kendall_hiles

              Never mind, I tried it and saw the box.  Add this to your script

               

              pcbApp.Gui.SuppressTrivialDialogs = True

              • 4. Re: Question about popup menus
                kendall_hiles

                For the Printer, why not just call

                 

                    app.Gui.ProcessCommand ("Print Setup")