Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/18/2023 in all areas

  1. argumentum

    Opt(SetExitCode,0/1)

    We get new features but the awareness does not propagate and become common knowledge fast enough so, here is an example of use: Opt("SetExitCode", 1) OnAutoItExitRegister("__OnAutoItExit") Example() Func Example() Local $n, $a[6] = [5, 5, 4, 3, 2, 1] For $n = 1 To 100 ToolTip('..crashing in ' & $a[$n], 50, 50, "CrashTest") ConsoleWrite('..crashing in ' & $a[$n] & @CRLF) Sleep(500) Next EndFunc ;==>Example Func __OnAutoItExit() Local $sExitMethod Switch @exitMethod Case 0 $sExitMethod = "closed by natural closing." Case 1 $sExitMethod = "closed by Exit function." Case 2 $sExitMethod = "closed by clicking on exit of the systray." Case 3 $sExitMethod = "closed by user logoff." Case 4 $sExitMethod = "closed by Windows shutdown." Case Else $sExitMethod = "closed by no clue." EndSwitch ;~ If @exitCode Then MsgBox(262144, @ScriptName, "I could do something with the error from here", 2) MsgBox(262144, @ScriptName, "Oh !, wait, we now can =)" & @CR & _ @CR & "The error was: " & Hex(@exitCode) & _ @CR & "Meaning: """ & FatalErrormessageFromExitCode(@exitCode) & """" & _ @CR & "and the ExitMethod was """ & $sExitMethod & """" & _ @CR & @CR & " =)", 60) EndFunc ;==>__OnAutoItExit Func FatalErrormessageFromExitCode($iExitCode) ; from the help file Local $sExitCode = 'uncatalogued event' Switch $iExitCode Case 0x7FFFF068 $sExitCode = '"EndWith" missing "With". ' Case 0x7FFFF069 $sExitCode = 'Badly formatted "Func" statement. ' Case 0x7FFFF06A $sExitCode = '"With" missing "EndWith". ' Case 0x7FFFF06B $sExitCode = 'Missing right bracket '') '' in expression. ' Case 0x7FFFF06C $sExitCode = 'Missing operator in expression. ' Case 0x7FFFF06D $sExitCode = 'Unbalanced brackets in expression. ' Case 0x7FFFF06E $sExitCode = 'Error in expression. ' Case 0x7FFFF06F $sExitCode = 'Error parsing function call. ' Case 0x7FFFF070 $sExitCode = 'Incorrect number of parameters in function call. ' Case 0x7FFFF071 $sExitCode = '"ReDim" used without an array variable. ' Case 0x7FFFF072 $sExitCode = 'Illegal text at the end of statement (one statement per line). ' Case 0x7FFFF073 $sExitCode = '"If" statement has no matching "EndIf" statement. ' Case 0x7FFFF074 $sExitCode = '"Else" statement with no matching "If" statement. ' Case 0x7FFFF075 $sExitCode = '"EndIf" statement with no matching "If" statement. ' Case 0x7FFFF076 $sExitCode = 'Too many "Else" statements for matching "If" statement. ' Case 0x7FFFF077 $sExitCode = '"While" statement has no matching "WEnd" statement. ' Case 0x7FFFF078 $sExitCode = '"WEnd" statement with no matching "While" statement. ' Case 0x7FFFF079 $sExitCode = 'Variable used without being declared. ' Case 0x7FFFF07A $sExitCode = 'Array variable has incorrect number of subscripts or subscript dimension range exceeded. ' Case 0x7FFFF07B $sExitCode = 'Variable subscript badly formatted. ' Case 0x7FFFF07C $sExitCode = 'Subscript used on non-accessible variable. ' Case 0x7FFFF07D $sExitCode = 'Too many subscripts used for an array. ' Case 0x7FFFF07E $sExitCode = 'Missing subscript dimensions in "Dim" statement. ' Case 0x7FFFF07F $sExitCode = 'No variable given for "Dim", "Local", "Global", "Static" or "Const" statement. ' Case 0x7FFFF080 $sExitCode = 'Expected a "=" operator in assignment statement. ' Case 0x7FFFF081 $sExitCode = 'Invalid keyword at the start of this line. ' Case 0x7FFFF082 $sExitCode = 'Array maximum size exceeded. ' Case 0x7FFFF083 $sExitCode = '"Func" statement has no matching "EndFunc". ' Case 0x7FFFF084 $sExitCode = 'Duplicate function name. ' Case 0x7FFFF085 $sExitCode = 'Unknown function name. ' Case 0x7FFFF086 $sExitCode = 'Unknown macro. ' Case 0x7FFFF088 $sExitCode = 'Unable to get a list of running processes. ' Case 0x7FFFF08A $sExitCode = 'Invalid element in a DllStruct. ' Case 0x7FFFF08B $sExitCode = 'Unknown option or bad parameter specified. ' Case 0x7FFFF08C $sExitCode = 'Unable to load the internet libraries. ' Case 0x7FFFF08D $sExitCode = '"Struct" statement has no matching "EndStruct". ' Case 0x7FFFF08E $sExitCode = 'Unable to open file, the maximum number of open files has been exceeded. ' Case 0x7FFFF08F $sExitCode = '"ContinueLoop" statement with no matching "While", "Do" or "For" statement. ' Case 0x7FFFF090 $sExitCode = 'Invalid file filter given. ' Case 0x7FFFF091 $sExitCode = 'Expected a variable in user function call. ' Case 0x7FFFF092 $sExitCode = '"Do" statement has no matching "Until" statement. ' Case 0x7FFFF093 $sExitCode = '"Until" statement with no matching "Do" statement. ' Case 0x7FFFF094 $sExitCode = '"For" statement is badly formatted. ' Case 0x7FFFF095 $sExitCode = '"Next" statement with no matching "For" statement. ' Case 0x7FFFF096 $sExitCode = '"ExitLoop/ContinueLoop" statements only valid from inside a For/Do/While loop. ' Case 0x7FFFF097 $sExitCode = '"For" statement has no matching "Next" statement. ' Case 0x7FFFF098 $sExitCode = '"Case" statement with no matching "Select" Or "Switch" statement. ' Case 0x7FFFF099 $sExitCode = '"EndSelect" statement with no matching "Select" statement. ' Case 0x7FFFF09A $sExitCode = 'Recursion level has been exceeded - AutoIt will quit to prevent stack overflow. ' Case 0x7FFFF09B $sExitCode = 'Cannot make existing variables static. ' Case 0x7FFFF09C $sExitCode = 'Cannot make static variables into regular variables. ' Case 0x7FFFF09D $sExitCode = 'Badly formated Enum statement ' Case 0x7FFFF09F $sExitCode = 'This keyword cannot be used after a "Then" keyword. ' Case 0x7FFFF0A0 $sExitCode = '"Select" statement is missing "EndSelect" or "Case" statement. ' Case 0x7FFFF0A1 $sExitCode = '"If" statements must have a "Then" keyword. ' Case 0x7FFFF0A2 $sExitCode = 'Badly formated Struct statement. ' Case 0x7FFFF0A3 $sExitCode = 'Cannot assign values to constants. ' Case 0x7FFFF0A4 $sExitCode = 'Cannot make existing variables into constants. ' Case 0x7FFFF0A5 $sExitCode = 'Only Object-type variables allowed in a "With" statement. ' Case 0x7FFFF0A6 $sExitCode = '"long_ptr", "int_ptr" and "short_ptr" DllCall() types have been deprecated. Use "long*", "int*" and "short*" instead. ' Case 0x7FFFF0A7 $sExitCode = 'Object referenced outside a "With" statement. ' Case 0x7FFFF0A8 $sExitCode = 'Nested "With" statements are not allowed. ' Case 0x7FFFF0A9 $sExitCode = 'Variable must be of type "Object". ' Case 0x7FFFF0AA $sExitCode = 'The requested action with this object has failed. ' Case 0x7FFFF0AB $sExitCode = 'Variable appears more than once in function declaration. ' Case 0x7FFFF0AC $sExitCode = 'ReDim array can not be initialized in this manner. ' Case 0x7FFFF0AD $sExitCode = 'An array variable can not be used in this manner. ' Case 0x7FFFF0AE $sExitCode = 'Can not redeclare a constant. ' Case 0x7FFFF0AF $sExitCode = 'Can not redeclare a parameter inside a user function. ' Case 0x7FFFF0B0 $sExitCode = 'Can pass constants by reference only to parameters with "Const" keyword. ' Case 0x7FFFF0B1 $sExitCode = 'Can not initialize a variable with itself. ' Case 0x7FFFF0B2 $sExitCode = 'Incorrect way to use this parameter. ' Case 0x7FFFF0B3 $sExitCode = '"EndSwitch" statement with no matching "Switch" statement. ' Case 0x7FFFF0B4 $sExitCode = '"Switch" statement is missing "EndSwitch" or "Case" statement. ' Case 0x7FFFF0B5 $sExitCode = '"ContinueCase" statement with no matching "Select" Or "Switch" statement. ' Case 0x7FFFF0B6 $sExitCode = 'Assert Failed! ' Case 0x7FFFF0B8 $sExitCode = 'Obsolete function/parameter. ' Case 0x7FFFF0B9 $sExitCode = 'Invalid Exitcode (reserved for AutoIt internal use). ' Case 0x7FFFF0BA $sExitCode = 'Variable cannot be accessed in this manner. ' Case 0x7FFFF0BB $sExitCode = 'Func reassign not allowed. ' Case 0x7FFFF0BC $sExitCode = 'Func reassign on global level not allowed. ' EndSwitch Return SetError(0, $iExitCode, $sExitCode) EndFunc ;==>FatalErrormessageFromExitCode #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/mo #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Opt("SetExitCode", 1) If $CmdLine[0] = 0 Then ; https://www.autoitscript.com/autoit3/docs/appendix/Exitcodes.htm ; for CUI compile, adding "/ErrorStdOut" will write out the line number and error description" ; "(8) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:" MsgBox(262144, "ExitCode:", "0x" & Hex(RunWait('"' & @AutoItExe & '" /ErrorStdOut ' & (@Compiled ? '' : '"' & @ScriptFullPath & '" ') & '/crash')), 8) ElseIf $CmdLine[1] = "/crash" Then $CmdLine[100] = "hmmm" EndIf Edit: There are wrapper functions in v3.3.16.1 but did not know, otherwise I'd have saved me the coding. These func. are _FormatAutoItExitCode() and _FormatAutoItExitMethod() . I created the post after reviewing my tracs and decided to bla, bla, bla ... , and posted
    3 points
  2. I learned a lot from my earlier post in General Help and Support section. I especially thank @TheXman for his kind help and guidance. The time-of-day clock in any desktop or a laptop computer does not keep the time very well. Usualy it gains or loses several seconds a day. I wanted my desktop's system time to be as accurate as possible without consuming too much of resources. I came up with this program and I am satisfied with it. I am pretty sure that my desktop's system time is always within 20 milliseconds of NTP server time. The following is time sync log of my desktop for a typical day. Created by my NTP_TimeSync.au3, this log shows what the program does. 2021/12/19 06:16:53.887 Offset: -0.360 second(s), GGL Latency: 59.505 milliseconds*4 This is the first line which shows that my desktop was turned on at 6:16 in the morning and it's system time was sync'ed to NTP time. The desktop must have picked up the initial system time from its CMOS clock and it was 360 milliseconds ahead of the NTP server time. It took 59.505 milliseconds to fetch NTP time from Google time server. *4 at the end of the line indicates that periodic time adjustment was enabled and my desktop's clock was set to run at the rate of 4/156250 faster than the default time keeper, by using _Date_Time_SetSystemTimeAdjustment() function. This means the system time will gain 23.04*4=92.16 milliseconds every hour. This number(4) was picked up from an ini file, which is created when this program is run for the first time. 2021/12/19 11:55:02.322 Offset: -0.017 second(s), GGL Latency: 55.908 milliseconds*3 This is the seventh line which shows that my desktop's clock was running too fast now and the SystemTimeAdjustment value was reduced by 1 unit. The program must have updated the ini file as well. I found that my desktop needs 3 or 4 units of spike in SystemTimeAdjustment value for a typical day. With 4, the clock runs a little too fast; with 3, it runs a little too slow. If my program is run in 1-hour intervals, it will usually find an optimum SystemTimeAdjustment value in several hours and record it in NTP_TimeSync.ini file. This value is applied at the time of logon and the system time offset will be continuously monitored to see if an adjustment is required of this value. As can be seen in the log, the program is run every hour. I have a Windows Task where two triggers are defined: one to run upon logon and another to run every hour thereafter at 55 minutes of each hour. The Task was set up to run with highest privileges to allow time reset without security alert. The periodic time adjustment function is disabled when the time-of-day is reset by the Windows default time sync mechanism. So I turned it off in "Time and language - Date and time - Set time automatically" of Windows 10 Settings menu. This function reverts to disabled status when the device is turned off. I chose Google as my primary time server after comparing several alternatives. Though pool.ntp.org has usually far shorter response times, Google was most consistent in terms of standard deviation of response times. 2021/12/18 22:57:24 Shutdown 2021/12/19 06:16:53.887 Offset: -0.360 second(s), GGL Latency: 59.505 milliseconds*4 2021/12/19 06:55:01.794 Offset: -0.010 second(s), GGL Latency: 56.038 milliseconds 2021/12/19 07:55:01.829 Offset: -0.012 second(s), GGL Latency: 58.372 milliseconds 2021/12/19 08:55:01.783 Offset: -0.014 second(s), GGL Latency: 57.055 milliseconds 2021/12/19 09:55:01.825 Offset: -0.011 second(s), GGL Latency: 62.304 milliseconds 2021/12/19 10:55:02.331 Offset: -0.014 second(s), GGL Latency: 60.053 milliseconds 2021/12/19 11:55:02.322 Offset: -0.017 second(s), GGL Latency: 55.908 milliseconds*3 2021/12/19 12:55:02.337 Offset: +0.010 second(s), GGL Latency: 57.104 milliseconds 2021/12/19 13:55:02.352 Offset: +0.008 second(s), GGL Latency: 55.385 milliseconds 2021/12/19 14:55:02.342 Offset: +0.011 second(s), GGL Latency: 58.324 milliseconds 2021/12/19 15:55:02.351 Offset: +0.010 second(s), GGL Latency: 59.801 milliseconds 2021/12/19 16:55:02.344 Offset: +0.009 second(s), GGL Latency: 57.410 milliseconds 2021/12/19 17:55:02.352 Offset: +0.009 second(s), GGL Latency: 57.528 milliseconds 2021/12/19 18:55:02.393 Offset: +0.011 second(s), GGL Latency: 58.598 milliseconds 2021/12/19 19:55:02.408 Offset: +0.010 second(s), GGL Latency: 58.423 milliseconds 2021/12/19 20:55:02.345 Offset: +0.010 second(s), GGL Latency: 57.704 milliseconds 2021/12/19 21:55:02.368 Offset: +0.009 second(s), GGL Latency: 55.841 milliseconds 2021/12/19 22:55:02.375 Offset: +0.009 second(s), GGL Latency: 57.590 milliseconds 2021/12/19 23:34:34 Shutdown Edited Jan 13, 2022: I found that the system time offsets vs server time, when calculated several times in short successions, can vary up to 5 msilliseconds depending on the internet latency. So i changed my code to calculate system time offsets 5 times in 200 ms intervals and take the median value as the true offset. I also took care of Daylight Saving Time issue in log file by logging current time instead of system time adjusted by time zone offset. The new source code is attached as NTP_TmeSync_2.au3. Edited Feb 7, 2022: A small error was found and corrected in NTP_TimeSync2.au3. The first line of WriteLog() function was changed: From: If $pTime = "" Then To: If $sMessage <> "" Then NTP_TimeSync.au3 NTP_TimeSync_2.au3
    1 point
  3. Unless there's a better way… checking that the third byte in @IPAddress1 changes from 0 to something else seems to work on my 'puter: #include <Constants.au3> #include <Date.au3> #include <MsgBoxConstants.au3> Opt('MustDeclareVars', 1) Func CurrTime()     Return _DateDiff('s', "1970/01/01 00:00:00", _NowCalc()) EndFunc Func Tethered()     Local $res = StringRegExp(@IPAddress1,"^192\.168\.(\d+)\.(\d+)$", 1)     If $res[0] = 0 Then ;Is third byte 0/something else?         Return False     Else         Return True     EndIf EndFunc Local $StartTime = CurrTime() ;Wait 180s/3mn While (CurrTime() < $StartTime + 180) And Not Tethered()     ConsoleWrite("@IPAddress1=" & @IPAddress1 & @CRLF)     Sleep(1000) WEnd Local $outcome = (Tethered()) ? "Tethered" : "Not Tethered" MsgBox($MB_ICONINFORMATION, "Out", $outcome)
    1 point
  4. You guys are absolutely amazing Thank you both for this solution, it works like a charm! Unfortunately I can only mark a single post as solution So I marked Melba's post as the solution and pixelsearch's post got a like
    1 point
  5. Never heard of all this until your post, thanks argumentum
    1 point
  6. If it can help, I use it in scripts as Melba23 just indicated, with this code : Case $idRadio_1 $iHow_Choose_img = 1 ; a whole folder (no recursion) using FileSelectFolder() Remove_Style($WS_TABSTOP, $idRadio_1) ; cf note dans F10() , pareil pour tous les autres boutons radios ci-dessous. Case $idRadio_2 $iHow_Choose_img = 2 ; a whole folder + subfolders, using FileSelectFolder() Remove_Style($WS_TABSTOP, $idRadio_2) Case $idRadio_3 $iHow_Choose_img = 3 ; pick files individually, using FileOpenDialog() Remove_Style($WS_TABSTOP, $idRadio_3) ;==================================================== Func Remove_Style($iStyleToRemove, $id1, $id2 = 0, $id3 = 0, $id4 = 0, $id5 = 0, _ $id6 = 0, $id7 = 0, $id8 = 0, $id9 = 0, $id10 = 0) Local $hControl, $iStyle For $i = 1 To @NumParams - 1 ; @NumParams doit être compris entre 2 et 11. Le 1er paramètre sera toujours le style à ôter. $hControl = GUICtrlGetHandle(Eval("id" & $i)) $iStyle = _WinAPI_GetWindowLong($hControl, $GWL_STYLE) If BitAND($iStyle, $iStyleToRemove) = $iStyleToRemove Then _WinAPI_SetWindowLong($hControl, $GWL_STYLE, BitXOR($iStyle, $iStyleToRemove)) Endif Next EndFunc ; Remove_Style() The function can also be called like this (real syntax found in the script) : Remove_Style($WS_TABSTOP, $idRadio_1, $idRadio_2, $idRadio_3, $idRadio_4, $idRadio_11, _ $idRadio_12, $idRadio_13, $idToolTip, $idButton_OK, $idButton_Cancel)
    1 point
  7. This one works perfect, thanks @Gianni and @argumentum for your help.
    1 point
  8. @argumentum's version works fine here. Aren't you using a different txt than the one you attached above? can you try this little variant that shows the calculated crc and the one included in the different files? $data = FileRead(@ScriptDir & "\Tel.txt") $iBangPos = StringInStr($data, "!") $crcOK = StringMid($data, $iBangPos + 1, 4) $data = StringLeft($data, $iBangPos) ConsoleWrite('>>>' & @TAB & _Crc16($data) & ' <-> ' & $crcOK & @CRLF) ; ======================================================= ; Function _Crc16 ; Purpose: Return the crc16 checksum of the input value ; Author: 'roby' at http://www.autoitscript.com/forum ; ======================================================= Func _Crc16($value) $value = Binary($value) Local $crc = 0xFFFF Local $table[256] = [ _ 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, _ 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, _ 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, _ 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, _ 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, _ 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, _ 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, _ 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, _ 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, _ 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, _ 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, _ 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, _ 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, _ 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, _ 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, _ 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, _ 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, _ 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, _ 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, _ 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, _ 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, _ 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, _ 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, _ 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, _ 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, _ 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, _ 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, _ 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, _ 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, _ 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, _ 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, _ 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040] $crc = 0 ; <<<< this changed For $i = 1 To BinaryLen($value) $crc = BitXOR(BitShift($crc, 8), $table[BitAND(BitXOR($crc, BinaryMid($value, $i, 1)), 0xFF)]) Next Return Hex($crc, 4) EndFunc ;==>_Crc16
    1 point
  9. Yep, this was a bug in the latest base SciTE code which was fixed after reporting it.
    1 point
  10. #include <String.au3> $data = FileRead(@ScriptDir & "\Tel (1).txt") $data = _StringBetween($data, "", "!") $data[0] &= "!" ; <<<< this changed ;~ ConsoleWrite('>' & $data[0] & '<' & @CRLF) ConsoleWrite('>>>' & _Crc16($data[0]) & ' = !F7F2' & @CRLF) ; ======================================================= ; Function _Crc16 ; Purpose: Return the crc16 checksum of the input value ; Author: 'roby' at http://www.autoitscript.com/forum ; ======================================================= Func _Crc16($value) $value = Binary($value) Local $crc = 0xFFFF Local $table[256] = [ _ 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, _ 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, _ 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, _ 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, _ 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, _ 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, _ 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, _ 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, _ 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, _ 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, _ 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, _ 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, _ 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, _ 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, _ 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, _ 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, _ 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, _ 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, _ 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, _ 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, _ 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, _ 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, _ 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, _ 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, _ 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, _ 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, _ 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, _ 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, _ 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, _ 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, _ 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, _ 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 ] $crc = 0 ; <<<< this changed For $i = 1 To BinaryLen($value) $crc = BitXOR(BitShift($crc, 8), $table[BitAND(BitXOR($crc, BinaryMid($value, $i, 1)), 0xFF)]) Next Return Hex($crc, 4) EndFunc ;==>_Crc16
    1 point
  11. kurtykurtyboy

    Writing hand

    I don't know either, but I think it's great!
    1 point
  12. ioa747

    SciTE PlusBar

    PutTxtVarFromClip.au3 Put the Clipboard text as $sTxt variable The idea came to me a few days ago from this post 209881-capturing-empty-data-and-adding-text because I needed to convert the text into a variable to post it (in the end I didn't do it, and replaced it with ClipGet() ) inspiration from @Gianni in the post - Thanks for that ; https://www.autoitscript.com/forum/topic/208404-scite-plusbar/page/2/?tab=comments#comment-1515128 ;------------------------------------------------------------------------------ ; Title...........: PutTxtVarFromClip.au3 ; Description.....: Put the Clipboard text as $sTxt variable ;------------------------------------------------------------------------------ #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\ICO\PutTxtVarFromClip.ico #AutoIt3Wrapper_Res_Description=Put the Clipboard text as $sTxt variable #AutoIt3Wrapper_Res_Fileversion=0.0.0.1 #AutoIt3Wrapper_Res_ProductName=PutTxtVarFromClip.au3 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WindowsConstants.au3> #include <SendMessage.au3> Global $ClipBack If Not WinExists("[CLASS:SciTEWindow]") Then Exit EndIf $ClipBack = ClipGet() ; backup clip data SciTE_PutTxtVarFromClip() ClipPut($ClipBack) ; Restore clip data ;---------------------------------------------------------------------------------------- Func SciTE_PutTxtVarFromClip() ; Put the Clipboard text as $sTxt variable Local $hSciTE = WinActivate("[CLASS:SciTEWindow]") Local $hCtrlHnd = ControlGetFocus($hSciTE) $hCtrlHnd = ControlGetHandle($hSciTE, '', $hCtrlHnd) Local $sVarName = "$sTxt" Local $sListing = 'Local ' & $sVarName & ' = ""' & @CRLF Local $aStr = StringSplit(ClipGet(), @CRLF, 1) ; get the clipboard content For $i = 1 To $aStr[0] $sListing &= $sVarName & ' &= "' & StringReplace($aStr[$i], '"', '""') & '" & @CRLF' & @CRLF Next ClipPut($sListing) _SendMessage($hCtrlHnd, $WM_PASTE) EndFunc ;==>SciTE_PutTxtVarFromClip ;-------------------------------------------------------------------------------------------- I am attaching the icon as well PutTxtVarFromClip.ico Back to first post
    1 point
  13. Welcome Albertxu, Add this before you send function Opt('SendKeyDelay', 250); default 5. higher number = slower
    1 point
×
×
  • Create New...