FileSelectFile filter Topic is solved
FileSelectFile filter
Is it possible to display more options (lines), in the FileSelectFile dialog's "files of type" drop-down list?
Re: FileSelectFile filter
The documentation shows how to include multiple file types.
Re: FileSelectFile filter
Could u give me an example, pls
Re: FileSelectFile filter
Sure, go to https://autohotkey.com/docs/commands/FileSelectFile.htm and look at it.
Re: FileSelectFile filter
If I understand your question correctly, you would have to use a DllCall for this, the build-in FileSelectFile does not support it.mas wrote:Is it possible to display more options (lines), in the FileSelectFile dialog's "files of type" drop-down list?
example: (original code from majkinator, edited by me)
Code: Select all
If (A_PtrSize = 8) {
MsgBox, 64-bit not supported. Use 32-bit AHK.
ExitApp
}
Filter := "AHK and Texts (*.ahk;*.txt)|AutoHotkeys (*.ahk)|Texts (*.txt)"
MsgBox, % SelectFile(0, "MultiLine Filter", Filter, "", A_ScriptFullPath, "", "ALLOWMULTISELECT")
;-------------------------------------------------------------------------------
SelectFile(hOwner, Title := "", Filter := "", DefaultFilter := ""
, Root := "", DefaultExt := "", Flags := "FILEMUSTEXIST HIDEREADONLY") {
;-------------------------------------------------------------------------------
static OFN_S := 0
, OFN_READONLY := 0x1
, OFN_OVERWRITEPROMPT := 0x2
, OFN_HIDEREADONLY := 0x4
, OFN_NOCHANGEDIR := 0x8
, OFN_SHOWHELP := 0x10
, OFN_NOVALIDATE := 0x100
, OFN_ALLOWMULTISELECT := 0x200
, OFN_EXTENSIONDIFFERENT := 0x400
, OFN_PATHMUSTEXIST := 0x800
, OFN_FILEMUSTEXIST := 0x1000
, OFN_CREATEPROMPT := 0x2000
, OFN_NOREADONLYRETURN := 0x8000
, OFN_NOTESTFILECREATE := 0x10000
, OFN_ENABLEXPLORER := 0x80000
, OFN_NODEREFERENCELINKS := 0x100000
, OFN_DONTADDTORECENT := 0x2000000
, OFN_FORCESHOWHIDDEN := 0x10000000
If (Filter = "") ; default string for filter
Filter := "All Files (*.*)"
SplitPath, Root, rootFN, rootDir
hFlags := 0x80000 ; always set OFN_ENABLEXPLORER
Loop, Parse, Flags, %A_TAB%%A_SPACE%, %A_TAB%%A_SPACE%
If (A_LoopField != "")
hFlags |= OFN_%A_LoopField%
If (hFlags = "")
Return, "Some of the flags are invalid: " Flags
VarSetCapacity(FN, 0XFFFF)
VarSetCapacity(lpstrFilter, 4 * StrLen(Filter), 0)
If (rootFN != "")
DllCall("RtlMoveMemory", "Str", FN, "Str", rootFN
, "UInt", (StrLen(rootFN) + 1) * (A_IsUnicode ? 2 : 1))
; contruct FilterText separated by zero
delta := 0 ; used by Loop as offset
loop, Parse, Filter, |
{
desc := A_LoopField
ext := SubStr(A_LoopField, InStr(A_LoopField, "(") + 1, -1)
LenD := StrLen(A_LoopField) + 1
LenE := StrLen(ext) + 1 ; including zero
If A_IsUnicode
LenD *= 2, LenE *= 2
DllCall("RtlMoveMemory", "Uint", &lpstrFilter + delta, "Str", desc, "Uint", LenD)
DllCall("RtlMoveMemory", "Uint", &lpstrFilter + delta + LenD, "Str", ext, "int", LenE)
delta += LenD + LenE
}
; OPENFILENAME structure
VarSetCapacity(OFN, 90, 0)
NumPut(76, OFN, 0, "UInt") ; Length of Structure
NumPut(hGui, OFN, 4, "UInt") ; HWND
NumPut(&lpstrFilter, OFN, 12, "UInt") ; Pointer to FilterStruc
NumPut(DefaultFilter, OFN, 24, "UInt") ; DefaultFilter Pair
NumPut(&FN, OFN, 28, "UInt") ; lpstrFile / InitialisationFileName
NumPut(0xffff, OFN, 32, "UInt") ; MaxFile / lpstrFile length
NumPut(&rootDir, OFN, 44, "UInt") ; StartDir
NumPut(&Title, OFN, 48, "UInt") ; DlgTitle
NumPut(hFlags, OFN, 52, "UInt") ; Flags
NumPut(&DefaultExt, OFN, 60, "UInt") ; DefaultExt
Result := SubStr(Flags, 1, 1) = "S"
? DllCall("comdlg32\GetSaveFileName" (A_IsUnicode ? "W" : "A"), "UInt", &OFN )
: DllCall("comdlg32\GetOpenFileName" (A_IsUnicode ? "W" : "A"), "UInt", &OFN )
If (Result = 0)
Return
Adr := &FN
f := d := DllCall("MulDiv", "Int", Adr, "Int",1, "Int",1, "str")
Result := ""
If StrLen(d) != 3 ; windows adds "\" when in rootdir, doesn't do that otherwise
d .= "\"
If MultiSelect := InStr(Flags, "ALLOWMULTISELECT")
Loop
If f := DllCall("MulDiv", "Int", Adr += (StrLen(f)+1)*(A_IsUnicode ? 2 : 1), "Int",1, "Int",1, "str")
Result .= d f "`n"
Else {
IfEqual, A_Index, 1, SetEnv, Result, %d% ; if user selects only 1 file with multiselect flag, windows ignores this flag
Break
}
Return, MultiSelect ? SubStr(Result, 1, -1) : SubStr(d, 1, -1)
}
Re: FileSelectFile filter
Thank u wolf_II.
I think it's what I need.
I have to see how to adapt the code for x64, because I am on x64 version/os...
Thank u again
I think it's what I need.
I have to see how to adapt the code for x64, because I am on x64 version/os...
Thank u again
Re: FileSelectFile filter
In case you want to see, here is my current progress of my attempt to make it work on AHK 64-bit.
It contains the attempt to rewrite the OPENFILENAME structure to allow 32/64 bitness. But it still gives me GetLastError = 87 with 64 bit AHK.
I will not be able to make more progress at present, so you can use it to start your adaptation if you like.
It contains the attempt to rewrite the OPENFILENAME structure to allow 32/64 bitness. But it still gives me GetLastError = 87 with 64 bit AHK.
I will not be able to make more progress at present, so you can use it to start your adaptation if you like.
Code: Select all
hOwner := 0 ; handle of owner
Title := "MultiLine Filter" ; window title
; pipe-delimited list of lines that go into drop-down box
Filter := "AHK and Texts (*.ahk; *.txt)|AutoHotkeys (*.ahk)|Texts (*.txt)"
Index := 2 ; select this line in drop-down box
Select := A_ScriptFullPath ; pre-select this file
DefExt := "" ; add this extension if none is given
Flags := "ALLOWMULTISELECT" ; flags
MsgBox, % SelectFile(hOwner, Title, Filter, Index, Select, DefExt, Flags)
;-------------------------------------------------------------------------------
SelectFile(hOwner, Title := "", Filter := "", FilterIndex := 1
, Root := "", DefaultExt := "", Flags := "FILEMUSTEXIST HIDEREADONLY") {
;-------------------------------------------------------------------------------
static OFN_S := 0
, OFN_READONLY := 0x00000001
, OFN_OVERWRITEPROMPT := 0x00000002
, OFN_HIDEREADONLY := 0x00000004
, OFN_NOCHANGEDIR := 0x00000008
, OFN_SHOWHELP := 0x00000010
; OFN_ENABLEHOOK := 0x00000020
; OFN_ENABLETEMPLATE := 0x00000040
; OFN_ENABLETEMPLATEHANDLE := 0x00000080
, OFN_NOVALIDATE := 0x00000100
, OFN_ALLOWMULTISELECT := 0x00000200
, OFN_EXTENSIONDIFFERENT := 0x00000400
, OFN_PATHMUSTEXIST := 0x00000800
, OFN_FILEMUSTEXIST := 0x00001000
, OFN_CREATEPROMPT := 0x00002000
; OFN_SHAREAWARE := 0x00004000
, OFN_NOREADONLYRETURN := 0x00008000
, OFN_NOTESTFILECREATE := 0x00010000
; OFN_NONETWORKBUTTON := 0x00020000
; OFN_NOLONGNAMES := 0x00040000
, OFN_EXPLORER := 0x00080000
, OFN_NODEREFERENCELINKS := 0x00100000
; OFN_LONGNAMES := 0x00200000
; OFN_ENABLEINCLUDENOTIFY := 0x00400000
; OFN_ENABLESIZING := 0x00800000
; OFN_ := 0x01000000
, OFN_DONTADDTORECENT := 0x02000000
; OFN_ := 0x04000000
; OFN_ := 0x08000000
, OFN_FORCESHOWHIDDEN := 0x10000000
; OFN_ := 0x20000000
; OFN_ := 0x40000000
; OFN_ := 0x80000000
If (Filter = "") ; default string for filter
Filter := "All Files (*.*)"
SplitPath, Root, rootFN, rootDir
hFlags := 0x80000 ; always set OFN_EXPLORER
Loop, Parse, Flags, %A_TAB%%A_SPACE%, %A_TAB%%A_SPACE%
If (A_LoopField != "")
hFlags |= OFN_%A_LoopField%
If (hFlags = "")
Return, "Some of the flags are invalid: " Flags
VarSetCapacity(FN, 0xFFFF)
VarSetCapacity(lpstrFilter, 4 * StrLen(Filter), 0)
If (rootFN != "")
DllCall("RtlMoveMemory", "Str", FN, "Str", rootFN
, "UInt", (StrLen(rootFN) + 1) * (A_IsUnicode ? 2 : 1))
; contruct FilterText separated by zero
delta := 0 ; used by Loop as offset
loop, Parse, Filter, |
{
desc := A_LoopField
ext := SubStr(A_LoopField, InStr(A_LoopField, "(") + 1, -1)
LenD := StrLen(A_LoopField) + 1
LenE := StrLen(ext) + 1 ; including zero
If A_IsUnicode
LenD *= 2, LenE *= 2
DllCall("RtlMoveMemory", "UInt", &lpstrFilter + delta, "Str", desc, "UInt", LenD)
DllCall("RtlMoveMemory", "UInt", &lpstrFilter + delta + LenD, "Str", ext, "Int", LenE)
delta += LenD + LenE
}
; OPENFILENAME structure
VarSetCapacity(OFN, Length := A_PtrSize = 8 ? 120 : 76, 0)
NumPut(Length, OFN, A_PtrSize = 8 ? 0 : 0, "Int") ; Length of Structure
NumPut(hOwner, OFN, A_PtrSize = 8 ? 8 : 4, "Ptr") ; HWND
; A_PtrSize = 8 ? 16 : 8, "Ptr" ; hInstance
NumPut(&lpstrFilter, OFN, A_PtrSize = 8 ? 24 : 12, "Ptr") ; Pointer to FilterStruc
; A_PtrSize = 8 ? 32 : 16, "Ptr" ; lpstrCustomFilter
; A_PtrSize = 8 ? 40 : 20, "Int" ; nMaxCustFilter
NumPut(FilterIndex, OFN, A_PtrSize = 8 ? 44 : 24, "Int") ; DefaultFilter Pair
NumPut(&FN, OFN, A_PtrSize = 8 ? 48 : 28, "Ptr") ; lpstrFile / InitialisationFileName
NumPut(0xFFFF, OFN, A_PtrSize = 8 ? 56 : 32, "UInt") ; nMaxFile / lpstrFile length
; A_PtrSize = 8 ? 64 : 36, "Ptr" ; lpstrFileTitle
; A_PtrSize = 8 ? 72 : 40, "Int" ; nMaxFileTitle
NumPut(&rootDir, OFN, A_PtrSize = 8 ? 80 : 44, "Ptr") ; StartDir
NumPut(&Title, OFN, A_PtrSize = 8 ? 88 : 48, "Ptr") ; DlgTitle
NumPut(hFlags, OFN, A_PtrSize = 8 ? 96 : 52, "UInt") ; Flags
; A_PtrSize = 8 ? 100 : 56, ; WORD lpstrFileTitle
; A_PtrSize = 8 ? 102 : 58, ; WORD nMaxFileTitle
NumPut(&DefaultExt, OFN, A_PtrSize = 8 ? 104 : 60, "Ptr") ; DefaultExt
Result := SubStr(Flags, 1, 1) = "S"
? DllCall("comdlg32\GetSaveFileName" (A_IsUnicode ? "W" : "A"), "UInt", &OFN)
: DllCall("comdlg32\GetOpenFileName" (A_IsUnicode ? "W" : "A"), "UInt", &OFN)
ListVars
MsgBox, % DllCall("GetLastError", "UInt")
If (Result = 0)
Return
Adr := &FN
f := d := DllCall("MulDiv", "Int", Adr, "Int", 1, "Int", 1, "Str")
Result := ""
If StrLen(d) != 3 ; windows adds "\" when in rootdir, doesn't do that otherwise
d .= "\"
If MultiSelect := InStr(Flags, "ALLOWMULTISELECT")
Loop {
Adr += (StrLen(f) + 1) * (A_IsUnicode ? 2 : 1)
f := DllCall("MulDiv", "Int", Adr, "Int", 1, "Int", 1, "Str")
If f
Result .= d f "`n"
Else {
If (A_Index = 1)
Result := d ; if user selects only 1 file with multiselect flag, windows ignores this flag
Break
}
}
Return, SubStr(MultiSelect ? Result : d, 1, -1)
}
Re: FileSelectFile filter
comdlg32 ???
I'm not sure but I think that comdlg32 ("32") will not work properly on x64.
I think u should see this:
https://autohotkey.com/boards/viewtopic.php?t=13302
https://translate.google.com/translate? ... rev=search
IFileOpenDialog := ComObjCreate("{DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7}", "{D57C7288-D4AD-4768-BE02-9D969532D960}")
....
I'm not sure but I think that comdlg32 ("32") will not work properly on x64.
I think u should see this:
https://autohotkey.com/boards/viewtopic.php?t=13302
https://translate.google.com/translate? ... rev=search
IFileOpenDialog := ComObjCreate("{DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7}", "{D57C7288-D4AD-4768-BE02-9D969532D960}")
....
Re: FileSelectFile filter Topic is solved
I tried
FileOpenDialog.ahk
from
https://autohotkey.com/boards/viewtopic ... 42&t=10802
and works fine
FileOpenDialog.ahk
from
https://autohotkey.com/boards/viewtopic ... 42&t=10802
and works fine
Re: FileSelectFile filter
Thank you for the link. I will take a close look when I have the time.
FYI: I use this (comdlg32.dll) successfully with AHK Ansi / AHK Unicode and AHK 64bit.
FYI: I use this (comdlg32.dll) successfully with AHK Ansi / AHK Unicode and AHK 64bit.
Code: Select all
; tests
Select_Font(0, Style, Name, Color)
MsgBox, %Style%`n%Name%`n%Color%
Select_Color(0, Color)
MsgBox, %Color%
;-------------------------------------------------------------------------------
Select_Font(hGui, ByRef Style, ByRef Name, ByRef Color) { ; using comdlg32.dll
;-------------------------------------------------------------------------------
static SubKey := "SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI"
;-----------------------------------
; LOGFONT structure
;-----------------------------------
VarSetCapacity(LOGFONT, 128, 0)
If RegExMatch(Style, "s\K\d+", s) {
RegRead, LogPixels, HKLM, %SubKey%, LogPixels
NumPut(s * LogPixels // 72, LOGFONT, 0, "Int")
}
If RegExMatch(Style, "w\K\d+", w)
NumPut(w, LOGFONT, 16, "Int")
If InStr(Style, "italic")
NumPut(255, LOGFONT, 20, "Int")
If InStr(Style, "underline")
NumPut(1, LOGFONT, 21, "Int")
If InStr(Style, "strikeout")
NumPut(1, LOGFONT, 22, "Int")
StrPut(Name, &LOGFONT + 28, StrLen(Name) + 1)
;-----------------------------------
; CHOOSEFONT structure
;-----------------------------------
; CHOOSEFONT structure expects text color in BGR format
BGR := convert_Color(Color)
If (A_PtrSize = 8) { ; 64 bit
VarSetCapacity(CHOOSEFONT, 104, 0)
NumPut( 104, CHOOSEFONT, 0, "UInt") ; StructSize
NumPut( hGui, CHOOSEFONT, 8, "UInt") ; hwndOwner
NumPut(&LOGFONT, CHOOSEFONT, 24, "UInt") ; lpLogFont
NumPut( 0x141, CHOOSEFONT, 36, "UInt") ; Flags
NumPut( BGR, CHOOSEFONT, 40, "UInt") ; bgrColor
}
Else { ; 32 bit
VarSetCapacity(CHOOSEFONT, 60, 0)
NumPut( 60, CHOOSEFONT, 0, "UInt") ; StructSize
NumPut( hGui, CHOOSEFONT, 4, "UInt") ; hwndOwner
NumPut(&LOGFONT, CHOOSEFONT, 12, "UInt") ; lpLogFont
NumPut( 0x141, CHOOSEFONT, 20, "UInt") ; Flags
NumPut( BGR, CHOOSEFONT, 24, "UInt") ; bgrColor
}
;-----------------------------------
; call ChooseFont function
;-----------------------------------
FuncName := "comdlg32\ChooseFont" (A_IsUnicode ? "W" : "A")
If Not DllCall(FuncName, "UInt", &CHOOSEFONT)
Return, False
;-----------------------------------
; results to return
;-----------------------------------
; style
Style := "s" NumGet(CHOOSEFONT, A_PtrSize = 8 ? 32 : 16, "Int") // 10
Style .= " w" NumGet(LOGFONT, 16)
If NumGet(LOGFONT, 20, "UChar")
Style .= " italic"
If NumGet(LOGFONT, 21, "UChar")
Style .= " underline"
If NumGet(LOGFONT, 22, "UChar")
Style .= " strikeout"
; name
Name := StrGet(&LOGFONT + 28)
; chosen color
RGB := convert_Color(NumGet(CHOOSEFONT, A_PtrSize = 8 ? 40 : 24, "UInt"))
Color := SubStr("0x00000", 1, 10 - StrLen(RGB)) SubStr(RGB, 3)
Return, True
}
;-------------------------------------------------------------------------------
Select_Color(hGui, ByRef Color) { ; using comdlg32.dll
;-------------------------------------------------------------------------------
; CHOOSECOLOR structure expects text color in BGR format
BGR := convert_Color(Color)
; unused, but a valid pointer to the structure
VarSetCapacity(CUSTOM, 64, 0)
;-----------------------------------
; CHOOSECOLOR structure
;-----------------------------------
If (A_PtrSize = 8) { ; 64 bit
VarSetCapacity(CHOOSECOLOR, 72, 0)
NumPut( 72, CHOOSECOLOR, 0) ; StructSize
NumPut( hGui, CHOOSECOLOR, 8) ; hwndOwner
NumPut( BGR, CHOOSECOLOR, 24) ; bgrColor
NumPut(&CUSTOM, CHOOSECOLOR, 32) ; lpCustColors
NumPut( 0x103, CHOOSECOLOR, 40) ; Flags
}
Else { ; 32 bit
VarSetCapacity(CHOOSECOLOR, 36, 0)
NumPut( 36, CHOOSECOLOR, 0) ; StructSize
NumPut( hGui, CHOOSECOLOR, 4) ; hwndOwner
NumPut( BGR, CHOOSECOLOR, 12) ; bgrColor
NumPut(&CUSTOM, CHOOSECOLOR, 16) ; lpCustColors
NumPut( 0x103, CHOOSECOLOR, 20) ; Flags
}
;-----------------------------------
; call ChooseColorA function
;-----------------------------------
If Not DllCall("comdlg32\ChooseColorA", "UInt", &CHOOSECOLOR)
Return, False
;-----------------------------------
; result to return
;-----------------------------------
; chosen color
RGB := convert_Color(NumGet(CHOOSECOLOR, A_PtrSize = 8 ? 24 : 12, "UInt"))
Color := SubStr("0x00000", 1, 10 - StrLen(RGB)) SubStr(RGB, 3)
Return, True
}
;-------------------------------------------------------------------------------
convert_Color(Color) { ; convert RGB <--> BGR
;-------------------------------------------------------------------------------
$_FormatInteger := A_FormatInteger
SetFormat, Integer, Hex
Result := (Color & 0xFF) << 16 | Color & 0xFF00 | (Color >> 16) & 0xFF
SetFormat, Integer, % $_FormatInteger
Return, Result
}
Re: FileSelectFile filter
Thank u, thank u, thank u
I was just looking for smth. like these, I mean select font and color...
I was just looking for smth. like these, I mean select font and color...
-
- Posts: 77
- Joined: 18 Apr 2018, 08:49
Re: FileSelectFile filter
I know this topic is Old, but I currently want a function which is do the same as "FileSelectFile" but with additional feature which is "multi-filter"(docs|text files|music|videos). As how I read all your conversations, you said that Fileselectfile does not support it.wolf_II wrote:Thank you for the link. I will take a close look when I have the time.
FYI: I use this (comdlg32.dll) successfully with AHK Ansi / AHK Unicode and AHK 64bit.
Code: Select all
; tests Select_Font(0, Style, Name, Color) MsgBox, %Style%`n%Name%`n%Color% Select_Color(0, Color) MsgBox, %Color% ;------------------------------------------------------------------------------- Select_Font(hGui, ByRef Style, ByRef Name, ByRef Color) { ; using comdlg32.dll ;------------------------------------------------------------------------------- static SubKey := "SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI" ;----------------------------------- ; LOGFONT structure ;----------------------------------- VarSetCapacity(LOGFONT, 128, 0) If RegExMatch(Style, "s\K\d+", s) { RegRead, LogPixels, HKLM, %SubKey%, LogPixels NumPut(s * LogPixels // 72, LOGFONT, 0, "Int") } If RegExMatch(Style, "w\K\d+", w) NumPut(w, LOGFONT, 16, "Int") If InStr(Style, "italic") NumPut(255, LOGFONT, 20, "Int") If InStr(Style, "underline") NumPut(1, LOGFONT, 21, "Int") If InStr(Style, "strikeout") NumPut(1, LOGFONT, 22, "Int") StrPut(Name, &LOGFONT + 28, StrLen(Name) + 1) ;----------------------------------- ; CHOOSEFONT structure ;----------------------------------- ; CHOOSEFONT structure expects text color in BGR format BGR := convert_Color(Color) If (A_PtrSize = 8) { ; 64 bit VarSetCapacity(CHOOSEFONT, 104, 0) NumPut( 104, CHOOSEFONT, 0, "UInt") ; StructSize NumPut( hGui, CHOOSEFONT, 8, "UInt") ; hwndOwner NumPut(&LOGFONT, CHOOSEFONT, 24, "UInt") ; lpLogFont NumPut( 0x141, CHOOSEFONT, 36, "UInt") ; Flags NumPut( BGR, CHOOSEFONT, 40, "UInt") ; bgrColor } Else { ; 32 bit VarSetCapacity(CHOOSEFONT, 60, 0) NumPut( 60, CHOOSEFONT, 0, "UInt") ; StructSize NumPut( hGui, CHOOSEFONT, 4, "UInt") ; hwndOwner NumPut(&LOGFONT, CHOOSEFONT, 12, "UInt") ; lpLogFont NumPut( 0x141, CHOOSEFONT, 20, "UInt") ; Flags NumPut( BGR, CHOOSEFONT, 24, "UInt") ; bgrColor } ;----------------------------------- ; call ChooseFont function ;----------------------------------- FuncName := "comdlg32\ChooseFont" (A_IsUnicode ? "W" : "A") If Not DllCall(FuncName, "UInt", &CHOOSEFONT) Return, False ;----------------------------------- ; results to return ;----------------------------------- ; style Style := "s" NumGet(CHOOSEFONT, A_PtrSize = 8 ? 32 : 16, "Int") // 10 Style .= " w" NumGet(LOGFONT, 16) If NumGet(LOGFONT, 20, "UChar") Style .= " italic" If NumGet(LOGFONT, 21, "UChar") Style .= " underline" If NumGet(LOGFONT, 22, "UChar") Style .= " strikeout" ; name Name := StrGet(&LOGFONT + 28) ; chosen color RGB := convert_Color(NumGet(CHOOSEFONT, A_PtrSize = 8 ? 40 : 24, "UInt")) Color := SubStr("0x00000", 1, 10 - StrLen(RGB)) SubStr(RGB, 3) Return, True } ;------------------------------------------------------------------------------- Select_Color(hGui, ByRef Color) { ; using comdlg32.dll ;------------------------------------------------------------------------------- ; CHOOSECOLOR structure expects text color in BGR format BGR := convert_Color(Color) ; unused, but a valid pointer to the structure VarSetCapacity(CUSTOM, 64, 0) ;----------------------------------- ; CHOOSECOLOR structure ;----------------------------------- If (A_PtrSize = 8) { ; 64 bit VarSetCapacity(CHOOSECOLOR, 72, 0) NumPut( 72, CHOOSECOLOR, 0) ; StructSize NumPut( hGui, CHOOSECOLOR, 8) ; hwndOwner NumPut( BGR, CHOOSECOLOR, 24) ; bgrColor NumPut(&CUSTOM, CHOOSECOLOR, 32) ; lpCustColors NumPut( 0x103, CHOOSECOLOR, 40) ; Flags } Else { ; 32 bit VarSetCapacity(CHOOSECOLOR, 36, 0) NumPut( 36, CHOOSECOLOR, 0) ; StructSize NumPut( hGui, CHOOSECOLOR, 4) ; hwndOwner NumPut( BGR, CHOOSECOLOR, 12) ; bgrColor NumPut(&CUSTOM, CHOOSECOLOR, 16) ; lpCustColors NumPut( 0x103, CHOOSECOLOR, 20) ; Flags } ;----------------------------------- ; call ChooseColorA function ;----------------------------------- If Not DllCall("comdlg32\ChooseColorA", "UInt", &CHOOSECOLOR) Return, False ;----------------------------------- ; result to return ;----------------------------------- ; chosen color RGB := convert_Color(NumGet(CHOOSECOLOR, A_PtrSize = 8 ? 24 : 12, "UInt")) Color := SubStr("0x00000", 1, 10 - StrLen(RGB)) SubStr(RGB, 3) Return, True } ;------------------------------------------------------------------------------- convert_Color(Color) { ; convert RGB <--> BGR ;------------------------------------------------------------------------------- $_FormatInteger := A_FormatInteger SetFormat, Integer, Hex Result := (Color & 0xFF) << 16 | Color & 0xFF00 | (Color >> 16) & 0xFF SetFormat, Integer, % $_FormatInteger Return, Result }
The Idea of this artificial GUI function is awesome. But I currently want to have only the function to do a simple fileselectfile but just supports multi filters, I hope you all can help me
Developer of AJOM's DOTA2 MOD Master, Easiest way to MOD your DOTA2 without the use of internet . I created this program using Autohotkey thats why I love Autohotkey and the community!
GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
GitHub:
https://github.com/Aldrin-John-Olaer-Manalansan
Re: FileSelectFile filter
I have corrected the link in the message of user mas. The link was from a topic of mine but that later I used for another function. The functions are all for AHKv2.
It seems that you have started another topic.
It seems that you have started another topic.
Who is online
Users browsing this forum: Google [Bot] and 161 guests