Jump to content

Recommended Posts

Posted

Hello i am creating an appication where people should could choose a square area.

i made this so far

#include <misc.au3>
#include <winapi.au3>
Dim $Mpos_1 = "", $Mpos_1A = "", $Mpos_2 = "", $Mpos_2A = "", $line = ""
$LineColor = 0x00ff00; color BGR
$LineWidth = 5
global $RDW_ERASENOW
HotKeySet( "{ESC}", "Get_Exit")

While 1
   ;Sleep(1)
   $list = winlist()
   for $i = 1 to $list[0][0]
       if winactive($list[$i][0],"") = true then
    Global $hnd = WinGethandle($list[$i][0],"")
EndIf

Next
            Local $firstPos = MouseGetPos()
            DrawBox($firstPos[0],$firstPos[1],$firstPos[0]+80,$firstPos[1])

_WinAPI_RedrawWindow($hnd,Default,Default,$RDW_ERASENOW)
WEnd


Func DrawBox($firstPos_x, $firstPos_y, $secondPos_x, $secondPos_y)

    If $firstPos_x = "" Or $secondPos_x = "" Then
        Return
    EndIf

    $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $firstPos_x, "int", $firstPos_y, "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $secondPos_x, "int", $secondPos_y)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $secondPos_x, "int", $secondPos_y+80)
     DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $secondPos_x-80, "int", $secondPos_y+80)
      DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $secondPos_x-80, "int", $secondPos_y)
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0])

EndFunc ;==>Get_drawing

Func Get_Exit()
    Exit
EndFunc ;==>Get_Exit

the problem is, it will just keep draw new sqares again and aqain i tried to make a move function like this

func move()
 $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int", $firstPos_x, "int", $firstPos_y, "int", 0)
endfunc

but that didn't work nether.

So can someone help me.

thanks in advance.

Posted (edited)

What do you expect when you put the function DrawBox() into a While/Wend loop?

Try this:

;Coded by UEZ 2010

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

HotKeySet( "{ESC}", "Get_Exit")
$width = 80
$heigth = 80
$mpos = MouseGetPos()
Local $hGUI_Rect = GUICreate("", $width, $heigth,  $mpos[0], $mpos[1], $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST + $WS_EX_LAYERED)
GUISetBkColor(0x00)
_WinAPI_SetLayeredWindowAttributes($hGUI_Rect, 0x00, 0xD0, 0)
GUICtrlCreateGraphic(0, 0, $width, $heigth)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00)
GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 8)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, $width, $heigth)
GUISetState(@SW_SHOW)

While Sleep(50)
    $mpos = MouseGetPos()
    WinMove($hGUI_Rect, "", $mpos[0] - $width / 2, $mpos[1] - $heigth / 2)
WEnd

Func Get_Exit()
    GUIDelete($hGUI_Rect)
    Exit
EndFunc ;==>Get_Exit

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...