Sign in to follow this  
Followers 0
autoitrulez

circle around mouse

11 posts in this topic

is there a way so a circle of pixels will apear around the mouse, like say it's +15, there will be a circle around the mouse with a radius of 15 or something along those lines?

Thanks again

Share this post


Link to post
Share on other sites



I would personally create a "Region"ed window and WinMove it according to the mousepos

Lar.

A what? :P

I'm curious, what's a "Region"ed window? I get that you want a transparent GUI with the circle drawn on it, and then move the GUI to follow the mouse pointer. But I have no idea how to achieve such a GUI and that phrase was pretty opaque to me. Could you elaborate for us slow people... :)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

yes, very confsed with regioned window?

is there anyway ti make a pixel or something without the gui..causer then it will use alot of cpu consumption to move the gui as the mouse moves

Edited by autoitrulez

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ESC to exit...

#include <GUIConstants.au3>

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

$GUI = GUICreate("test",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

wow, very kool and nice, btw, which can i edit to change radius and density of circle?

I c the If Not @error Then WinMove($GUI,"",$pt[0] - 15,$pt[1] - 15) line controls how center the cursor is...

i clearly have to edit this to change size of circle, but shape changes also wen i edit

I want to know, because I want there to b an input box to put the size in for a gui

Edited by autoitrulez

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

this is how i created a bigger circle

i just added ten to each of these

$GUI = GUICreate("test",40,40,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)

GUISetBkColor(0xFF0000)

$a = CreateRoundRectRgn(0,0,40,40,40,40)

$b = CreateRoundRectRgn(4,4,32,32,36,36)

square

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

$a = CreateRoundRectRgn(0,0,50,50,10,10)
$b = CreateRoundRectRgn(4,4,42,42,6,6)
Edited by CWorks

Share this post


Link to post
Share on other sites

heres a little waste of effort

#include <GUIConstants.au3>

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

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

$aSize = 40
$density = 1;Keep higher than 1, and less than 1/4 Asize
$Roundness = 40;0 = Square, same as $aSize makes it circle

$a = CreateRoundRectRgn(0,0,$asize,$asize,$Roundness,$Roundness)
$bSize = $aSize - $density*2
$b = CreateRoundRectRgn($density,$density,$bsize,$bsize,$Roundness,$Roundness)
$csize = $asize/2
$c = CreateRoundRectRgn($asize/2/2,$asize/2/2,$csize,$csize,$Roundness,$Roundness)
$d = CreateRoundRectRgn($asize/2/2+$density,$asize/2/2+$density,$csize-($density*2),$csize-($density*2),$Roundness,$Roundness)

CombineRgn($a,$b,$c,$d)
SetWindowRgn($GUI,$a)

GUISetState()
GUISetState(@SW_DISABLE)

While 1
    Sleep(50)
    $pt = MouseGetPos()
    If Not @error Then WinMove($GUI,"",$pt[0] - (($asize + $bsize) /4),$pt[1] - (($asize + $bsize) /4))
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, ByRef $rgn3, ByRef $rgn4)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn3, "int", 3)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn4, "int", 3)
EndFunc

Func bye()
    Exit
EndFunc

makes it more like a dartboard u get 2 circles, and u just change the $aSize $Density and $Roundness to do exactly what they say, the rest are automatic. Should work fine ^^ this was fun

Share this post


Link to post
Share on other sites

ESC to exit...

#include <GUIConstants.au3>

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

$GUI = GUICreate("test",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
Cool! :)

The slow people thank you... :P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Another approach is to draw a circle directly as rysoria does in his OutlineControl routine. I did not get this to work on my system erlier today thought but I think that is due to some pen and brush issues

Share this post


Link to post
Share on other sites

this is how i created a bigger circle

i just added ten to each of these

square

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

$a = CreateRoundRectRgn(0,0,50,50,10,10)
$b = CreateRoundRectRgn(4,4,42,42,6,6)oÝ÷ Ûú®¢×j¸nX³yÛaz¶ëºÚ"µÍÚ[ÛYH  ÑÕRPÛÛÝ[Ë]LÉÝÂÝÙ^TÙ]
    ][ÝÞÑTÐßI][ÝË    ][Ý×ÐYI][ÝÊBÌÍÚPÚÛTHÈ    ÏOOHY]ÈÜY[ÚÛHY]È
