Jump to content
Sign in to follow this  
steveR

ControlCommand function

Recommended Posts

I did a search but didn't find anything to help explain this to me. If i have simple gui with 1 button enabled and 1 disabled :

CODE
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 200, 200,-1,-1 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

WinSetOnTop("MyGUI","",1)

$Button_1 = GuiCtrlCreateButton("Button1", 20, 50, 50, 50)

GUICtrlSetState($Button_1,$gui_disable)

$Button_2 = GuiCtrlCreateButton("Button2", 80, 50, 50, 50)

;GUICtrlSetState($Button_2,$gui_disable)

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

MsgBox(0,"","Button 1")

case $msg = $Button_2

MsgBox(0,"","Button_2")

EndSelect

WEnd

Exit

And i run this sample script on it:

CODE

$b1 = "Button1"

$b2 = "Button2"

MsgBox(0,"b1",ControlCommand("MyGui","",$b1,"IsEnabled",""))

MsgBox(0,"E1",@error)

MsgBox(0,"b2",ControlCommand("MyGui","",$b2,"IsEnabled",""))

MsgBox(0,"E2",@error)

Shouldn't the first MsgBox return a zero? Can someone explain to me how that fucntion works?

Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites

Maybe you could recheck the syntax by looking in the help file?

The second parameter is the text parameter. That helps AutoIt find the right window, when you have windows with similar names.

If you are sure there's no window with the same name, you can use "" for the text parameter.

Share this post


Link to post
Share on other sites

I got it working but I'm not sure what the problem was.

Maybe the title you need specify is case sensitive.

I changed several things.

Script 1

; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 200, 200,-1,-1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_VISIBLE, $WS_CLIPSIBLINGS))
WinSetOnTop("MyGUI","",1)
$Button_1 = GuiCtrlCreateButton("Button_1", 20, 50, 50, 50)
GUICtrlSetState($Button_1,$gui_disable)
$Button_2 = GuiCtrlCreateButton("Button_2", 80, 50, 50, 50)
;GUICtrlSetState($Button_2,$gui_disable)
GuiSetState()
While 1
   Sleep(25)
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        MsgBox(0,"","Button 1")
    case $msg = $Button_2
        MsgBox(0,"","Button_2")
    EndSelect

WEnd
Exit

Script 2

If IsButtonEnabled("MyGUI", "", "Button1") Then
   MsgBox(0,"b1", "Yes, button 1 is enabled.")
Else
   MsgBox(0,"b1", "No, button 1 is disabled.")
EndIf

If IsButtonEnabled("MyGUI", "", "Button2") Then
   MsgBox(0,"b1", "Yes, button 2 is enabled.")
Else
   MsgBox(0,"b1", "No, button 2 is disabled.")
EndIf

Func IsButtonEnabled($WinTitle, $WinText, $BtnID)
   Return ControlCommand($WinTitle, $WinText, $BtnID, "IsEnabled", "")
EndFunc

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...