Jump to content
Sign in to follow this  

bitAND magic numbers help

Recommended Posts

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)


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post

Link to post
Share on other sites

From the WinGetState helpfile and its example script:


$WIN_STATE_MINIMIZED (16) = Window is minimized


If BitAND($iState, 16) Then
    MsgBox($MB_SYSTEMMODAL, "", "Notepad is minimized and the state returned by WinGetState was - " & $iState)


According to the helpfile, you can also use $WIN_STATE_MINIMIZED, but I can't find that anywhere so either I'm missing something or the helpfile is wrong there. So I guess you're forced to just take that magic number from the help file or define your own constants.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post

Link to post
Share on other sites

There is a ticket, although I don't see much of a description. https://www.autoitscript.com/trac/autoit/attachment/ticket/3216/WinGetState Example.au3

Indeed the statement - Constants are defined in "AutoItConstants.au3" - is misleading. I'm not sure if they belong there anyway.

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.

  • Similar Content

    • By Robinson1
      Okay it's about the style of the AutoIT Language. Concerning: 
      BitAND, BitOR, BitXOR, BitXOR, 
      BitShift, BitRotate
      That's a very simple but fundamental question:
       Why BitAND is not  infix?

      In most other common programming languages it is.
      Let's take JavaScript. Here I write:
      Result = Value & Mask
      But on AutoIT it's
      $Result = BitAND ( $Value , $Mask ) That's more the Lisp / prefix way.
      While the logical and is indeed infix
      $bIsEnable = $bIsGUI_chkEnabled and $bIsGUI_chkChecked
      So I wonder why it is like this.
      What is the Idea behind this language design decision?  

      Okay Autoit is a matured Language but yeah -  It's never to late for a change.
      Wasn't there ideas to unify it any way?
      So we also make the 'Bit' operations infix as well?
      ... while Just keeping the 'old' prefix version -for backwards compatibility - as well.

      UPDATE #1: Now I created a ticket for this:

      Well to generalise/modulate It more I may bring it down to the Subject Verb Object  thing you have with language.
      "I go swimming" that's S-V-O or some infix.
      "Swimming I go". is O-S-V - postfix and sound much like yoda-style. While
      "go I swimming" is V-S-O - prefix and 'feels' more like kinda question.

      There is no right or wrong here - however personally I find infix is most appropriate here.
    • 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.
    • By 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
  • Create New...