Jump to content

Testing a Control Button


bvnseven
 Share

Recommended Posts

Been reading in this forum about disabled controls and I almost have an answer.

Need to check for a certain Control (a button) being disabled; if it is then there are no errors.

0 errors dictates one course of action, 1 error dictates another action and > 1 error is something else.

plans are to use an if-then-else (pseudocode below):

if guictrlgetstate($ctrlID)= 64 then ;64=enabled=1 or more errors/128=disabled=no errors

(get rid of errors here)

endif

SOMETHING ELSE; HOW DO YOU SPECIFY THE "$CTRLID"?? I KNOW THE NUMBER IS 1027, BUT HOW DO YOU SAY THAT??

Link to comment
Share on other sites

I'm not sure you are going to get useful state from a non-AutoIt window's control that way.

You might have to use _WinAPI_GetWindowLong() using the $GWL_STYLE option and interpret the bits per MSDN: Window Styles:

#include <WinAPI.au3>
#include <Constants.au3>

$hButton = ControlGetHandle("[CLASS:#32770; TITLE:Save As]", "", "[CLASS:Button; INSTANCE:1]")
$iState = _WinAPI_GetWindowLong($hButton, $GWL_STYLE)
ConsoleWrite("$hButton = " & $hButton & @LF & "$iState = " & $iState & @LF)

Another problem with your approach is that more than one state can be present at the same time. So even if the control is enabled and its state is returned as you expect, the value might not be exactly 64. You have to check a particular bit:

If BitAnd(GuiCtrlGetState($ctrlID), $GUI_ENABLE) Then

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...