Что нового

Возможно ли привязать директорию к Input AutoComplete

Tauhid

Новичок
Сообщения
3
Репутация
0
Здравствуйте. В AutoIt'е новичок :-\
На просторах интернета встретил интересную функцию:

Код:
#include
<GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>

Global Const $SHACF_AUTOAPPEND_FORCE_OFF = 0x80000000
Global Const $SHACF_AUTOAPPEND_FORCE_ON = 0x40000000
Global Const $SHACF_AUTOSUGGEST_FORCE_OFF = 0x20000000
Global Const $SHACF_AUTOSUGGEST_FORCE_ON = 0x10000000
Global Const $SHACF_DEFAULT = 0x00000000
Global Const $SHACF_FILESYS_ONLY = 0x00000010
Global Const $SHACF_FILESYS_DIRS = 0x00000020
Global Const $SHACF_FILESYSTEM = 0x00000001
Global Const $SHACF_URLHISTORY = 0x00000002
Global Const $SHACF_URLMRU = 0x00000004
Global Const $SHACF_USETAB = 0x00000008
Global Const $SHACF_URLALL = BitOR($SHACF_URLHISTORY, $SHACF_URLMRU)
Global Const $SHACF_VIRTUAL_NAMESPACE = 0x00000040
; #FUNCTION# ===========================================================================================================
; Name...........: __WinAPI_SHAutoComplete
; Description ...: Instructs system edit controls to use AutoComplete to help complete URLs or file system paths in a
;                  Input or ComboBoxEx control.
; Syntax.........: __WinAPI_SHAutoComplete ( $hWnd [, $dwFlag = $SHACF_DEFAULT] )
; Parameters ....: $hWnd        - Handle of parent window
;                  $dwFlags     - The flags to control the operation of SHAutoComplete:
;                  | $SHACF_AUTOAPPEND_FORCE_OFF    - Ignore the registry default and force the AutoAppend feature off.
;                                                     This flag must be used in combination with one or more of the
;                                                     SHACF_FILESYS* or SHACF_URL* flags.
;                  | $SHACF_AUTOAPPEND_FORCE_ON     - Ignore the registry value and force the AutoAppend feature on. The
;                                                     completed string will be displayed in the edit box with the added
;                                                     characters highlighted. This flag must be used in combination with
;                                                     one or more of the SHACF_FILESYS* or SHACF_URL* flags.
;                  |$SHACF_AUTOSUGGEST_FORCE_OFF    - Ignore the registry default and force the AutoSuggest feature off.
;                                                     This flag must be used in combination with one or more of the
;                                                     SHACF_FILESYS* or SHACF_URL* flags.
;                  |$SHACF_AUTOSUGGEST_FORCE_ON     - Ignore the registry value and force the AutoSuggest feature on. A
;                                                     selection of possible completed strings will be displayed as a
;                                                     drop-down list, below the edit box.
;                                                     This flag must be used in combination with one or more of the
;                                                     SHACF_FILESYS* or SHACF_URL* flags.
;                  |$SHACF_DEFAULT                  - The default setting, equivalent to SHACF_FILESYSTEM + SHACF_URLALL.
;                                                     SHACF_DEFAULT cannot be combined with any other flags.
;                  |$SHACF_FILESYS_ONLY             - Include the file system only.
;                  |$SHACF_FILESYS_DIRS             - Include the file system and directories, UNC servers, and UNC server
;                                                     shares.
;                  |$SHACF_FILESYSTEM               - Include the file system and the rest of the Shell (Desktop, Computer,
;                                                     and Control Panel, for example).
;                  |$SHACF_URLHISTORY               - Include the URLs in the user's History list.
;                  |$SHACF_URLMRU                   - Include the URLs in the user's Recently Used list.
;                  |$SHACF_USETAB                   - Allow the user to select from the autosuggest list by pressing the
;                                                     TAB key. If this flag is not set, pressing the TAB key will shift
;                                                     focus to the next control and close the autosuggest list. If
;                                                     SHACF_USETAB is set, pressing the TAB key will select the first item
;                                                     in the list. Pressing TAB again will select the next item in the list,
;                                                     and so on. When the user reaches the end of the list, the next TAB key
;                                                     press will cycle the focus back to the edit control. This flag must be
;                                                     used in combination with one or more of the SHACF_FILESYS* or
;                                                     SHACF_URL* flags listed on this page.
;                  |$SHACF_URLALL                   - Include the URLs in the users History and Recently Used lists.
;                                                     Equivalent to SHACF_URLHISTORY + SHACF_URLMRU.
;                  |$SHACF_VIRTUAL_NAMESPACE
; Author ........: Subz
; Remarks .......: The first four flags are used to override the Internet Explorer registry settings. The user can change these 
;                  settings manually by launching the Internet Options property sheet from the Tools menu and clicking the 
;                  Advanced tab.
;                  https://msdn.microsoft.com/en-us/library/windows/desktop/bb759862(v=vs.85).aspx
; ===============================================================================================================================
Func __WinAPI_SHAutoComplete($hWnd, $dwFlags = $SHACF_DEFAULT)
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    Local $hWndEdit, $aResult
    Switch _WinAPI_GetClassName($hWnd)
        Case 'ComboBoxEx32'
            $hWndEdit = _GUICtrlComboBoxEx_GetEditControl($hWnd)
        Case 'Edit'
            $hWndEdit = $hWnd
        Case Else
            Return
    EndSwitch
    $aResult = DllCall('shlwapi.dll', 'long', 'SHAutoComplete', 'hwnd', $hWndEdit, 'int', $dwFlags)
    If @error Or Not $aResult[0] Then Return SetError(@error, @extended, '')
    Return SetExtended($aResult[0], $aResult[2])
EndFunc ;==>__WinAPI_SHAutoComplete

Global $hGui_FileSystem
Global $hGui_WebHistory
Example()

Func Example()
    ; Create GUI
    $hGui = GUICreate('Example', 600, 100)

    GUICtrlCreateLabel('Website History:', 5, 5, 150, 21)
    $hGui_WebHistory = GUICtrlCreateInput('http://', 2, 2, 380, 21)
        __WinAPI_SHAutoComplete($hGui_WebHistory, BitOR($SHACF_AUTOAPPEND_FORCE_ON, $SHACF_URLHISTORY, $SHACF_USETAB))

    $hGui_FileSystem = _GUICtrlComboBoxEx_Create($hGui, "", 2, 42, 396, 120)


    GUISetState(@SW_SHOW)

    _GUICtrlComboBoxEx_BeginUpdate($hGui_FileSystem)
    _GUICtrlComboBoxEx_AddDir($hGui_FileSystem, @WindowsDir & "\*.exe")
    _GUICtrlComboBoxEx_EndUpdate($hGui_FileSystem)
        __WinAPI_SHAutoComplete($hGui_FileSystem, BitOR($SHACF_AUTOAPPEND_FORCE_ON, $SHACF_FILESYSTEM, $SHACF_USETAB))

    Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Вопрос такой: Можно ли для Input средствами данной функции привязать содержимое директории? То есть вместо отображения url отображать содержимое папки.
 
Верх