Jump to content

Recommended Posts

Local $sAxName
Local $oMSComm

$sAxName = "MSCOMMLib.MSComm.1"
$oMSComm = ObjCreate($sAxName)
MsgBox(0, Default, StringFormat("Name: %s, Obj %d, Err %d", $sAxName, IsObj($oMSComm), @error))

I'm talking to serial ports (for Arduino) using the MSComm object.  It all runs fine from SciTE or .exe.  If I compile to .a3x the object is not created.  I could manage without .a3x but I like it because it compiles faster.


Link to post
Share on other sites
  • Developers

Are you running the ax3 with the x86 or x64 AutoIt3.exe version? 
Might Want to play with that as that is the only reason I can think of that could case this.


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
Live for the present,
Dream of the future,
Learn from the past.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Exit
      Au3toCmd  ---  Avoid false positives
      Since many virus scanners sometimes prevent a "compiled autoit EXE" from being executed as "false positive", the "*.A3X" format is a suitable format to avoid this problem.
      In order to simplify this procedure, I wrote the Au3toCmd script. Here a *.Cmd file is generated from a *.Au3 file. The necessary files Autoit3.exe and *.A3x are added to the "*.Cmd" file as "alternate data streams" "Base64" encoded data.
      Now the Autoit Script can be called by clicking on the cmd file and the anti-virus scanners do not recognize the "false positive".
      If the short-term flashing of the CMD window bothers you, you can click the desktop shutcut that runs in a minimized window.
      Unfortunately, because the "alternate data streams", this CMD file cannot be distributed via FTP or email.
      Only a USB stiof ck or removable disk formatted with NTFS can be used.
      As the new version now uses Base64 data instead of ADS, this statement is out of date.
      For reasons of compatibility, the old version was sunk into the spoiler here.
      Here the new  version using base64 data
      ;============================================================================================================== ; Script Name: Au3toCmd.au3 ; Description: Creates a CMD file from any AU3 file. ; The CMD file will contain the compiled version (A3X) of the AU3 input file ; and the AUTOIT3.EXE file as BASE64 data. ; This avoids the problem with the false positives of the virus scanners on EXE files. ; To avoid the short-term flashing of the CMD window, a shortcut is created on the desktop ; that runs in a minimized window. You may delete or move it. ; ; ; Syntax: Au3toCmd (input-file) ; Default: none ; Parameter: Name of AU3 file (optional) ; can be set by using SHIFT+F8 in SciTE4AutoIt3 Editor. ; if parameter is empty, a FileOpenDialog prompts you. ; ; ; The execxution environment can be set by using the #AutoIt3Wrapper directives in the source code. ; #AutoIt3Wrapper_Version=Prod/P/0/Beta/B/1 ; #AutoIt3Wrapper_UseX64=Y/1/N/0 ; #AutoIt3Wrapper_Icon=C:\users\...\anyname.ico ; ; Example: Au3toCmd c:\testdir\testfile.au3 ; ; Author: Exit ( http://www.autoitscript.com/forum/user/45639-exit ) ; SourceCode: http://www.autoitscript.com/forum/index.php?showtopic=201562 Version: 2022.01.11 ; COPYLEFT: © 2020 Freeware by "Exit" ; ALL WRONGS RESERVED ;============================================================================================================== #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Prod #AutoIt3Wrapper_UseX64=Y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $_a2c_Debug =0 ; change to '1' for debugging informations on output console #include <File.au3> Global $sSourcepath, $sSourceData, $sTargetpath, $aPathSplit, $sDrive, $sDir, $sFileName, $sExtension, $sIconPath = "", $iIconNumber = 0, $sRDir Exit _Main() Func _Main() __DebugInfo() If Not _Sourcepath() Then Return SetError(1, 0, 0) If Not _IconPath() Then Return SetError(2, 0, 0) If Not _Targetpath() Then Return SetError(3, 0, 0) EndFunc ;==>_Main Func _Sourcepath() If $cmdline[0] > 0 Then $sSourcepath = $cmdline[1] If Not FileExists($sSourcepath) Then Beep(1000, 80) $sSourcepath = FileOpenDialog(" Enter AU3 Inputfile for Au3toCmd Application ", "", "Autoit Files(*.au3)", 3) If @error Then Return SetError(5, MsgBox(16 + 262144, Default, "Error: No Inputfile given", 3), 0) EndIf $sSourcepath = _PathFull($sSourcepath) $aPathSplit = _PathSplit($sSourcepath, $sDrive, $sDir, $sFileName, $sExtension) FileChangeDir($sDrive & $sDir) $sSourceData = FileRead($sSourcepath) __CW("Sourcepath: " & $sSourcepath & @LF) Return 1 EndFunc ;==>_Sourcepath Func _IconPath() Local $aTemp = StringRegExp($sSourceData, "(?m)\n#AutoIt3Wrapper_Icon=(.*)", 1) If IsArray($aTemp) And FileExists($aTemp[0]) Then $sIconPath = $aTemp[0] ElseIf FileExists($sDrive & $sDir & $sFileName & ".ico") Then $sIconPath = $sDrive & $sDir & $sFileName & ".ico" Else $sIconPath = @WindowsDir & "\system32\shell32.dll" ;~ $iIconNumber = 71 $iIconNumber = 132 EndIf __CW("IconNumber: " & $iIconNumber & " IconPath: " & $sIconPath & @CRLF) Return 1 EndFunc ;==>_IconPath Func _Targetpath() Local $sA3Dir, $sA3Ver, $hTargetpath, $t, $x64 = 0, $beta = 0 $sTargetpath = $sDrive & $sDir & $sFileName & ".cmd" FileDelete($sTargetpath) $beta = StringRegExp($sSourceData, "(?m)\n#AutoIt3Wrapper_Version=[bByY1]", 0) $sA3Dir = RegRead("HKLM\SOFTWARE" & ((@OSArch = 'X64') ? "\Wow6432Node" : "") & "\AutoIt v3\AutoIt", ($beta ? "beta" : "") & "InstallDir") $sA3Ver = RegRead("HKLM\SOFTWARE" & ((@OSArch = 'X64') ? "\Wow6432Node" : "") & "\AutoIt v3\AutoIt", ($beta ? "beta" : "") & "Version") __CW("Regread A3Dir: " & $sA3Dir & " Version: " & $sA3Ver & @CRLF) If Not (FileExists($sA3Dir & "\autoit3.exe") And FileExists($sA3Dir & "\au3check.exe") And FileExists($sA3Dir & "\Aut2Exe\Aut2exe.exe")) Then Return SetError(9, MsgBox(16 + 262144, Default, "Error: Autoit " & ($beta ? "Beta Version " : "") & "not installed on this system.", 0), 0) $x64 = StringRegExp($sSourceData, "(?m)\n#AutoIt3Wrapper_UseX64=[yY1]", 0) __CW("X64: >" & $x64 & "< beta: >" & $beta & "< A3Dir: " & $sA3Dir & @LF) If ShellExecuteWait($sA3Dir & "\au3check.exe", ' -q "' & $sSourcepath & '"', "", "", @SW_HIDE) Then Return SetError(10, MsgBox(16 + 262144, Default, "Error: Input file """ & $sSourcepath & """ has Errors according to Au3Check.exe. ", 0), 0) If ShellExecuteWait($sA3Dir & "\Aut2Exe\Aut2exe" & ($x64 ? '_x64' : '') & ".exe", "/In """ & $sSourcepath & """ /out """ & $sTargetpath & ".sa3x"" " & ($x64 ? '/X64' : ' ')) Then Return SetError(11, MsgBox(16 + 262144, Default, "Error : Cannot create target file """ & $sTargetpath & ".sa3x"" ", 0), 0) FileCopy($sA3Dir & "\Autoit3" & ($x64 ? '_x64' : '') & ".exe", $sTargetpath & ".sprog") $hTargetpath = FileOpen($sTargetpath, $FO_APPEND) FileWriteLine($hTargetpath, _ '@if not DEFINED _ set _=_ & start "" /min "%~f0" %* & exit' _ & @CRLF & 'cd /D %~dp0' _ & @CRLF & 'set r=%appdata%\Au3toCmd\' _ & @CRLF & 'set n=%~n0' _ & @CRLF & 'set ver=' & $sA3Ver _ & @CRLF & 'set x64=' & ($x64 ? "_64" : "") _ & @CRLF & 'if not exist "%r%exe\%ver%\AutoIt3%x64%.exe" (' _ & @CRLF & ' mkdir %r%exe\%ver%\' _ & @CRLF & ' more +35 %0 >~~' _ & @CRLF & ' certutil -decode -f ~~ "%r%exe\%ver%\AutoIt3%x64%.exe"' _ & @CRLF & ' del ~~' _ & @CRLF & ')' _ & @CRLF & 'call :ts %0 "%r%a3x\%n%.a3x"' _ & @CRLF & 'if %t1% geq %t2% (' _ & @CRLF & 'mkdir %r%a3x\' _ & @CRLF & 'certutil -decode -f %0 "%r%a3x\%n%.a3x"' _ & @CRLF & ')' _ & @CRLF & 'wmic process call create ''"%r%exe\%ver%\AutoIt3%x64%.exe" "%r%a3x\%n%.a3x" "%*"'' ' _ & @CRLF & 'rem pause' _ & @CRLF & 'exit' _ & @CRLF & ':ts t1 t2' _ & @CRLF & 'set t1=%~t1' _ & @CRLF & 'set t2=%~t2' _ & @CRLF & 'set t1=%t1:~3,2%%t1:~0,2%%t1:~11,2%%t1:~14,2%' _ & @CRLF & 'set t2=%t2:~3,2%%t2:~0,2%%t2:~11,2%%t2:~14,2%' _ & @CRLF & 'goto :eof' _ ) RunWait(@ComSpec & " /c " & 'certutil -encode -f "' & $sTargetpath & '.sa3x" "' & $sTargetpath & '.a3x"', "", @SW_HIDE) $t = FileRead($sTargetpath & '.a3x') FileDelete($sTargetpath & '.sa3x') FileDelete($sTargetpath & '.a3x') FileWriteLine($hTargetpath, $t) RunWait(@ComSpec & " /c " & 'certutil -encode -f "' & $sTargetpath & '.sprog" "' & $sTargetpath & '.prog"', "", @SW_HIDE) $t = FileRead($sTargetpath & '.prog') FileDelete($sTargetpath & '.sprog') FileDelete($sTargetpath & '.prog') FileWriteLine($hTargetpath, $t) FileClose($hTargetpath) If Not FileCreateShortcut($sTargetpath, @DesktopDir & "\" & $sFileName & ".lnk", $sDrive & $sDir, "", "", $sIconPath, "", $iIconNumber, 7) Then Return SetError(16, MsgBox(16 + 262144, Default, "Unable to create shortcut", 0), 0) __CW("$sTargetpath: " & $sTargetpath & @LF) MsgBox(64 + 262144, Default, $sTargetpath & " and " & @CRLF & @DesktopDir & "\" & $sFileName & ".lnk created." & @CRLF & @CRLF & "X64 Mode=" & ($x64 ? "Yes" : "No") & " Beta Mode=" & ($beta ? "Yes" : "No"), 0) Return 1 EndFunc ;==>_Targetpath Func __CW($sText) If Not Eval("_a2c_Debug") Then Return ;~ FileWriteLine(@ScriptFullPath & ".console.txt", $sText) ConsoleWrite($sText & @CRLF) EndFunc ;==>__CW Func __DebugInfo() FileDelete(@ScriptFullPath & ".console.txt") If @Compiled Then $_a2c_Debug = 0 If Not Eval("_a2c_Debug") Then Return __CW("============ Start of DebugInfo ===============") __CW("Au3toCmd Version: " & (StringRegExp(FileRead(@ScriptFullPath), "(?i)Version: (.*)", 1))[0]) __CW("@ScriptFullPath: " & @ScriptFullPath) __CW("@AutoItExe: " & @AutoItExe) __CW("@AutoItVersion: " & @AutoItVersion) __CW("@AutoItX64: " & @AutoItX64) __CW("@CPUArch: " & @CPUArch) __CW("@OSArch: " & @OSArch) __CW("@OSBuild: " & @OSBuild) __CW("@OSLang: " & @OSLang) __CW("@OSType: " & @OSType) __CW("@OSVersion: " & @OSVersion) __CW("@OSServicePack: " & @OSServicePack) __CW("@UserName: " & @UserName) __CW("@UserProfileDir: " & @UserProfileDir) __CW("============ End of DebugInfo ===============") EndFunc ;==>__DebugInfo ; End of Au3toCmd.au3 script The script can be called with a file name of an AU3 script as a parameter.
      If no name is entered, a query is made.
      Suggestions, improvements and bug reports are welcome.
    • By t0nZ
      Computer Plucker is a fork and a "restoration" of Computer stats utility by @Rogue5099 (link)
      You can obtain various data about local machine, as from the screenshot.

      But my goal is not (only) to provide another PC stats tool, but to develop a very basic remote inventory tool, like (a small subset of) the abandoned Spiceworks or the Microsoft SCCM.
      So this script can be deployed on a machine as a standalone executable (yes you need only ONE file to distribute) , and launching the .EXE it installs itself to a folder (es. c:\autoit\computerplucker)
      In tools menù you can set two tasks and not only
      one for creating every week a file.ini with all the data of the machine. another one  for creating every week a file.ini with all the data of the machine PLUS uploading a CRYPTED record of the machine in a free mysql DB online For my needs, I am  deploying the .exe and schedule the second task, uploading data one time a week.
      In tools menù you will find also commands for:
      manual creating the .ini data file  to upload the data in crypted records to upload the data in clear text records (for testing..) total uninstall of ComputerPlucker, with a simple security code. many other tasks in not so logical order.. next version I have to tidy the menù... So my plan is to deploy this on my machines, and have the data in a online DB, this DB will be for me only a "cache" for data records to be downloaded (and deleted) by another script.
      As today the account of this TEST DB is embedded in code, using the "File to Base64 String' Code Generator" by @UEZ (used also for embedding icons and XML task definitions)
          Local $mysqlhost = "sql11.freemysqlhosting.net"
          Local $mysqlport = "3306"
          Local $mysqldb = "sql11403701"
          Local $mysqluser = "sql11403701"
          Local $mysqlpsw = "QtL7T9U5GV"
      The DB is one table of 30 mysql tinytext fields... very simple indeed...
      You can try to upload data to this DB and access (phpmyadmin or a random mysql browser app) to see the results.
      Or you can use my ComputerPluckerDBbrowser (see at the end of this post) a script to collect and manage the data.

      PRIVACY warning: you are uploading data of your PC account and PC data, test as your risk (or test in another account...)
      I also created a small post in a blog for not so geek friends, and I have a more advanced version of the data browser, you can have more info lookin' here. 😀
      Attached you will find the code, and all the necessary includes are at this >link<.
      ComputerPlucker.EXE is downloadable >HERE<
      ComputerPluckerDBbrowser.EXE is downloadable >HERE<

    • By Inpho
      Hi All,
      I didn't know where to put this; my apologies if this is the wrong location.
      When you plug a Samsung mobile device (phone, tablet, etc.) into the USB of a Windows PC, you can right-click the device in My Computer and select Properties. Here, it will show you the correct serial number of the device. Clearly Windows doesn't use adb to get the SN so I'm stuck at how to get the SN without adb and where the device doesn't have a drive letter assigned to it.
      When I last picked this up, I tried seemingly everything I could from wmi(?) and winmgmts(?) but either it's hidden cloak-and-dagger style or I can't see the forest for the trees...
      Does anyone know what API Windows uses when getting the serial number of a device Windows calls a Portable Media Player?

    • By jantograaf
      Hi all,
      I'm trying to write a script that connects with a VBA/COM API to get the status of a connected phone. I've been looking up and down this forum for tips or other user's experiences, but I can't seem to find anything (even remotely) similar. It shouldn't be so hard to do, however.
      Software I'm trying to connect to
      I'm trying to integrate CallCenter by using their API, which is documented over here : JustRemotePhone API Reference
      Things I've tried
      I've tried using ObjCreate but I don't get any result, it always returns the same (negative) error.
      #Version 1 tried ObjCreate("JustRemotePhone.RemotePhoneService") #Version 2 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService") #Version 3 tried ObjCreate("JustRemotePhoneCOM.RemotePhoneService.Application") None of the three versions I tried seem to deliver any result other than a negative error value which basically says that the given class is not valid.
      I am starting to get the hang of AutoIt by now, but unmanaged programming languages and object-oriented stuff is still quite a grey zone for me. If anyone could help me 'talk' to this application, I'd be immensely grateful!
      Thanks in advance and kind regards from Belgium!
    • By mikered82
      Could someone help me please with a UDF/library/example to communicate with Arduino thru USB using V-USB Driver (HID Device).
      I want to implement remote control for PC (TV Tuner remote). Arduino would read and decode data from an IR Sensor then send the decoded data to the PC thru USB.
      Thanks! Any help much appreciated!!
  • Create New...