[^[ÊBÌÍÚPÚÛQH ÌÍÚPÚÛT
ÌÍÜH[ÝÙQÙ]ÜÊ
BÌÍÑÕRHHÕRPÜX]J   ][ÝÝÝ    ][ÝË  ÌÍÚPÚÛQ    ÌÍÚPÚÛQ    ÌÍÜÌHH  ÌÍÚPÚÛT    ÌÍÜÌWHH ÌÍÚPÚÛT    ÌÍÕÔ×ÔÔT ÌÍÕÔ×ÑVÕÔSÔÕ
BÕRTÙ]ÐÛÛÜ
BÌÍØHHÐÜX]TÝ[XÝÛ    ÌÍÚPÚÛQ    ÌÍÚPÚÛQ    ÌÍÚPÚÛQ    ÌÍÚPÚÛQ
BÌÍØHÐÜX]TÝ[XÝÛ


    ÌÍÚPÚÛQH
K
    ÌÍÚPÚÛQH
K
    ÌÍÚPÚÛQH
K
    ÌÍÚPÚÛQH
JBÐÛÛX[TÛ   ÌÍØK ÌÍØBÔÙ]Ú[ÝÔÛ   ÌÍÑÕRK  ÌÍØJBÕRTÙ]Ý]J
BÕRTÙ]Ý]JÕ×ÑTÐPJBÚ[HBTÛY
L
BIÌÍÜH[ÝÙQÙ]ÜÊ
BRYÝÜ[Ú[[ÝJ ÌÍÑÕRK  ][ÝÉ][ÝË    ÌÍÜÌHH  ÌÍÚPÚÛT    ÌÍÜÌWHH ÌÍÚPÚÛTBÑ[[ÈÐÜX]TÝ[XÝÛ  ÌÍÛ  ÌÍÝ  ÌÍÝË    ÌÍÚ  ÌÍÙLK    ÌÍÙLBIÌÍÜ]HØ[
    ][ÝÙÙLÌ ][ÝË  ][ÝÛÛÉ][ÝË    ][ÝÐÜX]TÝ[XÝÛ][ÝË   ][ÝÛÛÉ][ÝË    ÌÍÛ  ][ÝÛÛÉ][ÝË    ÌÍÝ  ][ÝÛÛÉ][ÝË    ÌÍÛ
È  ÌÍÝË    ][ÝÛÛÉ][ÝË    ÌÍÝ
È  ÌÍÚ  ][ÝÛÛÉ][ÝË    ÌÍÙLK    ][ÝÛÛÉ][ÝË    ÌÍÙLBT]  ÌÍÜ]ÌB[[ÈÏOIÝ×ÐÜX]TÝ[XÝÛ[ÈÐÛÛX[TÛTY   ÌÍÜÛKTY ÌÍÜÛBQØ[
    ][ÝÙÙLÌ ][ÝË  ][ÝÛÛÉ][ÝË    ][ÝÐÛÛX[TÛ][ÝË   ][ÝÛÛÉ][ÝË    ÌÍÜÛK   ][ÝÛÛÉ][ÝË    ÌÍÜÛK   ][ÝÛÛÉ][ÝË    ÌÍÜÛ    ][ÝÚ[ ][ÝËÊB[[ÈÏOIÝ×ÐÛÛX[TÛ[ÈÔÙ]Ú[ÝÔÛ   ÌÍÚÝÚ[ ÌÍÜÛBQØ[
    ][ÝÝÙÌ  ][ÝË  ][ÝÛÛÉ][ÝË    ][ÝÔÙ]Ú[ÝÔÛ][ÝË    ][ÝÚÛ    ][ÝË  ÌÍÚÝÚ[ ][ÝÛÛÉ][ÝË    ÌÍÜÛ    ][ÝÚ[ ][ÝËJB[[ÈÏOIÝ×ÔÙ]Ú[ÝÔÛ[ÈØYJ
BQ^][[ÈÏOIÝ×ØY

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Having way too much fun playing with Larry's script! :)

This version has it all turned in to a couple of "MouseCircle" functions, suitable for turning into a UDF. The demo script uses the fuctions to varry the circle size and color over time:

; Put a ring around the mouse pointer
; Modified from a post by Larry @ http://www.autoitscript.com/forum/index.php?s=&showtopic=32676
#include <GUIConstants.au3>

; Hist ESC to quit
HotKeySet("{ESC}", "_Bye")

; Setup the automated update
Global $hMouseCircle = -1 ; Mouse circle GUI handle
Global $rMouseCircle = 20 ; <=== Edit this value to change circle radius
AdlibEnable("_MouseCircleUpdate", 125)

$hMouseCircle = _MouseCircleInit($rMouseCircle, 0x00FF00)
Sleep(2000) ; Show the default for 2sec

; Change circle size and color
While 1
    $cMouseCircle = 0xFF
    For $rMouseCircle = 8 To 64
        If $hMouseCircle <> -1 Then _MouseCircleDelete()
        $hMouseCircle = _MouseCircleInit($rMouseCircle, $cMouseCircle)
        Sleep(1000)
        $cMouseCircle = $cMouseCircle * 0x2 ; left shift
        If $cMouseCircle > 0xFFFFFF Then $cMouseCircle = 0xFF
    Next
WEnd


; =========================================
;  Local Functions
; =========================================

Func _MouseCircleInit($r, $Color)
    Local $D = $r * 2
    Local $pt = MouseGetPos()
    Local $hGUI = GUICreate("test", $D, $D, $pt[0] - $r, $pt[1] - $r, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor($Color)

    Local $Reg1 = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", 0, "long", 0, "long", $D, "long", $D, "long", $D, "long", $D)
    Local $Reg2 = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", 4, "long", 4, "long", $D - 4, "long", $D - 4, "long", $D, "long", $D)

    ; _CombineRgn($Reg1[0], $Reg2[0])
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $Reg1[0], "long", $Reg1[0], "long", $Reg2[0], "int", 3)
    
    ; _SetWindowRgn($hGUI, $Reg1[0])
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hGUI, "long", $Reg1[0], "int", 1)

    GUISetState()
    GUISetState(@SW_DISABLE)
    Return $hGUI
EndFunc   ;==>_MouseCircleInit

Func _MouseCircleUpdate()
    If $hMouseCircle <> -1 Then
        Local $pt = MouseGetPos()
        If Not @error Then WinMove($hMouseCircle, "", $pt[0] - $rMouseCircle, $pt[1] - $rMouseCircle)
    EndIf
EndFunc   ;==>_MouseCircleUpdate

Func _MouseCircleDelete()
    If $hMouseCircle <> -1 Then
        GUIDelete($hMouseCircle)
        $hMouseCircle = -1
    EndIf
EndFunc   ;==>_MouseCircleDelete

Func _bye()
    Exit
EndFunc   ;==>_bye

Cheers!

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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