Jump to content

kitoy

Active Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by kitoy

  1. @mikell, thank you very much. This is really great. By the way, is it possible to insert the $last_index to the next line if the string exceeds to the column width. I don't want to use the horizontal scroll. I've been looking in the _GUICrtlListView functions or in the parameters but I couldn't find one. For $i = 1 to 20 $last_index = MemoWrite($i & ". The quick brown fox jumps over the red lazy dog. Exceeding the text out of the column width.") Sleep(100) Next
  2. Found some error when the lines are already to long. Once the countdown starts, it will go back to the very first line. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet('{esc}', "_close") Global $_main = GUICreate("", 501, 313, -1, -1) Global $g_idMemo = GUICtrlCreateEdit("", 2, 2, 496, 274, $ES_AUTOVSCROLL + $ES_READONLY + $WS_VSCROLL) ;GUICtrlSetData(-1, "") GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") ;GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0) GUICtrlSetBkColor($g_idMemo, 0xFFFFE0) GUICtrlSetCursor($g_idMemo, -1) GUISetState(@SW_SHOW) For $i = 1 to 20 MemoWrite("test message " & $i) Sleep(100) Next ;~ Local $sEditText = ControlGetText($_main, "", $g_idMemo) ;~ Or Local $sEditText = GUICtrlRead($g_idMemo) For $i = 10 To 0 Step -1 GUICtrlSetData($g_idMemo, $sEditText & "Program will exit in " & $i & " seconds..." &@CRLF) Sleep(1000) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func MemoWrite($sMessage = "") GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func _close() Exit EndFunc ;==>_close
  3. Well, that answers my problem. Thanks everyone for the help. @mikell, @Malkey - both are the same but Malkey have another option. ;Local $sEditText = ControlGetText($_main, "", $g_idMemo) I believe this is now closed? Edit: Found a new error.
  4. I wanted to make a countdown timer without queueing the countdown message to the next line but the previous data is removed after using GUICtrlSetData. Any thoughts on how to display the previous data/message? Here is an example: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $_main = GUICreate("", 501, 313, -1, -1) Global $g_idMemo = GUICtrlCreateEdit("", 2, 2, 496, 274, $ES_AUTOVSCROLL + $ES_READONLY + $WS_VSCROLL) GUICtrlSetData(-1, "") 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) HotKeySet('{esc}', "_close") Func _close() Exit EndFunc ;==>_close Func MemoWrite($sMessage = "") GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite MemoWrite("test message 1") Sleep(1000) MemoWrite("test message 2") Sleep(1000) MemoWrite("test message 3") Sleep(1000) For $i = 5 to 0 Step -1 GUICtrlSetData($g_idMemo, "Program will exit in "&$i&" seconds...") Sleep(1000) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
  5. 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
  6. I see. Sorry for misunderstanding.
  7. I'm sorry but how am I going to use _arraytostring to .ini file?
  8. Update: Here is the latest one using config file. #include <Array.au3> #include <File.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> If _Singleton("test", 1) = 0 Then MsgBox(48, "Warning", "Program is already active!", 10) WinActivate("Distiller Backup Program") Exit EndIf Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close #region ### START Koda GUI section ### Form= Global $_main = GUICreate("Distiller Backup Program 1.0", 291, 113, -1, -1) Global $_run = GUICtrlCreateButton("R&un", 200, 72, 51, 25) Global $dropSelect = GUICtrlCreateCombo("", 48, 40, 201, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) $_config= IniRead(@ScriptDir & "\config.ini", "Version", "Distill", "") GUICtrlSetData(-1, $_config, "Adobe Acrobat Distiller DC") GUICtrlSetFont(-1, 11, 400, 0, "Calibri") Global $Label1 = GUICtrlCreateLabel("Select Distiller Version", 50, 20, 150, 17) GUICtrlSetFont(-1, 11, 400, 0, "Calibri") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### TraySetIcon("icon.ico") GUISetIcon("icon.ico") Global $distversion While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $_run Local $aTemp = StringSplit(GUICtrlRead($dropSelect), " ") $distversion = ($aTemp[$aTemp[0]]) If $distversion > 0 Then $distversion = $distversion & ".0" EndIf _runscript() Sleep(500) EndSwitch WEnd Func _runscript() Global $registry = 'HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\' & $distversion & '\WatchedFolders' Local $myip = @IPAddress1 Local $txtfile = $myip & "_Directories.txt" Local $newdate = @MON & "-" & @MDAY & "-" & @YEAR Local $myregfile = "BackUpRegistry_" & $newdate& ".reg" Local $progfile = @ProgramFilesDir & "\Adobe\Acrobat " & $distversion 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. For $i = 1 To 100 Local $regpath = RegEnumKey($registry, $i) $list = FileOpen($txtfile, 1) If @error <> 0 Then ExitLoop FileWrite($list, $regpath & @CRLF) Next ;### Copy available *.joboptions* based on document registry. Local $count = _FileCountLines($txtfile) For $a = 1 To $count If @OSVersion = "WIN_XP" Then ;Check if operating system is Windows XP or not. If yes, string "|" will be converted to "/" in the text file. $stringRep = _ReplaceStringInFile($txtfile, "|", "/") EndIf $regpath = RegEnumKey($registry, $a) Local $jobops = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" & $a Local $path = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" DirCreate($jobops) ;### Check if the distiller version is 5.0. If $distversion = "5.0" Then $stringRepRegX = StringReplace($regpath, "|", "/") FileCopy($stringRepRegX & "\*.joboptions*", $jobops) Else FileCopy($regpath & "\*.joboptions*", $jobops) EndIf Next ;### 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) EndIf ;### Move the text file and registration key inside the back-up folder. If FileExists($txtfile) Then FileMove($txtfile, "JobOptions_" & $newdate, 1) If FileExists($myregfile) Then FileMove($myregfile, "JobOptions_" & $newdate, 1) EndIf ElseIf @error Then MsgBox(48, "Error", $txtfile & " not found.") MsgBox(48, "Error", $myregfile & " not found.") EndIf ;### Messagebox after un/sucessful execution. If @error Then MsgBox(16, "Error", "Back-up unsuccessful. Program will exit in 5 seconds", 5) Else ;~ Sleep(500) MsgBox(64, "Success!", "Your back-up files can be found at:" & @CRLF & $path) Sleep(500) Exit ;# exit code after successful process. EndIf EndFunc ;==>_runscript config.ini: [Version] Distill = Adobe Acrobat Distiller 4|Adobe Acrobat Distiller 5|Adobe Acrobat Distiller 6|Adobe Acrobat Distiller 7|Adobe Acrobat Distiller 8|Adobe Acrobat Distiller 9|Adobe Acrobat Distiller 10|Adobe Acrobat Distiller 11|Adobe Acrobat Distiller DC
  9. @BrewManNH, thanks for the suggestion. If Not FileExists ($progfile) Then MsgBox(48, "WARNING!", "Incorrect version of Acrobat Distiller was selected." & @CRLF & "Please try again.") Return $_run EndIf @JLogan3o13, thanks for this. Here is what I came up to. GUICtrlSetData(-1, "Adobe Acrobat Distiller 4|Adobe Acrobat Distiller 5|Adobe Acrobat Distiller 6|Adobe Acrobat Distiller 7|" & _ "Adobe Acrobat Distiller 8|Adobe Acrobat Distiller 9|Adobe Acrobat Distiller 10|Adobe Acrobat Distiller 11|" & _ "Adobe Acrobat Distiller DC", "Adobe Acrobat Distiller DC") So I changed X to 10 and XI to 11 to avoid more loops. I also added ".0" since Program/Registry Files are using decimal points. i.e. 10.0, 11.0 Case $_run Local $aTemp = StringSplit(GUICtrlRead($dropSelect), " ") $distversion = ($aTemp[$aTemp[0]]) If $distversion > 0 Then $distversion = $distversion & ".0" EndIf I am also thinking to use .ini file so other people can easily add more versions in case new versions will be available. I will post it when I'm done.
  10. Update: I created a loop to trap the error "Variable used without being declared." Local $progfile = @ProgramFilesDir & "\Adobe\Acrobat " & $distversion If Not FileExists ($progfile) Then MsgBox(48, "WARNING!", "Incorrect version of distiller was selected." & @CRLF & "Please try again.") Call("_showgui") EndIf Here is latest one. #include <Array.au3> #include <File.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> If _Singleton("test", 1) = 0 Then MsgBox(48, "Warning:", "Program is already active!", 10) WinActivate("Distiller Backup Program") Exit EndIf Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close #region ### START Koda GUI section ### Form= Global $_main = GUICreate("Distiller Backup Program 1.0", 291, 113, -1, -1) Global $_run = GUICtrlCreateButton("R&un", 200, 72, 51, 25) Global $dropSelect = GUICtrlCreateCombo("", 48, 40, 201, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Adobe Acrobat Distiller 4|Adobe Acrobat Distiller 5|Adobe Acrobat Distiller 6|Adobe Acrobat Distiller 7|" _ & "Adobe Acrobat Distiller 8|Adobe Acrobat Distiller 9|Adobe Acrobat Distiller X|Adobe Acrobat Distiller XI|Adobe Acrobat Distiller DC", "Adobe Acrobat Distiller X") GUICtrlSetFont(-1, 11, 400, 0, "Calibri") Global $Label1 = GUICtrlCreateLabel("Select Distiller Version", 50, 20, 150, 17) GUICtrlSetFont(-1, 11, 400, 0, "Calibri") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### TraySetIcon("icon.ico") GUISetIcon("icon.ico") Global $distversion _showgui() Func _showgui() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $_run Switch GUICtrlRead($dropSelect) Case "Adobe Acrobat Distiller 4" $distversion = "4.0" Case "Adobe Acrobat Distiller 5" $distversion = "5.0" Case "Adobe Acrobat Distiller 6" $distversion = "6.0" Case "Adobe Acrobat Distiller 7" $distversion = "7.0" Case "Adobe Acrobat Distiller 8" $distversion = "8.0" Case "Adobe Acrobat Distiller 9" $distversion = "9.0" Case "Adobe Acrobat Distiller X" $distversion = "10.0" Case "Adobe Acrobat Distiller XI" $distversion = "11.0" Case "Adobe Acrobat Distiller DC" $distversion = "DC" EndSwitch _runscript() Sleep(500) Exit EndSwitch WEnd EndFunc Func _runscript() Global $registry = 'HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\' & $distversion & '\WatchedFolders' Local $myip = @IPAddress1 Local $txtfile = $myip & "_Directories.txt" Local $newdate = @MON & "-" & @MDAY & "-" & @YEAR Local $myregfile = "BackUpRegistry_" & $newdate& ".reg" Local $progfile = @ProgramFilesDir & "\Adobe\Acrobat " & $distversion If Not FileExists ($progfile) Then MsgBox(48, "WARNING!", "Incorrect version of distiller was selected." & @CRLF & "Please try again.") Call("_showgui") EndIf ;### List watchfolders in text file. For $i = 1 To 100 Local $regpath = RegEnumKey($registry, $i) $list = FileOpen($txtfile, 1) If @error <> 0 Then ExitLoop FileWrite($list, $regpath & @CRLF) Next ;### Copy available *.joboptions* based on document registry. Local $count = _FileCountLines($txtfile) For $a = 1 To $count If @OSVersion = "WIN_XP" Then ;Check if operating system is Windows XP or not. If yes, string "|" will be converted to "/" in the text file. $stringRep = _ReplaceStringInFile($txtfile, "|", "/") EndIf $regpath = RegEnumKey($registry, $a) Local $jobops = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" & $a Local $path = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" DirCreate($jobops) ;### Check if the distiller version is 5.0. If $distversion = "5.0" Then $stringRepRegX = StringReplace($regpath, "|", "/") FileCopy($stringRepRegX & "\*.joboptions*", $jobops) Else FileCopy($regpath & "\*.joboptions*", $jobops) EndIf Next ;### 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) EndIf ;### Move the text file and registration key inside the back-up folder. If FileExists($txtfile) Then FileMove($txtfile, "JobOptions_" & $newdate, 1) If FileExists($myregfile) Then FileMove($myregfile, "JobOptions_" & $newdate, 1) EndIf ElseIf @error Then MsgBox(48, "Error", $txtfile & " not found.") MsgBox(48, "Error", $myregfile & " not found.") EndIf ;### Messagebox after un/sucessful execution. If @error Then MsgBox(16, "Error", "Back-up unsuccessful. Program will exit in 5 seconds", 5) Else Sleep(500) MsgBox(64, "Success!", "Your back-up files can be found at:" & @CRLF & $path) EndIf EndFunc ;==>_runscript
  11. Yeah, I could. I'm still focusing on the other functions. After that, I will clean those redundant strings including this. My apologies. Anyway, here it is. #include <Array.au3> #include <File.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> If _Singleton("test", 1) = 0 Then MsgBox(48, "Warning:", "Program is already active!", 10) Exit EndIf Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close #region ### START Koda GUI section ### Form= Global $_main = GUICreate("Distiller Backup Program", 291, 113, -1, -1) Global $_run = GUICtrlCreateButton("R&un", 200, 72, 51, 25) Global $dropSelect = GUICtrlCreateCombo("", 48, 40, 201, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Adobe Acrobat Distiller 4|Adobe Acrobat Distiller 5|Adobe Acrobat Distiller 6|Adobe Acrobat Distiller 7|" _ & "Adobe Acrobat Distiller 8|Adobe Acrobat Distiller 9|Adobe Acrobat Distiller X|Adobe Acrobat Distiller XI|Adobe Acrobat Distiller DC", "Adobe Acrobat Distiller X") GUICtrlSetFont(-1, 11, 400, 0, "Calibri") Global $Label1 = GUICtrlCreateLabel("Select Distiller Version", 50, 20, 150, 17) GUICtrlSetFont(-1, 11, 400, 0, "Calibri") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### TraySetIcon("icon.ico") GUISetIcon("icon.ico") Global $distversion While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $_run Switch GUICtrlRead($dropSelect) Case "Adobe Acrobat Distiller 4" $distversion = "4.0" Case "Adobe Acrobat Distiller 5" $distversion = "5.0" Case "Adobe Acrobat Distiller 6" $distversion = "6.0" Case "Adobe Acrobat Distiller 7" $distversion = "7.0" Case "Adobe Acrobat Distiller 8" $distversion = "8.0" Case "Adobe Acrobat Distiller 9" $distversion = "9.0" Case "Adobe Acrobat Distiller X" $distversion = "10.0" Case "Adobe Acrobat Distiller XI" $distversion = "11.0" Case "Adobe Acrobat Distiller DC" $distversion = "DC" EndSwitch _runscript() Sleep(500) Exit EndSwitch WEnd Func _runscript() Global $registry = 'HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\' & $distversion & '\WatchedFolders' Local $myip = @IPAddress1 Local $myregfile = "BackUpRegistry.reg" Local $txtfile = $myip & "_Directories.txt" Local $newdate = @MON & "-" & @MDAY & "-" & @YEAR ;### List watchfolders in text file. For $i = 1 To 100 $regpath = RegEnumKey($registry, $i) $list = FileOpen($txtfile, 1) If @error <> 0 Then ExitLoop FileWrite($list, $regpath & @CRLF) Next ;### Copy available *.joboptions* based on document registry. Local $count = _FileCountLines($txtfile) For $a = 1 To $count $regpath = RegEnumKey($registry, $a) Local $jobops = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" & $a Local $path = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" DirCreate($jobops) FileCopy($regpath & "\*.joboptions*", $jobops) Next ;### Export Watchfolders' registry file. If FileExists($myregfile) Then FileDelete($myregfile) ;delete old registry file then replace a new one. RunWait(@ComSpec & ' /c reg EXPORT "' & $registry & '" ' & $myregfile & '', @ScriptDir, @SW_HIDE) Else RunWait(@ComSpec & ' /c reg EXPORT "' & $registry & '" ' & $myregfile & '', @ScriptDir, @SW_HIDE) EndIf ;### Move the text file and registration key inside the back-up folder. If FileExists($txtfile) Then FileMove($txtfile, "JobOptions_" & $newdate, 1) If FileExists($myregfile) Then FileMove($myregfile, "JobOptions_" & $newdate, 1) EndIf ElseIf @error Then MsgBox(4, "Error", "File not found.") EndIf ;### Messagebox after (un)sucessful execution. If @error Then MsgBox(16, "Error", "Back-up unsuccessful. Program will exit in 5 seconds", 5) Else Sleep(500) MsgBox(64, "Success!", "Your back-up files can be found at:" & @CRLF & $path) EndIf EndFunc ;==>_runscript
  12. Hi AutoBert, Sorry for not including that. Here it is. #include <Date.au3> $datenow =_NowDate() $datesplit = StringSplit($datenow, "/") $newdate = $datesplit[1] & "-" & $datesplit[2] & "-" & $datesplit[3]
  13. I am about to finish my script but I found the error, "Variable used without being declared." after compiling it and selecting another version not available in my drive. I know there is something wrong with this code but I couldn't pinpoint the error. Please help. #include <Array.au3> #include <DateToday.au3> ;### udf #include <File.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> If _Singleton("test", 1) = 0 Then MsgBox(48, "Warning:", "Program is already active!", 10) Exit EndIf Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close #region ### START Koda GUI section ### Form= Global $_main = GUICreate("Distiller Backup Program", 291, 113, -1, -1) Global $_run = GUICtrlCreateButton("R&un", 200, 72, 51, 25) Global $dropSelect = GUICtrlCreateCombo("", 48, 40, 201, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Adobe Acrobat Distiller 4|Adobe Acrobat Distiller 5|Adobe Acrobat Distiller 6|Adobe Acrobat Distiller 7|" _ & "Adobe Acrobat Distiller 8|Adobe Acrobat Distiller 9|Adobe Acrobat Distiller X|Adobe Acrobat Distiller XI|Adobe Acrobat Distiller DC", "Adobe Acrobat Distiller X") GUICtrlSetFont(-1, 11, 400, 0, "Calibri") Global $Label1 = GUICtrlCreateLabel("Select Distiller Version", 50, 20, 150, 17) GUICtrlSetFont(-1, 11, 400, 0, "Calibri") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### TraySetIcon("icon.ico") GUISetIcon("icon.ico") Global $distversion While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $_run Switch GUICtrlRead($dropSelect) Case "Adobe Acrobat Distiller 4" $distversion = "4.0" Case "Adobe Acrobat Distiller 5" $distversion = "5.0" Case "Adobe Acrobat Distiller 6" $distversion = "6.0" Case "Adobe Acrobat Distiller 7" $distversion = "7.0" Case "Adobe Acrobat Distiller 8" $distversion = "8.0" Case "Adobe Acrobat Distiller 9" $distversion = "9.0" Case "Adobe Acrobat Distiller X" $distversion = "10.0" Case "Adobe Acrobat Distiller XI" $distversion = "11.0" Case "Adobe Acrobat Distiller DC" $distversion = "DC" EndSwitch _runscript() Sleep(500) Exit EndSwitch WEnd Func _runscript() Global $registry = 'HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\' & $distversion & '\WatchedFolders' Local $myip = @IPAddress1 Local $myregfile = "BackUpRegistry.reg" Local $txtfile = $myip & "_Directories.txt" ;### List watchfolders in text file. For $i = 1 To 100 $regpath = RegEnumKey($registry, $i) $list = FileOpen($txtfile, 1) If @error <> 0 Then ExitLoop FileWrite($list, $regpath & @CRLF) Next ;### Copy available *.joboptions* based on document registry. Local $count = _FileCountLines($txtfile) For $a = 1 To $count $regpath = RegEnumKey($registry, $a) Local $jobops = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" & $a Local $path = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" DirCreate($jobops) FileCopy($regpath & "\*.joboptions*", $jobops) Next ;### Export Watchfolders' registry file. If FileExists($myregfile) Then FileDelete($myregfile) ;delete old registry file then replace a new one. RunWait(@ComSpec & ' /c reg EXPORT "' & $registry & '" ' & $myregfile & '', @ScriptDir, @SW_HIDE) Else RunWait(@ComSpec & ' /c reg EXPORT "' & $registry & '" ' & $myregfile & '', @ScriptDir, @SW_HIDE) EndIf ;### Move the text file and registration key inside the back-up folder. If FileExists($txtfile) Then FileMove($txtfile, "JobOptions_" & $newdate, 1) If FileExists($myregfile) Then FileMove($myregfile, "JobOptions_" & $newdate, 1) EndIf ElseIf @error Then MsgBox(4, "Error", "File not found.") EndIf ;### Messagebox after (un)sucessful execution. If @error Then MsgBox(16, "Error", "Back-up unsuccessful. Program will exit in 5 seconds", 5) Else Sleep(500) MsgBox(64, "Success!", "Your back-up files can be found at:" & @CRLF & $path) EndIf EndFunc ;==>_runscript
  14. Thank you spudw2k. I will try this one.
  15. Hi spudw2k, I'm using RunWait instead of ShellExecuteWait. RunWait(@ComSpec & ' /c reg EXPORT "HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\10.0\WatchedFolders" registry.txt', @ScriptDir) Here is my actual script. #include <Array.au3> #include <DateToday.au3> #include <File.au3> Local $distversion = "10.0" Local $registry = 'HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\'&$distversion&'\WatchedFolders' Local $myip = @IPAddress1 Local $myregfile = "BackUpRegistry.reg" Local $txtfile = $myip & "_Directories.txt" If FileExists($txtfile) Then FileDelete($txtfile) EndIf ;### Save distiller directories as text file. For $i = 1 To 100 $regpath = RegEnumKey($registry, $i) $list = FileOpen($txtfile, 1) If @error <> 0 Then ExitLoop FileWrite($list, $regpath & @CRLF) Next ;### Copy available *.joboptions* based on document registry. Local $count = _FileCountLines($txtfile) For $a = 1 To $count $regpath = RegEnumKey($registry, $a) Local $jobops = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" & $a Local $path = @ScriptDir & "\" & "JobOptions_" & $newdate & "\" DirCreate($jobops) FileCopy($regpath & "\*.joboptions*", $jobops) Next ;### Export Watchfolders' registry file. If FileExists($myregfile) Then FileDelete($myregfile) ;delete old registry file then replace a new one. RunWait(@ComSpec & ' /c reg EXPORT "'&$registry&'" '&$myregfile&'', @ScriptDir, @SW_HIDE) Else RunWait(@ComSpec & ' /c reg EXPORT "'&$registry&'" '&$myregfile&'', @ScriptDir, @SW_HIDE) EndIf ;### Move the text file and registration key inside the back-up folder. If FileExists($txtfile) Then FileMove($txtfile, "JobOptions_" & $newdate, 1) If FileExists($myregfile) Then FileMove($myregfile, "JobOptions_" & $newdate, 1) EndIf ElseIf @error Then MsgBox(4, "Error", "File not found.") EndIf ;### Messagebox after (un)sucessful execution. If @error Then MsgBox(16, "Error", "Back-up unsuccessful. Program will exit in 5 seconds", 5) Else Sleep(500) MsgBox(64, "Success!", "Your back-up files can be found at:" & @CRLF & $path) EndIf I'm still trying to figure out on how to determine the version of the distiller as I'm planning to run the script from multiple versions. Maybe you have an idea? Sorry for my bad scripting skills, I'm still new (a month or two) to this scripting world.
  16. Nevermind. Found the solution.
  17. Hi, I found this script for exporting registry file as text from Smartee. https://www.autoitscript.com/forum/topic/126953-export-several-registry-keys-into-one-file/ $path = @DesktopDir & "\registry.txt" $cache = "" ShellExecuteWait("regedit.exe", "/e "&$path&" HKEY_CLASSES_ROOT\.ico") $cache &= FileRead($path) ShellExecuteWait("regedit.exe", "/e "&$path&" HKEY_CLASSES_ROOT\.eml") $cache &= FileRead($path) ShellExecuteWait("regedit.exe", "/e "&$path&" HKEY_CLASSES_ROOT\.txt") $cache &= FileRead($path) FileOpen($path, 2) FileWrite($path, $cache) FileClose($path) However, it is not working in my end. I can only export blank text. I am trying to export the registry from a distiller. I also noticed the extensions(.ico, .eml and .txt) at the end of the key. However, this is not available in the distiller. Any suggestions? $path = @ScriptDir & "\registry.txt" $cache = "" ShellExecuteWait("regedit.exe", "/e "&$path&" HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\10.0\WatchedFolders\") $cache &= FileRead($path) FileOpen($path, 2) FileWrite($path, $cache) FileClose($path)
  18. Sorry, I'm still new to AutoIT.
  19. Hi Sir, I found this error while running the script.
×
×
  • Create New...