Sign in to follow this  
Followers 0
KevinO

need some help

2 posts in this topic

hello there

i want to draw a box like the picture

TdBRZbR.png

so it will for example detect the Blue Pixel (PixelSearch) and draw a box on it

the box is a .GIF file or GDI depends on whats easier

is this possible? and how need it to be done?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

i found this code, but now i want it to follow a moving pixel on my screen

#include <GUIConstants.au3>

HotKeySet("{ESC}","bye")

$GUI = GUICreate("",30,30,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)
GUISetBkColor(0xFF0000)

$a = CreateRoundRectRgn(0,0,30,30,30,30)
$b = CreateRoundRectRgn(4,4,22,22,26,26)

CombineRgn($a,$B)
SetWindowRgn($GUI,$a)

GUISetState()
GUISetState(@SW_DISABLE)

While 1
    Sleep(50)
    $pt = MouseGetPos()
    If Not @error Then WinMove($GUI,"",$pt[0] - 15,$pt[1] - 15)
WEnd

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc

Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc

Func bye()
    Exit
EndFunc

EDIT:

Found it working code is

#include <GUIConstants.au3>

HotKeySet("{ESC}","bye")

$GUI = GUICreate("",30,30,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)
GUISetBkColor(0xFF0000)

$a = CreateRoundRectRgn(0,0,30,30,30,30)
$b = CreateRoundRectRgn(4,4,22,22,26,26)

CombineRgn($a,$B)
SetWindowRgn($GUI,$a)

GUISetState()
GUISetState(@SW_DISABLE)

While 1
    Sleep(50)
    $coord = PixelSearch( 0, 0, @DesktopWidth, @DesktopHeight,0xD8FFCF)
    If Not @error Then WinMove($GUI,"",$coord[0] - 15, $coord[1] - 15)
WEnd

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc

Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc

Func bye()
    Exit
EndFunc

This is solved

Edited by KevinO

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0