The following AppleScript/Objective-C script shows the programmatic usage of an NSOpenPanel that applications use to open that dialog. In this case, and unlike Apple, I have set the correct frame size for a normal window.
Press control+command+R to run the following code after it has been copied, and pasted into the Script Editor.
use framework "AppKit"
use framework "Foundation"
use framework "OSAKit"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions
property NSThread : a reference to current application's NSThread
property NSString : a reference to current application's NSString
property NSURL : a reference to current application's NSURL
property NSArray : a reference to current application's NSArray
property NSOpenPanel : a reference to current application's NSOpenPanel
property HFS : "HFS"
property POSIX : "POSIX"
property default_location : "~/Desktop"
property file_types : {"com.adobe.pdf"}
if not (current application's NSThread's isMainThread()) as boolean then
display alert "This script must be run from the main thread using cntrl+cmd+R." buttons {"Cancel"} as critical
error number -128
end if
# choose POSIX, or HFS for returned file format
set openstuff to files_folders(HFS, default_location)
display dialog openstuff with title "Selected Stuff"
return
on files_folders(afmt, this_location)
set this_location to POSIX path of this_location
set this_location to ((NSString's stringWithString:this_location)'s stringByStandardizingPath()) as text
set z to NSURL's URLWithString:this_location
set these_types to current application's NSArray's array()
set oPanel to NSOpenPanel's openPanel()
tell oPanel
its setFloatingPanel:true -- over the top of all other windows
its setDirectoryURL:z
its setFrame:(current application's NSMakeRect(0, 0, 830, 580)) display:yes
its setTitle:"Open"
its setMessage:"Select additional file(s) and/or folder(s) with ⌘"
its setPrompt:"Open"
its setAllowsMultipleSelection:true
-- its setAllowedFileTypes:types
its setAllowedContentTypes:these_types
its setCanChooseFiles:true
its setCanChooseDirectories:true
its setTreatsFilePackagesAsDirectories:false
end tell
set returnCode to oPanel's runModal()
if returnCode is (current application's NSFileHandlingPanelCancelButton) then
error number -128
end if
-- set the POSIXpaths to (oPanel's |URL|()'s valueForKey:"path") as list
if afmt is "HFS" then
set the HFSpaths to oPanel's URLs's valueForKey:"_osa_hfsPath"
set txtStr to HFSpaths's componentsJoinedByString:return
else if afmt is "POSIX" then
set txtStr to ((oPanel's filenames)'s componentsJoinedByString:return) as text
else
-- neither is not an option, force user cancel
error number -128
end if
return txtStr as text
end files_folders