Eddi96

How do I compare a certain Line with a line in another Textfile?

18 posts in this topic

Hey guys,

I recently started scripting with Autoit. So please don't be too harsh with my noobish mistakes. So what I need is to compare the lastindex -5 of a logfile, which generates new lines after using a certain backupfunction, with a single line in another txt file. The Backupfunction whatsoever is irrelevant in my case. I only need some sort of comparison of the 5th last line, in a logfile, to a singe line in another textfile. I need it to send me a signal with f.e. "If the lastindex -5 = txtfile Then Run("C:\User\Desktop\succes.bat") I researched a bit and found that I can't use Robocopy for that case but might try it with StringCompare. I've read the intern help function of AutoIt but see no way on how to do it based on my knowledge. Can you guys help me out please?

 

Sincerely Eddi96

Share this post


Link to post
Share on other sites



Eddi96,

Welcome to the AutoIt forums.

Read both files into an array (using _FileReadToArray) and then compare the 5th-to-last line of one array (the [0] element of the array holds the line count) with the required line of the other.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
3 minutes ago, Melba23 said:

Eddi96,

Welcome to the AutoIt forums.

Read both files into an array (using _FileReadToArray) and then compare the 5th-to-last line of one array (the [0] element of the array holds the line count) with the required line of the other.

M23

Hey Melba,

Thank you for your quick response but could you give me an example with the given information?

-Logfile in directory: C:\theorg\theorg\logs\tadminevent.log

-Textfile to compare it to: C:\users\desktop\testfile.txt

If you want, I can post my Code in here so you see what I need it for.

 

Share this post


Link to post
Share on other sites

Eddi96,

Post examples of the 2 files (use the "Choose files" link under the editor to attach them) and I will see what I can do.

M23

P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

if line number is always the same, then FileReadLine() can accept a line number as 2nd argument:

FileReadLine('txt4melba1.txt', 40) ; read line #40 of specified file

so - after removing the comments you added to the end of the line, which obviously makes it different - you can use this:

If FileReadLine('txt4melba1.txt', 40) = FileReadLine('txt4melba2.txt') Then ConsoleWrite('OK' & @CRLF)

 

Edited by orbs

Share this post


Link to post
Share on other sites

Melba is usually pretty busy and I had some time to play...

this works fine here on my PC with test files,  did not use your files.

 

Good luck ;-)

Bill

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <File.au3>

Local $aRetArray, $sFilePath = @DesktopDir & "/test.txt"   ; path to your first text file

_FileReadToArray($sFilePath, $aRetArray)
Local $i = $aRetArray[0] -5         ; getting the position of your string  (last line - 5)
Local $sStr1 = $aRetArray[$i]       ; reading that poition

Local $sStr2 = FileReadLine(@DesktopDir & "/test2.txt", 1)    ; path to your second text file (1 is the line to read see orbs post)

ConsoleWrite("$sStr1 = " & $sStr1 & @CRLF)  ; some testing
ConsoleWrite("$sStr2 = " & $sStr2 & @CRLF)  ; some testing

; direct from the Help File   ( if $iCmp = 0 the you have a match)

; Compare two strings with using case sensitivity.
$iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE)
MsgBox($MB_SYSTEMMODAL, "", _
        "Comparing '" & $sStr1 & "' To '" & $sStr2 & "'" & @CRLF & _
        "StringCompare Result (mode $STR_CASESENSE): " & $iCmp)

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Eddi96,

Try this:

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

; Read log file into array
Local $aArray

_FileReadToArray("txt4melba1.txt", $aArray)
_ArrayDisplay($aArray, "", Default, 8) ; Just for example

; Read required match
$sCheck = FileRead("txt4melba2.txt")

; Now extract the required line from the log file
; It must not start "-----------" nor be a DTG
; Start from the bottom up
For $i = $aArray[0] To 1 Step -1
    If Not StringRegExp($aArray[$i], "(------|\d{2}\.\d{2}\.\d{4})") Then
        ; Found matching line - now check it
        If StringInStr($aArray[$i], $sCheck) Then
            MsgBox($MB_SYSTEMMODAL, "Match", "Line : " & $aArray[$i] & @CRLF & @CRLF & "Check: " & $sCheck)
            ; No point in looking further
            ExitLoop
        EndIf
    EndIf
Next

Please ask if you have any questions.

M23

Edit:

l3ill,

Thanks for jumping in - I do have a lot on this morning...

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This could be done using a simple regular expression
Here StringInStr is used for the comparison but "==" could simply be used instead

Local $line_in_file1, $index = -3

