Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/24/2020 in all areas

  1. jos, Thank you for all your hard work on SciTE4AutoIt3. I strongly agree that there is no need to update the SciTE4AutoIt3 every time there is an incremental change in scintilla. Many of the incremental changes in scintilla have to do with other programming languages or with features that are not used by SciTE4AutoIt3. If users are having an issue with SciTE4AutoIt3, if the issue is due to scintilla, and if a scintilla update will fix the issue, then the update would be worth considering. Otherwise updates should add important functionality. Scintilla supports multiple operating systems, has many developers, has almost as many editors based up SciTE, and has a massive number of users. Most of the scintilla version changes have added major features, improved performance, and/or have made interacting with multiple programming languages more efficient. The jump between scintilla version 3 and version 4 was significant. I again thank you for the extensive work it took to upgrade SciTE4AutoIt3 from version 3 to version 4. I am glad you waited until the more stable version 4.1 was released. Hopefully the jump from version 4 to version 5 will be less work. Reportedly the main new feature of version 5 will be (as you noted) to move the language lexers into a separate (Lexilla) library. Although this is not strictly necessary for SciTE4AutoIt3, I would like to support making the change once a stable version 5 is available. I occasionally use SciTE4AutoIt3 for other programming languages. Moving the lexers out of SciTE4AutoIt3.exe would make it easier for me to add modified lexers for other languages. drposts
    3 points
  2. This is a UDF to handle the AutoIt Error msgbox when our awesome code goes I've been using trancexx's code for the longest time and since I iron some wrinkles in my ( personal use ) UDF, decided to organize it in a dignifying way and post it. The ZIP with the code is in the downloads area. I'm posting this because most other handlers use /ErrorStdOut to catch errors and they are not that common, for us great coders So makes little sense to me to run 2 EXEs for something unlikely to happen. No one made a UDF of this, so, I did. oh, ..there are things where this will be of no use, say, infinite recursion or what not, so, if the the AutoIt Error msgbox was to popup then this UDF should do it. ...let me know if you liked it, or post your views to better it. Cheers There is also an EventViewer_GetMyEntries() down this post that may come in handy.
    1 point
  3. martin

    Serial Port /COM Port UDF

    Although serial ports are disappearing, they can still be useful. Here is a COMMs UDF. It provides an easy way to use serial ports without the restrictions and problems some methods have. USB to serial is ok, binary data is ok. This UDF requires my comMG.dll which can be in either the script folder or the Windows folder by default, or in the path specified using the function _CommSetDllPath. Note the following shortcomings: the dll link below is 32 bit so it will not work with a 64 bit apps, but there is a 64 bit version in my post around 25th March 2018 for people to try. The strings and character functions are all AnsiChar. Functions in the UDF are _CommVersion _CommListPorts _CommSetPort _CommPortConnection _CommClearOutputBuffer _CommClearInputBuffer _CommGetInputcount _CommGetOutputcount _CommSendString _CommGetString _CommGetLine _CommReadByte _CommReadChar _CommSendByte _CommSendBreak; not tested!!!!!!!!!! _CommCloseport _CommSwitch _CommReadByteArray _CommSendByteArray _CommsetTimeouts _CommSetXonXoffProperties _CommSetRTS (NB these will not work if Hardware handshaking is selected because _CommSetDTR then these lines are controlled by the data being sent.) _CommSetDllPath _CommGetLineStates -------------------------------------------------------------------------------------------------------------------------------- Go to Download Page For Commgv2 Download includes the dll and udf. Most recent changes 28th March 2014 - dll V2.83 Correct error setting 6 data bits as 7. 11th March 2014 dll V2.82 Allow data bits of 4 to 8 instead of only 7 and 8. 19th August 2013 dll v2.81 removes some unwanted eroor message popups. Might not remove popups for some Windows versions. 27th September 2012 Correct error closing port. New version of UDF if V2.90, new dll is commg.dll V2.79. Thanks to tfabris. 18th January 2012 Corrected typo in UDF V 2.87, and uploaded as V2.88 Increased max baud allowed by the dll from 200000 to 256000. New version now V2.78 17th January 2012 Modified thesleep addition to _CommGetLine so that reading data is not slowed down. 14th January 2012 Corrected _CommReadByte in UDF. Added sleep(20) to while loop in _CommGetLine to reduce CPU usage 20th December 2011 UDF version 2.86. - Changed function GetByte so it returned the error string given by the dll. Dll version 2.77 - removed an unwanted erro message dialogue from GetByte function. (Thanks funkey) 4th December 2011 New dll and example versions. Dll function SetPort corrected because it was not using the parameters passed for DTR and RTS. The example was setting flow control incorrectly: the settings for hardware handshaking and XON./XOFF were reversed. 25th August 2011 corrected function _CommClosePort. Example corrected for setting parity and flow 22nd December 2013 (thanks to MichaelXMike) mgrefcommg CommgExample.au3
    1 point
  4. Hey guys, the code that I've written/borrowed below is mostly an example of using the commUDF listed at the bottom, just applied to an Arduino with accompanying Arduino code. Uses Serial communication to turn on a LED, then reads a response from the arduino and prints it in the console. I hope it helps Autoit Code: #include <CommMG.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $CMPort = 3 Global $CmBoBaud = 9600 Global $sportSetError = '' Global $CmboDataBits = 8 Global $CmBoParity = "none" Global $CmBoStop = 1 Global $setflow = 2 _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow) If @error Then MsgBox(16, "Error!", "Can't connect to Arduino on port - " & $CMPort) Exit EndIf _CommSetRTS(0) _CommSetDTR(0) While 1 ; Just use to call function, doesn't need to be a loop. LED_ON() Sleep(100) LED_OFF() Sleep(100) WEnd Func LED_ON() _CommSendString("1") ;Sends the Arduino a string of "1" to turn on LED Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino. ConsoleWrite($ret & @CRLF) ;Print to Console. EndFunc ;==>LED_ON_OFF Func LED_OFF() _CommSendString("0") ;Sends Arduino string of "0" to turn off the LED Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino. ConsoleWrite($ret & @CRLF) ;Print to Console. EndFunc ;==>LED_BLINK_10 Arduino Code: int led = 12; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(led, OUTPUT); } void loop() { // put your main code here, to run repeatedly: if (Serial.available()) { int data = Serial.read(); if (data == '1') //On { digitalWrite(led, HIGH); //writeslow(); Serial.print("The LED is on!"); } if (data == '0') //Off { digitalWrite(led, LOW); Serial.print("The LED is OFF!"); } } } Serial/Com port UDF this is all based on
    1 point
  5. Hi everyone, Here is how to control a 180 degree Pulse Width Modulated (PWM) Servo in Arduino with AutoIT. Firstly, I'm re-posting this from a comment I made as I think it is valuable by it's self: Original Thread: I've adapted codes by reaper7 (see above link) to include a GUI to move 1 servo between 0-180 degrees. This GUI is simple, type a number between 0 and 180, then press 'Move Servo'. The servo will then move to the desired location. IMPORTANT: I'm assuming you are using a 180 degree servo here. If you are using a 90 degree servo, this may overextended your servo and damage it. Adjust to code in the Arduino code to suit your servo's rotational limits (3rd last line of Arduino code). For a 180 degree servo: val = map(data, 0,180, 0, 170) For a 90 degree servo: val = map(data, 0,180, 0, 90) On a trouble shooting note: At first I was having trouble getting AutoIT to even recognise the Arduino port. To fix this you have to put your script in the same folder as the commMG.au3 and commdll files. What worked for me was putting it all in the 'include' folder on the AutoIT install location. Put all 3 files in there. Also, make sure your commMG file is the same one we are all talking about here, if these codes don't match, no dice! Here is the link for the commMG.au3 and commdll files (just to make sure) https://www.mosaiccgl.co.uk/AutoItDownloads/confirm.php?get=COMMGvv2.zip eg: C:\Program Files (x86)\AutoIt3\Include AutoIT Code: expand popup #include <CommMG.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Global $CMPort = 7 Global $CmBoBaud = 9600 Global $sportSetError = '' Global $CmboDataBits = 8 Global $CmBoParity = "none" Global $CmBoStop = 1 Global $setflow = 2 _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow) If @error Then MsgBox(16,"Error!","Can't connect to Arduino on port - "&$CMPort) Exit EndIf _CommSetRTS(0) _CommSetDTR(0) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("AutoIT -->Arduino Servo Mover", 407, 115, 358, 304) Global $ServoValueInputBox = GUICtrlCreateInput("90", 232, 16, 137, 32);Defualt value is 90 (ie: 90- degrees) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") Global $ServoLabel = GUICtrlCreateLabel("Servo Value (0-180)",40, 16, 170, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") Global $MoveServoButton = GUICtrlCreateButton("Move Servo", 40, 56, 331, 49) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1     $nMsg = GUIGetMsg()     $Servo1 = GUICtrlRead($ServoValueInputBox)     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $MoveServoButton             GUICtrlRead($ServoValueInputBox)             _CommSendString(stringformat("A%03d",int($Servo1)))     EndSwitch WEnd Arduino Code: #include <Servo.h> Servo Servo1;  // create servo called Servo1 Servo Servo2;  // create servo called Servo2 char Address;  //Variable to store Incoming Packets ID int val = 0; int data = 0; void setup() {   Serial.begin(9600);   Servo1.attach(8);  // attaches the servo1 on pin 8 to the servo object } void loop() {   while (Serial.available() > 0)   {     Address = Serial.read();     if (Address == 'A') Read_Servo1();  // If ID = A goto Servo1   } }   void Read_Servo1() {   delay(2); int data100 = Serial.read()- '0';  // Read in first bit od data   delay(2); int data10 = Serial.read()- '0';  // Read in second bit od data   delay(2); int data1 = Serial.read()- '0';  // Read in third bit od data   data = 100*data100 + 10*data10 + data1; // Left shift each byte, add add together to get our value 000   val = map(data, 0,180, 0, 170);  // Asign our range of 0 - 180 to the servos range of  0 - 170   Servo1.write(val);  //Write the value to Serial   delay(10);      // waits 10ms for the servo to reach the position } Enjoy, Soil_Person
    1 point
  6. It has been solved long time ago, now working with or without...
    1 point
  7. mình đã tìm được rồi nên share cho những bạn thắc mắc giống mình. #include <ie.au3> $oIE = _IECreate("about:InPrivate") trans: I have found it, so share it for those who ask me the same question.
    1 point
  8. kenplaygirl, Welcome to the AutoIt forums. We are an English-speaking forum, so please use a translation service when posting again. Thanks in advance for your cooperation. M23
    1 point
  9. Here's some code I've ripped from my SMF program. Image_Get_Orientation.zip
    1 point
  10. Apparently Windows 8/10 handles image rotation differently than previous versions, it makes use of the Exif orientation flag. It may be the case that the image dimensions are landscape, but the exif rotation is at say, 90 degrees. Therefore the image appears to be portrait, but the actual dimensions are still landscape. Then again, I could be talking out of my arse, maybe someone can confirm this? https://jdhao.github.io/2019/07/31/image_rotation_exif_info/
    1 point
  11. Yes, it would be painted every time a drawing event occurs (e.g. LV was covered and is uncovered again). On the other hand that's necessary, as otherwise no table at all would be drawn. Look at the helpfile example for _GUIImageList_BeginDrag(), at the bottom you'll find the line "If BitAND($iItemSpec, 1) = 1 Then", that's where the item number is checked and it's either painted in white or blue. You can add a test there for id = 1 and set it to green, then you realize how it works, Edit: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> GUICreate("listview items", 220, 250, 100, 200) Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 230) ;,$LVS_SORTDESCENDING) Global $g_hListView = GUICtrlGetHandle($idListview) Local $idItem1 = GUICtrlCreateListViewItem("item1|col22|col23", $idListview) Local $idItem2 = GUICtrlCreateListViewItem("item2|col12|col13", $idListview) Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview) Local $idItem4 = GUICtrlCreateListViewItem("item4|col22|col23", $idListview) Local $idItem5 = GUICtrlCreateListViewItem("item5|col12|col13", $idListview) Local $idItem6 = GUICtrlCreateListViewItem("item6|col32|col33", $idListview) Local $idItem7 = GUICtrlCreateListViewItem("item7|col12|col13", $idListview) Local $idItem8 = GUICtrlCreateListViewItem("item8|col32|col33", $idListview) Global $s_Rows_to_Paint_Green = ";2;;5;" ; 0-based GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam) #forceref $hWndGUI, $iMsgID, $wParam Local $tNMHDR, $iCode, $x, $y, $tNMLISTVIEW, $hWndFrom, $tDraw, $iDrawStage, $iItemSpec $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If @error Then Return $iCode = DllStructGetData($tNMHDR, "Code") $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") Switch $hWndFrom Case $g_hListView Switch $iCode Case $NM_CUSTOMDRAW $tDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) $iDrawStage = DllStructGetData($tDraw, "dwDrawStage") $iItemSpec = DllStructGetData($tDraw, "dwItemSpec") Switch $iDrawStage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT If StringInStr($s_Rows_to_Paint_Green, ";" & $iItemSpec & ";") Then DllStructSetData($tDraw, "clrTextBk", 0x00ff00) Return $CDRF_NEWFONT EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    1 point
  12. Dan_555

    Simple Snippet Manager

    Ah, right, the source code and the executables are in the download section. Simple Snippet Manager Because it has over 1k of lines, i didn't pasted it. I have downloaded cSnippet (sometime) last year, and today again, and it gives an error when i switch to Scite ... I guess if it worked, i would probably use it, instead of writing a new one. Edit: Uploaded a new version with this addition (and a bugfix).
    1 point
  13. Hello, just looked around and googled for a proper way to decode base64 utf8 encoded strings and did not find good examples. So created own. Additionally includes base64 utf8 encoder. Possibly some one finds it useful. Used https://www.base64encode.org/ to encode base64-utf8 Global $b64 = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", "", 2); Func _getBase64Num($a) $a = Asc($a) If $a > 47 And $a < 58 Then Return $a + 4; ElseIf $a > 64 And $a < 91 Then Return $a - 65; ElseIf $a > 96 And $a < 123 Then Return $a - 71; ElseIf $a = 43 Then Return 62 ElseIf $a = 47 Then Return 63 Else Return 64 EndIf EndFunc Func _base64dec_arr($r) While StringCompare(StringLeft($r, 1), " ", 1) = 0 $r = StringMid($r, 2) WEnd Local $a, $d, $t, $c, $n, $o, $h, $i, $b = 0, $f = 0; If(StringLen($r) < 1) Then Return $r; Local $rlen = StringLen($r) Local $g = [1] Redim $g[Ceiling($rlen * 0.75)] $r = StringSplit($r, "", 2); While $b < $rlen $c = _getBase64Num($r[$b]) $b = $b + 1; $n = _getBase64Num($r[$b]) $b = $b + 1; $o = _getBase64Num($r[$b]) $b = $b + 1; $h = _getBase64Num($r[$b]) $b = $b + 1; $i = BitOR(BitShift($c, -18), BitShift($n, -12), BitShift($o, -6), $h) $a = BitAND(BitShift($i, 16), 255) $d = BitAND(BitShift($i, 8), 255) $t = BitAND(255, $i) If $o = 64 Then $g[$f] = $a $f = $f + 1; ElseIf $h = 64 Then $g[$f] = $a $f = $f + 1; $g[$f] = $d $f = $f + 1; Else $g[$f] = $a $f = $f + 1; $g[$f] = $d $f = $f + 1; $g[$f] = $t $f = $f + 1; EndIf WEnd If UBound($g) <> $f Then Redim $g[$f] EndIf Return $g; returns array EndFunc; Func _utf8_decode($str_data) ;expects array Local $tmp_arr = "", $i = 0, $c1, $c2, $c3, $strlen = UBound($str_data); While $i < $strlen $c1 = $str_data[$i]; If $c1 < 128 Then $tmp_arr = $tmp_arr & ChrW($c1); $i = $i + 1; ElseIf $c1 > 191 And $c1 < 224 Then $c2 = $str_data[$i + 1]; $tmp_arr = $tmp_arr & ChrW(BitOR(BitShift(BitAND($c1, 31), -6), BitAND($c2, 63))); $i = $i + 2; Else $c2 = $str_data[$i + 1]; $c3 = $str_data[$i + 2]; $tmp_arr = $tmp_arr & ChrW(BitOR(BitShift(BitAND($c1, 15), -12), BitShift(BitAND($c2, 63), -6), BitAND($c3, 63))); $i = $i + 3; EndIf WEnd Return $tmp_arr; EndFunc; Func _base64_utf8_dec($a) Return _utf8_decode(_base64dec_arr($a)) EndFunc Func _utf8_base64_enc($a) Return _base64_enc(_utf8_encode($a)) EndFunc Func _utf8_encode($stringOr) Local $utftext = "", $start = 0, $end = 0, $n = 0, $c1, $enc; Local $string = StringSplit($stringOr, "", 2); Local $stringl = UBound($string) While $n < $stringl $c1 = AscW($string[$n]) If $c1 > 127 Then If $c1 < 2048 Then $enc = ChrW(BitOR(BitShift($c1, 6), 192)) & ChrW(BitOR(BitAND($c1, 63), 128)) Else $enc = ChrW(BitOR(BitShift($c1, 12), 224)) & ChrW(BitOR(BitAND(BitShift($c1, 6), 63), 128)) & ChrW(BitOR(BitAND($c1, 63), 128)) EndIf If $end > $start Then $utftext = $utftext & StringMid($stringOr, $start + 1, $end - $start) EndIf $utftext = $utftext & $enc; $n = $n + 1; $start = $n; Else $n = $n + 1; EndIf $end = $n; WEnd If $end > $start Then $utftext = $utftext & StringMid($stringOr, $start + 1, $stringl - $start) EndIf Return $utftext; EndFunc; Func _base64_enc($rOr) Local $e, $t, $h, $o, $d = 0, $b = ""; Local $r = StringSplit($rOr, "", 2); Local $rL = UBound($r) While $d < $rL $e = AscW($r[$d]) $d = $d + 1; If $d < $rL Then $t = AscW($r[$d]) Else $t = 0; EndIf $d = $d + 1; If $d < $rL Then $h = AscW($r[$d]) Else $h = 0; EndIf $d = $d + 1; $o = BitOR(BitShift($e, -16), BitShift($t, -8), $h) $b = $b & $b64[BitAND(BitShift($o, 18), 63)] & $b64[BitAND(BitShift($o, 12), 63)] & $b64[BitAND(BitShift($o, 6), 63)] & $b64[BitAND(63, $o)] WEnd $rL = Mod($rL, 3); If $rL = 1 Then $b = StringLeft($b, StringLen($b) - 2) & "=="; ElseIf $rL = 2 Then $b = StringLeft($b, StringLen($b) - 1) & "="; EndIf Return $b EndFunc; MsgBox(0, _utf8_base64_enc("your string"), _base64_utf8_dec("eW91ciBzdHJpbmc=")); base64_dec_enc_utf8.au3
    1 point
×
×
  • Create New...