Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/02/2021 in all areas

  1. 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
  2. I really love this funny language called "English" which sometimes misleads me a bit. 😀
    1 point
  3. Could be changed. Waiting for other users/members opinion ....
    1 point
  4. I wonder if it would make more sense to provide a GUI interface that can be used to generate the Capabilities string. I've found a couple of web-based examples -- https://www.browserstack.com/automate/capabilities https://saucelabs.com/platform/platform-configurator#/
    1 point
  5. wouldn't it be possible to make it easier? I don't know but your suggested UDF seems to be complex for me. I also notice it could be ambiguous to use _Add as a getter passing default as parameter. Saludos
    1 point
  6. I'm not sure about If It's required or no. But Maybe you can deduct it reading this. Saludos
    1 point
  7. smbape

    OpenCV v4 UDF

    I must say that I am really amazed by your desire to learn. If I was a teacher, I would have loved to have a student like you. Keep it up. ; CVAPI(void) cveMinEnclosingCircle(cv::_InputArray* points, CvPoint2D32f* center, float* radius); Local $center = _cvPoint2f() ; equivalent of DllStructCreate($tagCvPoint2D32f) Local $radius = DllStructCreate("float value") _cveMinEnclosingCircleTyped("VectorOfPoint", $tVectorPointPtr.value, $center, $radius) $center = _cvPoint($center.x, $center.y) _cveCircleMat($img, $center, $radius.value, _cvScalar(0,255,0), 2)
    1 point
  8. I think you got an error somewhere : ConsoleWrite(Hex(3153232650000) & @CRLF) shows it is 0x02DE2B4FDF10. In no way related to your hex... Here another way to convert binary string to dec : $bVal = Binary("0x1F852F41") $tStruct = DllStructCreate("int data") $tStruct.data = $bVal ConsoleWrite($tStruct.data & @CRLF)
    1 point
  9. smbape

    OpenCV v4 UDF

    If you mean having a subset of $contours that validates the condition on _cveContourAreaTyped, then it is Local $good_contours = _VectorOfVectorOfPointCreate() Local $tVectorPointPtr2 = DllStructCreate("ptr value") For $i = 0 To _VectorOfVectorOfPointGetSize($contours) - 1 _VectorOfVectorOfPointGetItemPtr($contours, $i, $tVectorPointPtr2) Local $Area1 = _cveContourAreaTyped("VectorOfPoint", $tVectorPointPtr2.value) If $Area1 < 1000 Then ContinueLoop Else _VectorOfVectorOfPointPush($good_contours, $tVectorPointPtr2.value)
    1 point
  10. I once started this one, but it stalled 🤐
    1 point
  11. smbape

    OpenCV v4 UDF

    When you assign a value to a variable, the variable is set. However, your phrase makes me think that it is not what you mean. Can you explain? 7b is hard to translate since it involves manipulation of vectors and matrix Local $tVectorPointPtr = DllStructCreate("ptr value") Local $countours2 = _VectorOfVectorOfPointCreate() local $coutour = _VectorOfPointCreate() Local $rect = DllStructCreate($tagCvBox2D) Local $box = _cveMatCreate() For $i = 0 To _VectorOfVectorOfPointGetSize($contours) - 1 _VectorOfVectorOfPointGetItemPtr($contours, $i, $tVectorPointPtr) _cveMinAreaRectTyped("VectorOfPoint", $tVectorPointPtr.value, $rect) _cveBoxPointsTyped($rect, "Mat", $box) _VectorOfPointClear($coutour) For $xi = 0 To 3 Local $x = _cveMatGetAt("float", $box, _cvPoint(0, $xi)) Local $y = _cveMatGetAt("float", $box, _cvPoint(1, $xi)) _VectorOfPointPush($coutour, _cvPoint($x, $y)) Next _VectorOfVectorOfPointClear($countours2) _VectorOfVectorOfPointPush($countours2, $coutour) _cveDrawContoursTyped("Mat", $img, "VectorOfVectorOfPoint", $countours2, 0, _cvRGB(0, 0, 255), 3) Next
    1 point
  12. Unless you instruct otherwise, a new temporary user profile is used each time you launch the browser with webdriver. I haven't needed to save / restore cookies, so I don't really have advice in this area other than to point you to the _WD_Cookies function. Have you checked to see if the page uses frames?
    1 point
  13. Remove this (or move it to the end) if you want the rest of the script to work 😏
    1 point
  14. Well there is quite a number of problems with your code. The biggest issue is the fact that when you reshell autoit (shellexecute or run), it becomes a new process thus a completely new script. There is no link between the caller and the callee (unless you add command line parameters or use some other means like IPC). To get a good example of how you can reshell autoit on a single line of code, see help file / Using AutoIt / Command Line Parameters.
    1 point
  15. The methodology here is still far away from "in no time". It is not necessary to sort the array completely to calculate the median. The array only has to be divided step by step into elements larger or smaller than a certain value and if these sub-ranges are treated step by step in the same way, the element in the middle is available at the end. (= "quick select" algorithm) This way you can calculate the median much faster. Example script (the required UDF is in the appendix): #include "Stat_ListFunctions.au3" ; row size of array: Global Const $N = 1e4 + 1 Global Const $C = 5 ; create sample array: Global $aArray[$N][$C] For $i = 0 To $N -1 ; fill only one column with sample data $aArray[$i][2] = Random(0, $N, 1) Next ; copy sample array: $aArray2 = $aArray ; first method: full sort: $tTimer = TimerInit() $iMedian = _Median2DbySorting($aArray, 2) ConsoleWrite(StringFormat("method:\t%s\nmedian:\t%d\ntime:\t%.1f ms\n\n", "Full sort of array", $iMedian, TimerDiff($tTimer))) ; second method: partition of array $tTimer = TimerInit() $iMedian = _Median2DbyPartition($aArray2, 2) ConsoleWrite(StringFormat("method:\t%s\nmedian:\t%d\ntime:\t%.1f ms\n\n", "partition of array", $iMedian, TimerDiff($tTimer))) ; calculate the median of a column of a 2D-Array by sorting it Func _Median2DbySorting(ByRef $aArray, $iCol) Local Const $N = UBound($aArray) _ArraySort($aArray, 0, 0, 0, $iCol) Return Mod($N, 2) = 0 ? _ ($aArray[Int($N/2)][$iCol] + $aArray[Int($N/2) + 1][$iCol]) / 2 : _ $aArray[Int($N/2)][$iCol] EndFunc ; extract the column and calculate the median by partition Func _Median2DbyPartition(ByRef $aArray, $iCol) Local Const $N = UBound($aArray) Local $aTmp[$N] For $i = 0 To $N - 1 $aTmp[$i] = $aArray[$i][$iCol] Next Return _stat_Median($aTmp) EndFunc produces the following output: Stat-UDF.zip
    1 point
  16. 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
  17. Sure. Use _AD_GetObjectsInOU.
    1 point
  18. ;EXAMPLES OF USING @COMSPEC Reminder from Blindwig: "FYI - You only need to call comspec to run internal comands (DIR, COPY, MD, RD, etc) You don't need it for external commands (ATTRIB, CACLS, XCOPY, NET, etc)" ;~USE SIMPLE DOS COMMAND WITH PARAMETERS Run(@ComSpec & ' /k ' & 'dir /os') ;~USE SIMPLE COMMAND WITH FILENAME Run(@ComSpec & ' /k ' & 'attrib "c:\autoexec.bat"') ;~USE ATTRIB Run(@comspec & ' /k ' & 'attrib' & ' +R "run notepad1.au3"');add delay before checking status sleep(1500) run(@comspec & ' /k ' & 'attrib "run notepad1.au3"');delay this line to be sure attrib is set first ;~USE CACLS.EXE Run(@ComSpec & ' /k ' & 'cacls.exe "c:\my music\halloween.mp3"') run(@comspec & ' /k ' & 'cacls.exe "run notepad1.au3" /t /e /p jeff-dell\jeff:f') run(@comspec & ' /k ' & 'cacls.exe "run notepad1.au3" /t /e /p everyone:f') sleep(1500) run(@comspec & ' /k ' & 'cacls.exe "run notepad1.au3"') ;~GET CMD.EXE HELP Run(@ComSpec & " /k help | more") ;ADVANCED CONCEPTS FROM AUTOIT FORUM: $x = 1 RunWait(@ComSpec & " /c " & 'start explorer ' & '"' & 'http://www.atari.com/exchange/rct3/item?id=' & $x & '"', "", @SW_HIDE) RunWait(@ComSpec & ' /c ' & 'cd /d ' & $dir[$cliff] & $lang[$bob] & $op[$mike]) RunWait(@ComSpec & " /c " & "net send " & $MessageSentTo & GUIRead($TextMessageInput)) RunWait(@ComSpec & " /c " & "net send * " & GUIRead($TextMessageInput)) RunWait(@ComSpec & " /c ipconfig > " & "c:\ipconfig.txt", "", @SW_HIDE) Run(@ComSpec & " /c Start " & $SelectedURL, "", @SW_HIDE) RunWait(@ComSpec & ' /c defrag ' & $aD[$c] & ' /f') ; WinXP only RunWait(@ComSpec & ' /c defrag ' & $aD[$c] & ' -a -v >> "' & $sLog & '"') ;WinXP only RunWait(@ComSpec & " /k " & "cd /d " & $db & "\" & $lang & " && wget " & $dl & "/" & $lang & "/" & $sql, "") Run(@ComSpec & ' /c copy "c:\program files\diablo II\d2data.mpq" c:\temp\d2data.mpq') RunWait(@ComSpec & " /c start " & $file, @ScriptDir, @SW_HIDE) RunWait(@comspec & " /c net send "& $PC &" "& $Text,"",@sw_hide) Run(@ComSpec & " /c start clip.txt", @ScriptDir,@sw_hide) RunWait(@ComSpec & ' /C explorer.exe [url=http://www.users.on.net/johnson/resourcehacker/']http://www.users.on.net/johnson/resourcehacker/'[/url], '', @SW_HIDE) Run(@comspec & " /c au3record.exe /o>test.au3","",@SW_HIDE) RunWait(@ComSpec & ' /c "' & @TempDir & '\~execute.bat"', '', @SW_HIDE) Runwait(@comspec & " /c " & '"' & @ScriptDir & '\devcon.exe" enable =net *pci*',"",@SW_HIDE) RunWait(@ComSpec & " /c " & $row & ".exe -m LZX:21 -r -p -P " & $c & "\" & " n " & $c & ".cab" & " " & $c & "\*.*", $res) RunWait(@ComSpec & ' /c c:\psinfo.exe -c "\\' & $host & '" > c:\psinfo.txt', 'c:\', @SW_HIDE) RunWait(@ComSpec & ' /c c:\psinfo.exe -c "\\' & $host & '" > c:\psinfo.txt', 'c:\', @SW_HIDE) RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp 192.168.1.200', "", @SW_HIDE) RunWait(@ComSpec & ' /c debug < autoit3.dbg', @TempDir, @SW_HIDE) RunWait(@ComSpec & " /c " & 'netstat -n>c:\ip.txt' , "", @SW_HIDE) RunWait(@Comspec & " /c " & $sCmd & ">" & $sFileList,"",@SW_HIDE) Run(@ComSpec & ' /c start ' & $TAG & $F1, '', @SW_HIDE) RunWait(@Comspec & " /c """ & "nslookup "" " & $IP & " > hostname.txt") RunWait(@comspec & " /c dir *.EXE /s/b>" & $sExeListName,"",@SW_HIDE) RunWait(@comspec & " /c dir *.EXE /s/b|cb.exe","",@SW_HIDE);Uses(cb.exe) to route output from a commandline app straight to the clipboard .. which can then be interrogated from within AU3 (thereby avoiding the need to bounce the info through a file) RunWait(@ComSpec & " /c " & 'del /q /s "' & $dir & '"', "", @SW_HIDE) RunWait(@COMSPEC & $Mount & $parm2, $AlcoholDir, @SW_HIDE) Run(@ComSpec & " /c echo " & $PASS & "|idea.com " & $MODE & " " & _FileGetShortName($FILENAME), "", @SW_HIDE) $rc = RunWait(@ComSpec & ' /c Wscript.exe "' & @TempDir & '\NotesMsg.vbs" //T:30 > sent.log 2>&1', @TempDir, @SW_HIDE) $E = RunWait(@ComSpec & ' /c ""' & @TempDir & '\~blattmp.exe" "' & $TEXT & _ '" -to ' & $DEST & ' -binary -server ' & $SMTPSERVER & ' -log ' & @TempDir & _ '\~maillog.txt -timestamp -f ' & $SENDER & $SUBJECT & '-u ' & $AUTHLOGIN & _ ' -pw ' & $AUTHPASS & '"', @TempDir, @SW_HIDE) $cppid = Run(@ComSpec & ' /c cp "' & $source & '" "' & $dest & '"', @ScriptDir,@SW_HIDE); uses cp.exe from UnixTools $kk32 = runwait(@comspec & " /c dir /a /s /b %systemdrive%\kk32.dll",@SystemDir, @SW_HIDE) $surf = runwait(@comspec & " /c dir /a /s /b %systemdrive%\surf.dat",@SystemDir, @SW_HIDE) $ERRORCODE = RunWait(@ComSpec & " /c ping -n 1 -l 5 " & $IP & $NEXTIP, "", @SW_HIDE) $ERRORCODE = RunWait(@ComSpec & " /c ping -n 1 -l 5 " & $IP & $NEXTIP, "", @SW_HIDE) $val = RunWait(@ComSpec & ' /c xcopy "'& $source & "\" & $find[$i] & '" "' & $dest & '" /i /e /h /Y /D /Z',@TempDir) MsgBox(0, "testing",@ComSpec & " /c xcopy "& $source & "\" & $find[$i] & " " & $dest & " /i /e /h /Y /D")
    1 point
  19. UEZ

    What are /c and /k ???

    That's odd: Here an extract from that site: Cmd Starts a new instance of the command interpreter, Cmd.exe. Used without parameters, cmd displays Windows XP version and copyright information. Syntax cmd [[{/c|/k}] [/s] [/q] [/d] [{/a|/u}] [/t:fg] [/e:{on|off}] [/f:{on|off}] [/v:{on|off}] string] Top of pageTop of page Parameters /c : Carries out the command specified by string and then stops. /k : Carries out the command specified by string and continues. /s : Modifies the treatment of string after /c or /k. /q : Turns the echo off. /d : Disables execution of AutoRun commands. /a : Creates American National Standards Institute (ANSI) output. /u : Creates Unicode output. /t:fg : Sets the foreground f and background g colors. The following tables lists valid hexadecimal digits that you can use as the values for f and g. Br, UEZ
    1 point
  20. I want this function to LOOP INFINITE until i send a certain key. Please. Im new. METVSTUDIOS.
    1 point
×
×
  • Create New...