Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/25/2016 in all areas

  1. I've made a library, based on AutoItObject UDF with the goal of implementing getter and setter functionality and make it possible to define new object properties in as few steps as possible. Thank you to @trancexx for getting me on the right track, and all users in Hooking into the IDispatch interface for the code to get me going. If I've forgotten to add credit, please let me know Example: #include "AutoItObject_Internal.au3" $myCar = IDispatch() $myCar.make = 'Ford' $myCar.model = 'Mustang' $myCar.year = 1969 $myCar.__defineGetter('DisplayCar', DisplayCar) Func DisplayCar($oThis) Return 'A Beautiful ' & $oThis.parent.year & ' ' & $oThis.parent.make & ' ' & $oThis.parent.model EndFunc MsgBox(0, "", $myCar.DisplayCar) More examples: https://github.com/genius257/AutoItObject-Internal/tree/master/Examples Version: 4.0.1 AutoItObject_Internal.au3 Documentation Edit2 (19th March 2017): First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'. So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here.
    2 points
  2. CodeCrypter enables you to encrypt scripts without placing the key inside the script. This is because this key is extracted from the user environment at runtime by, for example: password user query any macro (e.g., @username) any AutoIt function call any UDF call some permanent environment variable on a specific machine (and not created by your script) a server response a device response anything else you can think of, as long as it's not stored in the script any combination of the above You need several scripts to get this to work, and they are scattered over several threads, so here's a single bundle that contains them all (including a patched version of Ward's AES.au3; with many thanks to Ward for allowing me to include this script here): Latest version: 3.4 (3 Dec 2021): please follow this link. Note: if you experience issues under Win8/8.1 (as some users have reported), please upgrade to Win10 (or use Win7) if you can; as far as I can tell, the scripts in the bundle all work under Win7 & Win10 (and XP). Moreover, I have no access to a Win8 box, so these issues will not be fixed, at least not by yours truly. How the bits and pieces fit together: CodeCrypter is a front-end for the MCF UDF library (you need version 1.3 or later). Its thread is here: '?do=embed' frameborder='0' data-embedContent>> The MCF package (also contained in the CodeScannerCrypter bundle) contains MCF.au3 (the library itself) plus a little include file called MCFinclude.au3. The latter you have to include in any script you wish to encrypt. Any code preceding it will not be encrypted, any code following it will be encrypted. You define the dynamic key inside MCFinclude.au3, in the UDF: _MCFCC_Init(). From the same post you can download an MCF Tutorial which I heartily recommend, because encrypting a script requires a number of steps in the right order, namely: In MCFinclude.au3, define and/or choose your dynamic key(s) (skip this step = use default setting) include MCFinclude.au3 in your target script Run CodeScanner (version 2.3+) on your target script, with setting WriteMetaCode=True (see '?do=embed' frameborder='0' data-embedContent>>), then close CodeScanner. Start CodeCrypter press the Source button to load your target file enable Write MCF0 (tick the first option in Main Settings) Enable "Encrypt" (last option in the Main Settings) Go to the Tab Encrypt and set up the encryption the way you want (skip this = use default settings) Return to Main Tab and press "Run" if all goes well, a new script called MCF0test.au3 is created in the same directory as your target. It has no includes and no redundant parts. Please check that it works as normal. (see Remarks if not) It all sounds far more complicated than it is, really. Not convinced? Check out: a simple HowTo Guide: HowToCodeCrypt.pdf an updated and extended Q & A pdf (FAQ, also included in the bundle) to help you get started:CodeCrypterFAQ.pdf For additional explanations/examples in response to specific questions by forum members (how it works, what it can/cannot do), see elsewhere in this thread, notably: Simple analogy of how it works: post #53, second part General Explanation and HowTo: post #9, 51, 75, 185/187, 196, 207, 270, 280 (this gets a bit repetitive) BackTranslation: post #179 Obfuscation: post #36 (general), 49 (selective obfuscation) Specific features and fixes: post #3 (security), 84 (redefining the expected runtime response), 169 (Curl Enum fix), 185/187 (using license keys), 194 (replacing Ward's AES UDF with different encryption/decryption calls), 251 (AV detection issue), 262 (extract key contents to USB on different target machine prior to encryption) Limitations: post #26 (@error/@extended), 149 (FileInstall), 191 (AES.au3 on x64) Not recommended: post #46/249 (static encryption), 102 (programme logic error), 237 (parsing password via cmdline) Technical notes: BackTranslation is a test to check that the MetaCode translation worked. Skip it at your peril. It also turns your multi-include composite script into a single portable file without redundant parts (you can opt to leave the redundant parts in, if you want). CodeCrypter can also obfuscate (vars and UDF names) and replace strings, variable names and UDF names with anything else you provide, for example, for language translation). After CodeScanner separates your target's structure from its contents, CodeCrypter (actually MCF, under the hood) can change any part, and then generate a new script from whichever pieces you define. See the MCF Tutorial for more explanation and examples. Encryption currently relies on Ward's excellent AES UDF and TheXman's sophisticated CryptoNG bundle. You can replace these with any other algorithm you like (but this is not trivial to do: edit MCFinclude.au3 UDF _MCFCC(), and MCF.au3 UDF _EncryptEntry(), see post #194 in this thread). AES by Ward, and CryptoNG by TheXman are also included in the bundle (with many thanks to Ward and TheXman for graciously allowing me to republish their outstanding work). Going to lie down now... RT
    1 point
  3. Check the contents of $cSavedPath&"\"&$cS_Group&"\"&$cS_Name&".ct83" Perhaps it's just full of white spaces and the edit control is being set properly.
    1 point
  4. See the output of: consolewrite(GUICtrlSetData($cVData,$cFileData1) & @crlf) Anyhow, to help you, you should post the entire code, I think there is something wrong with $GS1_TarToday
    1 point
  5. You're right, I overlooked that he said having installed the latest release. I promise to try hard not doing it again, Lord
    1 point
  6. SadBunny

    please help me

    What do you mean by "only one text"? A single letter, a single word, a single line, something else? Note that your "1" makes the system add something to whatever is in the input. If you want to change what's in that input, you'll have to replace what's in there by what you want to put in there. The most flexible one is to read what's in there (GUICtrlRead) into a variable, then do magic with that content, then put the result back in there (GUICtrlSetData). Flexible because in that way you can work with user input.
    1 point
  7. Gianni

    Connect two points with line

    .... also, from a quick search "Bresenham" within www.autoitscript.com --> within above link there are function to plot lines, circles, ellipses and Bezier segments: here a quick example of use: #cs The Beauty of Bresenham's Algorithm A simple implementation to plot lines, circles, ellipses and Bézier curves. http://members.chello.at/~easyfilter/bresenham.html #ce ; ------------------------------------------ #include <array.au3> Global $aArray[25][25] ; [x][y] 0 to 24 Global $aEmpty = $aArray plotLine(0,0,24,24) ; start y, start x , end y, end x _ArrayDisplay($aArray) $aArray = $aEmpty plotCircle(12, 12, 11) ; y center, x center, ray _ArrayDisplay($aArray) $aArray = $aEmpty ; plot an ellipse into a box plotEllipseRect(3, 1, 15, 8) ; y upleft, x upleft, y downright, x downright plotEllipseRect(1, 11, 23, 23) ; second ellipse in the same array _ArrayDisplay($aArray) $aArray = $aEmpty ; start point , curve point , end point plotQuadBezierSeg(0,0, 0,24, 24,24) ; y,x, y,x, y,x _ArrayDisplay($aArray) ; ------------------------------------------ ; Line Func plotLine($x0, $y0, $x1, $y1) Local $dx = Abs($x1 - $x0), $sx = $x0 < $x1 ? 1 : - 1 Local $dy = -Abs($y1 - $y0), $sy = $y0 < $y1 ? 1 : - 1 Local $err = $dx + $dy, $e2 ; /* error value e_xy */ While 1 ; /* loop */ setPixel($x0, $y0) If($x0 = $x1 And $y0 = $y1) Then ExitLoop ; break $e2 = 2 * $err If($e2 >= $dy) Then ; /* e_xy + e_x > 0 */ $err += $dy $x0 += $sx ; /* x step */ EndIf If($e2 <= $dx) Then ; /* e_xy + e_y < 0 */ $err += $dx $y0 += $sy ; /* y step */ EndIf WEnd EndFunc ;==>plotLine ; Circle Func plotCircle($xm, $ym, $r) Local $x = -$r, $y = 0, $err = 2 - 2 * $r ; /* II. Quadrant */ While($x < 0); Do setPixel($xm - $x, $ym + $y); /* I. Quadrant */ setPixel($xm - $y, $ym - $x); /* II. Quadrant */ setPixel($xm + $x, $ym - $y); /* III. Quadrant */ setPixel($xm + $y, $ym + $x); /* IV. Quadrant */ $r = $err; If($r <= $y) Then ; /* e_xy+e_y < 0 */ $y += 1 $err += $y * 2 + 1 EndIf If($r > $x Or $err > $y) Then ; /* e_xy+e_x > 0 or no 2nd y-step */ $x += 1 $err += $x * 2 + 1 EndIf WEnd ; While ($x < 0); EndFunc ;==>plotCircle ; Ellipse ; This function plots an ellipse inside a specified rectangle. Func plotEllipseRect($x0, $y0, $x1, $y1) Local $a = Abs($x1 - $x0), $b = Abs($y1 - $y0), $b1 = BitAND($b, 1) ; $b1 = $b & 1; /* values of diameter */ Local $dx = 4 * (1 - $a) * $b * $b, $dy = 4 * ($b1 + 1) * $a * $a ; /* error increment */ Local $err = $dx + $dy + $b1 * $a * $a, $e2; /* error of 1.step */ If($x0 > $x1) Then ; /* if called with swapped points */ $x0 = $x1 $x1 += $a EndIf If($y0 > $y1) Then $y0 = $y1 ; /* .. exchange them */ $y0 += ($b + 1) / 2 $y1 = $y0 - $b1 ; /* starting pixel */ $a *= 8 * $a; $b1 = 8 * $b * $b; While($x0 <= $x1) ; do [ setPixel($x1, $y0); /* I. Quadrant */ setPixel($x0, $y0); /* II. Quadrant */ setPixel($x0, $y1); /* III. Quadrant */ setPixel($x1, $y1); /* IV. Quadrant */ $e2 = 2 * $err; If($e2 <= $dy) Then $y0 += 1 $y1 -= 1 $dy += $a $err += $dy ; += $a; } /* y step */ EndIf If($e2 >= $dx Or 2 * $err > $dy) Then $x0 += 1 $x1 -= 1 $dx += $b1 $err += $dx ; += $b1; } /* x step */ EndIf WEnd ; while ($x0 <= $x1); While($y0 - $y1 < $b) ; [ /* too early stop of flat ellipses a=1 */ setPixel($x0 - 1, $y0); /* -> finish tip of ellipse */ $y0 += 1 setPixel($x1 + 1, $y0) ; ++); setPixel($x0 - 1, $y1); $y1 -= 1 setPixel($x1 + 1, $y1) ; --); WEnd EndFunc ;==>plotEllipseRect ; #cs ; Bézier curve ; This function plots a quadratic Bézier curve limited to gradients without sign change. Func plotQuadBezierSeg($x0, $y0, $x1, $y1, $x2, $y2) Local $sx = $x2 - $x1, $sy = $y2 - $y1; Local $xx = $x0 - $x1, $yy = $y0 - $y1, $xy; /* relative values for checks */ Local $dx, $dy, $err, $cur = $xx * $sy - $yy * $sx; /* curvature */ ; assert($xx * $sx <= 0 && $yy * $sy <= 0) ; /* sign of gradient must not change */ <--------- ? ? ? ? what's this ;If ($sx * (long) $sx + $sy * (long) $sy > $xx * $xx + $yy * $yy) Then ; { /* begin with longer part */ If($sx * $sx + $sy * $sy > $xx * $xx + $yy * $yy) Then ; { /* begin with longer part */ <--------- (Long) removed $x2 = $x0 $x0 = $sx + $x1 $y2 = $y0 $y0 = $sy + $y1 $cur = -$cur ; /* swap P0 P2 */ EndIf ; } If($cur <> 0) Then ;{ / * no straight line * / $xx += $sx ; ************************** $sx = ($x0 < $x2 ? 1 : - 1) $xx *= $sx ; = $x0 < $x2 ? 1 : -1 ; /* x step direction */ $yy += $sy $sy = ($y0 < $y2 ? 1 : - 1) $yy *= $sy ; = $y0 < $y2 ? 1 : -1 ; /* y step direction */ ; ************************** $xy = 2 * $xx * $yy $xx *= $xx $yy *= $yy ; /* differences 2nd degree */ If($cur * $sx * $sy < 0) Then ;{ /* negated curvature? */ $xx = -$xx $yy = -$yy $xy = -$xy $cur = -$cur EndIf ; } $dx = 4.0 * $sy * $cur * ($x1 - $x0) + $xx - $xy; /* differences 1st degree */ $dy = 4.0 * $sx * $cur * ($y0 - $y1) + $yy - $xy; $xx += $xx $yy += $yy $err = $dx + $dy + $xy; /* error 1st step */ While($dy < $dx) ; do { setPixel($x0, $y0); /* plot curve */ ; If ($x0 == $x2 && $y0 == $y2) Then Return; /* last pixel -> curve finished */ If($x0 = $x2 And $y0 = $y2) Then Return; /* last pixel -> curve finished */ $y1 = 2 * $err < $dx; /* save value for test of y step */ If(2 * $err > $dy) Then $x0 += $sx $dx -= $xy $dy += $yy $err += $dy ; += $yy; EndIf ; } /* x step */ If($y1) Then $y0 += $sy $dy -= $xy $dx += $xx $err += $dx ; += xx; EndIf ; } /* y step */ WEnd ;} while (dy < dx ); /* gradient negates -> algorithm fails */ EndIf ; } plotLine($x0, $y0, $x2, $y2); /* plot remaining part to end */ EndFunc ;==>plotQuadBezierSeg Func setPixel($x0, $y0); it draws a single pixel $aArray[$x0][$y0] = "*" Return EndFunc ;==>_setPixel
    1 point
  8. ripdad

    please help me

    or... #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 451, 241, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33) $Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33) $Input1 = GUICtrlCreateInput("", 112, 80, 257, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 GUICtrlSetData($Input1,"Hello", 1); <-- case $Button2 GUICtrlSetData($Input1,"World", 1); <-- EndSwitch WEnd
    1 point
  9. HotKeySet("{SPACE}", "captureSpace") Local $iTimer = TimerInit() While (True) Sleep(100) WEnd Func captureSpace() If (TimerDiff($iTimer) >= 1000) Then ConsoleWrite("More than a second passed, allowed" & @CRLF) HotKeySet("{SPACE}") Send("{SPACE}") HotKeySet("{SPACE}", "captureSpace") $iTimer = TimerInit() Else ConsoleWrite("Stop spamming space bar!" & @CRLF) EndIf EndFunc ;==>captureSpace
    1 point
  10. No need to reinvent the wheel -> quick search! #include <Array.au3> Global $aCanvas[25][12] drawBresenhamLine($aCanvas, 1, 1, 10, 21) _ArrayDisplay($aCanvas) Func drawBresenhamLine(ByRef $aArray, $iX0, $iY0, $iX1, $iY1, $bSE = True) Local $iDx = Abs($iX1 - $iX0) Local $iSx = $iX0 < $iX1 ? 1 : -1 Local $iDy = Abs($iY1 - $iY0) Local $iSy = $iY0 < $iY1 ? 1 : -1 Local $iErr = ($iDx > $iDy ? $iDx : -$iDy) / 2, $e2 Local $iSX = $iX0, $iEY = $iY0 While $iX0 <= $iX1 $aArray[$iY0][$iX0] = "*" If ($iX0 = $iX1) And ($iY0 = $iY1) Then ExitLoop $e2 = $iErr If ($e2 > -$iDx) Then $iErr -= $iDy $iX0 += $iSx EndIf If ($e2 < $iDy) Then $iErr += $iDx $iY0 += $iSy EndIf WEnd If $bSE Then $aArray[$iEY][$iSx] = "S" $aArray[$iY1][$iX1] = "E" EndIf Return 1 EndFunc ;==>drawBresenhamLine
    1 point
  11. JLogan3o13

    please help me

    Why are you bumping your post after 4 minutes? You need to wait at least 24 hours before bumping. You can do something like this: #include <GUIConstantsEx.au3> Local $sText = "" $Form1 = GUICreate("Form1", 451, 241, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 120, 136, 113, 33) $Button2 = GUICtrlCreateButton("Button2", 248, 136, 145, 33) $Input1 = GUICtrlCreateInput("", 112, 80, 257, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 $sText &= "Hello" GUICtrlSetData ($Input1, $sText) case $Button2 $sText &= " World" GUICtrlSetData ($Input1, $sText) EndSwitch WEnd
    1 point
  12. $t = DllStructCreate("byte element[1]") $t.element = 0x20 ConsoleWrite(String($t.element) & @CRLF) As I stated in post #15, it is not (instead the suspect is valid for BinaryToString function). Anyhow jchd's code is better than yours, because it uses n bytes + 4 for each block of data of n bytes, while yours uses 2 * n bytes + 3 for each block.
    1 point
  13. An implementation of what I recommended in previous post, immune to character misinterpretation: #include <Crypt.au3> #include <FileConstants.au3> Local $Encrypted = @ScriptDir & "\Encrypted.txt" Local $Decrypted = @ScriptDir & "\Decrypted.txt" Local $password = "any" _Crypt_Startup() Local $vBlock Local $hCipherText = FileOpen($Encrypted, $FO_OVERWRITE + $FO_CREATEPATH + $FO_BINARY) $vBlock = _Crypt_EncryptData("One; ", $password, $CALG_AES_256) FileWrite($hCipherText, BinaryLen($vBlock)) FileWrite($hCipherText, $vBlock) FileClose($hCipherText) $hCipherText = FileOpen($Encrypted, $FO_APPEND + $FO_BINARY) $vBlock = _Crypt_EncryptData("Two but with text longer than AES blocksize; ", $password, $CALG_AES_256) FileWrite($hCipherText, BinaryLen($vBlock)) FileWrite($hCipherText, $vBlock) FileClose($hCipherText) $hCipherText = FileOpen($Encrypted, $FO_APPEND + $FO_BINARY) $vBlock = _Crypt_EncryptData("Three.", $password, $CALG_AES_256) FileWrite($hCipherText, BinaryLen($vBlock)) FileWrite($hCipherText, $vBlock) FileClose($hCipherText) MsgBox (0,"", "Original strings have been encrypted separately, with their binary length prepended, in " & $Encrypted) Local $iFileSize = FileGetSize($Encrypted), $iBlockLength $hCipherText = FileOpen($Encrypted, $FO_BINARY) $hRecoverText = FileOpen($Decrypted, $FO_OVERWRITE + $FO_CREATEPATH) While $iFileSize > 0 $iBlockLength = Int(FileRead($hCipherText, 4)) $iFileSize -= 4 $EncryptedContent = FileRead($hCipherText, $iBlockLength) $iFileSize -= $iBlockLength FileWrite($hRecoverText, BinaryToString(_Crypt_DecryptData($EncryptedContent, $password, $CALG_AES_256))) WEnd FileClose($hRecoverText) MsgBox (0,"", "Encrypted Strings have been decrypted and re-joined in " & $Decrypted) Two points to consider: 1) this works as long as plaintext strings are less than MaxInt32 2) if you may have input strings containing Unicode characters beyond ANSI, they should be converted to UTF8 before encryption and from UTF8 after decryption.
    1 point
  14. jguinch

    change format number

    @AutoBert : yes, twice. One for the dot and one for the comma... (read the value in the OP again)
    1 point
  15. @dnszs - Autobert was giving you the definitions of click and speed settings. When you write it out it'll look like... MouseClick("right", 1782, 620, 1, 10)
    1 point
  16. ^^ AutoitObject isn't maintained. The version I tested with was compiled by @AdmiralAlkex and I think x64 version isn't working. I'm not sure if he changed some compile options or is it something else. You actually don't need AutoItObject for simple tasks like this, because ObjCreateInterface() exist for some time now, so you can write: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <string.au3> #include <array.au3> Global $tMyObject Global $g_idGUIEdit ; read html page from bottom of this script ; and write it to a file on disk CreateHtmlPage() Example() Exit Func Example() Local $hGUIMain = GUICreate("Event Test", 1000, 600) $g_idGUIEdit = GUICtrlCreateEdit("", 500, 405, 490, 175) GUICtrlSetFont(-1, 9, 400, -1, 'Courier New') GUICtrlCreateLabel("Below are some Browser events 'captured' from the above web page by AutoIt", 500, 385, 990, 20) Local $idGUIExit = GUICtrlCreateButton(" Close and exit", 5, 580, 990, 15) Local $hButton1 = GUICtrlCreateButton("Add an Item to timeline", 10, 400, 150, 40) GUISetState() ;Show GUI ; We prepare the Internet Explorer as our test subject Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 5, 5, 990, 380) ; <- embedd $oIE in the AutoIt GUI ; load our web page, javascript and css in the browser ToolTip("...downloading javascript, please wait") $oIE.navigate('file:///' & @ScriptDir & '\Page.html') Sleep(1000) ; Give it some time to load the web page ToolTip("") Do ; wait for document Sleep(250) $oDocument = $oIE.document Until IsObj($oDocument) ; https://msdn.microsoft.com/en-us/library/52f50e9t(v=vs.94).aspx ; $ohJS is a reference to the javascript Global Obj ; ------------------------------------------------- Global $ohJS = $oIE.document.parentwindow.JSglobal $ohJS.AutoIt = __ObjectFromTag("__MyInterface_", "write hresult(bstr)", $tMyObject) ; --- Setup catch of events --- ; https://msdn.microsoft.com/en-us/library/aa769764(v=vs.85).aspx ; HTMLDocumentEvents2 interface (catch OnClick, OnMouseOver, .... etc Global $oEventObject = ObjEvent($oDocument, "IEEvent2_", "HTMLDocumentEvents2") ; OK, this events are catched ; Attempt to catch events fired by the DataSet. ; items is the DataSet obj created in the Browser ;~ Global $oEventObject = ObjEvent($ohJS.items);, "OnDataSet_") ; ???? how to catch events from the DataSet <---- ????? ; ----------------------------- ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idGUIExit ExitLoop Case $hButton1 ; add a job to the timeline (a simple example just to test) ; to generate a unique ID I use the following: @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC Local $result = $ohJS.eval("items.add([{id: " & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @MSEC & ", content: '<b>item 4</b> Added at " & @HOUR & ":" & @MIN & ":" & @SEC & " ', start: '2014-01-19'}]);") ConsoleWrite("DataSet now contains " & $ohJS.items.length & " Items" & @CRLF) EndSwitch WEnd ; the end $oEventObject.Stop ; Tell IE we don't want to receive events. $oEventObject = 0 ; Kill the Event Object $oIE = 0 ; Remove IE from memory (not really necessary). ;__DeleteObjectFromTag($tMyObject) ; also not really necessary GUIDelete($hGUIMain) ; Remove GUI EndFunc ;==>Example ; --- event management zone --- ; A few Internet Explorer Event Functions ; below function are fired by events occurred in the browser Volatile Func IEEvent2_onClick($oEvent) ConsolePrint("mouse click: " & $oEvent.clientX & ',' & $oEvent.clientY & ' on ' & $oEvent.srcElement.NodeName & ' - ' & $oEvent.srcElement.ID) EndFunc ;==>IEEvent2_onClick Volatile Func IEEvent2_onDblClick($oEvent) ConsolePrint("mouse DoubleClick: @" & $oEvent.clientX & ',' & $oEvent.clientY) EndFunc ;==>IEEvent2_onDblClick Volatile Func OnDataSet_add($oEvent) ConsolePrint("!!!! event from DataSet " & IsObj($oEvent)) ; type EndFunc ;==>OnDataSet_add Func ConsolePrint($sMsg) Local Const $iMaxLines = 9 ; keep last 12 lines only $sMsg = @HOUR & ':' & @MIN & ':' & @SEC & ':' & @MSEC & @TAB & $sMsg & @CRLF $sMsg = StringReplace(GUICtrlRead($g_idGUIEdit) & $sMsg, @CR, @CR) If @extended > $iMaxLines Then ; more than $iMaxLines $sMsg = StringMid($sMsg, StringInStr($sMsg, @CR, 0, -1 * $iMaxLines) + 2) EndIf GUICtrlSetData($g_idGUIEdit, $sMsg) EndFunc ;==>ConsolePrint Func CreateHtmlPage() Local $sStart = @LF & "#cs;HTML" Local $sEnd = "#ce;HTML" & @CR Local $aArray = _StringBetween(FileRead(@ScriptFullPath), $sStart, $sEnd) Local $sPage = @ScriptDir & '\Page.html' Local $hFile = FileOpen($sPage, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) FileWrite($hFile, $aArray[0]) FileFlush($hFile) FileClose($hFile) EndFunc ;==>CreateHtmlPage Func __ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ; last param is IID_IUnknown by default If $bIsUnknown = Default Then $bIsUnknown = True Local $sInterface = $tagInterface ; copy interface description Local $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _ "AddRef dword();" & _ "Release dword();" ; Adding IUnknown methods If $bIsUnknown Then $tagInterface = $tagIUnknown & $tagInterface ; Below line is really simple even though it looks super complex. It's just written weird to fit in one line, not to steal your attention Local $aMethods = StringSplit(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($tagInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), @LF, 3) Local $iUbound = UBound($aMethods) Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback ; Allocation $tInterface = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[" & $iUbound & "];int_ptr Callbacks[" & $iUbound & "];ulong_ptr Slots[16]") ; 16 pointer sized elements more to create space for possible private props If @error Then Return SetError(1, 0, 0) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] ; Replace COM types by matching dllcallback types $sTagPart = StringReplace(StringReplace(StringReplace(StringReplace($aSplit[1], "object", "idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr") $sMethod = $sFunctionPrefix & $sNamePart $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringReplace($sTagPart, $sRet, "", 1) $sParams = "ptr" & $sParams $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle Next DllStructSetData($tInterface, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tInterface, "Size", $iUbound) ; number of interface methods DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), $sIID, $sInterface, $bIsUnknown) ; pointer that's wrapped into object EndFunc Func __DeleteObjectFromTag(ByRef $tInterface) For $i = 1 To DllStructGetData($tInterface, "Size") DllCallbackFree(DllStructGetData($tInterface, "Callbacks", $i)) Next $tInterface = 0 EndFunc Func __MyInterface_QueryInterface($pSelf, $pRIID, $pObj) Local $tStruct = DllStructCreate("ptr", $pObj) DllStructSetData($tStruct, 1, $pSelf) Return 0 ; $S_OK EndFunc Func __MyInterface_AddRef($pSelf) Return 1 EndFunc Func __MyInterface_Release($pSelf) Return 1 EndFunc volatile Func __MyInterface_write($pSelf, $pString) ConsolePrint(DllStructGetData(DllStructCreate("wchar[" & DllStructGetData(DllStructCreate("dword", $pString - 4), 1) / 2 & "]", $pString), 1)) Return 0 ; $S_OK EndFunc #cs;HTML <!DOCTYPE HTML> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script type="text/javascript"> var JSglobal = (1,eval)("this"), AutoIt; </script> <style type="text/css"> body, html { font-family: arial, sans-serif; font-size: 11pt; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.16.1/vis.min.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="visualization" style="border-width:3px; border-color:yellow; border-style:double;"></div> <p></p> <div id="log"></div> <script type="text/javascript"> // DOM element where the Timeline will be attached var container = document.getElementById('visualization'); // Create an empty DataSet (allows two way data-binding) var items = new vis.DataSet({type: { start: 'ISODate', end: 'ISODate', notes: '' }}); // items.addEventListener('click',resetElements,true); // add items to the DataSet items.add([ {id: 1, content: 'item 1 <b>start</b>', start: '2014-01-23'}, {id: 2, content: 'item 2', start: '2014-01-18 00:00', end: '2014-01-18 23:59'}, {id: 3, content: 'item 3', start: '2014-01-21'}, {id: 5, content: 'item 5', start: '2014-01-28', type:'point'}, {id: 6, content: 'item 6', start: '2014-01-26'} ]); // Configuration for the Timeline var options = {orientation: 'top', editable: { add: true, remove: true, updateTime: true, updateGroup: true } }; // Create a Timeline var timeline = new vis.Timeline(container, items, options); // turn events on timeline.on('rangechange', function (properties) { logEvent('rangechange', properties); }); timeline.on('rangechanged', function (properties) { logEvent('rangechanged', properties); }); timeline.on('select', function (properties) { logEvent('select', properties); }); items.on('*', function (event, properties) { logEvent(event, properties); }); function logEvent(event, properties) { var log = document.getElementById('log'); var msg = document.createElement('div'); msg.innerHTML = 'event=' + JSON.stringify(event) + ', ' + 'properties=' + JSON.stringify(properties); log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg); AutoIt.write(msg.innerHTML); } </script> </body> </html> #ce;HTML ;
    1 point
  17. Here is the whole potato...Get FTP Server file names into a single dimension array, count the number of files, and download them. I like .ini files so here is the one I used. <instructions go here> ...THIS WILL OVERWRITE EXISITING FILES WITHOUT WARNING...look closely at the settings below... <end instructions> [SERVER] Server=upload.comcast.net UserName=************* Password=************** FileFolder=WorkFolder/Projects/ FileMask=*.* LocalFolder=C:\WorkFolder\Projects [BATTLE] ShowFileCount=7 #include <C:\program files\autoit3\include\Ftp.au3> #include <C:\program files\autoit3\include\Array.au3> ; lets read in values and settings needed for FTP operations $FTPconfig = "FTP_DL.ini" $FTPserver = IniRead($FTPconfig, "SERVER", "Server", "NotFound") $FTPuser = IniRead($FTPconfig, "SERVER", "UserName", "NotFound") $FTPpass = IniRead($FTPconfig, "SERVER", "Password", "NotFound") $FTPfolder = IniRead($FTPconfig, "SERVER", "FileFolder", "NotFound") $FTPfilemask = IniRead($FTPconfig, "SERVER", "FileMask", "*.*") $LocalFolder = IniRead($FTPconfig, "SERVER", "LocalFolder", "NotFound") $FileCount = IniRead($FTPconfig, "BATTLE", "ShowFileCount",5) If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else MsgBox(4096, "in-the-blind FTP file download", "FTP Server: " & $FTPserver & @CRLF & "UserName: " & $FTPuser & @CRLF & "Password: " & $FTPpass & @CRLF & "From FTP Path: " & $FTPfolder & @CRLF & "To Local Path: " & $LocalFolder) EndIf ; setup FTP Operations $dllhandle = DllOpen('wininet.dll') $Open = _FTPOpen('ftp'); I roll with Comcast so this is all I need here $Conn = _FTPConnect($Open, $FTPserver, $FTPuser, $FTPpass) Dim $Handle Dim $DllRect $l_Flags = 2; Binary Download mode $l_Fail = 0; Overwite local files is OK $l_Attributes = 0; I don't know what this is for $l_Context = 0; no callbacks required $i=1 Dim $dl_file[2]; there are more files on the FTP server right now--the array can grow larger as needed ;lets create a single dimension array with file names from the FTP Server $FileInfo = _FtpFileFindFirst($Conn, $ftpfolder & $ftpfilemask, $Handle, $DllRect) If $FileInfo[0] Then Do $dl_file[$i] = $FileInfo[10] $FileInfo = _FtpFileFindNext($Handle, $DllRect) Redim $dl_file[UBound($dl_file,1)+1] $i = $i + 1 Until Not $FileInfo[0] EndIf ; need to delete the last {empty} element Redim $dl_file[UBound($dl_file,1)-1] ; store the file count in element [0] of the array holding the file names $dl_file[0] = UBound($dl_file)-1 _ArrayDisplay($dl_file,"FTP Server Files") ; now to download the files $i=1 For $i = 1 to $FileCount; or you can use $dl_file[0] if you want to download everything $file_dl = $dl_file[$i] $FTP_DL = _FTPGetFile($Conn, $ftpfolder & $file_dl, $LocalFolder & "\" & $file_dl, $l_Flags, $l_Fail, $l_Attributes, $l_Context) Next ; close up resources used _FtpFileFindClose($Handle, $DllRect) _FTPClose($Open) DllClose($dllhandle) MsgBox(0,"FTP Server Download","Download Complete --> " & $dl_file[0] & " files should be there") Tomorrow, I will reverse the process...Upload from local computer to FTP server.
    1 point
×
×
  • Create New...