$tmp = StringRegExp(FileRead("txt4melba1.txt"), '(\N+)(?=(?:\R\N+){' & -$index-1 & '}$)', 1)  ; get line -3 in file 1
If not @error Then $line_in_file1 = $tmp[0]
;Msgbox(0,"line -3 in file 1", $line_in_file1)

; get 1st line in file 2 , removing leading/trailing white spaces
$constant_line = StringStripWS(FileReadLine("txt4melba2.txt", 1), 3) 
;Msgbox(0,"constant line", $constant_line)

Msgbox(0,"?", (StringInStr($line_in_file1, $constant_line) ? "match" : "doesn't match") )

 

Edited by mikell
typo

Share this post


Link to post
Share on other sites

Thank you very much Melba and Bill,

I couldn't bring Melbas script to work but I succeded with Bills. The problem I have now is, it is written to give me the the Signal 1 if the lines match, right?

; Compare two strings with using case sensitivity.
$iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE)
MsgBox($MB_SYSTEMMODAL, "", _
        "Comparing '" & $sStr1 & "' To '" & $sStr2 & "'" & @CRLF & _
        "StringCompare Result (mode $STR_CASESENSE): " & $iCmp)

Somehow it allways tells me $iCmp = 1

 

I wanted to use it further on as

If $iCmp = 1 Then MsgBox(64, "Infobox", "The given Lines Match", )

EndIf

But if it allways tells me $iCmp ist 1 I can't really rely on that.

Do you have an Idea on why it does that? I tried it multiple times and it was the same awnser.

Share this post


Link to post
Share on other sites
4 minutes ago, Eddi96 said:

Thank you very much Melba and Bill,

I couldn't bring Melbas script to work but I succeded with Bills. The problem I have now is, it is written to give me the the Signal 1 if the lines match, right?

; Compare two strings with using case sensitivity.
$iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE)
MsgBox($MB_SYSTEMMODAL, "", _
        "Comparing '" & $sStr1 & "' To '" & $sStr2 & "'" & @CRLF & _
        "StringCompare Result (mode $STR_CASESENSE): " & $iCmp)

Somehow it allways tells me $iCmp = 1

 

I wanted to use it further on as

If $iCmp = 1 Then MsgBox(64, "Infobox", "The given Lines Match", )

EndIf

But if it allways tells me $iCmp ist 1 I can't really rely on that.

Do you have an Idea on why it does that? I tried it multiple times and it was the same awnser.

Sorry, I didn't know how to edit my previous post.

I Noticed my mistake $iCmp = 0 has to be the awnser. I will try and change a few things and keep you informed!

Share this post


Link to post
Share on other sites

Also just an FYI (in case you hadn't noticed...)

Those 2 ConsoleWrites will help you figure out what your code is doing. 

This will show up in the bottom of the Scite window every time you run the script and show what those 2 variables actually are.

At this point you can see whether they are the same or not and how you need to change your code to make it work.

Bill

 

p.s. To edit your post use the EDIT button right next to the QUOTE button you keep using :lmao:

Clipboard01.jpg

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I have some updates guys,

1st of all, I seem to not have an Edit button. And 2nd I have some Problems with using the output 0 which I get when the Lines match. Here is my whole code, maybe I just made some simple mistakes.

#RequireAdmin


#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <File.au3>

Test()

Func Test()
    ; Das GUI
    Local $hGUI = GUICreate("Test", 300, 200)

    ; Erstellung der Buttons
    Local $idRevision = GUICtrlCreateButton("Datenrevision", 30, 170, 85, 25)
    Local $idExpress = GUICtrlCreateButton("ExpressDasi", 120, 170, 85, 25)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Darstellung des GUI
    GUISetState(@SW_SHOW, $hGUI)

    Local $iPID = 0

    ; Loop bis der benutzer auf Close drückt
   While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

             Case $idRevision

               Revision()

             Case $idExpress

               Express()

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

    ; Close the Notepad process using the PID returned by Run.
    If $iPID Then ProcessClose($iPID)
EndFunc







Func Express()

MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.")

Opt("WinWait",3) ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert

Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5")            ; Startet den Shutdown anderer Benutzer im THEORG und
                                                    ; sperrt die Benutzung bis UNLOCK durchgeführt wird.
Run("C:\THEORG\SUPPORT\BACKUP\TBSYS.EXE /SERVICE")    ;

WinWait("THEORG-Datensicherung") ; Wartet mit der Durchführung der Tastenanschläge bis das Fenster "THEORG-Datensicherung" offen ist.
    $Sek = 1
        Sleep($Sek * 5000);5 sekunden später
    ControlSend("THEORG-Datensicherung","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{DOWN}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

$Sek = 1
        Sleep($Sek * 500);0,5 sekunden später   ;
    ControlSend("Bestätigung","",0,"{RIGHT}")    ; Diese zwei Tastenanschläge sorgen für die
                                                ; nicht überschreibung der zuvor
$Sek = 1                                        ; durchgeführten Express Datensicherung.
        Sleep($Sek * 500);0,5 sekunden später    ;
    ControlSend("Bestätigung","",0,"{ENTER}")    ;

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")
        $Sek = 1

        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")
    $Sek = 1

        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
     Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 15000);15 sekunden später; Die mehrstellige Zahl ändern um die länge der Datenrevision anzupassen. Beispiel: 1 m = 60s = 60000ms
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500)
    Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer

