Jump to content
Collins

HOW DO I HIDE AND DISABLE BUTTONS

Recommended Posts

Collins

Hello, am trying to hide and disable buttons when one button is clicked..
Below is my code..

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>




Global $g_bPaused = False

HotKeySet("{PAUSE}", "HotKeyPressed")
HotKeySet("{ESC}", "HotKeyPressed")
HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d


#Region ##
$SELF_ASSISTANT = GUICreate("SELF ARTIFICIAL ASSISTANT", 615, 437, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP,$DS_MODALFRAME,$DS_CONTEXTHELP))
GUISetBkColor(0x000000)
$sign_in = GUICtrlCreateButton("Sign in ", 152, 136, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(1, $GUI_ENABLE)
GUICtrlSetState(-1, $GUI_SHOW)
GUICtrlSetCursor (-1, 0)
$redeem = GUICtrlCreateButton("Redeem Code", 152, 232, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(-1, $GUI_ENABLE)
GUICtrlSetState(-1, $GUI_SHOW)
GUICtrlSetCursor (-1, 0)


$Progress1 = GUICtrlCreateProgress(152, 400, 302, 8, BitOR($PBS_MARQUEE,$WS_BORDER))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
$redeem_now = GUICtrlCreateButton("Redeem Now", 153, 319, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 0)
$sign_in2 = GUICtrlCreateButton("Sign in", 150, 318, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 0)
$username = GUICtrlCreateInput("", 152, 152, 297, 30, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 0)
$password = GUICtrlCreateInput("", 150, 230, 297, 30, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 5)
$redeembox = GUICtrlCreateInput("", 150, 199, 297, 30, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 5)
$back = GUICtrlCreateButton("Go Back", 512, 360, 97, 33, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE)
            ToolTip('Script is minimized', 0, 0)

        Case $iOS_Elites_Kit
           $back = GUICtrlCreateButton("Go Back", 512, 360, 97, 33, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(-1, $GUI_ENABLE)
GUICtrlSetState(-1, $GUI_SHOW)
GUICtrlSetCursor (-1, 1)

        Case $sign_in
$sign_in = GUICtrlCreateButton("Sign in ", 152, 136, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
 GUICtrlSetState(-1, $GUI_DISABLE)
            GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 0)
           $redeem = GUICtrlCreateButton("Redeem Code", 152, 232, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
           GUICtrlSetState(-1, $GUI_DISABLE)
            GUICtrlSetState(-1, $GUI_HIDE)
            GUICtrlSetCursor (-1, 0)

$back = GUICtrlCreateButton("Go Back", 512, 360, 97, 33, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(-1, $GUI_ENABLE)
GUICtrlSetState(1, $GUI_SHOW)
GUICtrlSetCursor (1, 1)


        Case $redeem
        Case $register
           $back = GUICtrlCreateButton("Go Back", 512, 360, 97, 33, BitOR($BS_CENTER,$WS_BORDER))

GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 1)
        Case $redeem_now
        Case $sign_in2
        Case $username
        Case $password
        Case $redeembox
        Case $back
           $back = GUICtrlCreateButton("Go Back", 512, 360, 97, 33, BitOR($BS_CENTER,$WS_BORDER))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetCursor (-1, 1)
    EndSwitch
 WEnd



 Func HotKeyPressed()
    Switch @HotKeyPressed ; The last hotkey pressed.
        Case "{PAUSE}" ; String is the {PAUSE} hotkey.
            $g_bPaused = Not $g_bPaused
            While $g_bPaused
                Sleep(100)
                ToolTip('Script is "Paused"', 0, 0)
            WEnd
            ToolTip("")

        Case "{ESC}" ; String is the {ESC} hotkey.
            Exit

        Case "+!o" ; String is the Shift-Alt-d hotkey.
        GUISetState(@SW_SHOW)

    EndSwitch
EndFunc   ;==>HotKeyPressed

 

Share this post


Link to post
Share on other sites
Subz

Your code is confusing, which buttons are you trying to hide?  You appear to overwrite your controls each time you click the button, here are some basic examples for enabling/disabling single control or multiple controls:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>




Global $g_bPaused = False

HotKeySet("{PAUSE}", "HotKeyPressed")
HotKeySet("{ESC}", "HotKeyPressed")
HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d


#Region ##
$SELF_ASSISTANT = GUICreate("SELF ARTIFICIAL ASSISTANT", 615, 437, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP,$DS_MODALFRAME,$DS_CONTEXTHELP))
    GUISetBkColor(0x000000)

$idStart1 = GUICtrlCreateDummy()
    $sign_in = GUICtrlCreateButton("Sign in ", 152, 136, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
        GUICtrlSetState(1, $GUI_ENABLE)
        GUICtrlSetState(-1, $GUI_SHOW)
        GUICtrlSetCursor (-1, 0)

    $redeem = GUICtrlCreateButton("Redeem Code", 152, 232, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
        GUICtrlSetState(-1, $GUI_ENABLE)
        GUICtrlSetState(-1, $GUI_SHOW)
        GUICtrlSetCursor (-1, 0)
$idEnd1 = GUICtrlCreateDummy()

    $Progress1 = GUICtrlCreateProgress(152, 400, 302, 8, BitOR($PBS_MARQUEE,$WS_BORDER))
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetState(-1, $GUI_HIDE)

$idRedeemStart = GUICtrlCreateDummy()
$redeem_now = GUICtrlCreateButton("Redeem Now", 153, 319, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetCursor (-1, 0)

$redeembox = GUICtrlCreateInput("", 150, 199, 297, 30, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetCursor (-1, 5)
$idRedeemEnd = GUICtrlCreateDummy()

$idSignInStart = GUICtrlCreateDummy()
    $sign_in2 = GUICtrlCreateButton("Sign in", 150, 318, 297, 49, BitOR($BS_CENTER,$WS_BORDER))
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetState(-1, $GUI_HIDE)
        GUICtrlSetCursor (-1, 0)

    $username = GUICtrlCreateInput("", 152, 152, 297, 30, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetState(-1, $GUI_HIDE)
        GUICtrlSetCursor (-1, 0)

    $password = GUICtrlCreateInput("", 150, 230, 297, 30, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
        GUICtrlSetState(-1, $GUI_DISABLE)
        GUICtrlSetState(-1, $GUI_HIDE)
        GUICtrlSetCursor (-1, 5)
$idSignInEnd = GUICtrlCreateDummy()

$back = GUICtrlCreateButton("Go Back", 512, 360, 97, 33, BitOR($BS_CENTER,$WS_BORDER))
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUICtrlSetCursor (-1, 1)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Local $iOS_Elites_Kit, $register

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE)
            ToolTip('Script is minimized', 0, 0)
        Case $iOS_Elites_Kit
        Case $sign_in
            For $i = $idStart1 To $idEnd1
                GUICtrlSetState($i, $GUI_DISABLE)
                GUICtrlSetState($i, $GUI_HIDE)
                GUICtrlSetCursor ($i, 0)
            Next
            For $i = $idRedeemStart To $idRedeemEnd
                GUICtrlSetState($i, $GUI_DISABLE)
                GUICtrlSetState($i, $GUI_HIDE)
                GUICtrlSetCursor($i, 0)
            Next
            For $i = $idSignInStart To $idSignInEnd
                GUICtrlSetState($i, $GUI_ENABLE)
                GUICtrlSetState($i, $GUI_SHOW)
                GUICtrlSetCursor($i, 1)
            Next
            GUICtrlSetState($back, $GUI_ENABLE)
            GUICtrlSetState($back, $GUI_SHOW)
            GUICtrlSetCursor($back, 1)
        Case $redeem
        Case $register
        Case $redeem_now
        Case $sign_in2
        Case $username
        Case $password
        Case $redeembox
        Case $back
            For $i = $idStart1 To $idEnd1
                GUICtrlSetState($i, $GUI_ENABLE)
                GUICtrlSetState($i, $GUI_SHOW)
                GUICtrlSetCursor ($i, 1)
            Next
            For $i = $idRedeemStart To $idRedeemEnd
                GUICtrlSetState($i, $GUI_DISABLE)
                GUICtrlSetState($i, $GUI_HIDE)
                GUICtrlSetCursor($i, 0)
            Next
            For $i = $idSignInStart To $idSignInEnd
                GUICtrlSetState($i, $GUI_DISABLE)
                GUICtrlSetState($i, $GUI_HIDE)
                GUICtrlSetCursor($i, 0)
            Next
            GUICtrlSetState($back, $GUI_DISABLE)
            GUICtrlSetState($back, $GUI_HIDE)
            GUICtrlSetCursor($back, 0)
    EndSwitch
 WEnd



 Func HotKeyPressed()
    Switch @HotKeyPressed ; The last hotkey pressed.
        Case "{PAUSE}" ; String is the {PAUSE} hotkey.
            $g_bPaused = Not $g_bPaused
            While $g_bPaused
                Sleep(100)
                ToolTip('Script is "Paused"', 0, 0)
            WEnd
            ToolTip("")

        Case "{ESC}" ; String is the {ESC} hotkey.
            Exit

        Case "+!o" ; String is the Shift-Alt-d hotkey.
        GUISetState(@SW_SHOW)

    EndSwitch
EndFunc   ;==>HotKeyPressed

 

Share this post


Link to post
Share on other sites
Collins

Thank you. It worked

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

×