Hallo
ich möchte Execute über mehrer zeilen laufen lassen
wie geht das ?
$befehl = 'MsgBox (0,"",1)' & @CRLF & _
'MsgBox (0,"",2)' & @CRLF & _
'MsgBox (0,"",3)' & @CRLF & _
'MsgBox (0,"",4)'
Execute ($befehl)
Hallo
ich möchte Execute über mehrer zeilen laufen lassen
wie geht das ?
$befehl = 'MsgBox (0,"",1)' & @CRLF & _
'MsgBox (0,"",2)' & @CRLF & _
'MsgBox (0,"",3)' & @CRLF & _
'MsgBox (0,"",4)'
Execute ($befehl)
So funktioniert das: ![]()
$befehl = 'MsgBox (0,"",1)' & @CRLF & _
'MsgBox (0,"",2)' & @CRLF & _
'MsgBox (0,"",3)' & @CRLF & _
'MsgBox (0,"",4)'
_Execute($befehl)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _Execute($iCmd)
Local $iSplit = StringSplit($iCmd, @CRLF)
For $xi = 1 To $iSplit[0]
Execute($iSplit[$xi])
Next
EndFunc ;==>_Execute
ja genauso habe ich das auch gemacht aber da akceptiert es ja keine schleife weil sie ja 2 zeilen oder mehr braucht
$befehl = 'While 1' & @CRLF & _
'For $a = 1 to 9999999' & @CRLF & _
'Tooltip ($a,0,0)' & @CRLF & _
'Next' & @CRLF & _
'WEnd'
_Execute($befehl)
[/autoit][autoit][/autoit][autoit][/autoit][autoit]Func _Execute($iCmd)
Local $iSplit = StringSplit($iCmd, @CRLF)
For $xi = 1 To $iSplit[0]
Execute($iSplit[$xi])
Next
EndFunc ;==>_Execute
geht nicht ![]()
Mit Execute kann man nur Befehle wie MsgBox oder FileRead etc. ausführen. Mit Schleifen funktioniert das nicht!
gibt es dann andere möglichkeiten ?
Ja. Selber Funktionen erstellen. Kann aber sehr aufwändig werden.
Es geht auch anders.
Aber du hattest dir eine Endlosschleife gebaut. ![]()
Was soll die zählergesteuerte Schleife innerhalb einer Endlosschleife. ?
So gehts:
[autoit]$befehl = 'For $a = 1 to 99' & @CRLF & _
'Tooltip ($a,0,0)' & @CRLF & _
'Sleep(20)' & @CRLF & _
'Next'
FileWrite(@TempDir & "\temp.script.au3", $befehl)
RunWait(@AutoItExe & ' /AutoIt3ExecuteScript "' & @TempDir & '\temp.script.au3"')
FileDelete(@TempDir & "\temp.script.au3")
So ungefähr müsste es aussehen:
$Source = '$Answer1 = MsgBox(262212, "Hallo", "Klick any button ^^")' & @CRLF _
& '$Answer2 = MsgBox(262212, "Hallo", "Klick any button ^^")' & @CRLF _
& 'If $Answer1 = $Answer2 Then' & @CRLF _
& ' MsgBox(0, "", "Sie haben 2x das selbe gewählt.")' & @CRLF _
& 'EndIf'
_RunPlugIn($Source)
; #FUNCTION# ====================================================================================================================
; Name...........: _RunPlugIn
; Description ...: Führt einen Plug-In aus
; Syntax.........: _RunPlugIn($Source)
; Parameters ....: $Source - Source in AutoIt
; Author ........: Burak Keskin <[email='Burak.keskin@arcor.de'][/email]>
; ===============================================================================================================================
Func _RunPlugIn($Source)
Local $StartLoop_Line, $EndLoop_Line
$Split1 = StringSplit($Source, @LF)
For $NextLoop1 = 1 To $Split1[0]
$Split2 = StringSplit($Split1[$NextLoop1], "=")
$Split3 = StringSplit($Split1[$NextLoop1], " ")
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] <> "For" And $Split3[1] <> "If" Then
If $Split2[0] > 1 Then
Assign(StringTrimLeft(StringTrimRight($Split2[1], 1), 1), Execute(StringTrimLeft(StringReplace($Split2[2], @CR, ""), 1)))
ElseIf $Split2[0] = 1 Then
Execute(StringReplace($Split1[$NextLoop1], @CR, ""))
EndIf
EndIf
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] = "For" Then
$StartLoop_Line = $NextLoop1
For $NextLoop2 = $StartLoop_Line To $Split1[0]
If StringInStr($Split1[$NextLoop2], "Next") Then
$EndLoop_Line = $NextLoop2
ExitLoop
EndIf
Next
$From = $Split3[4]
$To = $Split3[6]
$StartLoop_Line += 1
$EndLoop_Line -= 1
$VarName = $Split3[2]
For $FNLoop = Number($From) To Number($To)
For $NextLoop3 = Number($StartLoop_Line) To Number($EndLoop_Line)
Execute(StringReplace($Split1[$NextLoop3], @CR, ""))
Next
Next
$NextLoop1 = $EndLoop_Line
EndIf
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] = "If" Then
$StartLoop_Line2 = $NextLoop1
For $NextLoop2 = $StartLoop_Line To $Split1[0]
If StringInStr($Split1[$NextLoop2], "EndIf") Then
$EndLoop_Line2 = $NextLoop2
ExitLoop
EndIf
Next
$Var1 = $Split3[2]
$Var2 = $Split3[4]
$StartLoop_Line2 += 1
$EndLoop_Line2 -= 1
$IfType = $Split3[3]
If StringLeft(Eval("Var1"), 1) = "$" Then
$Var1 = Eval(StringTrimLeft(Eval("Var1"), 1))
Else
$Var1 = Eval("Var1")
EndIf
If StringLeft(Eval("Var2"), 1) = "$" Then
$Var2 = Eval(StringTrimLeft(Eval("Var2"), 1))
Else
$Var2 = Eval("Var2")
EndIf
If $IfType = "=" Then
If String($Var1) = String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
ElseIf $IfType = "<" Then
If String($Var1) < String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
ElseIf $IfType = ">" Then
If String($Var1) > String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
ElseIf $IfType = "<>" Then
If String($Var1) <> String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
EndIf
$NextLoop1 = $EndLoop_Line2
EndIf
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] = "While" Then
EndIf
Next
EndFunc ;==>_RunPlugIn
geht das auch wen jemand kein autoit besitzt ?
weil es soll so funktionieren
Ja. Mit BugFix's Version, klappt das auch auf Computer ohne AutoIt, sobald dein Script Compiliert wurde.
Hier noch ein Vorschlag. Habs mal etwas angepasst:
$Source = 'For $FNLoop = 1 to 99' & @CRLF & _
'Tooltip ($FNLoop,0,0)' & @CRLF & _
'Sleep(20)' & @CRLF & _
'Next'
_RunPlugIn($Source)
[/autoit] [autoit][/autoit] [autoit]; #FUNCTION# ====================================================================================================================
; Name...........: _RunPlugIn
; Description ...: Führt einen Plug-In aus
; Syntax.........: _RunPlugIn($Source)
; Parameters ....: $Source - Source in AutoIt
; Author ........: Burak Keskin <[email='Burak.keskin@arcor.de'][/email]>
; ===============================================================================================================================
Func _RunPlugIn($Source)
Local $StartLoop_Line, $EndLoop_Line
[/autoit] [autoit][/autoit] [autoit]$Split1 = StringSplit($Source, @LF)
[/autoit] [autoit][/autoit] [autoit]For $NextLoop1 = 1 To $Split1[0]
[/autoit] [autoit][/autoit] [autoit]$Split2 = StringSplit($Split1[$NextLoop1], "=")
$Split3 = StringSplit($Split1[$NextLoop1], " ")
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] <> "For" And $Split3[1] <> "If" Then
If $Split2[0] > 1 Then
Assign(StringTrimLeft(StringTrimRight($Split2[1], 1), 1), Execute(StringTrimLeft(StringReplace($Split2[2], @CR, ""), 1)))
ElseIf $Split2[0] = 1 Then
Execute(StringReplace($Split1[$NextLoop1], @CR, ""))
EndIf
EndIf
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] = "For" Then
$StartLoop_Line = $NextLoop1
For $NextLoop2 = $StartLoop_Line To $Split1[0]
If StringInStr($Split1[$NextLoop2], "Next") Then
$EndLoop_Line = $NextLoop2
ExitLoop
EndIf
Next
$From = $Split3[4]
$To = $Split3[6]
$StartLoop_Line += 1
$EndLoop_Line -= 1
$VarName = $Split3[2]
For $FNLoop = Number($From) To Number($To)
For $NextLoop3 = Number($StartLoop_Line) To Number($EndLoop_Line)
Execute(StringReplace($Split1[$NextLoop3], @CR, ""))
Next
Next
$NextLoop1 = $EndLoop_Line
EndIf
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] = "If" Then
$StartLoop_Line2 = $NextLoop1
For $NextLoop2 = $StartLoop_Line To $Split1[0]
If StringInStr($Split1[$NextLoop2], "EndIf") Then
$EndLoop_Line2 = $NextLoop2
ExitLoop
EndIf
Next
$Var1 = $Split3[2]
$Var2 = $Split3[4]
$StartLoop_Line2 += 1
$EndLoop_Line2 -= 1
$IfType = $Split3[3]
If StringLeft(Eval("Var1"), 1) = "$" Then
$Var1 = Eval(StringTrimLeft(Eval("Var1"), 1))
Else
$Var1 = Eval("Var1")
EndIf
If StringLeft(Eval("Var2"), 1) = "$" Then
$Var2 = Eval(StringTrimLeft(Eval("Var2"), 1))
Else
$Var2 = Eval("Var2")
EndIf
If $IfType = "=" Then
If String($Var1) = String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
ElseIf $IfType = "<" Then
If String($Var1) < String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
ElseIf $IfType = ">" Then
If String($Var1) > String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
ElseIf $IfType = "<>" Then
If String($Var1) <> String($Var2) Then
For $NextLoop4 = $StartLoop_Line2 To $EndLoop_Line2
Execute(StringReplace($Split1[$NextLoop4], @CR, ""))
Next
EndIf
EndIf
$NextLoop1 = $EndLoop_Line2
EndIf
;---------------------------------------------------------------------------------------------------------------
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;---------------------------------------------------------------------------------------------------------------
If $Split3[1] = "While" Then
EndIf
[/autoit] [autoit][/autoit] [autoit]Next
EndFunc ;==>_RunPlugIn
geht das auch wen jemand kein autoit besitzt ?
weil es soll so funktionieren
Welchen Sinn soll denn das Ausführen von AutoIt-Befehlen außerhalb der AutoIt-Umgebung haben? Was soll das werden?
Habe ein mini Autoit geschriben was scripts erstellt (ohne farben) und das soll script sofort starten wie eben bei autoit ![]()