Leaderboard
Popular Content
Showing content with the highest reputation on 11/23/2016 in all areas
-
(+n) + (-n) + (-n) = baloney ???? [SOLVED]
argumentum and 2 others reacted to MuffinMan for a topic
"Pence Conversion" is a VERY different thing in the US!3 points -
LAST VERSION - 1.0 25-Jan-15 This is my way to use the API ReadDirectoryChangesW in AutoIt. The problem is that to use this function will not work fully without creating thread. To solve this problem, I wrote the simple DLL that provides work with threads. As a result, the AutoIt script only receives and processes the appropriate data from thread. To evaluate all features of the library, please see the full example with GUI for monitoring directories. For more information, see description for each function within the library. The following are the main features of the RDC UDF library. Creating multiple threads (unlimited) for monitoring different directories.Support for hot (unsafe) unplugging of removable devices such as USB flash drive, etc.Support for network drives.Support for 32- and 64-bit processes (RDC.dll and RDC_x64.dll).Easy to use functions from the library.Full examples, including GUI. Available functions RDC UDF Library v1.0 (x86 and x64) Previous downloads: 17 RDC.zip Examples Simple (Notification mode) Advanced GUI1 point
-
I've had this one rolling around my brain for a while now. And while I can't take credit for much of anything at this point since it's just implementation, here's a framework for Time-based One-Time Password authentication, ie Google Authenticator. I've added links in all the places where I've harvested code. I'm planning on building this into an actual authenticator app, so this is just step one. As always, thanks to everyone whose code contributed. _GAuth.au3 #include-once #include <_HMAC.au3> #include <Date.au3> ;; http://tools.ietf.org/html/rfc6238 Func _GenerateTOTP($key, $keyIsBase32 = True, $time = Default, $period = 30, $digits = 6) Local $DIGITS_POWER[9] = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000] ; time is some number of seconds If $time = Default Then $time = _GetUnixTimeUTC() $time = StringFormat("%016X", Floor($time / $period)) If $keyIsBase32 Then $key = _Base32ToHex($key, True) ; return binary Else $key = StringToBinary($key) EndIf ; HMAC function expects binary arguments Local $hash = _HMAC_SHA1($key, Binary("0x" & $time)) Local $offset = BitAND(BinaryMid($hash, BinaryLen($hash), 1), 0xf) Local $otp = BitOR(BitShift(BitAND(BinaryMid($hash, $offset + 1, 1), 0x7f), -24), _ BitShift(BitAND(BinaryMid($hash, $offset + 2, 1), 0xff), -16), _ BitShift(BitAND(BinaryMid($hash, $offset + 3, 1), 0xff), -8), _ BitAND(BinaryMid($hash, $offset + 4, 1), 0xff) _ ) $otp = Mod($otp, $DIGITS_POWER[$digits]) Return StringFormat("%0" & $digits & "i", $otp) EndFunc ;; http://www.autoitscript.com/forum/topic/153617-seconds-since-epoch-aka-unix-timestamp/ Func _GetUnixTimeUTC() ; returns number of seconds since EPOCH in UTC Local $aSysTimeInfo = _Date_Time_GetTimeZoneInformation() Local $utcTime = "" Local $sDate = _NowCalc() If $aSysTimeInfo[0] = 2 Then $utcTime = _DateAdd('n', $aSysTimeInfo[1] + $aSysTimeInfo[7], $sDate) Else $utcTime = _DateAdd('n', $aSysTimeInfo[1], $sDate) EndIf Return _DateDiff('s', "1970/01/01 00:00:00", $utcTime) EndFunc ;; http://tomeko.net/online_tools/base32.php?lang=en Func _Base32ToHex($sInput, $returnBinary = False) $sInput = StringRegExpReplace(StringUpper($sInput), "[^A-Z2-7]", "") Local $key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" Local $buffer = 0, $bitsLeft = 0, $i = 0, $count = 0, $output = "", $val While $i < StringLen($sInput) $val = StringInStr($key, StringMid($sInput, $i + 1, 1)) - 1 ; StringInStr returns 1 as 1st position If $val >=0 And $val < 32 Then $buffer = BitOR(BitShift($buffer, -5), $val) $bitsLeft += 5 If $bitsLeft >= 8 Then $output &= Chr(BitAND(BitShift($buffer, $bitsLeft - 8), 0xFF)) $bitsLeft -= 8 EndIf EndIf $i += 1 WEnd If $bitsLeft > 0 Then $buffer = BitShift($buffer, -5) $output &= Chr(BitAND(BitShift($buffer, $bitsLeft - 3), 0xFF)) EndIf If $returnBinary Then Return StringToBinary($output) Else Return $output EndIf EndFunc #cs Alternate base32 to hex functions Func _b32toh($input) $input = StringRegExpReplace(StringUpper($input), "[^A-Z2-7]", "") Local $ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" Local $bits = "", $hex = "", $val, $i For $i = 0 To StringLen($input) - 1 $val = StringInStr($ch, StringMid($input, $i + 1, 1)) - 1 $bits &= StringFormat("%05s", _itob($val)) Next $i = 0 Local $chunk While ($i + 4) <= StringLen($bits) $chunk = StringMid($bits, $i + 1, 4) $hex &= StringFormat("%X", _btoi($chunk)) $i += 4 WEnd Return $hex EndFunc ; int to binary (0's and 1's) string Func _itob($int) Local $o = "" While $int $o = BitAND($int, 1) & $o $int = BitShift($int, 1) WEnd Return $o EndFunc ; binary (0's and 1's) string to int Func _btoi($b) Local $p = 0, $o = 0 For $i = StringLen($b) To 1 Step -1 $o += (2 ^ $p) * Number(StringMid($b, $i, 1)) $p += 1 Next Return $o EndFunc #ce Func _TOTPTestVectors() #cs Test vectors operate in HOTP mode. The test token shared secret uses the ASCII string value "12345678901234567890". With Time Step X = 30, and the Unix epoch as the initial value to count time steps, where T0 = 0, the TOTP algorithm will display the following values for specified modes and timestamps. +-------------+--------------+------------------+----------+--------+ | Time (sec) | UTC Time | Value of T (hex) | TOTP | Mode | +-------------+--------------+------------------+----------+--------+ | 59 | 1970-01-01 | 0000000000000001 | 94287082 | SHA1 | | | 00:00:59 | | | | | 1111111109 | 2005-03-18 | 00000000023523EC | 07081804 | SHA1 | | | 01:58:29 | | | | | 1111111111 | 2005-03-18 | 00000000023523ED | 14050471 | SHA1 | | | 01:58:31 | | | | | 1234567890 | 2009-02-13 | 000000000273EF07 | 89005924 | SHA1 | | | 23:31:30 | | | | | 2000000000 | 2033-05-18 | 0000000003F940AA | 69279037 | SHA1 | | | 03:33:20 | | | | | 20000000000 | 2603-10-11 | 0000000027BC86AA | 65353130 | SHA1 | | | 11:33:20 | | | | +-------------+--------------+------------------+----------+--------+ #ce Local $times[6] = [59, 1111111109, 1111111111, 1234567890, 2000000000, 20000000000] For $i = 0 To 5 ConsoleWrite(StringFormat("%016X", Floor($times[$i] / 30)) & " : " & _ _GenerateTOTP("12345678901234567890", False, $times[$i], 30, 8) & @CRLF) Next EndFunc _HMAC.au3 #include-once #include <Crypt.au3> ;; http://www.autoitscript.com/forum/topic/145556-solved-hmac-sha1/?p=1028830 Func _HMAC_SHA1($key, $message) If Not IsBinary($key) Then $key = Binary($key) If Not IsBinary($message) Then $message = Binary($message) Local $blocksize = 64 Local $a_opad[$blocksize], $a_ipad[$blocksize] Local Const $oconst = 0x5C, $iconst = 0x36 Local $opad = Binary(''), $ipad = Binary('') If BinaryLen($key) > $blocksize Then $key = _Crypt_HashData($key, $CALG_SHA1) For $i = 1 To BinaryLen($key) $a_ipad[$i-1] = Number(BinaryMid($key, $i, 1)) $a_opad[$i-1] = Number(BinaryMid($key, $i, 1)) Next For $i = 0 To $blocksize - 1 $a_opad[$i] = BitXOR($a_opad[$i], $oconst) $a_ipad[$i] = BitXOR($a_ipad[$i], $iconst) Next For $i = 0 To $blocksize - 1 $ipad &= Binary('0x' & Hex($a_ipad[$i], 2)) $opad &= Binary('0x' & Hex($a_opad[$i], 2)) Next Return _Crypt_HashData($opad & _Crypt_HashData($ipad & $message, $CALG_SHA1), $CALG_SHA1) EndFunc Func _HMAC_MD5($key, $message) If Not IsBinary($key) Then $key = Binary($key) If Not IsBinary($message) Then $message = Binary($message) Local $blocksize = 64 Local $a_opad[$blocksize], $a_ipad[$blocksize] Local Const $oconst = 0x5C, $iconst = 0x36 Local $opad = Binary(''), $ipad = Binary('') If BinaryLen($key) > $blocksize Then $key = _Crypt_HashData($key, $CALG_MD5) For $i = 1 To BinaryLen($key) $a_ipad[$i-1] = Number(BinaryMid($key, $i, 1)) $a_opad[$i-1] = Number(BinaryMid($key, $i, 1)) Next For $i = 0 To $blocksize - 1 $a_opad[$i] = BitXOR($a_opad[$i], $oconst) $a_ipad[$i] = BitXOR($a_ipad[$i], $iconst) Next For $i = 0 To $blocksize - 1 $ipad &= Binary('0x' & Hex($a_ipad[$i], 2)) $opad &= Binary('0x' & Hex($a_opad[$i], 2)) Next Return _Crypt_HashData($opad & _Crypt_HashData($ipad & $message, $CALG_MD5), $CALG_MD5) EndFunc Example: Use the test vectors function to test HOTP mode, or visit http://gauth.apps.gbraad.nl/ for a live test site. The default account uses "JBSWY3DPEHPK3PXP" as the key ( https://code.google.com/p/google-authenticator/wiki/KeyUriFormat ). ConsoleWrite(_GenerateTOTP("JBSWY3DPEHPK3PXP") & @CRLF)1 point
-
Hi guys, thanks to this request, I wrote my version of GetLogicalProcessorInformation UDF for x86 e x64: ; #FUNCTION# ======================================================================================================================== ; Name...........: _WinAPI_GetLogicalProcessorInformation ; Description ...: Retrieves information about logical processors and related hardware. ; Syntax.........: _WinAPI_GetLogicalProcessorInformation() ; Return values .: On success it returns a bidimensional array: on rows there is the list of processor sets, these are the columns: ; |[0] - A logical processor affinity mask, which indicates the logical processors that the information applies to. ; |[1] - If setted, then the specified logical processors share a single processor core. ; |[2] - How many active processors that share functional units are in the relationship ; (it is setted only if the previous element is setted too) ; |[3] - If setted, it identifies the NUMA node (it can be 0). ; |[4] - If setted, the specified logical processors share a physical package. ; |[5] - A bidimensional array: on rows there is the cache list, these are the columns: ; |[0] - The cache level ; |[1] - The cache associativity ; |[2] - The cache line size, in bytes ; |[3] - The cache size, in bytes ; |[4] - The cache type ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; Remarks .......: Search GetLogicalProcessorInformation in MSDN Library. ; Author ........: j0kky ; Modified ......: 1.0.0 ; Links .........: https://msdn.microsoft.com/it-it/library/windows/desktop/ms683194(v=vs.85).aspx ; ==================================================================================================================================== Func _WinAPI_GetLogicalProcessorInformation() Local $hDll = DllOpen("kernel32.dll") If @error Then Return SetError(-2, 0, -1) Local Const $ERROR_INSUFFICIENT_BUFFER = 122 Local $aRet = DllCall($hDll, "BOOL", "GetLogicalProcessorInformation", "ptr", Null, "dword*", 0) If @error Or Not (DllCall($hDll, "DWORD", "GetLastError")[0] = $ERROR_INSUFFICIENT_BUFFER) Then DllClose($hDll) Return SetError(-1, 0, -1) EndIf Local $nReturnLength = $aRet[2] Local $tBuffer = DllStructCreate("byte[" & $nReturnLength & "]") Local $pBuffer = DllStructGetPtr($tBuffer) $aRet = DllCall($hDll, "BOOL", "GetLogicalProcessorInformation", "ptr", $pBuffer, "dword*", $nReturnLength) If @error Or Not $aRet[0] Then DllClose($hDll) Return SetError(-1, 0, -1) EndIf Local Const $tagSYSTEM_LOGICAL_PROCESSOR_INFORMATION = "ULONG_PTR ProcessorMask; INT_PTR Relationship; BYTE UnionBuffer[16]" Local $tSYSTEM_LOGICAL_PROCESSOR_INFORMATION = DllStructCreate($tagSYSTEM_LOGICAL_PROCESSOR_INFORMATION, $pBuffer) Local $nSize = DllStructGetSize($tSYSTEM_LOGICAL_PROCESSOR_INFORMATION), $tCACHE_DESCRIPTOR, _ $aResult[1][6], _ ;mask, core, logical, numa, package, cache $aCacheModel[0][5], _ ;level, associativity, line size, size, processor cache type $nOffset = 0, $nArraySize, $aCache, $vProcessor, $nProcessorMask $aResult[0][0] = $tSYSTEM_LOGICAL_PROCESSOR_INFORMATION.ProcessorMask $aResult[0][5] = $aCacheModel Do $tSYSTEM_LOGICAL_PROCESSOR_INFORMATION = DllStructCreate($tagSYSTEM_LOGICAL_PROCESSOR_INFORMATION, $pBuffer + $nOffset) $nProcessorMask = $tSYSTEM_LOGICAL_PROCESSOR_INFORMATION.ProcessorMask $nArraySize = UBound($aResult) For $i = 0 To ($nArraySize - 1) If $aResult[$i][0] = $nProcessorMask Then $vProcessor = $i ExitLoop EndIf Next If $vProcessor = Null Then ReDim $aResult[$nArraySize + 1][6] $aResult[$nArraySize][0] = $nProcessorMask $aResult[$nArraySize][5] = $aCacheModel $vProcessor = $nArraySize EndIf Switch $tSYSTEM_LOGICAL_PROCESSOR_INFORMATION.Relationship Case 0 ;RelationProcessorCore $aResult[$vProcessor][1] += 1 If (DllStructCreate("byte Flags", DllStructGetPtr($tSYSTEM_LOGICAL_PROCESSOR_INFORMATION, "UnionBuffer")).Flags) = 1 Then For $i = 1 To (($nSize = 24) ? 32 : 64) $aResult[$vProcessor][2] += (Mod($nProcessorMask, 2) ? 1 : 0) $nProcessorMask = Floor($nProcessorMask / 2) Next EndIf Case 1 ;RelationNumaNode $aResult[$vProcessor][3] = DllStructCreate("dword NodeNumber", DllStructGetPtr($tSYSTEM_LOGICAL_PROCESSOR_INFORMATION, "UnionBuffer")).NodeNumber Case 2 ;RelationCache $tCACHE_DESCRIPTOR = DllStructCreate("byte Level; byte Associativity; word LineSize; dword Size; INT Type", _ DllStructGetPtr($tSYSTEM_LOGICAL_PROCESSOR_INFORMATION, "UnionBuffer")) $aCache = $aResult[$vProcessor][5] $nArraySize = UBound($aCache) ReDim $aCache[$nArraySize + 1][5] $aCache[$nArraySize][0] = $tCACHE_DESCRIPTOR.Level $aCache[$nArraySize][1] = $tCACHE_DESCRIPTOR.Associativity $aCache[$nArraySize][2] = $tCACHE_DESCRIPTOR.LineSize $aCache[$nArraySize][3] = $tCACHE_DESCRIPTOR.Size $aCache[$nArraySize][4] = $tCACHE_DESCRIPTOR.Type $aResult[$vProcessor][5] = $aCache Case 3 ;RelationProcessorPackage $aResult[$vProcessor][4] += 1 EndSwitch $nOffset += $nSize $vProcessor = Null Until $nOffset = $nReturnLength DllClose($hDll) Return $aResult EndFunc ;==>_WinAPI_GetLogicalProcessorInformation Usage example: #include <array.au3> $array = _WinAPI_GetLogicalProcessorInformation() _ArrayDisplay($array, "Processor set list:") For $i = 0 To UBound($array) - 1 _ArrayDisplay($array[$i][5], "Processor set " & $i + 1 & " cache:") Next1 point
-
Why not, but then you can spare the .INI files altogether by prepending the block length before the block itself, an int32 would do. Note that AES uses a fixed 128-bit blocksize, so dealing with multiples of blocksize shouldn't be very hard indeed!1 point
-
Just an idea, what about: - filewrite the content encrypted by _Crypt_EncryptData (with last param setted to True) - write to an .ini file the lenght, in bytes, written - filewrite another content encrypted by _Crypt_EncryptData (with last param setted to True) - write to an .ini file the lenght, in bytes, written - ...... Then you can FileRead and decrypt each block of data (because you can retrieve its lenght by the .ini file)1 point
-
When invoking CryptEncrypt() the data passed must adhere to the underlying Windows function requirements (https://msdn.microsoft.com/en-us/library/windows/desktop/aa379924(v=vs.85).aspx): " When a block cipher is used, this data length must be a multiple of the block size unless this is the final section of data to be encrypted and the Final parameter is TRUE. " Since you embed to encryption function call inside a FileWrite you have exactly zero chance to remark that an error was raised inside. So your alternatives are either to use a stream cipher or to postpone encrypting stuff until you gather enough data (multiple of AES block).1 point
-
1 point
-
Or you can use the native WMI Console -- Tested on two computers. #RequireAdmin Opt('MustDeclareVars', 1) Local $rtn = GetPOH() MsgBox(0, 'Result', $rtn) Exit ;=============================================================================================================== Func GetPOH() Local $pid = Run('WMIC /NAMESPACE:\\root\wmi PATH MSStorageDriver_ATAPISmartData', '', @SW_HIDE, 6) If @error Or Not $pid Then Return -1 Local $stdout = '' Do Sleep(10) $stdout &= StdoutRead($pid, 0, 0) Until @error MsgBox(0, 'Smart Data (debug)', $stdout) ; split headers from data Local $a = StringSplit($stdout, @CRLF, 1) ; there are 3 sets of curly brackets in the data, we want the second set Local $s = StringTrimLeft($a[2], StringInStr($a[2], '{', 0, 2) + 7) Local $array, $n, $str For $i = 1 To 10 ; get end position of attribute string $n = StringInStr($s, ',', 0, 12) + 1 ; get the attribute string from data to a separate var $str = StringLeft($s, $n) ; remove that attribute string from data $s = StringTrimLeft($s, $n) ; search for attribute 9, which is the POH string If Number(StringLeft($str, 1)) = 9 Then ; trim to position of the DeviceID string $s = StringTrimLeft($a[2], StringInStr($a[2], 'IDE') - 1) ; get DeviceID string $s = StringLeft($s, StringInStr($s, ' ') - 1) & @CRLF & @CRLF ; split the POH string $array = StringSplit($str, ',') ; get POH calculation $s &= Number($array[6]) + (Number($array[7]) * 256) & ' (Power On Hours)' ; return the DeviceID and POH Return $s EndIf Next Return -2 EndFunc1 point
-
I modified my previous script to allow you to change easily the URL inserted: TCPStartup() If @error Then _ReportError(@error, @extended, @ScriptLineNumber - 1) Local $sIPAddress = TCPNameToIP("www.hearthpwn.com") If @error Then _ReportError(@error, @extended, @ScriptLineNumber - 1) Local $iSocket = TCPConnect($sIPAddress, 80) If @error Then _ReportError(@error, @extended, @ScriptLineNumber - 1) $sLink = "http://www.hearthpwn.com/decks/670319-tempo-aggro-mage-82-ratio-easy-rank-5" $sRegEx = StringRegExp($sLink, "hearthpwn\.com/(.*)", 1) If @error Then _ReportError("Bad link", "", @ScriptLineNumber - 1) $sLink = $sRegEx[0] TCPSend($iSocket, "GET /" & $sLink & "?cookieTest=1 HTTP/1.1" & @CRLF & _ "Host: www.hearthpwn.com" & @CRLF & _ "Connection: close" & @CRLF & @CRLF) If @error Then _ReportError(@error, @extended, @ScriptLineNumber - 1) Local $sData = "", $hTimer = TimerInit() While 1 $sRecv = _TCPRecv($iSocket, 2048) If $sRecv Then $sData &= $sRecv If @error Or @extended Then If @error Then _ReportError(@error, @extended, @ScriptLineNumber - 1) ExitLoop EndIf If $sRecv Then $hTimer = TimerInit() If TimerDiff($hTimer) > 3000 Then ExitLoop Sleep(10) WEnd ConsoleWrite("Response received: " & $sData & @CRLF) TCPCloseSocket($iSocket) TCPShutdown() Func _ReportError($iError, $iExtended, $iLine) ConsoleWrite("Error: " & $iError & @CRLF & _ "Extended: " & $iExtended & @CRLF & _ "Line: " & $iLine & @CRLF) TCPShutdown() Exit EndFunc Func _TCPRecv($iMainsocket, $iMaxLen, $iFlag = 0) If IsArray($iMainsocket) And (UBound($iMainsocket, 0) = 1) And (UBound($iMainsocket) > 0) Then $iMainsocket = $iMainsocket[0] If $iFlag = Default Then $iFlag = 0 $iMainsocket = Number($iMainsocket) $iMaxLen = Number($iMaxLen) $iFlag = Number($iFlag) If $iMainsocket < 0 Or _ $iMaxLen < 1 Or _ Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(-4, 0, -1) ; invalid parameter Local $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, 0, -1) ;missing DLL Local $bError = 0, $nCode = 0, $nExtended = 0 If Not $bError Then $aRet = DllCall($hWs2, "int", "ioctlsocket", "uint", $iMainsocket, "long", 0x8004667e, "ulong*", 1) ;FIONBIO If @error Then $bError = -1 ElseIf $aRet[0] <> 0 Then ;SOCKET_ERROR $bError = 1 EndIf EndIf Local $tBuf = DllStructCreate("char[" & $iMaxLen & "]") $aRet = DllCall($hWs2, "int", "recv", "uint", $iMainsocket, "ptr", DllStructGetPtr($tBuf), "int", $iMaxLen, "int", 0) If @error Then $bError = -1 ElseIf ($aRet[0] = -1) Or ($aRet[0] = 4294967295) Then ;SOCKET_ERROR $bError = 1 $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $bError = -1 ElseIf $aRet[0] = 0 Or $aRet[0] = 10035 Then ;WSAEWOULDBLOCK $nCode = -10 ;internal function value, it means no error EndIf ElseIf $aRet[0] = 0 Then $bError = 1 $nCode = -10 $nExtended = 1 ;connection closed Else Local $sResult = DllStructGetData($tBuf, 1) ;data If BitAND($iFlag, 2) = 2 Then ;EOT If StringRight($sResult, 1) = Chr(3) Then $sResult = StringTrimRight($sResult, 1) $nExtended = 2 ;End of Text reached EndIf EndIf If BitAND($iFlag, 1) = 1 Then $sResult = Binary($sResult) EndIf If $bError < 0 Then $nCode = -1 ;internal error $nReturn = "" ;failure ElseIf $bError > 0 Then If Not $nCode Then $aRet = DllCall($hWs2, "int", "WSAGetLastError") If @error Then $nCode = -1 Else $nCode = $aRet[0] EndIf If $nCode = 0 Then $nCode = -3 ;undefined error EndIf If $nCode = -10 Then $nCode = 0 $nReturn = "" Else $nReturn = $sResult EndIf DllClose($hWs2) Return SetError($nCode, $nExtended, $nReturn) EndFunc ;==>_TCPRecv You just need to edit $sLink variable on line 7... You should follow some recommendation before starting: - you are sending a GET request to the server, and it is composed by various headers, try to know at least the ones you are using - server answers to you with a response composed by a status code, some other headers and (maybe) the datas you are searching for - if you are trying to download source code from a private area of that site (which requires a login to be viewed), you must be able to play with Set-Cookie and Cookie headers Have fun with your project!1 point
-
Sure. Simply replace "|English Product 1|English Product 2" with "|Please select a product (English)|English Product 1|English Product 2". The only problem is that you somehow need to ignore the first selection because it is not a valid selection you want to process. So the code I suggest is a bit simpler.1 point
-
I suggest something like this: #include <Constants.au3> #include <GUIConstants.au3> #include <StringConstants.au3> Opt('MustDeclareVars', 1) Global $iGUI_Elements = 5, $iCurrentLanguage = 0, $iCurrentGUI = 1 Global $iLanguages = 3, $sLanguages = "English|Thailand|Indonesia", $sSelectedLanguage Global $aGUI1[$iGUI_Elements], $aGUILanguage1[$iGUI_Elements][$iLanguages] = [["English title 1", "Thai title 1", "Indonisian title 1"], ["English Combo 1", "Thai Combo 1", "Indonisian Combo 1"], ["Please select a product (English)", "Please select a product (Thai)", "Please select a product (Indonisian)"], ["|English Product 1|English Product 2", "|Thai Product 1|Thai Product 2", "|Indonisian Product 1|Indonisian Product 2"], ["English Button 1", "Thai Button 1", "Indonisian Button 1"]] Global $aGUI2[$iGUI_Elements], $aGUILanguage2[$iGUI_Elements][$iLanguages] = [["English title 2", "Thai title 2", "Indonisian title 2"], ["English Combo 2", "Thai Combo 2", "Indonisian Combo 2"], ["English label 2", "Thai Label 2", "Indonisian Label 2"], ["English Button 2", "Thai Button 2", "Indonisian Button 2"]] Global $idCombo, $aLanguages = StringSplit($sLanguages, "|", $STR_NOCOUNT) $aGUI1[0] = GUICreate($aGUILanguage1[0][$iCurrentLanguage], 315, 170, -1, -1) ; GUI title $aGUI1[1] = GUICtrlCreateLabel($aGUILanguage1[1][$iCurrentLanguage], 10, 10, 93, -1) ; Label $idCombo = GUICtrlCreateCombo("", 105, 10, 195, -1, 0x0003) ; Combo GUICtrlSetData(-1, $sLanguages, $aLanguages[0]) $aGUI1[2] = GUICtrlCreateLabel($aGUILanguage1[2][$iCurrentLanguage], 105, 40, 195, -1) ; Label $aGUI1[3] = GUICtrlCreateCombo("", 105, 57, 195, -1, 0x0003) ; Combo2 GUICtrlSetData(-1, $aGUILanguage1[3][$iCurrentLanguage]) $aGUI1[4] = GUICtrlCreateButton($aGUILanguage1[4][$iCurrentLanguage], 10, 130, 290, -1) ; Button GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCombo $sSelectedLanguage = GUICtrlRead($idCombo) For $i = 0 To UBound($aLanguages) - 1 If $sSelectedLanguage = $aLanguages[$i] Then If $i <> $iCurrentLanguage Then $iCurrentLanguage = $i _SwitchLanguage($aGUI1, $aGUILanguage1) ExitLoop EndIf EndIf Next EndSwitch WEnd Func _SwitchLanguage(ByRef $aGUI, ByRef $aGUILanguage) Local $iRC = WinSetTitle($aGUI[0], "", $aGUILanguage[0][$iCurrentLanguage]) For $i = 1 To UBound($aGUI) - 1 GUICtrlSetData($aGUI[$i], $aGUILanguage[$i][$iCurrentLanguage]) Next EndFunc ;==>_SwitchLanguage1 point
-
Certutil is a command line tool which will help you to get the informations you want from a certificate file. _Stringbetween is an AutoIt function which can extract some text from a string. The automation you did by accessing the file properties is the last way you should use because the automation of a Window can conflict with the user actions (mouse, keyboard of other windows) and the window you want to automate can differ between several computers (tabs are not the same, not the same options, or else...). The best way is to avoid the use of this kind of automation when possible. Sure, it's more complicated and often requires to have sufficient knowledges in scripting but if your code is good enough, you won't have any surprise. To help you, it's also possible to use some external command line tools to simplify the job. For this reasons, danyfirex gave you an idea with certutil.exe (run it from your AutoIt script to get the certificate informations) and _Stringbetween to parse the result. What I'm telling you is my own advice, but sure it can all be discussed. If your method suits you and it covers your needs, so much the better.1 point
-
... and you're left with an invalid value: 9.921.111 point
-
For this blasphem, your punishment will be to write an AutoIt program to compute(*) the value of r (expressed in yards, feet, inches and rational fraction down to 1/128") in the case where the radius R of the field is 405.3 m in the following problem: https://en.wikipedia.org/wiki/Goat_problem Estimate yourself lucky that the solution is shown in full! As a side bonus it should also make you feel how practical are imperial units. (*) without just mutiplicating the numeric value for r=1 by R, please!1 point
-
As far as I know $strJson.openTextFile("json.txt").readall ReadAll is parameter not method . Check this on MSDN.1 point
-
(+n) + (-n) + (-n) = baloney ???? [SOLVED]
argumentum reacted to Melba23 for a topic
argumentum, Nothing - search the forum for floating point arithmetic and all will become clear. If faced with the same problem I would do something like this: Local $a[] = [1600, -1384.92, -215.08] $nTotal = _Total($a) ConsoleWrite($nTotal &@CRLF) Func _Total($aElements) $nTotal = 0 For $i = 0 To UBound($aElements) - 1 $nTotal += (100 * $aElements[$i]) Next Return $nTotal / 100 EndFunc Which is basically what you were doing. M23 Edit: Guten abend, UEZ.1 point -
@Mbee, you should have no problem listing or viewing files managed by this UDF in Windows Explorer. but if you try to operate on them - e.g. move them, delete them etc. - you may encounter the same issue this UDF came to resolve in the first place.1 point
-
This script is pretty nice! However, in my case I find that using AutoIt's _FileReadToArray() is a bit faster for me. I was inspired by your script so I wrote my own function that converts 1D arrays to 2D arrays. '?do=embed' frameborder='0' data-embedContent>> My script combined with your _FileFromArray2D() works wonders on large data (and obviously small data too). I was able to cut down the time from 18 minutes or more (using AutoIt's built-in UDFs) down to mere seconds or less (using the above combo). Kudos!1 point
-
Description <grin> After diving into S.M.A.R.T from a previous thread... hmm, might as well take a stab at it. One thing I did find after testing - The Drive Temperature is fairly accurate! Then all I had to find out was how to calculate POH. And, it dawned on me that it turns over every 1000... or is it 200, hmm. (It's 256) Anyway it starts back at 1 and adds the total to another column. So, I figured out (if my math was correct) that my hard drive's life is about half over. (sob) There are about 20 known programs out there in cyberspace. I tested about half of them. Almost none of those would show what I really wanted to know. 1. How many hours was on the HD. 2. What is the HD life expectancy. Well, I found out both those answers after I made this script. Let me know if any problems. I'll see what I can do about it. Download Version 1.01 _WMI_GetATAPISmartData_v1.01.au3 Updated: November 26, 2012 1) changed some logic. 2) added more error handling. 3) added two additional ways to detect SSD's.1 point
-
Contextmenu on a Edit Control
argumentum reacted to Zedna for a topic
Solution from MsCreator is interesting but it will not catch Shift+F10. More elegant is to use GUIRegisterMsg() & WM_CONTEXTMENU but here is problem that this evemt is sent only from parent window. In edit with it's default popupmenu it's handled in WndProc so there should be used Subclassing (with callback) and WM_CONTEXTMENU handled there. Here is link with explanation from MSDN: link Here is concept of catching WM_CONTEXTMENU by GUIRegisterMsg() - it's working only on main window #include <GuiConstants.au3> Global Const $WM_CONTEXTMENU = 0x007B $Gui = GUICreate("test") $Edit = GUICtrlCreateEdit("", 20, 20) $hEdit = GUICtrlGetHandle($Edit) $DummyMenu = GUICtrlCreateDummy() $ContextMenu = GUICtrlCreateContextMenu($DummyMenu) $CommonMenuItem = GUICtrlCreateMenuItem("Common", $ContextMenu) $FileMenuItem = GUICtrlCreateMenuItem("File", $ContextMenu) GUICtrlCreateMenuItem("", $ContextMenu) $ExitMenuItem = GUICtrlCreateMenuItem("Exit", $ContextMenu) GUISetState() GUIRegisterMsg($WM_CONTEXTMENU, "MY_WM_CONTEXTMENU") ConsoleWrite("gui " & $Gui & @LF) ConsoleWrite("edit " & $hEdit & @LF) While 1 ;~ $CurInfo = GUIGetCursorInfo($Gui) $Msg = GUIGetMsg() Select Case $Msg = -3 Exit ;~ Case $CurInfo[3] = 1 And $CurInfo[4] = $Edit ;~ ShowMenu($Gui, $ContextMenu) EndSelect WEnd Func MY_WM_CONTEXTMENU($hWnd, $Msg, $wParam, $lParam) ;~ ConsoleWrite("hwnd " & $hWnd & @LF) ;~ ConsoleWrite("wparam " & $wParam & @LF) If $hWnd = $Gui Then ShowMenu($Gui, $ContextMenu) Return EndIf Return $GUI_RUNDEFMSG EndFunc ; Show a menu in a given GUI window which belongs to a given GUI ctrl Func ShowMenu($hWnd, $nContextID) Local $hMenu = GUICtrlGetHandle($nContextID) $arPos = MouseGetPos() Local $x = $arPos[0] Local $y = $arPos[1] DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc1 point