AutoIT GUICtrlSetState/GUICtrlGetState set state is different from get state

喜欢而已 提交于 2019-12-11 04:04:03

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/20381019/autoit-guictrlsetstate-guictrlgetstate-set-state-is-different-from-get-state

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!