Sign in to follow this  
Followers 0
mastrboy

Convert Batch Script To Auto-it Gui

6 posts in this topic

#1 ·  Posted (edited)

How would i start converting this batch script to auto-it?

(i know how to create a gui, but i don't know how to update it's context)

@echo off
cls
REM slett alle cache mapper under hummingbird
REM (vis problemer med å slette skjulte filer/mapper, kjør attrib -h -r cache /D /S først)

IF EXIST %tmp%\cachedel.log echo Log fil for sletting av Humminbird cache pr bruker > %tmp%\cachedel.log
echo Søker etter cache filer og sletter dem.
FOR /R /D %%G in (*) DO IF EXIST "%%G\hummingbird\cache" rd "%%G\hummingbird\cache" /s /q && echo "%%G\hummingbird\cache" ble slettet >> %tmp%\cachedel.log
echo Cache filer slettet, 
echo.
echo Hvil du åpne logg filen?
set /P logopen=[J,N]? 
IF /I %logopen%==J start %systemroot%\notepad.exe %tmp%\cachedel.log

:EOF

something like

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 50, 42, 485, 333, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetData($Edit1, "AEdit1")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
;;;;;;;
    EndSelect
WEnd
Exit

and the edit form being updated for each deleted dir

with a verbose gui, so you can see whats being deleted.

(bad english, i know)

Edited by mastrboy

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I don't understand exactly this batch file, but here is something to beginning :)

#include <GUIConstants.au3>
#Include <File.au3>

$Form1 = GUICreate("AForm1", 622, 441, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 50, 42, 485, 333, -1, $WS_EX_CLIENTEDGE)
$btn1 = GUICtrlCreateButton("Action",250,400,100)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $btn1
            Action("C:\hummingbird\cache\")
    EndSelect
WEnd

Func Action($dir_name)
    $FileList=_FileListToArray($dir_name,"*.*",1)
    If @Error Then Return
    
    For $i = 1 to UBound($FileList) - 1
        $file_name = $FileList[$i]
        GUICtrlSetData ($Edit1, $file_name & @CRLF,1)
        FileDelete($dir_name & $file_name)
    Next

    DirRemove($dir_name,1)
    GUICtrlSetData ($Edit1, @CRLF & $dir_name & " deleted.",1)
EndFunc

Be carefull when using FileDelete(), DirRemove() ...

Edited by Zedna

Share this post


Link to post
Share on other sites

WOW.. Sorry for awakening an old post but just wanted to tell Zedna what a cool script that is. It helps me understand the workings behind the gui a little better.

Thanks a bunch.

Share this post


Link to post
Share on other sites

WOW.. Sorry for awakening an old post but just wanted to tell Zedna what a cool script that is. It helps me understand the workings behind the gui a little better.

Thanks a bunch.

Hi gesller

I hear your appreciation :(

I'm pleased to help somebody to give a right direction

Happy scripting in AutoIt :shocked:

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