Sign in to follow this  
Followers 0
pastl

Drawing a rectangle during mouse movement

6 posts in this topic

Hi together,

is it possible to draw a rectangle during mouse movement and resize it all the time. Something like when the mouse left button is pressed start drawing it. I tried something like this:

While 1
        If _IsPressed("01", $UserDLL) Then
            Local $Start_Pos = MouseGetPos()
;~              While 1
;~                  Local $Mouse_Pos = MouseGetPos()
;~                  Local $Ausschnitt
;~                  GUICtrlDelete($Ausschnitt)
;~                  $Ausschnitt = GUICtrlCreateLabel($Start_Pos[0], $Start_Pos[1], $Mouse_Pos[0], $Mouse_Pos[1], 0x1000)
;~                  If Not _IsPressed("01", $UserDLL) Then ExitLoop
;~              WEnd
            ExitLoop
        EndIf
    WEnd

Thanks for your help.

pastl

p.s. sorry for my english.

Share this post


Link to post
Share on other sites



ummm why are there comments on every line?

Share this post


Link to post
Share on other sites

hello,

ummm why are there comments on every line?

if you mean these:

;~ While 1
;~                   Local $Mouse_Pos = MouseGetPos()
;~                   Local $Ausschnitt
;~                   GUICtrlDelete($Ausschnitt)
;~                   $Ausschnitt = GUICtrlCreateLabel($Start_Pos[0], $Start_Pos[1], $Mouse_Pos[0], $Mouse_Pos[1], 0x1000)
;~                   If Not _IsPressed("01", $UserDLL) Then ExitLoop
;~               WEnd

They are not working.

pastl

Share this post


Link to post
Share on other sites

while im saying your code wont work if you comment that stuff thats just putting a comment its not code... or do u mean its not like that in the actual ill look at it and just remove the comments

Share this post


Link to post
Share on other sites

#include <Misc.au3>
#include <GUIConstants.au3>

Opt( 'GUIOnEventMode', 1)

$UserDLL = DllOpen("user32.dll")
$gui = GUICreate( '')
GUISetOnEvent( $GUI_EVENT_CLOSE, 'quit')
GUISetState()

While 1
    draw_label()
WEnd


Func draw_label()
    Local $MouseCoordMode, $Start_Pos, $Ausschnitt, $Mouse_Pos
While 1
    If _IsPressed("01", $UserDLL) Then
        $MouseCoordMode = Opt( 'MouseCoordMode', 2)
        $Start_Pos = MouseGetPos()
        $Ausschnitt = GUICtrlCreateLabel( 'text...', 0, 0, 1, 1, $SS_SUNKEN)
        GUICtrlSetBkColor( $Ausschnitt, 0)
        
        While _IsPressed("01", $UserDLL)
            $Mouse_Pos = MouseGetPos()
            GUICtrlSetPos( $Ausschnitt, $Start_Pos[0], $Start_Pos[1], $Mouse_Pos[0] - $Start_Pos[0], $Mouse_Pos[1] - $Start_Pos[1])
            Sleep( 10)
        WEnd
    
        Opt( 'MouseCoordMode', $MouseCoordMode)
        Return $Ausschnitt
    EndIf
    
    Sleep( 10)
WEnd
EndFunc

Func quit()
    Exit
EndFunc

Func onautoitexit()
    DllClose( $UserDLL)
EndFunc

Share this post


Link to post
Share on other sites

Hello UP NORTH,

thanks for your help, this was wath i was looking for.

Greatings pastl

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