MsgBox(64, "InfoBox", "Die Express-Datensicherung wurde erfolgreich durchgeführt.")
EndFunc

Func Revision()

  MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.")

   Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5")

$Sek = 1
        Sleep($Sek * 5000);5 sekunden später

Run("c:\THEORG\THEORG\TADMIN.exe /REVISION") ; Startet die Datenrevision!

Opt("WinWait",3) ; ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert

WinWait("Datenrevision und Datenbank-Update") ;Wartet mit der Durchführung der Tastenanschläge bis das Fenster "TDatenrevision und datenbank-Update" offen ist.
   $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{K}{ALT up}")
   $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}")
   $Sek = 1
      Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}")
   $Sek = 1
         Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}")

   $Sek = 1
      Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{F}{ALT up}")
   $Sek = 1
      Sleep($Sek * 500)




      Local $aRetArray, $sFilePath = ("C:\THEORG\THEORG\LOGS\TADMINEvent.log")   ; Pfad zur LogDatei

_FileReadToArray($sFilePath, $aRetArray)
Local $i = $aRetArray[0] -4         ; Position des Strings (last line - 4)
Local $sStr1 = $aRetArray[$i]       ; Liest die Position

Local $sStr2 = FileReadLine("C:\THEORG\THEORG\LOGS\Vergleich.txt", 1)    ; Pfad zum Vergleich und die Zeile 1 zum lesen

ConsoleWrite("$sStr1 = " & $sStr1 & @CRLF)  ; Test
ConsoleWrite("$sStr2 = " & $sStr2 & @CRLF)  ; Test

; wenn $iCmp = 0 dann stimmt das Ergebnis

; Vergleich der beiden Strings
$iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE)

If $iCmp = 0 Then
      Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer
 MsgBox(64, "InfoBox", "Die Datenrevision wurde erfolgreich durchgeführt und das Programm ist nun wieder verwendbar")

 Else

    MsgBox(64, "InfoBox", "Die Datenrevision ist Fehlgeschlagen, bitte Fragen Sie Ihren EDV Betreuer nach Auskunft!")

EndIf


EndFunc

Hopefully you can help me improve my script. I am really thankfull so far!

no edit.PNG

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites

Eddi96,

You need a certain number of posts before you get "Edit" privileges. And when you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yeah forgot about that...

I cant test your code but I did test your if statement with my code from above and it works fine here

If $iCmp = 0 Then

;~       Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer
 MsgBox(64, "InfoBox", "Die Datenrevision wurde erfolgreich durchgeführt und das Programm ist nun wieder verwendbar")

 Else

    MsgBox(64, "InfoBox", "Die Datenrevision ist Fehlgeschlagen, bitte Fragen Sie Ihren EDV Betreuer nach Auskunft!")

EndIf

Probably something else within the function causing it not to fire (winwaits tend to cause problems sometimes). I suggest adding some error checking to see wo deine "bremse" sind ;-)

Bill

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I found the mistake, it takes some time until the actual programm finishes the Logfile, I just had to add a sleep.

Thank you so much guys!!! Love you all!

Here is the finished code in case someone wants to see how I used the function above. I hope it helps!

#RequireAdmin

#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <File.au3>

Test()

Func Test()
    ; Das GUI
    Local $hGUI = GUICreate("Test", 300, 200)

    ; Erstellung der Buttons
    Local $idRevision = GUICtrlCreateButton("Datenrevision", 30, 170, 85, 25)
    Local $idExpress = GUICtrlCreateButton("ExpressDasi", 120, 170, 85, 25)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Darstellung des GUI
    GUISetState(@SW_SHOW, $hGUI)

    Local $iPID = 0

    ; Loop bis der benutzer auf Close drückt
   While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

             Case $idRevision

               Revision()

             Case $idExpress

               Express()

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

    ; Close the Notepad process using the PID returned by Run.
    If $iPID Then ProcessClose($iPID)
EndFunc

Func Testing()

      Local $aRetArray, $sFilePath = ("C:\THEORG\THEORG\LOGS\TADMINEvent.log")   ; Pfad zur LogDatei

