2015-01-06 5 views
-1

디렉토리에있는 파일 목록을 표시하려고합니다.autoit - 디렉토리에 파일을 표시하는 방법?

; Includes the GuiConstants (required for GUI function usage) 
#include <GuiConstants.au3> 
#include <File.au3> 
#include <Array.au3> 

Global $inputBox, $downloadsURL, $files 

; Change to OnEvent mode 
Opt('GUIOnEventMode', 1) 

; GUI Creation 
GuiCreate("Downloads Script", 400, 200) 

; Runs the GUIExit() function if the GUI is closed 
GUISetOnEvent($GUI_EVENT_CLOSE, 'GUIExit') 


; Button1 
GUICtrlCreateButton("Download File", -1, 60) 
GUICtrlSetOnEvent(-1, 'runDownload') ; Runs function when pressed 

Func runDownload() 
$files = _FileListToArray("C:\Users\<user.name>\Pictures" , "*." , 1) 
_ArrayDisplay($files) 

EndFunc 


; Shows the GUI after the function completes 
GUISetState(@SW_SHOW) 

; Idles the script in an infinite loop - this MUST be included when using OnEvent mode 
While 1 
    Sleep(500) 
WEnd 

; This function makes the script exit when the GUI is closed 
Func GUIExit() 
Exit 
EndFunc 

버튼을 클릭 한 후 아무 일도 발생하지 :

이것은 내가 지금까지 가지고 관련 코드입니다. 스크립트는 그냥 영원히 실행됩니다 .... 내가 뭘 놓치고 있습니까 ??

이 스크립트의 장기적인 목표는 특정 디렉토리 내에있는 파일을 실행하는 것입니다. "Run"또는 "Run"에 배열 값을 전달할 수 있습니까? "ShellExecute"기능은 무엇입니까?

도움을 주셔서 감사합니다. 도움을 주실 수 있습니다 ... 감사합니다! 당신이 그것을 실행하게 변경 어떤

답변

1
; Includes the GuiConstants (required for GUI function usage) 
#include <GuiConstants.au3> 
#include <File.au3> 
#include <Array.au3> 


Global $inputBox, $downloadsURL, $files 


; Change to OnEvent mode 
Opt('GUIOnEventMode', 1) 


; GUI Creation 
GUICreate("Downloads Script", 400, 200) 
; Runs the GUIExit() function if the GUI is closed 
GUISetOnEvent($GUI_EVENT_CLOSE, 'GUIExit') 

; Button1 
GUICtrlCreateButton("Download File", 0, 60) 
GUICtrlSetOnEvent(-1, 'runDownload') ; Runs function when pressed 

; Shows the GUI after the function completes 
GUISetState(@SW_SHOW) 


; Idles the script in an infinite loop - this MUST be included when using OnEvent mode 
While 1 
    Sleep(500) 
WEnd 

Func runDownload() 
    $files = _FileListToArray(@UserProfileDir & "\Pictures", "*.*", 1) 
    _ArrayDisplay($files) 
EndFunc ;==>runDownload 

; This function makes the script exit when the GUI is closed 
Func GUIExit() 
    Exit 
EndFunc ;==>GUIExit 
+1

당신은 조금 설명해야 ... 미안 해요 – Samoth

+1

, 나는 두 가지를 비교하여 분명한 생각했다. 그들은''*. ''을 가지고 있고''*. *''을 요구합니다. 사용자 프로필 디렉토리 매크로를 사용하여 보편적으로 사용할 수있게 만들었습니다. –

관련 문제