Hello,
Here is a new plugin for you. Lately, the insufficient support for desktop file browsing was a few times a topic here in the forum.
Now I offer you a plugin, that treats exactly this problem. I hope you can use it.
Here is the command list:
String GetFirstSystemDrive()
String GetNextSystemDrive()
String GetSystemDriveType(String Drive)
String GetSystemDriveInformation(String Drive, Integer InfoType)
InfoType(0) = Serial
InfoType(1) = Component Length (max number of chars between backslashes)
InfoType(2) = File-System (FAT, NTFS, ...)
InfoType(3) = Volume Name
Integer CreateFolder(String FolderName)
String GetWorkingDirectory()
Integer DeleteFolder(String FolderName)
Integer SetWorkingDirectory(String Path)
Integer FileCopy(String SourceFile, String DestFile, Integer Overwrite)
Overwrite(0) = Exists file will not overwritten.
Overwrite(1) = Exists file will overwritten.
Integer FileMove(String SourceFile, String DestFile)
Integer FolderMove(String SourceFolder, DestFolder)
Integer FileDelete(String FileName)
String GetFirstFile(String FolderFile)
String GetNextFile()
Integer GetCurrentFileAttributes()
Integer GetFileAttributes(String FileName)
String GetCurrentFileCreationDate(Integer SeperatorChar)
String GetCurrentFileCreationTime(Integer SeperatorChar)
String GetCurrentFileLastAccessDate(Integer SeperatorChar)
String GetCurrentFileLastAccessTime(Integer SeperatorChar)
String GetCurrentFileLastWriteDate(Integer SeperatorChar)
String GetCurrentFileLastWriteTime(Integer SeperatorChar)
Integer GetCurrentFileSizeLow()
Integer GetCurrentFileSizeHigh()
String GetCurrentFileSizeAsHexString(Integer Long) ('Long' means SizeHigh:SizeLow)
String GetCurrentFileSizeAsString(Integer Long) ('Long' means SizeHigh:SizeLow)
String GetFullPathFromFile(String FileName)
String GetFirstFolder(String Path)
String GetNextFolder()
The commands starting with 'GetCurrentFile ...'. Refer to the file obtained with GetFirstFile and GetNextFile.
[UPDATE:27-04-2017]
New Function ChooseFileDialog
New Function SaveAsDialog
New Function MessageBox
Function in detail:
String ChooseFileDialog(String Title, String Filter, Integer MultiSelect)
If you enable multi select, and select multiple files. This returns a string containing the selected directory and then all files in it. All are separated by the pipe ('|').
String SaveAsDialog(String Title, String Filter)
Integer MessageBox(String Message, String Title)
Integer MessageBox(String Message, String Title, Integer Buttons)
Integer MessageBox(String Message, String Title, Integer Buttons, Integer Icon)
Integer MessageBox(String Message, String Title, Integer Buttons, Integer Icon, Integer DefaultButton)
Buttons(0) = The message box contains one push button: OK.
Buttons(1) = The message box contains two push buttons: OK and Cancel.
Buttons(2) = The message box contains three push buttons: Abort, Retry, and Ignore.
Buttons(3) = The message box contains two push buttons: Yes, No & Cancel.
Buttons(4) = The message box contains two push buttons: Yes and No.
Buttons(5) = The message box contains two push buttons: Retry and Cancel.
Buttons(6) = The message box contains three push buttons: Cancel, Try Again, Continue. Use this message box type instead of (2) Abort, Retry, and Ignore.
Icon(16) = A stop-sign icon appears in the message box.
Icon(32) = A question-mark icon appears in the message box.
Icon(48) = An exclamation-point icon appears in the message box.
Icon(64) = An icon consisting of a lowercase letter i in a circle appears in the message box.
DefaultButton = Set the button to default. 0, 1 or 2 (e.g. 0=Cancel, 1=Try Again, 2=Continue)
return value can be ...
0 = unexpected error.
1 = The OK button was selected.
2 = The Cancel button was selected.
3 = The Abort button was selected.
4 = The Retry button was selected.
5 = The Ignore button was selected.
6 = The Yes button was selected.
7 = The No button was selected.
10 = The Try Again button was selected.
11 = The Continue button was selected.
[UPDATE:06-05-2017]
New Function - String GetCL()
[UPDATE:16-10-2018]
Added 64Bit DLL
[UPDATE:02-03-2019]
Added New Function - Void SetDialogPosition(Integer PosX, Integer PosY) -> Set the Position for ChooseFileDialog and SaveAsDialog
Added New Function - Void SetInitialDir(String Directory) -> Set the Initial Directory for ChooseFileDialog and SaveAsDialog
[UPDATE:07-04-2019]
Added New Function - Void SetWindowStyle(Integer Style) -> Set the Style of AppGameKit output window ->
StyleFlags
Added New Function - Void SetWindowExStyle(Integer ExStyle) -> Set the ExStyle of AppGameKit output window ->
ExStyleFlags
[UPDATE:03-07-2019]
Added New Function - Void OpenDateTimePicker() -> Open a modal DateTimePicker dialog
Added New Function - Integer GetDateYear() -> returns the selected year.
Added New Function - Integer GetDateMonth() -> returns the selected month.
Added New Function - Integer GetDateDay() -> returns the selected day.
Added New Function - Integer GetDateDayOfWeek() -> returns the selected day of week. 0 = Sunday, 1 = Monday ...
Added New Function - Integer GetDateHour() -> returns the selected hour.
Added New Function - Integer GetDateMinute() -> returns the selected minute.
Added New Function - Integer GetDateSecond() -> returns the selected second.
Added New Function - String GetDateString(String format) -> returns the selected date as a formated string
d = Day of Month without leading zero.
dd = Day of Month with leading zero.
ddd = Three chars day of week.
dddd= Full name of week.
M = Month as digits without leading zero.
MM = Month as digits with leading zero.
MMM = Three chars month name.
MMMM= Full name of month.
Y = Years last two gigits without leading zero.
YY = Years last two gigits with leading zero.
YYYY= Four digit Year.
Added New Function - String GetTimeString(String format) -> returns the selected time as a formated string
h = Hours - 12 hour clock without leading zero.
hh = Hours - 12 hour clock with leading zero.
H = Hours - 24 hour clock without leading zero.
HH = Hours - 12 hour clock with leading zero.
m = Minutes without leading zero.
mm = Minutes with leading zero.
s = Seconds without leading zero.
ss = Seconds with leading zero.
[UPDATE:06-07-2019]
Change OpenDateTimePicker - returns now 0 - clicking on cancel, 1- clicking on ok.
[UPDATE:19-10-2019]
Change GetCL - now returns a pipe ( | ) seperated string. Now you can access the arguments via the string functions. GetStringToken(comandline$, "|", token_number)
[UPDATE:01-12-2019]
Added New Function - Void SetWindowPosition(Integer posX, Integer posY, Integer zOrder, Integer width, Integer height, Integer flags) ->
wraps SetWindowPos function to set the AGK-Window.
posX, posY ->
set the position of the AGK-Window
width, height ->
set the size of the AGK-Window. Please let it at 0 (zero). I dont know what happens if not. Use instead Agk-Commands.
zOrder, flags ->
refer ms documentation of function SetWindowPos for more information. (Parameters hWndInsertAfter and uFlags)
Added New Function - String ChooseFolderDialog(String title, String initialDir) -> A Dialog to select a folder.
Fixed - The ChooseFileDialog filter sometimes has an unusual behavior.
[UPDATE:14-10-2020]
SetDialogPosition now set the position relative to its main window.
[UPDATE:29-11-2020]
ChooseFileDialog is now resizeable.
[UPDATE:16-02-2021]
Functions GetCursorX(Mode) and GetCursorY(Mode) added
Mode = 0 -> Mouse coordinates absolut.
Mode = 1 -> Mouse coordinate relative to client area off the active window.
Functions GetWindowX() and GetWindowY() added to receive the Window Position (top/left corner of the window)
Added GetMouseButtons() function. This receives the state of the mouse buttons.
Bit 1 (1) = Left Button
Bit 2 (2) = Right Button
Bit 3 (4) = Middle Button
Bit 4 (8) = Extra Button 1
Bit 5 (16) = Extra Button 2
Includes a tag definition file.
[UPDATE:07-06-2021]
Added OpenConsole() - Opens a console window.
Added ConsoleWrite(String Text) - Writes a message in the console window.
[UPDATE:07-06-2021]
Added ConsoleCommand(String Cmd) - Executes a command and displays it in the open console.
[UPDATE:20-06-2021]
Added OpenColorDialog(Integer Color) - Opens a colour dialogue and returns the defined colour as an integer.
Added GetCustomColor(Integer ColorNum) - Returns the custom colour specified in ColorNum. ColorNum must be between 0 and 15.
Added SetCustomColor(Integer ColorNum, Integer Color) - Sets a custom colour to the specified value. ColorNum must be between 0 and 15.
[UPDATE:24-06-2021]
GetWindowMessage()
This returns the last window message.
You can find the messages here.
This is only an overview. For descriptions of the individual messages, simply search for the respective message on the MS page.
GetHitTestMessage()
This returns the value after a WM_NCHITTEST.
The values and description can be found here.
GetWindowParamL()
GetWindowParamW()
Here you get the corresponding wParam and lParam values that are transferred together with the message.
Not all of them can be used.
[UPDATE:30-07-2021]
Init() -
returns 1 on successful initialisation otherwise 0.
Some functions do not work correctly under AgkStudio. For example, GetWindowX/Y. Now it is fixed.
[UPDATE:03-08-2021]
RegExMatch(String str, String regex)
Compares the text (str) with the regular expression (regex). If it matches, 1 is returned, otherwise 0.
RegExSearch(String str, String regex)
Searches the text (str) for regex and returns all found words in a JSON string array.
RegExSearchPosition(String str, String regex)
The same as before, but in this case it returns the position and length of the strings found in a JSON array.
RegExReplace(String str, String regex, String replace)
All occurrences of the regex in the string str are replaced with replace.
RegExReplace(String str, String regex, String replace, Integer start, Integer end)
Like the previous function, but here you can specify a range within the text that will be searched and replaced.
If start < 0, the beginning of the text is automatically set.
If end < 0, the end of the text is automatically set.
[UPDATE:17-02-2022]
BrowseFolderDialogCompletely rewritten. Now uses new Windows design. Position and size are automatically managed by Windows. Size and position can be changed after opening the dialogue Windows remembers this.
SaveAsDialogCompletely rewritten. Now uses new Windows design. Position and size are automatically managed by Windows. Size and position can be changed after opening the dialogue Windows remembers this.
ChooseFileDialogCompletely rewritten. Now uses new Windows design. Position and size are automatically managed by Windows. Size and position can be changed after opening the dialogue Windows remembers this. The return string is dynamically allocated. So it is now possible to get a longer return string than 780 characters.
[UPDATE:03-09-2022]
Integer EnumSystemSounds() Enumerates all SystemSounds. Returns the number of sounds. Names and files can be read later using GetSystemSoundName and GetSystemSoundFile.
String GetSystemSoundName(Integer Index) Reads out the name of the system sound. Index is 0 based and must be between 0 and what EnumSystemSounds returns -1.
String GetSystemSoundFile(Integer Index) Reads out the file name of the system sound. Index is 0 based and must be between 0 and what EnumSystemSounds returns -1.
void PlaySystemSound(String Name, Integer Mode) Play the specified sound. It can be either a name from the system or a file name. Then the file name must also contain the drive and path. If no sound is found none will be played. Mode can be 1 for play async 2 for file name or 3 for combined.
[UPDATE:11-09-2022]
-
OpenColorDialog returns 0 or 1 (zero, one) selected color can be retrieved with
GetChosenColor
-
GetChosenColor() returns the selected color from OpenColorDialog.
[UPDATE:11-09-2022]
-
GetDriveSpace(Path as String, Type as Integer, Mode as Integer)
This command returns the memory of the medium to which the path points.
Parameter Path - The path to the medium to be checked.
Parameter Type - can be 0,1 or 2.
0 - returns the entire memory of the medium.
1 - returns the total free memory.
2 - returns the memory available from the calling user. Is usually as much as Type 1.
Parameter Mode - can be 0,1,2 or 3.
0 - Shows the requested memory in bytes.
1 - Displays the requested memory in KBytes.
2 - Displays the requested memory in MBytes.
3 - Displays the requested memory in GBytes.
Note that if the value returned is greater than a 32 bit number, there will be a value overflow and the function will return a value less than 0.
In this case, the memory should be retrieved in kilo, mega or giga bytes.
If the path does not exist or the parameters Type or Mode are invalid, a -1 is returned.
-
GetDriveMetric(Path as String, Type as Integer)
This command gets the size and number of sectors and clusters of the media.
Parameter Path - The path to the medium to be checked.
Parameter Type - can be 0,1,2 or 3.
0 - returns the total number of clusters.
1 - returns the number of clusters that are still free.
2 - returns the number of sectors per cluster.
3 - returns the size in bytes per sector.
The free memory could be calculated here with - number of free clusters x sectors per cluster x bytes per sector.
[UPDATE:27-04-2023]
-
EnumDesktopModes()
Before the other DesktopModes commands can be executed,
EnumDesktopModes must be done at least once.
This lists all resolution modes internally.
However, this is limited to 32 bit colour depth.
These can be retrieved with the commands GetDesktopModeWidth,GetDesktopModeHeight,GetDesktopModeFrequency and GetDesktopModeJSON.
The return value is the number of modes that were found.
All following commands can only be called if
EnumDesktopModes has been called at least once before.
-
GetDesktopModeWidth(Integer mode)
Returns the width in pixels of the resolution from the specified mode.
-
GetDesktopModeHeight(Integer mode)
Returns the height in pixels of the resolution of the specified mode.
-
GetDesktopModeFrequency(Integer mode)
Returns the screen refresh rate of the resolution from the specified mode.
-
GetDesktopModeJSON(Integer mode)
Returns the width, height, bits per pixel and screen refresh rate in the form of a JSON string.
-
GetDesktopMode(Integer width, Integer height)
This command is used to find out which mode is best suited to the specified resolution.
-
int GetDesktopMode()
Returns the mode that matches the current resolution set.
-
void SetDesktopMode(Integer mode)
Sets the specified mode. The desktop resolution is set according to the mode.
-
RestoreDesktopMode()
Restores the desktop resolution according to the registry.
[UPDATE:27-04-2023]
-
ChooseFileDialogEx(String Title, String Filter, Integer Flags)
Same as ChooseFileDialog only by the flags parameter the behavior of the dialog box can be set better.
Possible values are:
#Constant FOS_OVERWRITEPROMPT = 0x2
#Constant FOS_STRICTFILETYPES = 0x4
#Constant FOS_NOCHANGEDIR = 0x8
#Constant FOS_PICKFOLDERS = 0x20
#Constant FOS_FORCEFILESYSTEM = 0x40
#Constant FOS_ALLNONSTORAGEITEMS = 0x80
#Constant FOS_NOVALIDATE = 0x100
#Constant FOS_ALLOWMULTISELECT = 0x200
#Constant FOS_PATHMUSTEXIST = 0x800
#Constant FOS_FILEMUSTEXIST = 0x1000
#Constant FOS_CREATEPROMPT = 0x2000
#Constant FOS_SHAREAWARE = 0x4000
#Constant FOS_NOREADONLYRETURN = 0x8000
#Constant FOS_NOTESTFILECREATE = 0x10000
#Constant FOS_HIDEMRUPLACES = 0x20000
#Constant FOS_HIDEPINNEDPLACES = 0x40000
#Constant FOS_NODEREFERENCELINKS = 0x100000
#Constant FOS_OKBUTTONNEEDSINTERACTION = 0x200000
#Constant FOS_DONTADDTORECENT = 0x2000000
#Constant FOS_FORCESHOWHIDDEN = 0x10000000
#Constant FOS_DEFAULTNOMINIMODE = 0x20000000
#Constant FOS_FORCEPREVIEWPANEON = 0x40000000
#Constant FOS_SUPPORTSTREAMABLEITEMS = 0x80000000
See description on MS page.
[UPDATE:27-04-2023]
-
SetInitialDir works again. To get the last selected directory again just pass an empty string to
SetInitialDir.
And some code snippets.
System-Drive-Enumeration:
type SystemDrive
Volume as String
VolName as String
Serial as String
ComLength as Integer
FileSystem as String
endtype
function GetDrives(drvList Ref as SystemDrive[])
drive as SystemDrive
drive.Volume = FileExplore.GetFirstSystemDrive()
drive.Serial = FileExplore.GetSystemDriveInformation(drive.Volume, 0)
drive.ComLength = Val(FileExplore.GetSystemDriveInformation(drive.Volume, 1))
drive.FileSystem = FileExplore.GetSystemDriveInformation(drive.Volume, 2)
drive.VolName = FileExplore.GetSystemDriveInformation(drive.Volume, 3)
while(len(drive.Volume) > 0)
drvList.Insert(drive)
drive.Volume = FileExplore.GetNextSystemDrive()
drive.Serial = FileExplore.GetSystemDriveInformation(drive.Volume, 0)
drive.ComLength = Val(FileExplore.GetSystemDriveInformation(drive.Volume, 1))
drive.FileSystem = FileExplore.GetSystemDriveInformation(drive.Volume, 2)
drive.VolName = FileExplore.GetSystemDriveInformation(drive.Volume, 3)
endwhile
endfunction drvList.length()
Folder Enumeration:
function GetFolders(fldList Ref as String[])
folder as String
folder = FileExplore.GetFirstFolder("Y:\*.*")
while(len(folder) > 0)
fldList.Insert(folder)
folder = FileExplore.GetNextFolder()
endwhile
endfunction fldList.length()
File Enumeration:
function GetFiles(fldList Ref as String[])
file as String
file = FileExplore.GetFirstFile("Y:\*.*")
while(len(file) > 0)
fldList.Insert(file)
file = FileExplore.GetNextFile()
endwhile
endfunction fldList.length()
Please tell me if you find bugs or have some suggestions.
And if you feel the urgent need to support this project then you are welcome to donate a few coins.