Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File/folder dialog extender
Copy      Help
;;within a file/folder dialog, display a menu of folders, and navigate
;;the dialog to the selected folder

;;first handle folder browse dialog
int browse = win("Browse For Folder" "#32770")
if browse = win
,int edit = child("" "Edit" browse)
,;;display menu to prompt user for folder to open
,if (mac("Folders"))
,,;;extract out selected folder name
,,str fld
,,GetLastSelectedMenuItem 0 &fld 0
,,fld.get(fld 5 fld.len-6)
,,;;set hidden window to folder and OK dialog
,,but 1 browse
;;retrieve the file dialog edit control and its value
int office = 0
int vs = 0

;;standard file dialogs
Acc edt=acc("File name:" "TEXT" win "Edit" "" 0x1801 0x0 0x20000040)
,vs = 1
,;;Visual Studio 2003/2005
,edt=acc("File name:" "TEXT" win "bosa_sdm_Mso96" "" 0x1801 0x0 0x20000040)
,,vs = 0
,,office = 1
,,;;Office 2003
,,edt=acc("File name:" "TEXT" win "bosa_sdm_Microsoft Office Word 11.0" "" 0x1801 0x0 0x20000040)
,,,;;WinZip extract
,,,office = 0
,,,edt = acc("Extract to:" "TEXT" win "Edit" "" 0x1801 0x0 0x20000040)

;;retrieve the current edit value
str s = edt.Value

;;display menu to prompt user for folder to open
if (mac("Folders"))
,;;extract out selected folder name
,str f
,GetLastSelectedMenuItem 0 &f 0
,f.get(f 5 f.len-6)
,;out f
,;;update edit value to specified folder
,,;;SetValue doesn't work for Office-style dialogs,
,,;;select and insert text instead
,,key (f)
,,key Y
,;;click OK button to navigate to that folder for regular file dialogs
,if !office
,,Acc ok=acc("" "PUSHBUTTON" win "Button" "" 0x1001)
,,,ok=acc("Open" "PUSHBUTTON" win "bosa_sdm_Mso96" "" 0x1001)
,;;restore original edit control value
,,key (s)

,;;and set focus to it
,key An

,;;dismiss VS file dialog drop-down
,if vs
,,key AD

Folders is expected to be a menu like

/pos text /dontrun /noedit
P&rogram Files :key "c:\program files"

I trigger FileDialog on Ctrl+; to get a list of common folders within any file/folder dialog and when navigate the dialog to the selected folder with a single keystroke.

I'm fairly new to QM, so please let me know of any improvements.

Forum Jump:

Users browsing this thread: 1 Guest(s)