Jump to content
Sign in to follow this  
Ruigerock

$Gui_Disable not recognized

Recommended Posts

Ruigerock

Goodmorning people,

I've been busy with a usefull script for work but one part is not working as I thought it would.

I took the known _IsEnabled function, change 3 words to have it check an disabled checkbox status

The code below is not the actual script but it demonstrates the error.

If you select "Check all but disabled" it will select all 3 checkboxes which is not my intention, ehh help?

#include <MsgBoxConstants.au3>
#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>

Local $box[03]

GuiCreate("Test", 300, 300, -1, -1)

$box[00] = GUICtrlCreateCheckbox("Unchecked", 20, 40, 240, 20)
$box[01] = GUICtrlCreateCheckbox("Disabled", 20, 60, 240, 20)
$box[02] = GUICtrlCreateCheckbox("Checked", 20, 80, 240, 20)
GUICtrlSetState($box[00], $GUI_UNCHECKED)
GUICtrlSetState($box[01], $GUI_DISABLE)
GUICtrlSetState($box[02], $GUI_CHECKED)
$Button_Ok = GUICtrlCreateButton("Check all but Disabled", 20 , 110, 180, 45)
$Button_KO = GUICtrlCreateButton("UnCheck all", 20 , 155, 180, 45)

GuiSetState()

Func _IsDisable($control)
    Return BitAND(GUICtrlRead($control), $GUI_DISABLE) = $GUI_DISABLE
EndFunc

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button_Ok
            For $i = 0 to 2
                If _IsDisable($box[$i]) Then
                    GUICtrlSetState($box[$i], $GUI_UNCHECKED)
                Else
                    GUICtrlSetState($box[$i], $GUI_CHECKED)
                EndIf
            Next
        Case $msg = $Button_KO
            For $i = 0 to 2
                GUICtrlSetState($box[$i], $GUI_UNCHECKED)
            Next
    EndSelect
WEnd

Share this post


Link to post
Share on other sites
Zedna

It seems that GUICtrlRead() returns for checkbox only $GUI_UNCHECKED/$GUI_CHECKED

so use GUICtrlGetState() instead of GUICtrlRead() which returns all states together.

Func _IsDisable($control)
    Return BitAND(GUICtrlGetState($control), $GUI_DISABLE) = $GUI_DISABLE
EndFunc
Edited by Zedna

Share this post


Link to post
Share on other sites
Ruigerock

Thank you Zedna, It works like a charm.

The help about GUICtrlRead confused me, it links to GUICtrlGetState without hinting to start using that function to retrieve the value

GUICtrlRead (ControlID [, advanced = 0] )

Default = 0 and it links to the table

Type                       Value

Checkbox, Radio state of the button. See State table

 

The topic has been solved :)

