Jump to content
Sign in to follow this  

Selection Box

Recommended Posts

Hi forum i am writing a selector tool to use with another program that i´m making to get the pixel raw data of a selected area on the screen... i have problems with the the selector tool

i use a GUI with pop up style to do the selection area efect.. and use winmove to resize when i click and drag the mouse.. my problem start when i try to drag from the right to the left or from the bottom to the top, otherwise works fine...

here is the code

#include <misc.au3>
#include <WindowsConstants.au3>
HotKeySet("{esc}", "_exit")
$DLL = DllOpen("user32.dll")
Global $pos
While 1
    $pos = MouseGetPos()
    If _IsPressed(01, $DLL) Then _drawbox()


Func _exit()
    ConsoleWrite("se cerro la dll" & @CRLF)
EndFunc   ;==>_exit

Func _drawbox()
    Local $hGui = GUICreate("selectionbox", 0, 0, $pos[0], $pos[1], $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x00ff00, $hGui)
    WinSetTrans($hGui, "", 50)

    While _IsPressed(01, $DLL)
        $pos2 = MouseGetPos()
            Case $pos2[0] < 0
                WinMove($hGui, "", $pos2[0], $pos[1], $pos[0]-$pos2[0], $pos2[1], 100)
            Case $pos2[1] < 0
                WinMove($hGui, "", $pos[0], $pos2[1], $pos2[0], $pos[1]-$pos2[1], 100)
            Case $pos2[0] < 0 And $pos2[1] < 0
                WinMove($hGui, "", $pos2[0], $pos2[1], $pos[0]-$pos2[0], $pos[1]-$pos2[1], 100)
            Case Else
                Opt("MouseCoordMode", 0)
                WinMove($hGui, "", $pos[0], $pos[1], $pos2[0], $pos2[1], 100)
    ConsoleWrite("x inicial = " & $pos[0] & " X final = " & $pos2[0] & @CRLF & "y inicial = " & $pos[1] & " y final = " & $pos2[0] & @CRLF)
    Opt("MouseCoordMode", 1) ; set the mousecoord like before
EndFunc   ;==>_drawbox

Maybe someine can help me and tell me also if there´s other way to do the selectionbox efect

Share this post

Link to post
Share on other sites


I posted a script which uses a "light window" to select an area here - I hope it might be of use. :huh2:

I have a similar version somewhere with an expanding rectangle if you would prefer that. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

thanks melva just what i look for.

what a good trik _WinAPI_SetWindowRgn() you create a inverse region ;)...

EDIT: Also... inmejorable... :huh2:

Edited by monoscout999

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...