6 Replies Latest reply on Jun 5, 2012 2:46 AM by Muppet Mark

    applescript create choose folder dialog with checkbox

    restless_mind Level 1

      Hi,

       

      can anybody tell me if it's possible to create an applescript choose folder dialog with a checkbox similar to the dialog window you get when you Place? I know how to choose a folder using:

       

      tell application "Adobe InDesign CS5"

                set myFolder to choose folder

      end tell

       

      and I know I can use a checkbox like this:

       

      tell application "Adobe InDesign CS5"

                set myDialog to make dialog with properties {name:"Folder to process"}

                tell myDialog

                          tell (make dialog column)

                                    set myRectanglesCheckbox to make checkbox control with properties {static label:"Include Sub folders", checked state:true}

       

                          end tell

                end tell

                set myResult to show myDialog

      end tell

       

      But is it possible to both of theses options together in one dialog window.

       

      Any help would be greatfully appreciated.

       

      Thanks,

      Nik

        • 1. Re: applescript create choose folder dialog with checkbox
          Muppet Mark Level 5

          Im not sure but think not… Mainly because the choose folder command belongs to standard additions ( does not need your tell app block btw ) and your check box is InDesign's own dialog control… I've not 'actually' used ID's dialogs with AppleScript so I may have overlooked something… You may be able to add choose folder to an event call back but I don't think that will give you the dialog you envisage…

          1 person found this helpful
          • 2. Re: applescript create choose folder dialog with checkbox
            restless_mind Level 1

            Hi Mark,

             

            Thanks for the response and that seems to make sence as I can't seem to find anything to do with choosing in the make dialog properties. I only included the choose folder in the tell block as I wanted the choose to come from within InDesign. I wander, if this is not possible with applescript then maybe it's possible to do this with a javascript that runs from within applescript?

             

            Thanks again for your time,

            Nik

            • 3. Re: applescript create choose folder dialog with checkbox
              Muppet Mark Level 5

              That could become convoluted very quickly… UI call backs and events is trouble enough in any language… passing betwixt I would not… You should maybe look at AppleScipt Studio for constructing your interface standard additions is exactly that… ExtendScript has the option of scriptUI which is pretty nice… but do look at the other route first…

              • 4. Re: applescript create choose folder dialog with checkbox
                restless_mind Level 1

                Points taken Mark, I understand what you're saying.There's always a workaround even if not as glamorous as what I intended.

                 

                Thanks again for your time,

                Nik

                • 5. Re: applescript create choose folder dialog with checkbox
                  sstanleyau Level 4

                  Mark said AppleScript Studio, but I suspect he means AppleScriptObjC -- Studio was deprecated in OS X 10.6. What you're after is known as a save panel with an accessory view.

                   

                  Actually, as long as you don't expect the checkbox to change anything while the dialog is showing you can get what you want without too much pain using ASObjC Runner:

                   

                  script openPlus

                    -- make a checkbox

                            set theCheckbox to current application's NSButton's alloc()'s initWithFrame_({{0, 8}, {200, 16}})

                    theCheckbox's setButtonType_(current application's NSSwitchButton)

                            theCheckbox's setTitle_("Include sub folders")

                    -- make a view and add the checkbox to it

                            set theView to current application's NSView's alloc()'s initWithFrame_({{0, 0}, {200, 32}})

                    theView's |addSubview_|(theCheckbox)

                    -- make an open panel

                            set thePanel to current application's NSOpenPanel's makeOpenAt_types_(path to home folder, {""})

                            thePanel's setMessage_("Folder to process")

                    thePanel's setCanChooseDirectories_(true)

                    thePanel's setCanChooseFiles_(false)

                    -- add the view to the panel

                    thePanel's setAccessoryView_(theView)

                    -- show and return results

                            tell thePanel to set theResult to showModal()

                            return {theResult, theCheckbox's state()}

                  end script

                   

                  tell application id "au.com.myriad-com.ASObjC-Runner" -- ASObjC Runner.app

                            set {thePath, checkBoxState} to run the script {openPlus} with response

                  end tell

                  if thePath is not missing value then -- missing value means Cancel

                    -- do your stuff

                  end if

                   

                  Message was edited by: Shane Stanley (added solution)

                  • 6. Re: applescript create choose folder dialog with checkbox
                    Muppet Mark Level 5

                    Shane, thanks I was aware of my out of touch terms…