Jump to content

old script rending a rectangle dosent work


joeyone
 Share

Recommended Posts

hi it was i while ago i done something in autoit, for a year ago or so

and when i now decided to install the program again and look at my old script that rendering a box

i cant get it to work. In the old script it worked perfectly but not nowadays

the errors i get is:

Variable used without being declared.

$gui: possibly used before declaration.

this is my code hope someone can help me correct this error

thanks in advance

hori()
verti()

Func hori()
    _GUICreateInvRect($gui, 3, 3, 124, 61)
EndFunc

;Vertikalt läge
Func verti()
    _GUICreateInvRect($gui, 3, 3, 61, 124)
EndFunc

Global $WS_POPUP
Global $WS_EX_TOPMOST
Global $WS_EX_DLGMODALFRAME


;Inställningar rektangel
$gui = GUICreate("GUI", 67, 130, 100, 100, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x48FF00)
_GUICreateInvRect($gui, 3, 3, 61, 124)
GUISetState()

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("      Bejeweled 2 Control", 160, 365, 100, 300, $WS_EX_DLGMODALFRAME)
GuiCtrlCreateLabel("", 42, 288, 78, 40)
GuiCtrlSetBkColor(-1, 0x00FF00)

Func _GUICreateInvRect($hwnd, $l, $t, $w, $h)
    $pos = WinGetPos($hwnd)
    $1 = 0
    $2 = 0
    $3 = $pos[2]
    $4 = $t
    $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = 0
    $3 = $l
    $4 = $pos[3]
    $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = $l + $w
    $2 = 0
    $3 = $pos[2]
    $4 = $pos[3]
    $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = $t + $h
    $3 = $pos[2]
    $4 = $pos[3]
    $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)

    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1)
EndFunc
Edited by joeyone
Link to comment
Share on other sites

  • Moderators

joeyone,

Quite a few changes since you last coded. :) Without knowing quite what you were expecting to get, I think this is fairly close:

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

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode

;Inställningar rektangel
$gui = GUICreate("GUI", 67, 130, 100, 100, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x48FF00)
_GUICreateInvRect($gui, 3, 3, 61, 124)
GUISetState()

$mainwindow = GUICreate("      Bejeweled 2 Control", 160, 365, 100, 300, $WS_EX_DLGMODALFRAME)
GuiCtrlCreateLabel("", 42, 288, 78, 40)
GuiCtrlSetBkColor(-1, 0x00FF00)
GUISetState()

hori()
verti()

While 1
    Sleep(10)
WEnd

Func hori()
    _GUICreateInvRect($gui, 3, 3, 124, 61)
EndFunc

;Vertikalt läge
Func verti()
    _GUICreateInvRect($gui, 3, 3, 61, 124)
EndFunc

Func _GUICreateInvRect($hwnd, $l, $t, $w, $h)
    $pos = WinGetPos($hwnd)
    $1 = 0
    $2 = 0
    $3 = $pos[2]
    $4 = $t
    $ret = _WinAPI_CreateRectRgn($1, $2, $3, $4)
    $1 = 0
    $2 = 0
    $3 = $l
    $4 = $pos[3]
    $ret2 = _WinAPI_CreateRectRgn($1, $2, $3, $4)
    $1 = $l + $w
    $2 = 0
    $3 = $pos[2]
    $4 = $pos[3]
    $ret3 = _WinAPI_CreateRectRgn($1, $2, $3, $4)
    $1 = 0
    $2 = $t + $h
    $3 = $pos[2]
    $4 = $pos[3]
    $ret4 = _WinAPI_CreateRectRgn($1, $2, $3, $4)

    _WinAPI_CombineRgn($ret, $ret, $ret2, 2)
    _WinAPI_CombineRgn($ret, $ret, $ret3, 2)
    _WinAPI_CombineRgn($ret, $ret, $ret4, 2)
    _WinAPI_SetWindowRgn($hwnd, $ret)
EndFunc

M23

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:

Spoiler

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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