AutoIT GUICtrlSetState/GUICtrlGetState set state is different from get state
Asked Answered
C

1

2

i ńeed help with my code.

 GUICtrlSetState($input_ID_betonarna,$gui_ENABLE)
 ConsoleWrite(GUICtrlGetState($input_ID_betonarna)&" "& $gui_ENABLE)

Output is: 80 64

Expected output is: 64 64

I know that output is sum of states but i do not have any table with GUIConstantsEx values.

Candescent answered 4/12, 2013 at 16:42 Comment(0)
E
4

Look into your AutoIt installation. In the "include" subfolder you should find the file GUIConstantsEx.au3 where those constants are defined:

Global Const $GUI_SHOW = 16
Global Const $GUI_HIDE = 32
Global Const $GUI_ENABLE = 64
Global Const $GUI_DISABLE = 128

The reason you get the value of 80 is because this is a bit mask and the control actually has 2 states: It is enabled and shown, so:

$GUI_SHOW = 16
$GUI_ENABLE = 64

The sum is 80 and that's what you got in your output.

Edit: If you want to test the state of a control for a specific state, for example to toggle the state of a button, then you can use the BitAND operator:

If BitAND(GUICtrlGetState($cmdOk), $GUI_DISABLE) = $GUI_DISABLE Then
    GUICtrlSetState($cmdOk, $GUI_ENABLE)
EndIf
Edition answered 4/12, 2013 at 19:26 Comment(2)
Thank you for perfect answer. My code now work OK. Thanks for hint with BitAND 'function'.Candescent
I found out that you can directly open included files from code editor (SciTE) with setting cursor at included file name and pressing ALT+I. Maybe this can help someone...Candescent

© 2022 - 2024 — McMap. All rights reserved.