Jump to content

Hide Files System in Removable


Recommended Posts

Hey guys,

I'm trying to use the delete files same time in Removable or change attrib to show.

ex: delete : Autorun.inf ===> Attrib = SH in Removable

this is try me :

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author:      GHOST SKIKDA
Script Function:
    Hide Files System in Removable.
#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 554, 454, 192, 114)
GUISetBkColor(0x000000)
$ListView1 = GUICtrlCreateListView("Name|Status", 16, 168, 522, 270, '', BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES))
_GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 400)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x800000)
$ListView1context = GUICtrlCreateContextMenu($ListView1)
$MenuItem1 = GUICtrlCreateMenuItem("Show", $ListView1context)
$MenuItem2 = GUICtrlCreateMenuItem("Hide", $ListView1context)
$MenuItem3 = GUICtrlCreateMenuItem("Delete", $ListView1context)
$Button1 = GUICtrlCreateButton("Scan", 462, 134, 75, 25, $WS_GROUP)
$Combo1 = GUICtrlCreateCombo("", 50, 136, 409, 25)
$Label1 = GUICtrlCreateLabel("Path : ", 16, 139, 35, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar1_PartsWidth[1] = [-1]
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_drivercombo()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _GUICtrlListView_DeleteAllItems($ListView1)
            Sleep(200)
            ;Search("f:\")
            _driver()
        Case $ListView1
    EndSwitch
WEnd
 
;~ Func _Search()
;~  $search = FileFindFirstFile("C:\*.*")
;~ If $search = -1 Then
;~   MsgBox(0, "Error", "No files/directories matched the search pattern")
;~   Exit
;~ EndIf
;~ $com=0
;~ While 1
;~   $file = FileFindNextFile($search)
;~   If @error Then ExitLoop
;~  $var = FileGetAttrib("C:\"&$file)
;~  If ($var = "RASH") or ($var = "SH") Then
;~    _GUICtrlListView_AddItem($ListView1, $file, $com)
;~    _GUICtrlListView_AddSubItem($ListView1, $com,$var, 1)
;~    ;_GUICtrlListView_SetItemChecked($ListView1, $com)
;~    $com=$com+1
;~  EndIf
;~ WEnd
;~ FileClose($search)
;~ _GUICtrlStatusBar_SetText($StatusBar1, @TAB & "Resultat =  " & _GUICtrlListView_GetItemCount($ListView1), 0)
;~ EndFunc
Func Search($current)
Local $search = FileFindFirstFile($current & "\*.*")
$com=0
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
$var = FileGetAttrib($current &"\"&$file)
If ($var = "RASH") or ($var = "SH") or ($var = "RAH") or ($var = "ASH") Then;StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") and
    _GUICtrlListView_AddItem($ListView1, $file, $com)
    _GUICtrlListView_AddSubItem($ListView1, $com,$var, 1)
        ;_GUICtrlListView_SetItemChecked($ListView1, $com)
    $com=$com+1
    Search($current & "\" & $file)
EndIf
Sleep (1)
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & "Resultat =  " & _GUICtrlListView_GetItemCount($ListView1), 0)
WEnd
EndFunc
Func _driver()
    $drv = DriveGetDrive( "Removable")
If NOT @error Then
    For $i = 2 to $drv[0]
        GUICtrlSetData($Combo1,$drv[$i])
        Search($drv[$i])
    Next
EndIf
EndFunc
 
Func _drivercombo()
    $drv = DriveGetDrive( "Removable")
If NOT @error Then
    For $i = 2 to $drv[0]
        GUICtrlSetData($Combo1,$drv[$i])
    Next
EndIf
EndFunc

Posted Image

post-32527-0-21616400-1317762043_thumb.j

[center]I LOVE ALGERIA .... ;-)[/center]
Link to comment
Share on other sites

  • Developers

As long as you can't make clear what you want, and maybe even in this case why you want it, you wont get much responses.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

As long as you can't make clear what you want, and maybe even in this case why you want it, you wont get much responses.

Jos

I want to delete hidden files within the removable, but after the selected

Now clear ?

[center]I LOVE ALGERIA .... ;-)[/center]
Link to comment
Share on other sites

There are several issues with your script.

- your Search function is recursive to an unlimited depth, which will take some time on large drives

- the listview only contains the filenames without a driveletter, in the _driver() function you parse through $i = 2 To $drv[0] removable drives (why 2?) and trigger the search function => if you have more than 1 drive in your list you can not say on which drive the file in the listview is afterwards. Better add the driveletter to the filename in the listview too.

- a sleep in the search function will slow down the search dramatically

- Here is a snippet of pseudo-code to inspire you how to delete only the checked files.

Case $MenuItem3
            For $i = 1 To _GUICtrlListView_GetItemCount($hListView)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
                    ; fileattrib -R
                    ; delete _GUICtrlListView_GetItemText($hListView, $i - 1)
                EndIf
            Next

also add Global $hListView = GUICtrlGetHandle($ListView1) at the top to get the handle for the LV.

Link to comment
Share on other sites

Thank you my friend KaFu

this code: $ i = 2 To $ drv [0] does not appear the floppy disk reader

try for yourself the full code

I added your code :

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.3.6.1
 Author:         GHOST SKIKDA
 Script Function:
 Hide Files System in Removable.
#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <File.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 554, 454, 192, 114)
GUISetBkColor(0x000000)
$ListView1 = GUICtrlCreateListView("Name|Status", 16, 168, 522, 270, '', BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES))
_GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 400)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x800000)
$ListView1context = GUICtrlCreateContextMenu($ListView1)
$MenuItem1 = GUICtrlCreateMenuItem("Show", $ListView1context)
$MenuItem2 = GUICtrlCreateMenuItem("Hide", $ListView1context)
$MenuItem3 = GUICtrlCreateMenuItem("Delete", $ListView1context)
$Button1 = GUICtrlCreateButton("Scan", 462, 134, 75, 25, $WS_GROUP)
$Combo1 = GUICtrlCreateCombo("", 50, 136, 409, 25)
$Label1 = GUICtrlCreateLabel("Path : ", 16, 139, 35, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar1_PartsWidth[1] = [-1]
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_drivercombo()
Global $hListView = GUICtrlGetHandle($ListView1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   _GUICtrlListView_DeleteAllItems($ListView1)
   Sleep(200)
   ;Search("f:\")
   _driver()
  Case $ListView1
  Case $MenuItem1
   For $i = 1 To _GUICtrlListView_GetItemCount($ListView1)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
     FileSetAttrib(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1),"-RASH")
                EndIf
            Next
  Case $MenuItem2
   For $i = 1 To _GUICtrlListView_GetItemCount($ListView1)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
     FileSetAttrib(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1),"+RASH")
                EndIf
            Next
  Case $MenuItem3
            For $i = 1 To _GUICtrlListView_GetItemCount($ListView1)
                If _GUICtrlListView_GetItemChecked($hListView, $i - 1) Then ; LV has 0-based index
                    ; fileattrib -R
                    ;delete_GUICtrlListView_GetItemText($hListView, $i - 1)
     MsgBox(0,"",GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1))
     FileSetAttrib(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1),"-RASH")
     FileDelete(GUICtrlRead($Combo1)&"\"&_GUICtrlListView_GetItemText($hListView, $i - 1))
                EndIf
            Next
 EndSwitch
WEnd
Func Search($current)
Local $search = FileFindFirstFile($current & "\*.*")
$com=0
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
$var = FileGetAttrib($current &"\"&$file)
If ($var = "RASH") or ($var = "SH") or ($var = "RAH") or ($var = "ASH") or ($var = "RHS")Then;StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") and
 _GUICtrlListView_AddItem($ListView1, $file, $com)
 _GUICtrlListView_AddSubItem($ListView1, $com,$var, 1)
  ;_GUICtrlListView_SetItemChecked($ListView1, $com)
 $com=$com+1
 Search($current & "\" & $file)
EndIf
Sleep (1)
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & "Resultat =  " & _GUICtrlListView_GetItemCount($ListView1), 0)
WEnd
EndFunc
Func _driver()
 $drv = DriveGetDrive( "Removable")
If NOT @error Then
 For $i = 2 to $drv[0]
  GUICtrlSetData($Combo1,$drv[$i])
  Search($drv[$i])
 Next
EndIf
EndFunc

Func _drivercombo()
 $drv = DriveGetDrive( "Removable")
If NOT @error Then
 For $i = 2 to $drv[0]
  GUICtrlSetData($Combo1,$drv[$i])
 Next
EndIf
EndFunc
[center]I LOVE ALGERIA .... ;-)[/center]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...