Verssuss

How make perfect resizable box

14 posts in this topic

#1 ·  Posted

i have 2 examples what i made but both dont even works perfect
at first example while changing size right and bottom side 'jumping'

at second exemple space inside flashing sometimes...

sorry but i need PERFECT one

First example 

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

HotKeySet("{ESC}", "On_Exit")

$GUI = GUICreate("box", 150, 150,-1,-1)
GUISetState()
$button_get_image = GUICtrlCreateButton("get box", -1,-1)
Local $hGui ; Local ?? Global ?? i dont get it what is right
$size = 50

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_get_image
            _getimg()
    EndSwitch
    Sleep(50)
WEnd

Func _getimg()
    HotKeySet("{[}", "_boxminus")
    HotKeySet("{]}", "_boxplus")
    GUISetState(@SW_MINIMIZE, $GUI)
    $pos = WinGetPos($hGUI)
    $hGUI = GUICreate(" Test", $size, $size, $pos[0] - ($size / 2), $pos[1] - ($size / 2), $WS_POPUP,-1,$GUI)
    GUISetBkColor(0x00FF00)
    GUISetState()

    _GDIPlus_Startup()
    $aPos = WinGetPos($hGUI)
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddRectangle($hPath, 0, 0, $aPos[2], $aPos[3])
    $hReg = _GDIPlus_RegionCreateFromPath($hPath)
    $hReg2 = _GDIPlus_RegionCreateFromRect(2, 2, $aPos[2] - 4, $aPos[3] - 4)
    _GDIPlus_RegionCombineRegion($hReg, $hReg2, 3)
    $hRGN = _GDIPlus_RegionGetHRgn($hReg)
    _WinAPI_SetWindowRgn($hGUI, $hRGN)

    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hReg)
    _GDIPlus_RegionDispose($hReg2)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()

    $lupa_aktywna = True

    While $lupa_aktywna = True
        $pos = MouseGetPos()
        WinMove($hGUI, "", $pos[0] - ($size / 2), $pos[1] - ($size / 2), $size, $size)
        While _IsPressed('01')
            GUISetState(@SW_HIDE, $hGUI)
            GUISetState(@SW_RESTORE, $GUI)
            $lupa_aktywna = False
            HotKeySet("[")
            HotKeySet("]")
        WEnd
    WEnd
EndFunc   ;==> crate box

Func _boxplus()
    $size = $size + 10
    If $size < 400 Then
        $pos = MouseGetPos()
        WinMove($hGUI, "", $pos[0] - ($size / 2), $pos[1] - ($size / 2), $size, $size)
        _GDIPlus_Startup()
        $aPos = WinGetPos($hGUI)
        $hPath = _GDIPlus_PathCreate()
        _GDIPlus_PathAddRectangle($hPath, 0, 0, $aPos[2], $aPos[3])
        $hReg = _GDIPlus_RegionCreateFromPath($hPath)
        $hReg2 = _GDIPlus_RegionCreateFromRect(2, 2, $aPos[2] - 4, $aPos[3] - 4)
        $aPos = WinGetPos($hGUI)
        _GDIPlus_RegionCombineRegion($hReg, $hReg2, 3)
        $hRGN = _GDIPlus_RegionGetHRgn($hReg)
        _WinAPI_SetWindowRgn($hGUI, $hRGN)

        _WinAPI_DeleteObject($hRGN)
        _GDIPlus_RegionDispose($hReg)
        _GDIPlus_RegionDispose($hReg2)
        _GDIPlus_PathDispose($hPath)
        _GDIPlus_Shutdown()
            Else
        HotKeySet("{]}")
        MsgBox(0,"ERROR", "Maximum size already exist")
        HotKeySet("{]}", "_boxplus")
    EndIf
EndFunc

Func _boxminus()
    If $size >= 40 Then $size = $size - 5
    If $size < 40 Then $size = $size - 1
    If $size > 4 Then
        $pos = MouseGetPos()
        WinMove($hGUI, "", $pos[0] - ($size / 2), $pos[1] - ($size / 2), $size, $size)
        _GDIPlus_Startup()
        $aPos = WinGetPos($hGUI)
        $hPath = _GDIPlus_PathCreate()
        _GDIPlus_PathAddRectangle($hPath, 0, 0, $aPos[2], $aPos[3])
        $hReg = _GDIPlus_RegionCreateFromPath($hPath)
        $hReg2 = _GDIPlus_RegionCreateFromRect(2, 2, $aPos[2] - 4, $aPos[3] - 4)
        _GDIPlus_RegionCombineRegion($hReg, $hReg2, 3)
        $hRGN = _GDIPlus_RegionGetHRgn($hReg)
        _WinAPI_SetWindowRgn($hGUI, $hRGN)

        _WinAPI_DeleteObject($hRGN)
        _GDIPlus_RegionDispose($hReg)
        _GDIPlus_RegionDispose($hReg2)
        _GDIPlus_PathDispose($hPath)
        _GDIPlus_Shutdown()
    Else
        HotKeySet("{[}")
        MsgBox(0,"ERROR", "Minimum size already exist")
        HotKeySet("{[}", "_boxminus")
    EndIf
