Jump to content

Recommended Posts

So I changed my script a bit as advised and use GUICtrlCreateEdit to have a console-like GUI. But I got this problem when I click my mouse to the text inside the box, the $sMessage will continue where the cursor was last pointed and destroys the flow of the text. How can I disable the cursor permanently even if I will click to the box?

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icon.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <File.au3>
#include <ComboConstants.au3>
#include <Misc.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
#include <GuiStatusBar.au3>
#include <Zip.au3> ;### by torels_


Global $_main = GUICreate("Distiller Backup Program", 501, 313, -1, -1)
Global $g_idMemo = GUICtrlCreateEdit("", 2, 2, 496, 274, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY + $WS_BORDER)
GUICtrlSetData(-1, "")
Global $_run = GUICtrlCreateButton("R&un", 424, 280, 67, 25)
GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
GUICtrlSetCursor ($g_idMemo, -1)
GUISetState(@SW_SHOW)

;###~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Welcome note
Sleep(250)
MemoWrite("Distiller Backup Program     Version 1.1.0" & @TAB & "User: " & @UserName & @CRLF)
Sleep(250)
MemoWrite("Checking Distiller version. Please wait...")
Sleep(1000)
MemoWrite("Distiller version found.")
Sleep(2000)

HotKeySet('{esc}', "_close")
Func _close()
    Exit
EndFunc   ;==>_close

Global $distversion
Local $sKey = "HKCU\SOFTWARE\Adobe\Acrobat Distiller"
Local $sPath

    For $k = 1 To 100
        $distversion = RegEnumKey($sKey, $k)
            If @error Then
                ExitLoop
            Else
                If StringRegExp($distversion, "^\d+") Or $distversion == "DC" Then
                    Sleep(1250)
                    MemoWrite("The current version is " & $distversion & ".")
                    ExitLoop
                EndIf
            EndIf
    Next

Func _runscript()

    Global $registry = 'HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\' & $distversion & '\WatchedFolders'
    Local $myip = @IPAddress1
    Global $tempFolder = ("C:\tempo\")
    DirCreate($tempFolder)
    Global $txtfile = $tempFolder & $myip & "_Directories.txt"
    Local $newdate = @MON & "-" & @MDAY & "-" & @YEAR
    Global $myregfile = $tempFolder & "BackUpRegistry_" & $newdate & ".reg"
    Local $progfile = @ProgramFilesDir & "\Adobe\Acrobat " & $distversion


    Local $newZip = @ScriptDir & "\JobOptions_" & $newdate & ".zip"

    If Not FileExists($progfile) Then
        MsgBox(48, "WARNING!", "Incorrect version of Acrobat Distiller was selected." & @CRLF & "Please try again.")
        Return $_run
    EndIf

    ;### List watchfolders in text file.
    MemoWrite(@CRLF & "Listing all watchfolders found:")
    Sleep(2000)
    For $i = 1 To 100
        Local $regpath = RegEnumKey($registry, $i)
        If @error <> 0 Then
            ExitLoop
        Else
            $list = FileOpen($txtfile, 1)
            MemoWrite($regpath)
            FileWrite($list, $regpath & @CRLF)
            Sleep(300)
        EndIf
        FileClose($list)
    Next

    _Zip_Create($newZip) ;create new zip package.

    ;### Copy available *.joboptions* based on document registry.
    Local $count = _FileCountLines($txtfile)
    For $a = 1 To $count
        If $distversion = "5.0" Then
            ;If yes, string "|" will be converted to "/" in the text file.
            $stringRep = _ReplaceStringInFile($txtfile, "|", "/")
        EndIf
        $regpath = RegEnumKey($registry, $a)
        Local $jobops = $tempFolder & $a
        DirCreate($jobops)

        ;### Check if the distiller version is 5.0.
        If $distversion = "5.0" Then
            $stringRepRegX = StringReplace($regpath, "|", "/")
            FileCopy($stringRepRegX & "\*.joboptions*", $jobops)
            _Zip_AddFile($newZip, $jobops) ;Add *.joboptions to zip package.
        Else
            FileCopy($regpath & "\*.joboptions*", $jobops)
            If Not FileExists($regpath & "\*.joboptions*") Then
                Sleep(1000)
                MemoWrite(@CRLF & 'Waning, unable to locate *.joboptions at "' & $regpath & '".' & @CRLF & '' & _
                        "Please check if the network drive is connected or watchfolder " &@CRLF& _
                        "is active and re-run the program.")
                Sleep(2000)
                ExitLoop
;~              $a = $a + 1
            Else
                _Zip_AddFile($newZip, $jobops) ;Add *.joboptions to zip package.
            EndIf
        EndIf
    Next

    _Zip_AddFile($newZip, $txtfile) ;Add text file to zip package.

    ;### Export Watchfolders' registry file.
    If FileExists($myregfile) Then
        FileDelete($myregfile) ;delete old registry file, if available, then replaces a new one.
        RunWait(@ComSpec & ' /c reg EXPORT "' & $registry & '" ' & $myregfile & '', @ScriptDir, @SW_HIDE)
    Else
        RunWait(@ComSpec & ' /c reg EXPORT "' & $registry & '" ' & $myregfile & '', @ScriptDir, @SW_HIDE)
        _Zip_AddFile($newZip, $myregfile) ;Add regristy file to zip package..
    EndIf

    ;### Messagebox after un/sucessful execution.
    If @error Then
        MsgBox(16, "Error", "Back-up unsuccessful. Program will exit in 5 seconds", 5)
    Else
        Sleep(2000)
        MemoWrite(@CRLF & "Your back-up files can be found at:" & @CRLF & $newZip)
        Sleep(500)
        DirRemove($tempFolder, 1)
        Return $_main
    EndIf
EndFunc   ;==>_runscript

Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $_run
            _runscript()
    EndSwitch
WEnd

 

Edited by kitoy
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...