Hab gestern eine interessante Alternative gefunden, um Objekte in AutoIt zu erstellen und zwar hier: http://www.source-center.de/forum/showthre…assen-in-AutoIt
Ich kann das sicher mal brauchen, vielleicht auch der/die eine oder andere von euch auch.
Spoiler anzeigen
;http://www.source-center.de/forum/showthre…assen-in-AutoIt
[/autoit] [autoit][/autoit] [autoit]AutoItSetOption('MustDeclareVars', 1)
Dim $oScriptControl = ObjCreate('MSScriptControl.ScriptControl')
$oScriptControl.Language = 'VBScript'
Dim $clsRectangle = $oScriptControl.Modules.Add('clsRectangle')
$clsRectangle.AddCode( _
'Class clsRectangle' & @CRLF & _
' Private a' & @CRLF & _
' Private b' & @CRLF & _
' Private Sub Class_Initialize' & @CRLF & _
' a = 2' & @CRLF & _
' b = 4' & @CRLF & _
' End Sub' & @CRLF & _
' Public Property Get Length' & @CRLF & _
' Length = a' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Let Length(NewLength)' & @CRLF & _
' a = NewLength' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Get Width' & @CRLF & _
' Width = b' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Let Width(NewWidth)' & @CRLF & _
' b = NewWidth' & @CRLF & _
' End Property' & @CRLF & _
' Public Function GetArea()' & @CRLF & _
' GetArea = a * b' & @CRLF & _
' End Function' & @CRLF & _
' Public Function GetPerimeter()' & @CRLF & _
' GetPerimeter = 2 * (a + b)' & @CRLF & _
' End Function' & @CRLF & _
'End Class' _
)
Dim $clsSquare = $oScriptControl.Modules.Add('clsSquare')
$clsSquare.AddCode( _
'Class clsSquare' & @CRLF & _
' Private a' & @CRLF & _
' Private Sub Class_Initialize' & @CRLF & _
' a = 2' & @CRLF & _
' End Sub' & @CRLF & _
' Public Property Get Length' & @CRLF & _
' Length = a' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Let Length(NewLength)' & @CRLF & _
' a = NewLength' & @CRLF & _
' End Property' & @CRLF & _
' Public Function GetArea()' & @CRLF & _
' GetArea = a^2' & @CRLF & _
' End Function' & @CRLF & _
' Public Function GetPerimeter()' & @CRLF & _
' GetPerimeter = 4 * a' & @CRLF & _
' End Function' & @CRLF & _
'End Class' _
)
Dim $clsTriangle = $oScriptControl.Modules.Add('clsTriangle')
$clsTriangle.AddCode( _
'Class clsTriangle' & @CRLF & _
' Private a' & @CRLF & _
' Private b' & @CRLF & _
' Private c' & @CRLF & _
' Private Sub Class_Initialize' & @CRLF & _
' a = 20' & @CRLF & _
' b = 21' & @CRLF & _
' c = 29' & @CRLF & _
' End Sub' & @CRLF & _
' Public Property Get AdjacentLeg' & @CRLF & _
' AdjacentLeg = a' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Let AdjacentLeg(NewAdjacentLeg)' & @CRLF & _
' a = NewAdjacentLeg' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Get OppositeLeg' & @CRLF & _
' OppositeLeg = b' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Let OppositeLeg(NewOppositeLeg)' & @CRLF & _
' b = NewOppositeLeg' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Get Hypotenuse' & @CRLF & _
' Hypotenuse = c' & @CRLF & _
' End Property' & @CRLF & _
' Public Property Let Hypotenuse(NewHypotenuse)' & @CRLF & _
' c = NewHypotenuse' & @CRLF & _
' End Property' & @CRLF & _
' Public Function GetArea()' & @CRLF & _
' GetArea = a * b / 2' & @CRLF & _
' End Function' & @CRLF & _
' Public Function GetPerimeter()' & @CRLF & _
' GetPerimeter = a + b + c' & @CRLF & _
' End Function' & @CRLF & _
'End Class' _
)
Dim $oRectangle = $clsRectangle.Eval('New clsRectangle')
ConsoleWrite('!--- Rechteck' & @CRLF)
_PrintRectangle($oRectangle)
$oRectangle.Length = 20
$oRectangle.Width = 40
_PrintRectangle($oRectangle)
ConsoleWrite(@CRLF)
[/autoit] [autoit][/autoit] [autoit]Dim $oSquare = $clsSquare.Eval('New clsSquare')
ConsoleWrite('!--- Quadrat' & @CRLF)
_PrintSquare($oSquare)
$oSquare.Length = 20
_PrintSquare($oSquare)
ConsoleWrite(@CRLF)
[/autoit] [autoit][/autoit] [autoit]Dim $oTriangle = $clsTriangle.Eval('New clsTriangle')
ConsoleWrite('!--- Rechtwinkliges Dreieck' & @CRLF)
_PrintTriangle($oTriangle)
$oTriangle.AdjacentLeg = 210
$oTriangle.OppositeLeg = 200
$oTriangle.Hypotenuse = 290
_PrintTriangle($oTriangle)
Func _PrintRectangle($p_oRectangle)
ConsoleWrite(' Länge:' & @TAB & $p_oRectangle.Length & @CRLF)
ConsoleWrite(' Breite:' & @TAB & $p_oRectangle.Width & @CRLF)
ConsoleWrite(' Fläche:' & @TAB & $p_oRectangle.GetArea & @CRLF)
ConsoleWrite(' Umfang:' & @TAB & $p_oRectangle.GetPerimeter & @CRLF)
ConsoleWrite(' -------' & @CRLF)
EndFunc ;==>_PrintRectangle
Func _PrintSquare($p_oSquare)
ConsoleWrite(' Länge:' & @TAB & $p_oSquare.Length & @CRLF)
ConsoleWrite(' Fläche:' & @TAB & $p_oSquare.GetArea & @CRLF)
ConsoleWrite(' Umfang:' & @TAB & $p_oSquare.GetPerimeter & @CRLF)
ConsoleWrite(' -------' & @CRLF)
EndFunc ;==>_PrintSquare
Func _PrintTriangle($p_oTriangle)
ConsoleWrite(' Ankathete:' & @TAB & $p_oTriangle.AdjacentLeg & @CRLF)
ConsoleWrite(' Gegenkathete:' & @TAB & $p_oTriangle.OppositeLeg & @CRLF)
ConsoleWrite(' Hypotenuse:' & @TAB & $p_oTriangle.Hypotenuse & @CRLF)
ConsoleWrite(' Fläche:' & @TAB & $p_oTriangle.GetArea & @CRLF)
ConsoleWrite(' Umfang:' & @TAB & $p_oTriangle.GetPerimeter & @CRLF)
ConsoleWrite(' -------' & @CRLF)
EndFunc ;==>_PrintTriangle