Jump to content

Disabling/Enabling several buttons at once


Recommended Posts

Hey, I've made a simple script if you want to mess around with it. The title pretty much sums up the problem though...

#include <GUIConstants.au3>
#include <Misc.au3>
GuiCreate("")
$a = GuiCtrlCreateButton("", 10, 10, 100, 100)
$b = GuiCtrlCreateButton("", 110, 10, 100, 100)
$c = GuiCtrlCreateButton("", 210, 10, 100, 100)
$d = GuiCtrlCreateButton("", 10, 110, 100, 100)
$e = GuiCtrlCreateButton("", 110, 110, 100, 100)
GuiSetState()
Do 
    $msg = GuiGetMsg()
    If BitAND(_IsPressed("11"), _ISpressed("4E")) Then 
        GuiCtrlSetState($a, $GUI_DISABLE) ;THIS is where I want to disable all the buttons
        Endif
Until $msg = $GUI_EVENT_CLOSE

I just want to know if it's possible and how to do it if it is possible...

Edit: Added the comment...

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

id say an easy way is make everything an array HAHAH took me awhile cuz $i was only supposed to go to 4 not 5 xD

#include <GUIConstants.au3>
#include <Misc.au3>
Global $a[5]
$GUI = GuiCreate("")
$a[0] = GuiCtrlCreateButton("", 10, 10, 100, 100)
$a[1] = GuiCtrlCreateButton("", 110, 10, 100, 100)
$a[2] = GuiCtrlCreateButton("", 210, 10, 100, 100)
$a[3] = GuiCtrlCreateButton("", 10, 110, 100, 100)
$a[4] = GuiCtrlCreateButton("", 110, 110, 100, 100)
GuiSetState()
Do
    $msg = GuiGetMsg()
    If BitAND(_IsPressed("11"),_ISpressed("4E")) Then
        For $i = 0 to 4
            GuiCtrlSetState($a[$i],$GUI_DISABLE)
        Next
        Endif
Until $msg = $GUI_EVENT_CLOSE
Link to comment
Share on other sites

id say an easy way is make everything an array HAHAH took me awhile cuz $i was only supposed to go to 4 not 5 xD

#include <GUIConstants.au3>
#include <Misc.au3>
Global $a[5]
$GUI = GuiCreate("")
$a[0] = GuiCtrlCreateButton("", 10, 10, 100, 100)
$a[1] = GuiCtrlCreateButton("", 110, 10, 100, 100)
$a[2] = GuiCtrlCreateButton("", 210, 10, 100, 100)
$a[3] = GuiCtrlCreateButton("", 10, 110, 100, 100)
$a[4] = GuiCtrlCreateButton("", 110, 110, 100, 100)
GuiSetState()
Do
    $msg = GuiGetMsg()
    If BitAND(_IsPressed("11"),_ISpressed("4E")) Then
        For $i = 0 to 4
            GuiCtrlSetState($a[$i],$GUI_DISABLE)
        Next
        Endif
Until $msg = $GUI_EVENT_CLOSE

Thanks a lot, that should save a lot of pointless lines...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

or

#include <GUIConstants.au3>
#include <Misc.au3>
Global $a[5]
$GUI = GuiCreate("")
$a[0] = GuiCtrlCreateButton("", 10, 10, 100, 100)
$a[1] = GuiCtrlCreateButton("", 110, 10, 100, 100)
$a[2] = GuiCtrlCreateButton("", 210, 10, 100, 100)
$a[3] = GuiCtrlCreateButton("", 10, 110, 100, 100)
$a[4] = GuiCtrlCreateButton("", 110, 110, 100, 100)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    If BitAND(_IsPressed("11"),_ISpressed("4E")) Then
        If GUICtrlGetState($a[0]) = 80 Then
        For $i = 0 to 4
            GuiCtrlSetState($a[$i],$GUI_DISABLE)
        Next
        Sleep(100)
    Elseif GUICtrlGetState($a[0]) = 144 Then
    For $i = 0 to 4
            GuiCtrlSetState($a[$i],$GUI_ENABLE)
        Next
        Sleep(100)
    EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
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...