Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/26/2019 in all areas

  1. Version 1.0.0.0 released Changelog can be found on the download page and the history in the ZIP file. For download please see my signature below. Please play with this version and tell me what doesn't work or is missing!
    2 points
  2. Danyfirex

    Hash HMAC

    Hello guys. Here is a small function to create a hash hmac similar to hash_hmac PHP function. Supported are: SHA512,SHA256,SHA1,SHA384,MD5 and RIPEMD160. Local $sSecret = "SecretKey" Local $sMessage = "AutoIt Rocks!!!" ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA512", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA256", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA1: " & @TAB & @TAB & _HashHMAC("SHA1", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA384: " & @TAB & @TAB & _HashHMAC("SHA384", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-MD5: " & @TAB & @TAB & _HashHMAC("MD5", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-RIPEMD160: " & @TAB & _HashHMAC("RIPEMD160", $sMessage, $sSecret) & @CRLF) Func _HashHMAC($sAlgorithm, $bData, $bKey, $bRaw_Output = False) Local $oHashHMACErrorHandler = ObjEvent("AutoIt.Error", "_HashHMACErrorHandler") Local $oHMAC = ObjCreate("System.Security.Cryptography.HMAC" & $sAlgorithm) If @error Then SetError(1, 0, "") $oHMAC.key = Binary($bKey) Local $bHash = $oHMAC.ComputeHash_2(Binary($bData)) Return SetError(0, 0, $bRaw_Output ? $bHash : StringLower(StringMid($bHash, 3))) EndFunc ;==>_HashHMAC Func _HashHMACErrorHandler($oError) ;Dummy Error Handler EndFunc ;==>_HashHMACErrorHandler It requires .NET Framework 2.0 or higher. Saludos
    1 point
  3. nend

    Regex toolkit

    New version V1.4.2 See the first post for the changes.
    1 point
  4. @TheXman, Thank you. A lot of your explanations are beyond my capacity. AutoIt is the only language I ever learned, and that at a time I was well over 60. Thank you for your kindness.
    1 point
  5. The NTP server doesn't do any conversions of the inbound data from string representations of binary to binary. The NTP server reads all data in the header as binary, regardless of how you send it. Option 1 is correct. Options 2 & 3 are incorrect. I already explained, in detail, why it happened to work in this specific case. This is second time that I am telling you the same thing. That means you didn't understand what I told you the first time. Binary concepts appear to be beyond your comprehension at the moment. If you are really interested in understanding my answer, maybe it would benefit you to spend some time understanding the difference between binary data and string representations of binary data. Also, if you are really interested in the NTP protocol, you should spend more time reading and absorbing the information in the RFC, especially as it pertains to sending client requests, the request header, and the response packet. As for binary data, I won't even go into the subject big-endian vs little-endian and 1's complement vs 2's complement. It would probably just confuse you even more. For the record, the NTP protocol users 2's complement and big-endian for its numbers. Here's a simple script that demonstrated the difference between actual binary data and string representations of binary data. It also shows the difference between your option 1, 2 & 3. Actually, options 2 & 3 send the same binary data. ConsoleWrite(Binary("0x1B0000") & @CRLF) ConsoleWrite(Binary("1B0000") & @CRLF) ConsoleWrite("1B0000" & @CRLF) Output: 0x1B0000 0x314230303030 1B0000
    1 point
  6. I'm not saying that the original code couldn't have been optimized and cleaned up a little, but it worked and the binary request was correct. But your change makes absolutely no sense. The first word of advice is if you don't know what a particular piece of code is doing, DON'T CHANGE IT! The fact that you got back a good response with your "modification" was sheer luck because, lucky for you in this particular case, most of the information in the NTP request header is ignored. You could have thrown almost any data in the request packet and gotten back a response with a timestamp in it. Obviously you do not work with binary data very often. What the MakePacket() function did was change the hex string representation of a binary packet into an actual binary packet. I'm still trying to understand how you came up with your "modification" though. There is a big difference between 0x1B and "3" and 0x00 and "0". They DO NOT equate to the same binary value. And binary packets are what is sent and received in the NTP protocol, not strings. For example, 0x1B in binary is 00011011. "3", in binary, assuming it is using ascii or UTF-8 encoding, is 00110011 (0x33). 0x00 in binary is 00000000. "0" in binary, assuming ascii or utf-8 encoding, is 00110000 (0x30). If you wanted to get rid of the MakePacket() function, then you could have done something like: ;Replace MakePacket("1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") ;With Binary("0x1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") If you look at the RFC, the first 8 bits of the request/response header is made up of 3 values, LI, VN, and Mode. LI, the Leap Indicator, is the first 2 bits. VN, the NTP version number, is the next 3 bits. And the last 3 bits designates the mode, which in you case should be Client (3). That is why the first byte of request, in the original code, was 0x1B. That breaks down like so: 0x1B = 00011011 00 = Leap Indicator (0) 011 = Version Number (NTPv3) 011 = Mode (3-Client) With your "modification, it breaks down like so: 0x33 = 00110011 00 = Leap Indicator (0) 110 = Version Number (NTPv6) ??? 011 = Mode (3-Client) So the fact is that you got lucky in that you got the Mode correct (Client Request). I guess the NTP server just ignored the fact that you said that you were using a non-existent NTP version or sent back an error packet with a valid timestamp. 😃
    1 point
  7. You were close. The json_dump() function is always helpful in trying to figure out the correct notation for accessing values. As it is named, it dumps all of the values with their corresponding, dot notation, accessors. Below, I slightly modified your code to show you how to use the json_dump() function and how to access your values using both bracket and dot notation. I hope that helps. #include "Json.au3" $response = '{"raw":{},"class":[{"name":"infer","value":"88.1"}],"ref":"ver1","ex":null,"pr":null,"n":null,"re":null,"res":null}' $oJSON = Json_Decode($response) ; Dump the json values Json_Dump($response) ; Bracket notation ConsoleWrite("name = " & json_Get($oJSON, '["class"][0]["name"]') & @CRLF) ConsoleWrite("value = " & json_Get($oJSON, '["class"][0]["value"]') & @CRLF) ; Dot notation ConsoleWrite("name = " & json_Get($oJSON, '.class[0].name') & @CRLF) ConsoleWrite("value = " & json_Get($oJSON, '.class[0].value') & @CRLF) Output: +-> .class[0].name =infer +-> .class[0].value =88.1 +-> .ref =ver1 +-> .ex =Null +-> .pr =Null +-> .n =Null +-> .re =Null +-> .res =Null name = infer value = 88.1 name = infer value = 88.1
    1 point
  8. Here a modern way to get date/time from all over the world : #include <Constants.au3> Local $String = BinaryToString(InetRead ("http://worldtimeapi.org/api/timezone/America/Toronto.txt",1)) MsgBox (0,"",$String) ;Local $String = BinaryToString(InetRead ( "http://worldtimeapi.org/api/timezone/Europe/Amsterdam",1)) Local $Time = StringRegExp ($String,'datetime: (.+?)T(\d+:\d+:\d+)', $STR_REGEXPARRAYMATCH) MsgBox ($MB_SYSTEMMODAL,"",$Time[0] & " " & $Time[1])
    1 point
  9. mysteriously that message disappeared, but i can't get it working, it says that the message has been sent but it's not, this is the console output: Message Sent Sucessfully! MessageId: ThreadId: Sent message labels_ids: Problem solved! Several possible reasons: 1) Your trial period could have expired (if you use one). Check your status at admin.google.com 2) There is no email address that you use in FROM field created in your G Suite. So just create one. 3) Your email address is not a Gmail account. It is possible to be a Google Account but not a Gmail account (for example if you use the account for YouTube but have never enabled Gmail). 4) You may need to enable the Gmail feature or Gmail API access in your G Suite.
    1 point
  10. Melba23

    Wannabee Mods

    Hi, A number of recent threads have degenerated into discussions between no doubt well-meaning members over the legality of the question asked - such spats are both unseemly and unnecessary. If you have not already noticed, there is a Moderation team charged by the site owner with keeping the site running smoothly in accordance with his wishes - so please leave the decisions to them. If the question is obviously illegal, then perhaps the first responder might point at the Forum rules as well as reporting the thread so that normal moderation action can be taken. But if there is any doubt, please still report the thread, but do NOT get involved in pointless discussions as to whether or not it is allowable - the Moderation team will make the final decision and will not be swayed by any other opinions, so save the wear on typing fingers and keyboards. In particular, if a Moderation team member has already posted permitting the thread to continue, it is completely out of order for a third party to post again questioning the decision - from now on this will be regarded as an unfriendly act and is likely to attract sanctions upon the wannabee-Mod. If there is really a burning need to discuss the matter further, please do so by PM - the Moderation team do not bite and are open to reasoned debate. M23
    1 point
  11. LarsJ

    ListView color hover item

    Thank you. The example below is better. Handles multiple columns. Takes care of horizontal movement of the cursor in the same row through different columns.The hot state is item specific. Subitems doesn't matter. Custom draw is handled in the item case. The subitem case is deleted.Hot state is properly set. Even if you leave and enter the listview through the same item (e.g. on the left side).Hot state is reset when the cursor is moved out of the listview. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt( "MustDeclareVars", 1 ) Global $hGUI, $iGUIw = 350, $iGUIh = 400, $fCursorInListView = False Global $hLV, $iLVx = 2, $iLVy = 2, $iLVw = $iGUIw - 4, $iLVh = $iGUIh - 4 Global $iHot = -1, $iHotPrev = -1 Example() Func Example() $hGUI = GUICreate( "Hot item", $iGUIw, $iGUIh ) Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2|Column 3", $iLVx, $iLVy, $iLVw, $iLVh ) GUICtrlSendMsg( $idLV, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_TRACKSELECT ) $hLV = GUICtrlGetHandle( $idLV ) For $i = 0 To 99 GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2" & "|Cell " & $i & ".3", $idLV ) Next Local $hHeader = _GUICtrlListView_GetHeader( $hLV ) Local $aPos = WinGetPos( $hHeader ) $iLVy += $aPos[3] $iLVh -= $aPos[3] GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState() Local $aInfo, $aTest While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_HOTTRACK Local $tInfo = DllStructCreate( $tagNMLISTVIEW, $lParam ) $iHot = DllStructGetData( $tInfo, "Item" ) If $iHot <> $iHotPrev Then If Not $fCursorInListView Then AdlibRegister( "ResetHotRow", 100 ) $fCursorInListView = True EndIf If $iHot <> -1 Then _GUICtrlListView_RedrawItems( $hLV, $iHot, $iHot ) If $iHotPrev <> -1 Then _GUICtrlListView_RedrawItems( $hLV, $iHotPrev, $iHotPrev ) If $iHot <> $iHotPrev Then If $iHot <> -1 Then $iHotPrev = $iHot ElseIf $iHotPrev <> -1 Then $iHot = $iHotPrev _GUICtrlListView_RedrawItems( $hLV, $iHot, $iHot ) EndIf EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Local $dwItemSpec = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) ; Item index If $dwItemSpec = $iHot Then ; Hot row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFE8D8 ) ; Light blue, BGR Else ; Other rows DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func ResetHotRow() Local $aPos = GUIGetCursorInfo() If $aPos[0] < $iLVx Or $aPos[0] > $iLVx + $iLVw Or _ $aPos[1] < $iLVy Or $aPos[1] > $iLVy + $iLVh Then $iHot = -1 _GUICtrlListView_RedrawItems( $hLV, $iHotPrev, $iHotPrev ) AdlibUnRegister( "ResetHotRow" ) $fCursorInListView = False $iHotPrev = -1 EndIf EndFunc One issue: There is a narrow area between first and second column, which is not hottrack enabled. The hot state is not updated when the cursor is moved vertically in this area. No problem between the other columns. The cause of this issue is probably, that the first column has a special role: It represents the items. All the other columns are alike. They represent the subitems.
    1 point
  12. LarsJ

    ListView color hover item

    Here are the ideas for a solution based on custom drawn items: #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $hGUI = GUICreate("Hover Test", 323, 184, 208, 168) $cInput = GUICtrlCreateInput("", 8, 24, 305, 21) $cListView = GUICtrlCreateListView("ListView", 8, 45, 305, 129) $hListView = GUICtrlGetHandle($cListView) GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_TRACKSELECT) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) For $i = 0 To 10 GUICtrlCreateListViewItem("TEST_" & $i, $cListView) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local Static $iHot = -1, $iHotPrev = -1 Local $hWndFrom, $iCode, $tNMHDR, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $LVN_HOTTRACK ; Sent when the user moves the mouse over an item $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iHot = DllStructGetData($tInfo, "Item") If $iHot <> $iHotPrev Then ;ConsoleWrite($iHot & @LF) If $iHot <> -1 Then _GUICtrlListView_RedrawItems( $hListView, $iHot, $iHot ) If $iHotPrev <> -1 Then _GUICtrlListView_RedrawItems( $hListView, $iHotPrev, $iHotPrev ) If $iHot <> $iHotPrev And $iHot <> -1 Then $iHotPrev = $iHot EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $ilParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem Local $dwItemSpec = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) ; Item index ;Local $iSubItem = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem" ) ; Subitem index ;Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state If $dwItemSpec = $iHot Then ; Hot row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0x00FF00 ) Else ; Other rows DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY It's not a complete solution.
    1 point
  13. mikell

    ListView color hover item

    A not so difficult way #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $hGUI = GUICreate("Hover Test", 323, 184, 208, 168) $cInput = GUICtrlCreateInput("", 8, 24, 305, 21) $cListView = GUICtrlCreateListView("ListView", 8, 45, 305, 129) $hListView = GUICtrlGetHandle($cListView) GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_TRACKSELECT) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) Global $items[11], $hotitem = -1 For $i = 0 To 10 $items[$i] = GUICtrlCreateListViewItem("TEST_" & $i, $cListView) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hot_item $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $LVN_HOTTRACK ; Sent when the user moves the mouse over an item $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ; ConsoleWrite(DllStructGetData($tInfo, "Item") & @LF) $index = DllStructGetData($tInfo, "Item") If $index <> $hotitem Then For $i = 0 to 10 GuiCtrlSetColor($items[$i], 0x000000) Next If $index <> -1 Then GuiCtrlSetColor($items[$index], 0xff0000) $hotitem = $index EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    1 point
  14. #Include <GUIConstantsEx.au3> #Include <GUIEdit.au3> #Include <WindowsConstants.au3> GUICreate('MyGUI', 400, 90) $Input1 = GUICtrlCreateInput('My Text 1', 20, 20, 360, 20) $Input2 = GUICtrlCreateInput('My Text 2', 20, 50, 360, 20) GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $ID = BitAND($wParam, 0xFFFF) Switch $ID Case $Input1, $Input2 ; etc Switch BitShift($wParam, 16) Case $EN_SETFOCUS GUICtrlSetState($ID, $GUI_FOCUS) _GUICtrlEdit_SetSel($lParam, 0, -1) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND
    1 point
×
×
  • Create New...