EndFunc

 Func On_Exit()
     Exit
 EndFunc

Second example
 

#include <GuiConstantsEx.au3>
#include <Windowsconstants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#Include <Misc.au3>
#Include <ScreenCapture.au3>

HotKeySet("{ESC}", "On_Exit")

$GUI = GUICreate("Clicker", 150, 150,-1,-1)
GUISetState()
$button_get_image = GUICtrlCreateButton("get box", -1,-1)
Local $hGui ; Local ?? Global ?? i dont get it what is right
$size = 50

While 1
    $pos = MouseGetPos()
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_get_image
            _getimg()
    EndSwitch
WEnd

Func _getimg()
    HotKeySet("{[}", "_boxminus")
    HotKeySet("{]}", "_boxplus")
    GUISetState(@SW_MINIMIZE, $GUI)
    $hGUI = GUICreate("", $size, $size, -1, -1, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_COMPOSITED, $WS_EX_TOPMOST))
    $pos = WinGetPos($hGUI)
    GUISetBkColor(0x00FF00)
    GuiCtrlCreateLabel("", 2, 2, $size-4, $size-4)
    GUICtrlSetBkColor(-1, 0xABCDEF)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    GUISetState()
    _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)

    $lupa_aktywna = True

    While $lupa_aktywna = True
        $pos = MouseGetPos()
        WinMove($hGUI, "", $pos[0] - ($size / 2), $pos[1] - ($size / 2), $size, $size)
        While _IsPressed('01')
            GUISetState(@SW_HIDE, $hGUI)
            GUISetState(@SW_RESTORE, $GUI)

            $lupa_aktywna = False
            HotKeySet("[")
            HotKeySet("]")
        WEnd
    WEnd
EndFunc

Func _boxminus()
    If $size >= 50 Then $size = $size - 5
    If $size < 50 Then $size = $size - 1
    If $size > 4 Then
        Sleep(0)
    Else
        HotKeySet("{[}")
        MsgBox(0,"ERROR", "Minimum size already exist")
        HotKeySet("{[}", "_boxminus")
    EndIf
EndFunc

Func _boxplus()
    If $size < 400 Then
        $size = $size + 10
    Else
        HotKeySet("{]}")
        MsgBox(0,"ERROR", "Maximum size already exist")
        HotKeySet("{]}", "_boxplus")
    EndIf
EndFunc

 Func On_Exit()
     Exit
 EndFunc

i have more examples made by myself but always something working wrong.
hope u can help me
THX

Share this post


Link to post
Share on other sites



#2 ·  Posted

anyone ?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Quote
Local $hGui ; Local ?? Global ?? i dont get it what is right

As this is outside function you should use Global

btw.

In relation to your other question in this thread:
You should wait at least 24 hour until you BUMP your questions, as this is not 24/7/366 Support forum, all everyone here are a volunteer.

I'm sure that somebody answer you ASAP.

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Local working as well anyway and sorry about 'spamm'. i read rulles and somehow i didint notice that paragraph

btw i dont see any point to declare any variable coz i will do it in function anyway 

Edited by Verssuss

Share this post


Link to post
Share on other sites

#5 ·  Posted

This is not 'spamm' and not rulles, rather netiquete.
You just have to be a little patient/understanding.

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#6 ·  Posted

so...i just wake up and im horny about new knowledge ^_^

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted

me too :)

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#8 ·  Posted

up

Share this post


Link to post
Share on other sites

#9 ·  Posted

Suggestion : in script #2 use a small sizing step, the sizing is slower but smoother

Func _boxplus()
    If $size < 400 Then
        $size = $size + 2
;.....

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

20 hours ago, mikell said:

Suggestion : in script #2 use a small sizing step, the sizing is slower but smoother

Func _boxplus()
    If $size < 400 Then
        $size = $size + 2
;.....

sure it not jumping anymore but it take to long to make big box. in future i will delete "If $size < 400 Then" to make box much bigger.
i cant belive that simple function not exist yet

Share this post


Link to post
Share on other sites

#11 ·  Posted

up

 

still hope

Share this post


Link to post
Share on other sites

#12 ·  Posted

there is a way to do that ?

Share this post


Link to post
Share on other sites

#13 ·  Posted

ideas ??

Share this post


Link to post
Share on other sites

#14 ·  Posted

any perfect script for that ?

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