Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/06/2017 in all areas

  1. chibill

    Canon EOS Digital Control

    Now I am not exactly sure if this is against the rules. (As Canon does not want you reverse engineering their tools to write your own. And don't offer there SDKs to the general public.) So if it sorry and you can promptly lock this. I came back to AutoIt after a good 5 years just to be able to control my Canon EOS Rebel Camera for the eclipse (August 21, 2017) and the following is what I have done as a "api" to their graphical interface for the camera. #include <String.au3> #include <Array.au3> Local Const $exposures = StringSplit("BULB|30 Sec|25 Sec|20 Sec|15 Sec|13 Sec|10 Sec|8 Sec|6 Sec|5 Sec|4 Sec|3.2 Sec|2.5 Sec|2 Sec|1.6 Sec|1.3 Sec|1 Sec|0.8 Sec|0.6 Sec|0.5 Sec|0.4 Sec|0.3 Sec|1/4 Sec|1/5 Sec|1/6 Sec|1/8 Sec|1/10 Sec|1/13 Sec|1/15 Sec|1/20 Sec|1/25 Sec|1/30 Sec|1/40 Sec|1/50 Sec|1/60 Sec|1/80 Sec|1/100 Sec|1/125 Sec|1/160 Sec|1/200 Sec|1/250 Sec|1/320 Sec|1/400 Sec|1/500 Sec|1/640 Sec|1/800 Sec|1/1000 Sec|1/1250 Sec|1/1600 Sec|1/2000 Sec|1/2500 Sec|1/3200 Sec|1/4000 Sec","|") Local Const $ISOS[6] = ["AUTO","100","200","400","800","1600"] Func Capture()     ControlClick(" EOS DIGITAL","","[NAME:takePictureButton]") EndFunc Func BULB()     ControlSend(" EOS DIGITAL","","[NAME:olcTv]","{DOWN}") EndFunc Func SetExposure($cur,$expos)     $index = _ArraySearch($exposures,$expos)     $index1 = _ArraySearch($exposures,$cur)     If $index-$index1 < 0 Then         ControlSend(" EOS DIGITAL","","[NAME:olcTv]",_StringRepeat("{Left}",$index1-$index))     Else         If $index-$index1 > 0 Then             ControlSend(" EOS DIGITAL","","[NAME:olcTv]",_StringRepeat("{RIGHT}",$index-$index1))         EndIf     EndIF EndFunc Func GUICtrlGetBkColor($hWnd)     Local $hDC = _WinAPI_GetDC($hWnd)     Local $iColor = _WinAPI_GetPixel($hDC, 10, 10)     _WinAPI_ReleaseDC($hWnd, $hDC)     Return Hex($iColor,6) EndFunc Func CheckWarning()     $i = GUICtrlGetBkColor(ControlGetHandle(" EOS DIGITAL","","[NAME:ledWarning]"))     Return $i == "E80000" EndFunc Func SetAutoISO()     ControlSend(" EOS DIGITAL","","[NAME:olcIso]","{DOWN}") EndFunc Func SetISO($iso)     SetAutoISO()     ControlSend(" EOS DIGITAL","","[NAME:olcIso]",_StringRepeat("{RIGHT}",_ArraySearch($ISOS,$iso))) EndFunc Now I know there are probably many problems with this. (Namely the first Const... ) And possibly some other areas that are just not logical. But bear in mind I am uploading this on the 20th after spending 2 days relearning AutoIt after 5 years of using Java and Python. Any improvements would be nice. (I have a lot I need to add still.) I can also work on a way to return the captured image.
    1 point
  2. .... Just for the record, (for those who can be interested) The DOM's window object, has some methods that you can easly call from within AutoIt (https://msdn.microsoft.com/en-us/library/ms535873(v=vs.85).aspx) One of this methods is setTimeout that allows you to execute a function or javascript code after an interval of time expressed in milliseconds. Well this is very interesting because it also allows you to execute chunks of javascript code passed as a string (of course the interesting is that you can pass the javascript code from within AutoIt). Also, if you set the timeout to 0, the code you passed is executed immediately. In my opinion, this method can be a perfect replacement of the execScript method no longer supported starting with IE11. Replacing this safer method in this snippet by @genius257 we can reference and call the eval Javascript function from within AutoIt, allowing interesting interaction between the two worlds (IE+javascript and AutoIt) here a simple and little example just to show what I'm talking about. #include <ie.au3> Local $oIE = _IECreate() Local $oDocument = _IEDocGetObj($oIE) Local $oWindow = $oDocument.ParentWindow ; I'm not been able (for now) to directly refeence the Javascript Global Object from within AutoIt ; anyway it can be referenced via the following JSglobal javascript variable accessed from AutoIt via the eval method $oWindow.setTimeout("JSglobal = (1,eval)('this');", 0) ; a reference to the JavaScript Global Object ; the following JSeval variable will be referenced directly from AutoIt (see below) $oWindow.setTimeout("document.body.JSeval = eval;", 0) ; a reference to the eval method Sleep(2000) ; give a little time to the browser to create above variables within the javascript environment. $eval = $oIE.Document.body.JSeval ; a reference to the eval javascript method from within AutoIt MsgBox(0, "Debug", "The $eval variable is of type " & VarGetType($eval) & @CRLF & "and is a refernce to the eval javascript method") ; Using the Javascript Global Object via eval ; https://docs.microsoft.com/en-us/scripting/javascript/reference/global-object-javascript MsgBox(0, "Debug", "Script infos:" & @CRLF & _ "-------------" & @CRLF & _ "Script Engine: " & $eval('JSglobal.ScriptEngine()') & @CRLF & _ "Script Version: " & $eval('JSglobal.ScriptEngineBuildVersion()')) ; calling javascript methods ; we use a javascript method to format a number ; and we get the result from javascript directly in an AutoIt variable by the javascript eval method $i = 1000000 ; an unformatted number Local $result = $eval('parseInt( ' & $i & ' ).toLocaleString();') MsgBox(0, "Debug", "This is a number formatted by javascript: " & $result) $eval("alert('Bye from JavaScript... see you later\nClick OK to quit')") _IEQuit($oIE)
    1 point
  3. Simpel

    replace url and split?

    Hi. This should work (only tested at https://regex101.com/r/e0X9Si/2): #include <Array.au3> $aUrl = "https://www.autoitscript.com.tr/" $pattern = '(?:http[s]?:\/\/)?(?:www\.)?([\w+\.]+)' $aArray = StringRegExp($aUrl, $pattern, 3) _ArrayDisplay($aArray) If your URL is more complex (special characters or so) then you have to tune the part between the last brackets. Conrad
    1 point
  4. I looked through the original code and figured out why it cut the last few off. The UDF searches through the file properties by number, some of the numbers in Windows 10 aren't used, and maybe in other versions as well, so the check in the If statement would skip those blank lines, and the properties count in the array's [0][0] element wouldn't get updated correctly.
    1 point
  5. This should work. $string = "I:\test\\xxx\jjj\\\kkk\k.jpg" $string=StringRegExpReplace($string,"\\{2,}","\\") ConsoleWrite($string & @CRLF) Saludos
    1 point
  6. Hi. I'm not sure if you really mean remove or mean replace woth only one "\". I guess second. So here is my try with StringRegExpReplace(): Local $string = "I:\test\\xxx\jjj\\\kkk\k.jpg" $string = StringRegExpReplace($string, "\\+", "\\") ConsoleWrite($string & @CRLF) Explanation: searchstring - \\+ - first \ is only masking second\ (otherwise it has another function) and + means one till all \ Replace it with \\. Here the first \ is masking the second \ again. Conrad
    1 point
  7. A simpler fix would be to change this line: ; from this $av_ret[0][0] += 1 ; to this $av_ret[0][0] = $I This is inside the If statement in the For loop, gives full results as well.
    1 point
  8. Does this help? ; Rename Files #include <Array.au3> ; Only required to display the arrays #include <File.au3> Local $re_A = _FileListToArrayRec('c:\Autoit\ForumTests\Dateisortierung\', '*.mp3', $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_FASTSORT, $FLTAR_FULLPATH) ;~ _ArrayDisplay($re_A) Local $FilesAndDate_A[UBound($re_A)][2] For $i = 0 To UBound($FilesAndDate_A) - 1 $FilesAndDate_A[$i][0] = $re_A[$i] $FilesAndDate_A[$i][1] = FileGetTime($re_A[$i], $FT_CREATED, $FT_STRING) Next ;~ _ArrayDisplay($FilesAndDate_A) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" For $i = 1 To UBound($FilesAndDate_A) - 1 _PathSplit($FilesAndDate_A[$i][0], $sDrive, $sDir, $sFileName, $sExtension) ConsoleWrite($sDrive & $sDir & $FilesAndDate_A[$i][1] & '_' & $sFileName & $sExtension & @CRLF) FileMove($FilesAndDate_A[$i][0], $sDrive & $sDir & $FilesAndDate_A[$i][1] & '_' & $sFileName & $sExtension, $FC_OVERWRITE) Next
    1 point
  9. Hello. You can do something like this: #include <Array.au3> Local $sStr = BinaryToString(InetRead("http://who.is/whois/autoitscript.com",1)) Local $aReg = StringRegExp($sStr, "(\d{4}-\d{2}-\d{2})", 1) _ArrayDisplay($aReg) Saludos
    1 point
  10. Could be something like this: #include <Excel.au3> Local $sFullPath = "filenamefullpath" Local $xlExclusive = 3 ; Exklusive mode Local $xlLocalSessionChanges = 2 ; The local user's changes are always accepted Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $sFullPath) $oWorkbook.Activesheet.EnableCalculation = True $oWorkbook.RefreshAll $oExcel.DisplayAlerts = False $oWorkbook.SaveAs("myfile.xlsx", Default, Default, Default, Default, Default, $xlExclusive, $xlLocalSessionChanges) _Excel_BookClose($oWorkbook, True) _Excel_Close($oExcel)
    1 point
  11. I see. Translating the VBA macro to AutoIt isn't a big task. Will post an example as soon as I find some spare time.
    1 point
×
×
  • Create New...