Advertisement
Guest User

Untitled

a guest
May 27th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. ; GLOBAL SETTINGS ===============================================================================================================
  2.  
  3. ;#Warn
  4. #NoEnv
  5. #SingleInstance Force
  6.  
  7. global WS_VSCROLL := 0x00200000
  8.  
  9. ; GUI ===========================================================================================================================
  10.  
  11. Gui, Margin, 5, 5
  12. Gui, Font, s10, Consolas
  13. Gui, Add, Edit, xm ym w140 h22 0x0002 gBitCalc vBCv1, 0x0800
  14. Gui, Add, DropDownList, x+20 yp w120 AltSubmit gBitCalc vBC, BitAnd||BitOr|BitXor|BitShift Left|BitShift Right
  15. Gui, Add, Edit, x+20 ym w140 h22 0x0002 gBitCalc vBCv2, 0x0202
  16. Gui, Font, s9, Consolas
  17. Gui, Add, Edit, xm y+5 w240 r6 -0x200000 0x0880 gBitCalc vBCRB
  18. Gui, Add, Edit, x+0 yp w100 r6 -0x200000 0x0880 gBitCalc vBCRH
  19. Gui, Add, Edit, x+0 yp w100 r6 -0x200000 0x0880 gBitCalc vBCRD
  20. Gui, Show, AutoSize
  21.  
  22. BitCalc:
  23. Gui, Submit, NoHide
  24. if (BC = 1)
  25. {
  26. OutPutB := ConvertToBin(BCv1) "`n&`n" ConvertToBin(BCv2) "`n=`n" ConvertToBin(BCv1 & BCv2)
  27. OutPutH := FormatIntH(BCv1) "`n&`n" FormatIntH(BCv2) "`n=`n" FormatIntH(BCv1 & BCv2)
  28. OutPutD := FormatHexD(BCv1) "`n&`n" FormatHexD(BCv2) "`n=`n" FormatHexD(BCv1 & BCv2)
  29. GuiControl,, BCRB, % OutPutB
  30. GuiControl,, BCRH, % OutPutH
  31. GuiControl,, BCRD, % OutPutD
  32. }
  33. else if (BC = 2)
  34. {
  35. OutPutB := ConvertToBin(BCv1) "`n|`n" ConvertToBin(BCv2) "`n=`n" ConvertToBin(BCv1 | BCv2)
  36. OutPutH := FormatIntH(BCv1) "`n|`n" FormatIntH(BCv2) "`n=`n" FormatIntH(BCv1 | BCv2)
  37. OutPutD := FormatHexD(BCv1) "`n|`n" FormatHexD(BCv2) "`n=`n" FormatHexD(BCv1 | BCv2)
  38. GuiControl,, BCRB, % OutPutB
  39. GuiControl,, BCRH, % OutPutH
  40. GuiControl,, BCRD, % OutPutD
  41. }
  42. else if (BC = 3)
  43. {
  44. OutPutB := ConvertToBin(BCv1) "`n^`n" ConvertToBin(BCv2) "`n=`n" ConvertToBin(BCv1 ^ BCv2)
  45. OutPutH := FormatIntH(BCv1) "`n^`n" FormatIntH(BCv2) "`n=`n" FormatIntH(BCv1 ^ BCv2)
  46. OutPutD := FormatHexD(BCv1) "`n^`n" FormatHexD(BCv2) "`n=`n" FormatHexD(BCv1 ^ BCv2)
  47. GuiControl,, BCRB, % OutPutB
  48. GuiControl,, BCRH, % OutPutH
  49. GuiControl,, BCRD, % OutPutD
  50. }
  51. else if (BC = 4)
  52. {
  53. OutPutB := ConvertToBin(BCv1) "`n<<`n" ConvertToBin(BCv2) "`n=`n" ConvertToBin(BCv1 << BCv2)
  54. OutPutH := FormatIntH(BCv1) "`n<<`n" FormatIntH(BCv2) "`n=`n" FormatIntH(BCv1 << BCv2)
  55. OutPutD := FormatHexD(BCv1) "`n<<`n" FormatHexD(BCv2) "`n=`n" FormatHexD(BCv1 << BCv2)
  56. GuiControl,, BCRB, % OutPutB
  57. GuiControl,, BCRH, % OutPutH
  58. GuiControl,, BCRD, % OutPutD
  59. }
  60. else if (BC = 5)
  61. {
  62. OutPutB := ConvertToBin(BCv1) "`n>>`n" ConvertToBin(BCv2) "`n=`n" ConvertToBin(BCv1 >> BCv2)
  63. OutPutH := FormatIntH(BCv1) "`n>>`n" FormatIntH(BCv2) "`n=`n" FormatIntH(BCv1 >> BCv2)
  64. OutPutD := FormatHexD(BCv1) "`n>>`n" FormatHexD(BCv2) "`n=`n" FormatHexD(BCv1 >> BCv2)
  65. GuiControl,, BCRB, % OutPutB
  66. GuiControl,, BCRH, % OutPutH
  67. GuiControl,, BCRD, % OutPutD
  68. }
  69. else
  70. GuiControl,, BCRB, % "ERROR"
  71. return
  72.  
  73. ; FUNCTIONS =====================================================================================================================
  74.  
  75. FormatIntH(Int) ; just me
  76. {
  77. ; Returns the hexadecimal string represention of the given integer value.
  78. ; Int - Integer value in the range of -9223372036854775808 to 9223372036854775807
  79. ; Typ - Type to determine the size of the returned hex string.
  80. ; You may pass one of the keys in the 'Types' object. If the parameter is omitted or 'Auto'
  81. ; is passed explicitely, the size will be determined as 'Int64', 'Int', 'Short', or 'Char'
  82. ; according to the value of 'Int'.
  83. if Int Is Not Integer
  84. return ""
  85. if (Int <= 255) && (Int >= -128)
  86. Len := 2
  87. else if (Int <= 65535) && (Int >= -32768)
  88. Len := 4
  89. else if (Int <= 4294967295) && (Int >= -2147483648)
  90. Len := 8
  91. else
  92. Len := 16
  93. VarSetCapacity(Hex, 17 << !!A_IsUnicode, 0)
  94. if (DllCall("Shlwapi.dll\wnsprintf", "Str", Hex, "Int", 17, "Str", "%016I64X", "UInt64", Int, "Int") = 16)
  95. return "0x" SubStr(Hex, StrLen(Hex) - Len + 1)
  96. return ""
  97. }
  98.  
  99. FormatHexD(nptr)
  100. {
  101. static u := A_IsUnicode ? "_wcstoui64" : "_strtoui64"
  102. static v := A_IsUnicode ? "_i64tow" : "_i64toa"
  103. if (InStr(nptr, "0x"))
  104. {
  105. VarSetCapacity(s, 66, 0)
  106. value := DllCall("msvcrt.dll\" u, "Str", nptr, "UInt", 0, "UInt", 16, "CDECL Int64")
  107. DllCall("msvcrt.dll\" v, "Int64", value, "Str", s, "UInt", 10, "CDECL")
  108. return s
  109. }
  110. return nptr
  111. }
  112.  
  113. ConvertToBin(h)
  114. {
  115. loop 32
  116. b := h & 1 b, h := h >> 1
  117. return b
  118. }
  119.  
  120. ; EXIT ==========================================================================================================================
  121.  
  122. GuiEscape:
  123. GuiClose:
  124. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement