Sign in to follow this  
Followers 0
Ahmed97

Help please with this script

7 posts in this topic

#1 ·  Posted (edited)

Hi guys :unsure:, i need ur help pls :>

First, sorry for bad english

second, i have problem with this script

see this script

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Blaa = GUICreate("Blah bla bla", 434, 98, 329, 300)
$browse = GUICtrlCreateButton("Browse", 352, 8, 75, 25, $WS_GROUP)
$start = GUICtrlCreateButton("start", 352, 64, 75, 25, $WS_GROUP)
$input = GUICtrlCreateInput("", 80, 11, 257, 21)
$txt = GUICtrlCreateLabel("choose folder", 8, 13, 68, 17)
$DelALL = GUICtrlCreateCheckbox("delete all files", 80, 48, 97, 17)
$DELexe = GUICtrlCreateCheckbox("delete exe files", 240, 48, 97, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $browse
            $Select = FileSelectFolder("Choose Folder Please", "")
            GUICtrlSetData($input, $Select)
        Case $nMsg = $start
            If GUICtrlRead($DelALL) = $GUI_CHECKED Then
                DirRemove($input,1 )
                If GUICtrlRead($DELexe) = $GUI_CHECKED Then
                    FileDelete($input & "\*.exe")
                EndIf
            EndIf

    EndSelect
WEnd

all things are clear in script ;)

want when i press on "Delete all files" the script Delete all files in the folder not the folder with files

,, when i press on "Delete exe files" the script Delete all exe files in the folder

and at the end script make ini file to read last buttons and dir i choosed so next time i open the script i see last changes i choosed and script press auto start.

Srry again for bad english ^^

please help guys, Thnx :D

Edited by TheMaster

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

_FileListToArray

#Include <File.au3>
#Include <Array.au3>

$FileList =_FileListToArray(@DesktopDir)
If @Error Then
    MsgBox (0,"","Error.")
    Exit
EndIf
;exe files
For $x = 1 To $FileList[0]
    If StringRight($FileList[$x],4) = ".exe" Then MsgBox (0,"1",$FileList[$x])
Next
;all files and folders
For $x = 1 To $FileList[0]
    MsgBox (0,"2",$FileList[$x])
Next

You can use _FileListToArray second and third parametar to get diffrent results, or you can filter the results yourself in loop like i did,

In the help file look for

IniRead()

IniWrite()

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$ini = @ScriptDir & "\history.ini"

$Blaa = GUICreate(@ScriptName, 434, 98, 329, 300)
$browse = GUICtrlCreateButton("Browse", 352, 8, 75, 25, $WS_GROUP)
$start = GUICtrlCreateButton("start", 352, 64, 75, 25, $WS_GROUP)
$input = GUICtrlCreateInput("", 80, 11, 257, 21)
$txt = GUICtrlCreateLabel("choose folder", 8, 13, 68, 17)
$DelALL = GUICtrlCreateCheckbox("delete all files", 80, 48, 97, 17)
$DELexe = GUICtrlCreateCheckbox("delete exe files", 240, 48, 97, 17)
GUICtrlSetData($input, IniRead($ini, "paths", "lastPath", ""))
GUICtrlSetState($DelALL, IniRead($ini, "settings", "dir", $GUI_UNCHECKED))
GUICtrlSetState($DELexe, IniRead($ini, "settings", "exeOnly", $GUI_UNCHECKED))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $browse
            $Select = FileSelectFolder("Choose Folder Please", "")
            GUICtrlSetData($input, $Select)
            IniWrite($ini, "paths", "lastPath", $Select)
        Case $nMsg = $start
            $directory = GUICtrlRead($input)
            If GUICtrlRead($DelALL) = $GUI_CHECKED Then
                DirRemove($directory, 1)
                IniWrite($ini, "settings", "dir", $GUI_CHECKED)
            ElseIf GUICtrlRead($DELexe) = $GUI_CHECKED Then
                FileDelete($directory & "\*.exe")
                IniWrite($ini, "settings", "exeOnly", $GUI_CHECKED)
            EndIf
            MsgBox(64, @ScriptName, "Done")
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

_FileListToArray

#Include <File.au3>
#Include <Array.au3>

$FileList =_FileListToArray(@DesktopDir)
If @Error Then
    MsgBox (0,"","Error.")
    Exit
EndIf
;exe files
For $x = 1 To $FileList[0]
    If StringRight($FileList[$x],4) = ".exe" Then MsgBox (0,"1",$FileList[$x])
Next
;all files and folders
For $x = 1 To $FileList[0]
    MsgBox (0,"2",$FileList[$x])
Next

You can use _FileListToArray second and third parametar to get diffrent results, or you can filter the results yourself in loop like i did,

In the help file look for

IniRead()

IniWrite()

hey bogQ, this script not work with me :> and i dont understand it, im new in autoit and im noob :unsure:

i have looked for ini read/write but it dont work for me, when i open the program it keep reading the ini file and cant select any another dir...may another script file ^^ ?

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$ini = @ScriptDir & "\history.ini"

$Blaa = GUICreate(@ScriptName, 434, 98, 329, 300)
$browse = GUICtrlCreateButton("Browse", 352, 8, 75, 25, $WS_GROUP)
$start = GUICtrlCreateButton("start", 352, 64, 75, 25, $WS_GROUP)
$input = GUICtrlCreateInput("", 80, 11, 257, 21)
$txt = GUICtrlCreateLabel("choose folder", 8, 13, 68, 17)
$DelALL = GUICtrlCreateCheckbox("delete all files", 80, 48, 97, 17)
$DELexe = GUICtrlCreateCheckbox("delete exe files", 240, 48, 97, 17)
GUICtrlSetData($input, IniRead($ini, "paths", "lastPath", ""))
GUICtrlSetState($DelALL, IniRead($ini, "settings", "dir", $GUI_UNCHECKED))
GUICtrlSetState($DELexe, IniRead($ini, "settings", "exeOnly", $GUI_UNCHECKED))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $browse
            $Select = FileSelectFolder("Choose Folder Please", "")
            GUICtrlSetData($input, $Select)
            IniWrite($ini, "paths", "lastPath", $Select)
        Case $nMsg = $start
            $directory = GUICtrlRead($input)
            If GUICtrlRead($DelALL) = $GUI_CHECKED Then
                DirRemove($directory, 1)
                IniWrite($ini, "settings", "dir", $GUI_CHECKED)
            ElseIf GUICtrlRead($DELexe) = $GUI_CHECKED Then
                FileDelete($directory & "\*.exe")
                IniWrite($ini, "settings", "exeOnly", $GUI_CHECKED)
            EndIf
            MsgBox(64, @ScriptName, "Done")
    EndSelect
WEnd

yeaah, This script working 100% :unsure: thnxx man

Thnxx all

Share this post


Link to post
Share on other sites

now i need another help to make Hotkeys in program...

see the script :

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$ini = @ScriptDir & "\history.ini"

$Blaa = GUICreate(@ScriptName, 434, 98, 329, 300)
$browse = GUICtrlCreateButton("Browse", 352, 8, 75, 25, $WS_GROUP)
$start = GUICtrlCreateButton("start", 352, 64, 75, 25, $WS_GROUP)
$input = GUICtrlCreateInput("", 80, 11, 257, 21)
$txt = GUICtrlCreateLabel("choose folder", 8, 13, 68, 17)
$DelALL = GUICtrlCreateCheckbox("delete all files", 80, 48, 97, 17)
$DELexe = GUICtrlCreateCheckbox("delete exe files", 240, 48, 97, 17)
GUICtrlSetData($input, IniRead($ini, "paths", "lastPath", ""))
GUICtrlSetState($DelALL, IniRead($ini, "settings", "dir", $GUI_UNCHECKED))
GUICtrlSetState($DELexe, IniRead($ini, "settings", "exeOnly", $GUI_UNCHECKED))
GUISetState(@SW_SHOW)

HotKeySet(("{CtrlH}"), GUISetState(@SW_HIDE)) ; Here fail :(
HotKeySet(("{CtrlS}"), GUISetState(@SW_SHOW)) ; Here fail :(


While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $browse
            $Select = FileSelectFolder("Choose Folder Please", "")
            GUICtrlSetData($input, $Select)
            IniWrite($ini, "paths", "lastPath", $Select)
        Case $nMsg = $start Or (GUICtrlRead($input) <> "")
            $directory = GUICtrlRead($input)
            If GUICtrlRead($DelALL) = $GUI_CHECKED Then
                DirRemove($directory, 1)
                IniWrite($ini, "settings", "dir", $GUI_CHECKED)
            ElseIf GUICtrlRead($DELexe) = $GUI_CHECKED Then
                FileDelete($directory & "\*.exe")
                IniWrite($ini, "settings", "exeOnly", $GUI_CHECKED)
            EndIf
    EndSelect
WEnd

; there failed

i need to press any key i choose to hide program, and another key to show it again

Share this post


Link to post
Share on other sites

HotKeySet("^h", "CtrlH") ;
HotKeySet("^s", "CtrlS") ;

Func CtrlH()
    GUISetState(@SW_HIDE,$Blaa)
EndFunc
Func CtrlS()
    GUISetState(@SW_HIDE,$Blaa)
EndFunc

Note that when using the

DirRemove($directory, 1)

it will remove all subdirectories


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0