Edited by Ruigerock

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  

  • Similar Content

    • Rskm
      By Rskm
      Hi, I wrote the below code to learn user defined functions.. jam is the function which calculates summation and division of two numbers $a, $b.. I expect the $sum and $div receives the results $r and $s respectively from the function... but the msbox in the main program doesn't display results properly, while the one inside func shows it correclty. how do I pull the values in $r and $s to $sum and $div respectively.. thanks for all the help on this forum
       
      global $a,$b,$sum,$div
      $a=1
      $b=2 jam($a,$b,$sum,$div) msgbox(0,"results",$sum&" , "&$div)     func jam($p,$q,$r,$s )
       $r=$p+$q  $s = $p/$q msgbox(0,"results",$r&" , "&$s) EndFunc  
    • MarkBe
      By MarkBe
      Hi
      I am trying to check a number of applications are up to date and install the update if required. This will run as a shutdown script, pushed out through Group Policy.
      I am querying various registry keys to determine if
      The software is actually installed The software is at the correct version Once the need for update is determined then it calls another function to run the update.
      If the software is up to date or not installed, it moves down to the next software section which changes the registry key variables and calls the registry query function again
      I have managed to get the function for (un)installs to work but I am having trouble with the registry query function
      #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> ; Here we go! ;########################################################################################################## ;Declare variables Global $RegKey86, $RegKey64, $RegValueName, $RegValueData, $CheckVersion86, $CheckVersion64 ; 7Zip ;########################################################################################################## _7Zip_Function() Func _7Zip_Function() ; Registry location and values that are checked for current software version ; Ensure the x64 key is preceeded with 'HKLM64' $RegKey86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegKey64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegValueName="DisplayVersion" $RegValueData="16.04" ; Excecution ; --------------------------------------------------------------------------------------------------------- If _CheckSW() = 1 Then _UninstallOldVer() _InstallSW() EndIf EndFunc ;==>_7Zip_Function ; Functions ;########################################################################################################## Func _CheckSW() $CheckVersion86=RegRead ($RegKey86, $RegValueName) $CheckVersion64=RegRead ($RegKey64, $RegValueName) If $CheckVersion86=$RegValueData Or $CheckVersion64=$RegValueData Then Return 0 ElseIf $CheckVersion86="" And $CheckVersion64="" Then Return 0 Else Return 1 EndIf EndFunc ;==>CheckSW  
    • WoodGrain
      By WoodGrain
      Hi guys,
      Could someone please tell me what I'm doing wrong with this code?
      I'm trying to take user input and then run a function with the same name, but it's not calling the function.
      So in the below after pressing Shift+F8 I would enter the text (without quotes) "testFunc".
      As you can see I've also tried this with IF statements, I'm new to using Switch/Case.
      HotKeySet("+{F8}", RunManually) Func RunManually() ;Use a case statement with 1 hot key and an InputBox to manually run functions $funcName = InputBox("Which Func to Run?", "Enter the name of the function to run") MsgBox(0, "Entered value", $funcName) ;If $funcName = testFunc Then testFunc() ;If $funcName = test2Func Then test2Func() Switch $funcName Case testFunc MsgBox(0, "Calling", "Calling Function") testFunc() MsgBox(0, "Called", "Function call finished") Case test2Func MsgBox(0, "Calling", "Calling Function") test2Func() MsgBox(0, "Called", "Function call finished") EndSwitch EndFunc While 1 ;testFunc() Sleep(1000) WEnd Func testFunc() MsgBox(0, "func running", "Seems to work!") EndFunc Func test2Func() MsgBox(0, "func 2 running", "2 Seems to work!") EndFunc Thanks!
    • j0kky
      By j0kky
      Hi guys,
      Bitwise operations in Autoit is possible only till 32 bit integers, but sometimes WinAPI requires to process 64 bit vectors... so?
      So you can use this little UDF to handle properly those integers!
      Func _BitAND64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitAND($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueANDed[64], $i For $i = 0 To 63 $aValueANDed[$i] = ($iValue1[$i] And $iValue2[$i]) ? 1 : 0 Next Return __BinToDec64($aValueANDed) EndFunc ;==>_BitAND64 Func _BitOR64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitOR($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueORed[64], $i For $i = 0 To 63 $aValueORed[$i] = ($iValue1[$i] Or $iValue2[$i]) ? 1 : 0 Next Return __BinToDec64($aValueORed) EndFunc ;==>_BitOR64 Func _BitXOR64($iValue1, $iValue2) If Not ((VarGetType($iValue1) = "Int64") Or (VarGetType($iValue2) = "Int64")) Then Return BitXOR($iValue1, $iValue2) $iValue1 = __DecToBin64($iValue1) $iValue2 = __DecToBin64($iValue2) Local $aValueXORed[64], $i For $i = 0 To 63 $aValueXORed[$i] = (($iValue1[$i] And (Not $iValue2[$i])) Or ((Not $iValue1[$i]) And $iValue2)) ? 1 : 0 Next Return __BinToDec64($aValueXORed) EndFunc ;==>_BitXOR64 Func _BitNOT64($iValue) If Not (VarGetType($iValue) = "Int64") Then Return BitNOT($iValue) $iValue = __DecToBin64($iValue) For $i = 0 To 63 $iValue[$i] = Not $iValue[$i] Next Return __BinToDec64($iValue) EndFunc ;==>_BitNOT64 Func __DecToBin64($iDec) Local $tDec = DllStructCreate("int64 num"), $aBin[64], $bBit, $i $tDec.num = $iDec For $i = 0 To 63 $bBit = (Mod($tDec.num, 2) ? 1 : 0) $aBin[63 - $i] = $bBit $tDec.num = Floor($tDec.num / 2) Next Return $aBin EndFunc ;==>__DecToBin64 Func __BinToDec64($aBin) Local $tDec = DllStructCreate("int64 num"), $i If $aBin[0] Then $tDec.num += 0x8000000000000000 ;2^63 = 9223372036854775808, but for Autoit the world ends at 9223372036854775807 (2^63 - 1) For $i = 1 To 63 If $aBin[$i] Then $tDec.num += 2 ^ (63 - $i) Next Return $tDec.num EndFunc ;==>__BinToDec64 If you are working with unsigned 64 bit integers and these functions return a negative value, don't worry, bitwise operations come out well, but Autoit manages all numbers as signed integers.
    • 232showtime
      By 232showtime
      good day,
      Please I need a little help ive been trying to find where I got this magic number and I remember it was for Minimize, but I really dont remember where I got this. Last thing I remember i was reading the help file and saw this minize magic numbers, but I cant find it anymore, I dnt wnt to use this magic number anymore OMG! please help...
      here it is.
      Local $hAaSf = "C:\Main.xlsx" ;Main excel Local $iStateAsf = WinGetState($hAaSf) BitAND($iStateAsf, 16)  
×