Skip to content

Instantly share code, notes, and snippets.

@pureexe
Created January 4, 2012 13:23
Show Gist options
  • Select an option

  • Save pureexe/1560017 to your computer and use it in GitHub Desktop.

Select an option

Save pureexe/1560017 to your computer and use it in GitHub Desktop.
[exp]safe-explorer.au3
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ExpListView.au3>
OnAutoItExitRegister('_Exit')
if $CmdLine[0]<>0 Then
$mainroot=$CmdLine[1]
Else
$mainroot=FileSelectFolder("เลือกfolder","","","")
EndIf
Global $hidden1load=0,$load1checkbox1=0,$load1checkbox2=0,$load1checkbox3=0,$load1checkbox4=0,$load1checkbox5=0
Global $sRestore = @ScriptDir & '\control.ini'
$hGUI = GUICreate("Safe explorer :: Flash drive safe check",735, 417)
Global $hList1 = _ExpListView_Create($hGUI, $mainroot, 13, False, 29, 43, 680, 350)
If FileExists($sRestore)And IniRead($sRestore, 'ListViews', 'List1', '')<>""Then
_ExpListView_ColumnViewsRestore($hList1, IniRead($sRestore, 'ListViews', 'List1', ''))
$hidden1load=IniRead($sRestore,"ListViews","hiddenshow",0)
$load1checkbox1=IniRead($sRestore,"ListViews","load1checkbox1",0)
$load1checkbox2=IniRead($sRestore,"ListVi.ews","load1checkbox2",0)
$load1checkbox3=IniRead($sRestore,"ListViews","load1checkbox3",0)
$load1checkbox4=IniRead($sRestore,"ListViews","load1checkbox4",0)
$load1checkbox5=IniRead($sRestore,"ListViews","load1checkbox5",0)
EndIf
Global $sCurrentDirectory1 = GUICtrlCreateInput("", 70, 12, 480, 18)
$Back1 = GUICtrlCreateButton("กลับ", 618, 8, 53, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Directory : ", 6, 12, 62, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$input1 = GUICtrlCreateButton("ไป", 562, 8, 53, 25, $WS_GROUP)
$setting = GUICtrlCreateButton("ตั้งค่า", 672, 8, 49, 25, $WS_GROUP)
GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hList1))
_ExpListView_SetFunction($hList1, '_Call_Function')
GUISetState(@SW_SHOW)
if $hidden1load=1 Then
Local $flag = _ToggleHidden($hList1)
_ExpListView_ShowHiddenFiles($hList1, $flag)
_ExpListView_Refresh($hList1)
endif
Local $iColumn_Value = 0
If $load1checkbox1 = 1 Then $iColumn_Value += 1
If $load1checkbox2 = 1 Then $iColumn_Value += 2
If $load1checkbox3 = 1 Then $iColumn_Value += 4
If $load1checkbox4 = 1 Then $iColumn_Value += 8
If $load1checkbox5 = 1 Then $iColumn_Value += 16
_ExpListView_SetColumns($hList1, $iColumn_Value)
While 1
$nMsg = GUIGetMsg()
;Switch $nMsg
Select
Case $nMsg=$GUI_EVENT_CLOSE
Exit
Case $nMsg=$Back1
_ExpListView_Back($hList1)
GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hList1))
Case $nMsg=$input1
Local $inputbox =GUICtrlRead($sCurrentDirectory1),$dirreturn
$dirreturn=_ExpListView_DirSetCurrent($hList1, $inputbox)
if $dirreturn<>1 Then MsgBox(64,"ERROR","ไม่พบfolderดังกล่าว")
_ExpListView_DirSetCurrent($hList1, $inputbox)
GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hList1))
Case $nMsg=$setting
_settinggui()
EndSelect
;EndSwitch
WEnd
;hWnd is the only parameter needed for the call function you create.
Func _Call_Function($hWnd)
Switch $hWnd
Case $hList1
GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hWnd))
EndSwitch
EndFunc ;==>_Call_Function
Func _ToggleHidden($List)
Static $bFlag1 = -1, $bFlag2 = -1
Switch $List
Case $hList1
$bFlag1 *= -1
If $bFlag1 = -1 Then Return False
EndSwitch
Return True
EndFunc ;==>_ToggleHidden
;Here we have a simple exit function that saves the column info so we can reload it at startup.
Func _Exit()
If Not FileExists($sRestore) Then _FileCreate($sRestore)
IniWrite($sRestore, 'ListViews', 'List1', _ExpListView_ColumnViewsSave($hList1))
IniWrite($sRestore,"ListViews","hiddenshow",$hidden1load)
IniWrite($sRestore,"ListViews","load1checkbox1",$load1checkbox1)
IniWrite($sRestore,"ListViews","load1checkbox2",$load1checkbox2)
IniWrite($sRestore,"ListViews","load1checkbox3",$load1checkbox3)
IniWrite($sRestore,"ListViews","load1checkbox4",$load1checkbox4)
IniWrite($sRestore,"ListViews","load1checkbox5",$load1checkbox5)
EndFunc ;==>_Exit
Func _settinggui()
Local $Checkbox1,$Checkbox2,$Checkbox3,$Checkbox4,$Checkbox5
$infogui= GUICreate("การตั้งค่า", 248, 272, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_DLGFRAME,$WS_GROUP,$WS_CLIPSIBLINGS),"",$hGUI)
$Checkbox1 = GUICtrlCreateCheckbox("แสดงขนาด", 74, 32, 79, 19)
$Checkbox2 = GUICtrlCreateCheckbox("แสดงเวลาแก้ไข", 74, 58, 95, 19)
$Checkbox3 = GUICtrlCreateCheckbox("แสดงประเภท", 74, 82, 79, 19)
$Checkbox4 = GUICtrlCreateCheckbox("แสดงเวลาสร้าง", 74, 104,111, 19)
$Checkbox5 = GUICtrlCreateCheckbox("แสดงเวลาเปิด", 74, 128, 111, 19)
$HiddenCheckbox = GUICtrlCreateCheckbox("แสดงไฟล์ที่ซ่อน", 74, 154, 111, 19)
$closeinfo = GUICtrlCreateButton("ปิด", 64, 192, 121, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
If $load1checkbox1 = 1 Then GUICtrlSetState($Checkbox1,$GUI_CHECKED)
If $load1checkbox2 = 1 Then GUICtrlSetState($Checkbox2,$GUI_CHECKED)
If $load1checkbox3 = 1 Then GUICtrlSetState($Checkbox3,$GUI_CHECKED)
If $load1checkbox4 = 1 Then GUICtrlSetState($Checkbox4,$GUI_CHECKED)
If $load1checkbox5 = 1 Then GUICtrlSetState($Checkbox5,$GUI_CHECKED)
If $hidden1load = 1 Then GUICtrlSetState($HiddenCheckbox,$GUI_CHECKED)
While 1
Local $s1Msg = GUIGetMsg()
Select
Case $s1Msg=$GUI_EVENT_CLOSE
GUISetState(@SW_HIDE,$infogui)
ExitLoop
Case $s1Msg=$closeinfo
GUISetState(@SW_HIDE,$infogui)
ExitLoop
Case $s1Msg=$Checkbox1 Or $s1Msg=$Checkbox2 or $s1Msg=$Checkbox3 Or $s1Msg=$Checkbox4 Or $s1Msg=$Checkbox5
Local $iColumn_Value = 0
If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
$iColumn_Value += 1
$load1checkbox1=1
Else
$load1checkbox1=0
EndIf
If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
$iColumn_Value += 2
$load1checkbox2=1
Else
$load1checkbox2=0
EndIf
If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
$iColumn_Value += 4
$load1checkbox3=1
Else
$load1checkbox3=0
EndIf
If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
$iColumn_Value += 8
$load1checkbox4=1
Else
$load1checkbox4=0
EndIf
If GUICtrlRead($Checkbox5) = $GUI_CHECKED Then
$iColumn_Value += 16
$load1checkbox5=1
Else
$load1checkbox5=0
EndIf
_ExpListView_SetColumns($hList1, $iColumn_Value)
Case $s1Msg=$HiddenCheckbox
If GUICtrlRead($HiddenCheckbox) = $GUI_CHECKED Then
$hidden1load=1
Else
$hidden1load=0
EndIf
Local $flag = _ToggleHidden($hList1)
_ExpListView_ShowHiddenFiles($hList1, $flag)
_ExpListView_Refresh($hList1)
EndSelect
WEnd
EndFunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment