Servus,
Zusammengefasst:
Ich möchte(der übliche Anfang) in Adobe Illustrator eine Grafik erstellen. Damit ich dies nicht per Hand erledigen muss, sollte das AutoIt für mich erledigen
Derweilen bin ich soweit, dass ein neues Dokument größe A4 erstellt wird. Um nun mit dem Zeichnen zu beginnen müsste ich den Mittelpunkt des Blattes herrausfinden. Um außerdem das Zeichnen selber zu erleichtern(bzw. das Rechnen zu erleichtern) wäre es gut wenn man ein virtuelles, metrisches "Raster" über die Pixelfläche des Blattes legen könnte.
Skript um ein neues Dokument zu öffnen:
[autoit]#RequireAdmin
Opt('MustDeclareVars', 1)
ShellExecute("Illustrator.exe")
WinWaitActive("Adobe Illustrator CS5")
WinActivate("Adobe Illustrator CS5")
Sleep(3000)
Send("^n")
Sleep(2000)
ControlClick("Neues Dokument", "", "ComboBox2", "left", "1", "933", "348")
Sleep(100)
ControlClick("Neues Dokument", "", "ComboBox2", "left", "1", "930", "444")
Sleep(100)
ControlClick("Neues Dokument", "", "Button2", "left", "1", "1062", "230")
Sleep(100)
Send("{ENTER}")
Exit
Hier ist das neu geöffnete Dokument
http://picfront.de/d/8oLx
Nun müsste man die Pixel des Blattes ermitteln.
Die Farbe in Hex: 0xffffff [Weiß]
Das sind diese hier:
http://picfront.de/d/8oLy
Dies sollte mit Pixelsearch funktionieren:
HotKeySet("!n","_a")
Func _a()
$coord = PixelSearch(560,262,1062,732,0x000000)
If Not @error Then
MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf
EndFunc
while 1
sleep(100)
WEnd
Um den Rahmen der Pixel(also die äußerste Pixelreihe) zu bekommen müsste man einfach linear,kreuzförmig von Innen nach außen suchen lassen oder?
Ich weiß leider nicht, wie ich diesen Ansatz realisieren könnte
Als nächstes das unterteilen des Pixelfeldes in metrische Sektoren.
Sollte in etwa virtuell so aussehen:
http://picfront.de/d/8oLE
Um die Pixel(also die "Koordinatenpunkte" des Bildschirms in ein metrisches System umzuwandeln benötigt man die Formel:
x(cm) * $dpi / 2,54 = y(pixel)
y(pixel) * 2,54/$dpi = x(cm)
Hierfür finde ich die UDF von [James1337] recht nützlich.
#cs
UDF by James1337
Functions: _MillimetersToPixel, _CentimetersToPixel, _PixelToMillimeters, _PixelToCentimeters
#ce
Func _MillimetersToPixel($Millimeters)
Local $DC = DllCall("user32.dll", "long", "GetDC", "long", 0)
Local $DeviceCaps = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $DC[0], "long", 90)
Local $DC = DllCall("user32.dll", "long", "ReleaseDC", "long", 0, "long", $DC)
Local $DPI = $DeviceCaps[0]
Local $Centimeters = $Millimeters * 10
Return $Centimeters * $DPI / 2.54
EndFunc
Func _CentimetersToPixel($Centimeters)
Local $DC = DllCall("user32.dll", "long", "GetDC", "long", 0)
Local $DeviceCaps = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $DC[0], "long", 90)
Local $DC = DllCall("user32.dll", "long", "ReleaseDC", "long", 0, "long", $DC)
Local $DPI = $DeviceCaps[0]
Return $Centimeters * $DPI / 2.54
EndFunc
Func _PixelToMillimeters($Pixel)
Local $DC = DllCall("user32.dll", "long", "GetDC", "long", 0)
Local $DeviceCaps = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $DC[0], "long", 90)
Local $DC = DllCall("user32.dll", "long", "ReleaseDC", "long", 0, "long", $DC)
Local $DPI = $DeviceCaps[0]
Return $Pixel / $DPI * 0.254
EndFunc
Func _PixelToCentimeters($Pixel)
Local $DC = DllCall("user32.dll", "long", "GetDC", "long", 0)
Local $DeviceCaps = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $DC[0], "long", 90)
Local $DC = DllCall("user32.dll", "long", "ReleaseDC", "long", 0, "long", $DC)
Local $DPI = $DeviceCaps[0]
Return $Pixel / $DPI * 2.54
EndFunc
Wenn man nun also die Mitte des Blattes ermittelt hatt, kann man zu zeichnen beginnen.
Was wird gezeichnet?
Das hier:
http://picfront.de/d/8oLI
Es wird aus einer Inputbox der Wert $s und $h ausgelesen.
Danach wird, mithilfe dieser Formel: r = (1/2) • { [(s/2)² / h] +h } , der Kreisradius (r) ermittelt.
In AutoIt schaut das in etwa so aus:
[autoit]include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Test", 278, 316, 472, 247)
$Input1 = GUICtrlCreateInput("s", 32, 32, 217, 21)
$Input2 = GUICtrlCreateInput("h", 32, 64, 217, 21)
$Button1 = GUICtrlCreateButton("= r", 33, 96, 217, 33)
$Button2 = GUICtrlCreateButton("Zeichnen", 33, 143, 217, 33)
GUISetState(@SW_SHOW)
;Damit kein , in AutoIt gelangt!====================================================================================
HotKeySet("{,}","Komma")
HotKeySet("{NUMPADDOT}","Komma")
Func Komma()
Send(".")
EndFunc
;===================================================================================================================
_Test()
Func _Test()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
$s = GUICtrlRead($Input1)
$h = GUICtrlRead($Input2)
$r1 = $s/2
$r2 =($r1)^2
$r3 = $r2/$h
$r4 = $r3 + $h
$r5 = $r4 * 0.5
$rT = ConsoleWrite($r5&@CRLF)
Case $Button2
_Draw()
EndSwitch
WEnd
EndFunc
Func _Draw()
;Blablabla
EndFunc ;==>_Exit
Eine Idee hab ich, nur mit dem Umsetzen hauts noch nicht ganz so hin...
Wäre dankbar wenn mich jemand dabei unterstützen könnte
Danke fürs Lesen und
Grüßé
Stoani