Wednesday, June 3, 2020

#1 2017-02-22 07:48:16 am

Registered: 2017-02-22
Posts: 1

Change folder in "open file" dialog

I've googled some keywords but most talked about the "open file" dialog by the script. My target is the Osirix software, which I have to click the menu item "Open Database Folder" then choose a specific folder according to date.

So this is not the traditional "open dialog and wait for user selection". I need to do something inside the dialog, including getting folder names and choosing the right folder. Anyone can give me some hints about this manipulation? smile



#2 2017-02-22 09:54:46 am

From:: Belgium
Registered: 2007-07-02
Posts: 86

Re: Change folder in "open file" dialog

Hi! Don't have Osirix. This said couldn't you use System Events to type text or path a bit like this:


   tell application "System Events"
       tell application process "Osirix"
           set frontmost to true
           click menu item "[Whatever menu item]" of menu "File" of menu bar item "File" of menu bar 1 -- or sth like that, make your own tests
           delay 1 -- if any delay is needed
           keystroke "d" using {shift down, command down} -- this would take you to the Desktop
           delay 1
           set {x, y} to position of button "[Whatever button name]" of window "[Whatever title]"
           click at {x + 10, y + 10}
           delay 1
           keystroke folder_name -- a variable you'd defined earlier in the script
           keystroke return -- if ever needed, just adapt to match your needs
           delay 2
       end tell
   end tell
on error the error_message number the error_number
   set the error_text to "Error: " & the error_number & ". " & the error_message
   display dialog the error_text buttons {"OK"} default button 1
   return the error_text
end try

Sorry to still code like an old boy.



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)