Leaderboard
Popular Content
Showing content with the highest reputation on 11/01/2021 in all areas
-
AutoIt Snippets
TheDcoder and one other reacted to JockoDundee for a topic
No worries, I just assumed that _ConsoleEraseLine() accidentally ate one of its own lines2 points -
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
-
EasyCodeIt A cross-platform implementation of AutoIt Introduction: EasyCodeIt is an attempt at implementing a programming language which is backward compatible with a sub-set of AutoIt which would work across multiple platforms with many aspects being agnostic to the platform-specific differences. Currently the primarily targeted platforms are Linux and Windows, more platforms may be supported in the future as per popular demand. For example it should be easy enough to port to Unix-like platforms such as BSD and Mac with the help of maintainers who are familiar with them. The main motivation behind the creation of this project is the lack of a proper easy-to-use scripting language in Linux, while there are numerous scripting languages which natively support it, none of them are as user-friendly and easy to use as AutoIt. (The "Easy" in "EasyCodeIt" reflects this) There was a previous thread in which the project was originally started, but it got too big and the discussion is too cluttered and hard to follow for any new readers, here is the thread for those who are interested in reading it: Progress: Frontend ā Tokenizer š§ Parser (work in progress) ā Expressions š·āāļø Statements (current priority) Backend ā° Interpreter (scheduled) I am currently working on expression parsing and syntax tree building. -- This section will be updated in the future with new progress. To stay notified š follow this thread to get update notifications (by using the "Follow" button on the top-right corner of this page) and šļø watch the GitHub repository to get any new activity on your feed. Code: The code is available on GitHub, please š star the project if you like it and would like to show your support, it motivates me a lot! (Also don't forget to š Like this post ) Chat: I created a room in Matrix (an open-source federated chat system) for EasyCodeIt, you can join it to chat with me and others who are in the room, it might be a good way to get the latest status updates from me You can preview the room without joining, and you don't need to be connected to it 24/7 like IRC. It works a bit like Slack for those who are familiar with it. Forum: I have created a dedicated forum to post more frequent updates, possibly in their own threads to better organize the discussion. Please sign-up and follow the blog section to get updates. By the way, you can also post pretty much anything there, both technical and non-technical stuff, it is intended to be a hangout for techies but not only for them. So casual discussions, funny cat videos etc. are allowed!1 point
-
EasyCodeIt - cross-platform AutoIt implementation
JockoDundee reacted to TheDcoder for a topic
@JockoDundee It's favoring the "more logical" approach of inversion before exponentiation > ./eci /tmp/controversy.txt { "op": "Raise", "args": [ { "op": "Invert", "args": [ 3.0 ] }, 2.0 ] } Here is the precedence used by the parser (starting from lowest to highest): /* Operators */ %precedence '?' %precedence ':' %left AND "And" OR "Or" %left LT '<' GT '>' LTE "<=" GTE ">=" EQU '=' NEQ "<>" SEQU "==" %left '&' %left '+' '-' %left '*' '/' %left '^' %left NOT "Not" %precedence INVERSION %precedence '.' /* WORKAROUND: Bison can't handle "sandwhich" operators which surround the 2nd part of a binary expression */ %precedence '[' %precedence '(' %precedence GROUPING1 point -
Hi, i just google for the values like this: '#define IPPROTO_TCP' Then the results show me header files defining the values.1 point
-
EasyCodeIt - cross-platform AutoIt implementation
TheDcoder reacted to JockoDundee for a topic
But what say your parser to the controversial, yet simple expression: -3^2 I would try it myself, but Iām driving1 point -
It was supposed to allow inputting either the string itself or an integer representing the length of the string to overwrite -- but as you pointed out, what if the "string" was itself an integer? So I was wrong to say in my last message that "it doesn't make a difference". I'd conveniently forgotten that I modified my code to respond to your comment, and then pretended that there was nothing to your comment in the first place. š Thank you for setting me straight. š1 point
-
Can I make a window interface with buttons using Autoit?
Leendert-Jan reacted to pseakins for a topic
In the Scite editor just press ALT-M to bring up the Coda form designer. It can be found on the menu under Tools.1 point -
try adding this lines at the beginning of your script: #include <WinAPIFiles.au3> ;Turn off redirection for a 32-bit script on 64-bit system. If @OSArch = "X64" And Not @AutoItX64 Then _WinAPI_Wow64EnableWow64FsRedirection(False)1 point
-
Do a mouse bounce like dvd bounce screen
Leendert-Jan reacted to Gianni for a topic
#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> ; #include <WinAPISysWin.au3> #include <WinAPI.au3> HotKeySet("{ESC}", "_Exit") Global $hGUI, $iWidth, $iHeight example() Func example() Local $sFileImage = @TempDir & "\logo.png" Local $sImageURL = "https://logodix.com/logo/1059815.png" Local $x = 10, $y = 10, $xDirection = 3, $yDirection = 3, $aPos If Not FileExists($sFileImage) Then InetGet($sImageURL, $sFileImage) _SetImage($x, $y, $sFileImage) ; FileDelete($sFileImage) While 1 $aPos = WinGetPos($hGUI) $x = $aPos[0] $y = $aPos[1] If $x + $iWidth > @DesktopWidth Then $x = @DesktopWidth - $iWidth $xDirection *= -1 EndIf If $x < 0 Then $x = 0 $xDirection *= -1 EndIf If $y + $iHeight > @DesktopHeight Then $y = @DesktopHeight - $iHeight $yDirection *= -1 EndIf If $y < 0 Then $y = 0 $yDirection *= -1 EndIf $x += $xDirection $y += $yDirection WinMove($hGUI, '', $x, $y) Sleep(10) WEnd FileDelete($sFileImage) EndFunc ;==>example Func _SetImage($Left, $Top, $Picture, $iOpacity = 255) _GDIPlus_Startup() Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend Local $hImage = _GDIPlus_ImageLoadFromFile($Picture) $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate('', $iWidth, $iHeight, $Left, $Top, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) Local $hLabel = GUICtrlCreateLabel('', 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $iWidth) DllStructSetData($tSize, "Y", $iHeight) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _GDIPlus_Shutdown() Return $hGUI EndFunc ;==>_SetImage Func _Exit() If WinActive("[ACTIVE]") = $hGUI Then Exit EndFunc ;==>_Exit1 point -
First we need answers to a few questions before we can decide how to use AutoIt and the OutlookEX UDF. Who is going to start the AutoIt script: The user? Windows autostarts the script when the user logs on? ... How often should the script be run? Just one time and then the user has to start start it again? In a loop until the user logs off? ... The files to attach are all defined in advance or should the user be able so select all or some additional attachments himself? The script creates a new mail item, attaches file(s) and displays the "mail composer". How do you determine that the user has finished the mail? By clicking the send button? When the status of the plugin icon changes? ...1 point
-
- _____ _____ _ _ - |_ _|___ ___ ___ _ _| __|___ ___|_|___| |_ - | | | -_| -_| | | |__ | _| _| | . | _| - |_| |___|___|_|_|_ |_____|___|_| |_| _|_| - By TarreTarreTarre|___|Build '1.0.0' |_| + F5 = Run script + F6 = Build 'AU3' + F7 = Build 'EXE' + F8 = Options GUI + F10 = Exit TeenyScript All example code and documentation moved to: http://teenyscript.tarre.nu/documentation Official Github repo: http://github.com/tarreislam/teenyscript F.A.Q Q: What is TeenyScript? A: TeenyScript is a Superset of AutoIt which makes it more advanced Q: How does it work? A: TeenyScript code are parsed into native AutoiT code Q: Does it depend on anything else than AutoIt? A: Just one dependency, that is AutoitObject, the best UDF ever created for AutoIt, besides that, only Native AutoIt is used Features "Anonymous" functions Endless scope nesting OOP (powered by AutoitObject) User-friendly integration Powerful macros Namespaces Lists Project support, for easy deployment Userfriendly GUI for userfriendly Tasks for the Userfriendly person And much more To come You decide, I am happy to do requests! Install and Update TeenyScript HOW TO GET STARTED Run TeenyScript.au3 Now this should see something like this in your console Code Press F8 and navigate to the misc tab to install SciTE calltips Run \ Build \ Compile How to run with Sublime Text Here is some examples of TeenyScript code ;Basic List usage $Example_A = Func() ; Create a list Local $myList = { 'Name': 'Tarre' } ; Add \ Change data on $MyList $myList{'Age'} = 25 ; Create MySecondList Local $MySecondList = { "Name" => "John", "Age" => "00" } ; Using variable instead of a string Local $KeyName = "Age" Local $KeyVal = 1337 $MySecondList{$KeyName} = $KeyVal ; You may also pass lists to lists. however this has to be done in this fashion. Local $oList = {'myList': $myList, 'mySecondList' => $MySecondList} ; Return the objects Return $oList EndFunc();call the function on the variable ; Loop through list and print their values $Example_B = Func() Local $MyList = {'A': 'Hello FROM A', 'B': 'Hello FROM B', 'C': 'Hello FROM C'} Local $aNames = ['A', 'B', 'C'] For $i = 0 To UBound($aNames) -1 MsgBox(0,0,$myList{$aNames[$i]}) Next EndFunc #MAIN MsgBox(0,"Example A 1", $Example_A.myList.Name) MsgBox(0,"Example A 2", $Example_A.myList.Age) MsgBox(0,"Example A 3", $Example_A.mySecondList.Name) MsgBox(0,"Example A 4", $Example_A.mySecondList.Age) $Example_B(); Execute examble B Here is a non class nested function calculator example (calculator.ts.au3) $calculator = Func($a, $and, $b) $division = Func($a, $b) if Not $a or Not $b Then Return "Error dividing 0" EndIf Return $a/$b EndFunc Switch $and Case '+' Return $a + $b Case '-' Return $a - $b Case '/' Return $division($a, $b) Case '*' Return $a * $b EndSwitch Return "Unkown attribute "&$and EndFunc #MAIN ConsoleWrite($calculator(25, '*', 25)&@CRLF) ConsoleWrite($calculator(25, '/', 0) & @CRLF) ConsoleWrite($calculator(1, '^', 2) & @CRLF) teeny-script.zip (OLD) TeenyScript beta2.zip (OLD) teeny-script Beta 4.zip (OLD) teeny-script Beta 5.zip (OLD) teeny-script BETA 6.zip (OLD) TeenyScript Beta 7.zip (OLD) teeny-script Beta 8.zip (OLD) TeenyScript-master 1.0.0.zip (OLD) TeenyScript-1.1.0.zip (OLD) TeenyScript-1.2.0.zip (OLD) TeenyScript-2.0.0.zip (OLRD, Release notes) TeenyScript-2.1.3.zip (Newest 2016-09-16, Release notes)1 point
-
Those who post vague questions are not only wasting their own time but also the time of those replying. So please provide the following to help those who help you. #include <Misc.au3> ; Version: 1.00. AutoIt: V3.3.8.1 ; Retrieve the recommended information of the current system when posting a support question. Local $sSystemInfo = 'I have a valid AutoIt support question and kindly provide the details of my system:' & @CRLF & @CRLF & _ 'AutoIt Version: V' & @AutoItVersion & ' [' & _Iif(@AutoItX64, 'X64', 'X32') & ']' & @CRLF & _ 'Windows Version: ' & @OSVersion & ' [' & @OSArch & ']' & @CRLF & _ 'Language: ' & @OSLang & @CRLF & @CRLF & _ 'The following information has been copied to the clipboard. Use Ctrl + V to retrieve the following information.' MsgBox(4096, 'System Info', $sSystemInfo) ClipPut($sSystemInfo)1 point
-
AutoIt Snippets
CarlD reacted to JockoDundee for a topic
0 points