soo, jetzt auch mal ein Projekt von mir
...nur ein kleines, was mir oft bei anderen Sachen hilft...
es handelt sich um eine Art "Bildschirm-Lineal", mit dem man Sachen markieren kann - und man bekommt Informationen wie Breite, x-Position, y-Position und Höhe angezeigt.
Oft nützlich bei Web-Design und GUI-Erstellung, wenn es auf Pixelgenaue Platzierungen ankommt
Bedienung:
F10 blendet ScreenRuler ein und aus (Bleibt im Hintergrund/Tray)
ESC beendet ScreenRuler
nun kurz ein paar Wörter über den Code:
ich verwende GUIPlus um aus einem JPG-Farbspektrum einen Array zu erstellen, bei Mausbewegungen ändern die Anzeigen im ScreenRuler die Farben
Um das Tool möglichst portabel zu machen, wird das JPG-Farbspektrum mit "resources.au3" in den Quellcode eingebunden -> die wunderschönen Farbeffekte gibts nur nach dem compilen
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=ScreenRuler.ico
#AutoIt3Wrapper_outfile=ScreenRuler_v10.exe
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_File_Add=spectrum.jpg, rt_rcdata, SPECTRUM_JPG
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <GDIPlus.au3>
#include <Array.au3>
#include "resources.au3"
$version=1.0
[/autoit] [autoit][/autoit] [autoit]#cs
README:
Das Icon ist GPL, von Alessandro Rei
resources.au3 gibts bei: ;get it from here: http://www.autoitscript.com/forum/topic/51103-resources-udf/
ich weiß nicht mehr wo ich die funktion _GDIPlus_BitmapGetPixel her hab....könnt ihr mir helfen?
KNOWN BUGS:
* die beiden labels flackern....
* ab und zu stürzt das Programm ab (4% der Fälle) mit "Subscript used with non-Array variable" - deshalb die vielen MsgBoxes überall wo ich Arrays verwende...
wenn es bei euch abstürzt, sagt mir bitte wo
(c) 2011 by r4lf von autoit.de
[/autoit] [autoit][/autoit] [autoit]#ce
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Opt("MouseCoordMode",2)
HotKeySet("{ESC}","myshutdown")
HotKeySet("{F10}","toggleme")
Func toggleme()
Global $shown
If $shown=1 Then
GUISetState(@SW_HIDE)
$shown=0
Else
GUISetState(@SW_SHOW)
$shown=1
EndIf
EndFunc
Func myshutdown()
Exit
EndFunc
Global $left,$top,$width,$height,$mousepressed, $shown,$pointer, $colorArray
$mousepressed=0
$shown=1
$left=105
$top=100
$width=229
$height=124
$pointer=0
;#########################################################################################################################
; Farbinformationen aus Farbspektrum in Array lesen
_GDIPlus_Startup()
$hImage=_ResourceGetAsImage("SPECTRUM_JPG")
$iPosY = 10
$xfrom=0
$xto=300-1
Dim $colorArray[1]=[0]
[/autoit] [autoit][/autoit] [autoit]For $n=$xfrom To $xto
$c=_GDIPlus_BitmapGetPixel($hImage, $n, $iPosY)
_ArrayAdd($colorArray,$c)
Next
_ArrayDelete($colorArray,0)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()
;#########################################################################################################################
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$Form1 = GUICreate("ScreenRuler", @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
WinSetTrans("ScreenRuler","",127)
GUISetBkColor(0xFFFFFF)
$LabelInfo = GUICtrlCreateLabel("left:105 top:100 width:229 height:124", 0, @DesktopHeight-27,@DesktopWidth, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1,0x08440B)
$LabelBox = GUICtrlCreateLabel("", 105, 100, 229, 124)
GUICtrlSetBkColor(-1,0x08440B)
GUISetState(@SW_SHOW)
$lastpressed=0
$move=0
Func getNextColor()
Global $pointer,$colorArray
If Not IsArray($colorArray) Then
MsgBox(16,"ERROR",'$colorArray is not an array o_O"')
EndIf
$c=$colorArray[$pointer]
$pointer+=1
If $pointer=300 Then $pointer=0
Return $c
EndFunc
While 1
If $shown=1 Then
If $lastpressed=0 Then
If _IsPressed(01) Then
$lastpressed=1
$i=GUIGetCursorInfo()
If IsArray($i) And $i[4]=$LabelBox Then
;move the box
$move=1
$rel=MouseGetPos()
If Not IsArray($rel) Then MsgBox(16,"ERROR","MOUSE POSITION ERROR. - rel")
$relx1=$rel[0]
$rely1=$rel[1]
$relx=$relx1-$left
$rely=$rely1-$top
Else
$mousepressed=1
$startpos=MouseGetPos()
If Not IsArray($startpos) Then MsgBox(16,"ERROR","MOUSE POSITION ERROR. - startpos")
$left=$startpos[0]
$top=$startpos[1]
GUICtrlSetPos($LabelBox,$left,$top,1,1)
$move=0
EndIf
EndIf
Else
If Not _IsPressed(01) Then
$lastpressed=0
primup()
Else
updateInfo()
If $move=1 Then
;move the field
$p=MouseGetPos()
If Not IsArray($p) Then MsgBox(16,"ERROR","MOUSE POSITION ERROR. - p")
$left=$p[0]-$relx
$top=$p[1]-$rely
GUICtrlSetPos($LabelBox,$left,$top)
Else
;draw the field
$pos=MouseGetPos()
If Not IsArray($pos) Then MsgBox(16,"ERROR","MOUSE POSITION ERROR. - pos")
$mx=$pos[0]
$my=$pos[1]
$width=$mx-$left
$height=$my-$top
If $width>0 And $height>0 Then
;quadrant 4
GUICtrlSetPos($LabelBox,$left,$top,$width,$height)
ElseIf $width>0 And $height<0 Then
;quadrant 1
$mheight=-$height
$mtop=$my
GUICtrlSetPos($LabelBox,$left,$mtop,$width,$mheight)
ElseIf $width<0 And $height>0 Then
;quadrant 3
$mwidth=-$width
$mleft=$mx
GUICtrlSetPos($LabelBox,$mleft,$top,$mwidth,$height)
ElseIf $width<0 And $height<0 Then
;quadrant 2
$mwidth=-$width
$mleft=$mx
$mheight=-$height
$mtop=$my
GUICtrlSetPos($LabelBox,$mleft,$mtop,$mwidth,$mheight)
Else
GUICtrlSetPos($LabelBox,$left,$top,1,1)
EndIf
EndIf
EndIf
EndIf
EndIf ;shown
WEnd
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func updateInfo()
[/autoit] [autoit][/autoit] [autoit]If $width>0 And $height>0 Then
;quadrant 4
$s="left:"&$left&" top:"&$top&" width:"&$width&" height:"&$height
ElseIf $width>0 And $height<0 Then
;quadrant 1
$mheight=-$height
$mtop=$my
$s="left:"&$left&" top:"&$mtop&" width:"&$width&" height:"&$mheight
ElseIf $width<0 And $height>0 Then
;quadrant 3
$mwidth=-$width
$mleft=$mx
$s="left:"&$mleft&" top:"&$top&" width:"&$mwidth&" height:"&$height
ElseIf $width<0 And $height<0 Then
;quadrant 2
$mwidth=-$width
$mleft=$mx
$mheight=-$height
$mtop=$my
$s="left:"&$mleft&" top:"&$mtop&" width:"&$mwidth&" height:"&$mheight
Else
$s="left:"&$left&" top:"&$top&" width:"&Abs($width)&" height:"&Abs($height)
EndIf
If GUICtrlRead($LabelInfo) <> $s Then
GUICtrlSetData($LabelInfo,$s)
$newc=getNextColor()
GUICtrlSetBkColor($LabelBox,$newc)
GUICtrlSetBkColor($LabelInfo,$newc)
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func primup()
$mousepressed=0
If $width>0 And $height>0 Then
;quadrant 4
ElseIf $width>0 And $height<0 Then
;quadrant 1
$top=$top+$height
$height=Abs($height)
ElseIf $width<0 And $height>0 Then
;quadrant 3
$left=$left+$width
$width=Abs($width)
ElseIf $width<0 And $height<0 Then
;quadrant 2
$top=$top+$height
$height=Abs($height)
$left=$left+$width
$width=Abs($width)
Else
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func primmove()
If $mousepressed=1 Then
$pos=MouseGetPos()
If Not IsArray($pos) Then MsgBox(16,"ERROR","MOUSE POSITION ERROR. - pos primmove")
$mx=$pos[0]
$my=$pos[1]
$width=$mx-$left
$height=$my-$top
GUICtrlSetPos($LabelBox,$left,$top,$width,$height)
EndIf
EndFunc
Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY)
;ich weiß nicht mehr wo ich diese funktion her hab...wisst ihr das? -.-
Local $tArgb, $pArgb, $aRet
$tArgb = DllStructCreate("dword Argb")
$pArgb = DllStructGetPtr($tArgb)
$aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb)
Return "0x" & Hex(DllStructGetData($tArgb, "Argb"), 6)
EndFunc
Inhalt der .zip:
* JPG-Farbspektrum
* Icon-Datei [GPL]
* resources.au3 [ von http://www.autoitscript.com/forum/topic/51103-resources-udf/]
bitte helft mir mit weiteren Ideen und Anregungen
viele Grüße,
r4lf
//Edit: @DesktopWidth und @DesktopHeight benutzt, Danke an Mattthias!