Xenobiologist Posted February 6, 2008 Posted February 6, 2008 (edited) Hi, not very useful, but maybe for somebody ... expandcollapse popup#include<GUIConstantsEx.au3> #include<WindowsConstants.au3> Opt('GUICloseOnESC', 1) Opt('GUIOnEventMode', 1) Opt("WinTitleMatchMode", 4) Global $shell = WinGetPos("classname=Shell_TrayWnd") Global $gui = GUICreate("Gui", 160, 160, @DesktopWidth - 160, @DesktopHeight - 160 - $shell[3], $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") While 1 $pos_X = MouseGetPos(0) $pos_Y = MouseGetPos(1) Global $colors_A = _getPixelColors($pos_X, $pos_Y, $pos_X + 150, $pos_Y + 150) _paintPixel($colors_A, $gui, 5, 5) WEnd Func _getPixelColors($start_X = 0, $start_Y = 0, $end_X = @DesktopWidth, $end_Y = @DesktopHeight) Local $opt = Opt('ColorMode', 1) Local $coord[$end_X - $start_X][$end_Y - $start_Y] For $x = 0 To UBound($coord, 1) - 1 For $y = 0 To UBound($coord, 2) - 1 $coord[$x][$y] = PixelGetColor($x + $start_X, $y + $start_Y) Next Next Opt('ColorMode', $opt) Return $coord EndFunc ;==>_getPixelColors Func _paintPixel(ByRef $coord, $handle, $start_X = 0, $start_Y = 0) Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", $handle) For $x = 0 To UBound($coord, 1) - 1 For $y = 0 To UBound($coord, 2) - 1 DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x + $start_X, "long", $y + $start_Y, "long", $coord[$x][$y]) Next Next DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0]) Return $coord EndFunc ;==>_paintPixel Func CLOSEClicked() Exit (0) EndFunc ;==>CLOSEClicked Mega Edited February 7, 2008 by Xenobiologist Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
JusGellin Posted February 6, 2008 Posted February 6, 2008 I guess I'm easily impressed, but that is pretty cool!!
JustinReno Posted February 7, 2008 Posted February 7, 2008 Wow, that is awesome, its like being able to past pictures in an edit control! Like word... Thanks. :) :D
Uriziel01 Posted February 7, 2008 Posted February 7, 2008 (edited) Really cool ! But i have problem with entering an variable as a $start_X , $start_Y, this is my code: expandcollapse popup#include <GUIConstants.au3> $gui=GUICreate("Gui",400,400,400,400) GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit() Sleep(200) $pos=MouseGetPos(0) $pos2=MouseGetPos(1) Global $colors_A = _getPixelColors($pos,$pos2, 150, 150) _paintPixel($colors_A,$gui, 50, 50) Wend Func _getPixelColors($start_X = 0, $start_Y = 0, $end_X = @DesktopWidth, $end_Y = @DesktopHeight) Local $opt = Opt('ColorMode', 1) Local $coord[$end_X - $start_X][$end_Y - $start_Y] For $x = 0 To UBound($coord, 1) - 1 For $y = 0 To UBound($coord, 2) - 1 $coord[$x][$y] = PixelGetColor($x + $start_X, $y + $start_Y) Next Next Opt('ColorMode', $opt) Return $coord EndFunc ;==>_getPixelColors Func _paintPixel(ByRef $coord, $handle, $start_X = 0, $start_Y = 0) Local $dc For $x = 0 To UBound($coord, 1) - 1 For $y = 0 To UBound($coord, 2) - 1 $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", $handle) DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x + $start_X, "long", $y + $start_Y, "long", $coord[$x][$y]) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0]) Next Next Return $coord EndFunc ;==>_paintPixel Edited February 7, 2008 by Uriziel01
Xenobiologist Posted February 7, 2008 Author Posted February 7, 2008 HI, the questions is what are you trying to achieve? Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Uriziel01 Posted February 7, 2008 Posted February 7, 2008 (edited) I want to view part of screen (150x150px) under my mouse cursor in my GUI window E:\Documents and Settings\PaBloo.URIZIEL01\Moje dokumenty\pixel.au3 (20) : ==> Array variable subscript badly formatted.: Local $coord[$end_X - $start_X][$end_Y - $start_Y] Local $coord[^ ERROR Edited February 7, 2008 by Uriziel01
Xenobiologist Posted February 7, 2008 Author Posted February 7, 2008 (edited) Hi, okay I see: Edit: Code deleted Mega Edited February 7, 2008 by Xenobiologist Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Xenobiologist Posted February 7, 2008 Author Posted February 7, 2008 (edited) Thank You, Very Much. Xenobiologist Hi,no problem, this might be even better for you:Edit: Code deleted (updated above)Mega Edited February 7, 2008 by Xenobiologist Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Zedna Posted February 7, 2008 Posted February 7, 2008 Just optimization: GetDC/ReleaseDC should be outside of LOOP!! Func _paintPixel(ByRef $coord, $handle, $start_X = 0, $start_Y = 0) Local $dc $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", $handle) For $x = 0 To UBound($coord, 1) - 1 For $y = 0 To UBound($coord, 2) - 1 DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x + $start_X, "long", $y + $start_Y, "long", $coord[$x][$y]) Next Next DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0]) Return $coord EndFunc ;==>_paintPixel Resources UDF ResourcesEx UDF AutoIt Forum Search
Xenobiologist Posted February 7, 2008 Author Posted February 7, 2008 Hi, yeah thanks Zedna ! Never tested that. So, this is much faster. --> expandcollapse popup#include<GUIConstantsEx.au3> #include<WindowsConstants.au3> Opt('GUICloseOnESC', 1) Opt('GUIOnEventMode', 1) Opt("WinTitleMatchMode", 4) Global $shell = WinGetPos("classname=Shell_TrayWnd") Global $gui = GUICreate("Gui", 160, 160, @DesktopWidth - 160, @DesktopHeight - 160 - $shell[3], $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") While 1 $pos_X = MouseGetPos(0) $pos_Y = MouseGetPos(1) Global $colors_A = _getPixelColors($pos_X, $pos_Y, $pos_X + 150, $pos_Y + 150) _paintPixel($colors_A, $gui, 5, 5) WEnd Func _getPixelColors($start_X = 0, $start_Y = 0, $end_X = @DesktopWidth, $end_Y = @DesktopHeight) Local $opt = Opt('ColorMode', 1) Local $coord[$end_X - $start_X][$end_Y - $start_Y] For $x = 0 To UBound($coord, 1) - 1 For $y = 0 To UBound($coord, 2) - 1 $coord[$x][$y] = PixelGetColor($x + $start_X, $y + $start_Y) Next Next Opt('ColorMode', $opt) Return $coord EndFunc ;==>_getPixelColors Func _paintPixel(ByRef $coord, $handle, $start_X = 0, $start_Y = 0) Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", $handle) For $x = 0 To UBound($coord, 1) - 1 For $y = 0 To UBound($coord, 2) - 1 DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x + $start_X, "long", $y + $start_Y, "long", $coord[$x][$y]) Next Next DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0]) Return $coord EndFunc ;==>_paintPixel Func CLOSEClicked() Exit (0) EndFunc ;==>CLOSEClicked Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Uriziel01 Posted February 7, 2008 Posted February 7, 2008 Wow Nice, really thx to both of you, now it have nice speed. Im now adding some effects (negative, blur,colorize etc. )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now