_FileReadToArray($sFilePath, $aRetArray)
Local $i = $aRetArray[0] -2         ; Position des Strings (last line - 2)
Local $sStr1 = $aRetArray[$i]       ; Liest die Position

Local $sStr2 = FileReadLine("C:\THEORG\THEORG\LOGS\Vergleich.txt", 1)    ; Pfad zum Vergleich und die Zeile 1 zum lesen

ConsoleWrite("$sStr1 = " & $sStr1 & @CRLF)  ; Test
ConsoleWrite("$sStr2 = " & $sStr2 & @CRLF)  ; Test

; wenn $iCmp = 0 dann stimmt das Ergebnis

; Vergleich der beiden Strings
$iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE)

$Sek = 1
      Sleep($Sek * 2000);2 sekunden später
If $iCmp = 0 Then

   Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer
 MsgBox(64, "InfoBox", "Die Datenrevision wurde erfolgreich durchgeführt und das Programm ist nun wieder verwendbar")

 Else

    MsgBox(64, "InfoBox", "Die Datenrevision ist Fehlgeschlagen, bitte Fragen Sie Ihren EDV Betreuer nach Auskunft!")

EndIf


EndFunc



Func Express()

MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.")

Opt("WinWait",3) ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert

Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5")          ; Startet den Shutdown anderer Benutzer im THEORG und
                                                    ; sperrt die Benutzung bis UNLOCK durchgeführt wird.
Run("C:\THEORG\SUPPORT\BACKUP\TBSYS.EXE /SERVICE")  ;

WinWait("THEORG-Datensicherung") ; Wartet mit der Durchführung der Tastenanschläge bis das Fenster "THEORG-Datensicherung" offen ist.
    $Sek = 1
        Sleep($Sek * 5000);5 sekunden später
    ControlSend("THEORG-Datensicherung","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{DOWN}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

$Sek = 1
        Sleep($Sek * 500);0,5 sekunden später   ;
    ControlSend("Bestätigung","",0,"{RIGHT}")  ; Diese zwei Tastenanschläge sorgen für die
                                                ; nicht überschreibung der zuvor
$Sek = 1                                        ; durchgeführten Express Datensicherung.
        Sleep($Sek * 500);0,5 sekunden später  ;
    ControlSend("Bestätigung","",0,"{ENTER}")  ;

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")
        $Sek = 1

        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")
    $Sek = 1

        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
     Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 15000);15 sekunden später; Die mehrstellige Zahl ändern um die länge der Datenrevision anzupassen. Beispiel: 1 m = 60s = 60000ms
    ControlSend("THEORG Datensicherung erstellen","",0,"{ENTER}")

    $Sek = 1
        Sleep($Sek * 500)
    Run("C:\theorg\theorg\TADMIN /UNLOCKSYSTEM") ; Öffnet THEORG wieder für alle Benutzer

MsgBox(64, "InfoBox", "Die Express-Datensicherung wurde erfolgreich durchgeführt.")
EndFunc

Func Revision()

  MsgBox(64, "InfoBox", "THEORG wird nun für alle Benutzer gesperrt.")

   Run("C:\theorg\theorg\TADMIN /SHUTDOWN=5")

$Sek = 1
        Sleep($Sek * 5000);5 sekunden später

Run("c:\THEORG\THEORG\TADMIN.exe /REVISION") ; Startet die Datenrevision!

Opt("WinWait",3) ; ; Gibt an, dass WinWait auf einen bestimmten Titel reagiert

WinWait("Datenrevision und Datenbank-Update") ;Wartet mit der Durchführung der Tastenanschläge bis das Fenster "TDatenrevision und datenbank-Update" offen ist.
   $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{K}{ALT up}")
   $Sek = 1
        Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}")
   $Sek = 1
      Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}")
   $Sek = 1
         Sleep($Sek * 500);0,5 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}")

   $Sek = 1
      Sleep($Sek * 15000);15 sekunden später
      controlsend("Datenrevision und Datenbank-Update","",0,"{ALT down}{F}{ALT up}")
   $Sek = 1
      Sleep($Sek * 500)
      controlsend("Datenrevision und Datenbank-Update","",0,"{ENTER}")
   $Sek = 1

Testing()

EndFunc

 

Edited by Eddi96
Adding code

Share this post


Link to post
Share on other sites

It's not inteded for external use. This is just a little tool me and my collegues will use to automate our backup and revision. Sorry for language Switching, Wir sind hier alle Fachinformatiker Systemintegration/Anwendungsentwicklung. Das war bloß ein kleines Projekt für mich und um das Programm, welches wir betreiben , näher kennenzulernen. Ich bin selber Noch Azubi und habe am 13.Juni angefangen :D

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