Sign in to follow this  
Followers 0
Aceguy

A little red box

5 posts in this topic

i would like to mark the area of a window with a red box, just the ouline, and transparent in the middle. i have tried.

$box1=GUICreate('',$aoe_r*2,$aoe_r*2,$xl2 - $aoe_r, $yl2 - $aoe_r, $WS_POPUP, bitor($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))

GUISetBkColor(0xff0000)

GUISetState(@SW_SHOW,$box1)

but that is a solid box.?

any ideas

:)

Share this post


Link to post
Share on other sites



like this?:

#include <WindowsConstants.au3>
#Include <Misc.au3>

$dll = DllOpen("user32.dll")

$color = "0x000000" ;black

$aoe_r=100
$x = $aoe_r*2
$y = $aoe_r*2
$mouse_pos = MouseGetPos()
$box1=GUICreate('',$x,$y,$mouse_pos[0]-$x/2, $mouse_pos[1]-$y/2, $WS_POPUP, bitor($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
GUISetBkColor(0xff0000)
$black = GUICtrlCreateGraphic(0, 0, $x, $y)
GUICtrlSetCursor(-1, 3)
GUICtrlSetColor(-1, 0)
WinSetTrans($box1, "", 100)
GUISetState(@SW_SHOW,$box1)

TrayTip("", "press Mouse Left Click to search" & @CRLF & "press Mouse Right Click to exit", 10)

Global $old_pos
dim $Get_Pixel[1]

While 1
    if WinActive($box1) Then
        if _IsPressed(01, $dll) Then
            GUISetState(@SW_HIDE, $box1)
            $Win_Pos = WinGetPos($box1)
            if $Win_Pos[0]+$Win_Pos[2] > @DesktopWidth then $Win_Pos[2] = $Win_Pos[2]-($Win_Pos[0]+$Win_Pos[2]-@DesktopWidth)
            if $Win_Pos[1]+$Win_Pos[3] > @DesktopHeight then $Win_Pos[3] = $Win_Pos[3]-($Win_Pos[1]+$Win_Pos[3]-@DesktopHeight)
            if $Win_Pos[0]<0 then
                $Win_Pos[2] = $Win_Pos[2]+$Win_Pos[0]
                $Win_Pos[0] = 0
            EndIf
            if $Win_Pos[1]<0 then
                $Win_Pos[3] = $Win_Pos[3]+$Win_Pos[1]
                $Win_Pos[1] = 0
            EndIf
            
            $Get_Pixel = PixelSearch($Win_Pos[0], $Win_Pos[1], $Win_Pos[0]+$Win_Pos[2], $Win_Pos[1]+$Win_Pos[3], $color)
            if @error Then
                TrayTip("", "Color was not found", 10)
            Else
                TrayTip("", "Color found at:" & @CRLF & "x: " & $Get_Pixel[0] & @CRLF & "y: " & $Get_Pixel[1] & @CRLF & "mouse moved to the pixel's coord.", 10)
                MouseMove($Get_Pixel[0], $Get_Pixel[1], 10)
            EndIf
            
            GUISetState(@SW_SHOW,$box1)
        ElseIf _IsPressed(02, $dll) Then
            _exit()
        EndIf
    EndIf
    $mouse_pos = MouseGetPos()
    if $old_pos <> $mouse_pos[0] & $mouse_pos[1] Then
        WinMove($box1, "", $mouse_pos[0]-$x/2, $mouse_pos[1]-$y/2, $x, $y)
        $old_pos = $mouse_pos[0] & $mouse_pos[1]
    EndIf
    Sleep(1)
WEnd

Func _exit ()
    DllClose($dll)
    Exit
EndFunc

Share this post


Link to post
Share on other sites

I use this function just for visually defining and then grabbing an area, but you can probably adapt it to your needs, a demo of the use is in this post Forum Link

;=================================   _DrawRect_Drag   ============================
; Function Name:    _DrawRect_Drag
; Requires:   <GUIConstants.au3> & <Misc.au3>
; Description:      Gives a visual aid while defineing Top\Left|bottom\Right of a given area
; Parameters:       $ActionKey        Hex code for key to press to begin and end render
;               $color   Color of the display box
; Syntax:            _DrawRect_Drag([$ActionKey][,$color])
; Author(s):       
; Returns:          $array[4]      $array[0] = Left, $array[1] = Top, $array[2] = Right, $array[3] = Bottom
;===============================================================================
Func _DrawRect_Drag($ActionKey = "2D", $color = 0xFF0000)

    Do
        $pos = MouseGetPos()
        Sleep(25)
    Until _IsPressed($ActionKey)
   
    Local $ScanWidth = 1, $ScanHeight = 1
    Local $positions[4]
    $positions[0] = $pos[0] ;LEFT
    $positions[1] = $pos[1] ;TOP
    $x = $pos[0]
    $y = $pos[1]
   
    $GUI_DR = GUICreate("", 0, 0, $x, $y, $WS_POPUP)
    WinSetTrans($GUI_DR,"",210)
    $Top_DR = GUICreate("Top Line", $ScanWidth, 2, $x, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Top_DR,"",210)
    GUISetState()
    $Left_DR = GUICreate("Left Line", 2, $ScanHeight, $x, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Left_DR,"",210)
    GUISetState()
    $Right_DR = GUICreate("Right Line", 2, $ScanHeight, $x + $ScanWidth - 2, $y, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Right_DR,"",210)
    GUISetState()
    $Bottom_DR = GUICreate("Bottom Line", $ScanWidth, 2, $x, $y + $ScanHeight, $WS_POPUP, -1, $GUI_DR)
    GUISetBkColor($color)
    WinSetTrans($Bottom_DR,"",210)
    GUISetState()
    Sleep(800)
   
    Do
        $MousePos = MouseGetPos()
        WinMove($Top_DR, "", $x, $y, $ScanWidth, 2)
        WinMove($Left_DR, "", $x, $y, 2, $ScanHeight)
        WinMove($Right_DR, "", $x + $ScanWidth - 2, $y, 2, $ScanHeight) 
        WinMove($Bottom_DR, "", $x, $y + $ScanHeight, $ScanWidth, 2)
        If Not (($MousePos[0] - $x) <= 0) Then
            $ScanWidth = $MousePos[0] - $x + 1
        EndIf
        If Not (($MousePos[1] - $y) <= 0) Then
            $ScanHeight = $MousePos[1] - $y - 1
        EndIf
    Until _IsPressed($ActionKey)
   
    $positions[2] = $MousePos[0] ;RIGHT
    $positions[3] = $MousePos[1] ;BOTTOM
   
    GUISetState(@SW_HIDE,$GUI_DR)
    GUISetState(@SW_HIDE,$Top_DR)
    GUISetState(@SW_HIDE,$Left_DR)
    GUISetState(@SW_HIDE,$Right_DR)
    GUISetState(@SW_HIDE,$Bottom_DR)

    Return $positions
EndFunc;==========================   _DrawRect_Drag   ============================

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

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