14 posts in this topic
By Kevin Finnegan
Long time lurker and now forum poster! I'm writing a relatively simple backup script for my firm that automates the copy, compression and organization of Leaver's data on one of our secured NAS systems. I personally found the best method to do this so far was to use 7zG.exe (GUI version of 7Zip which can use command-line too) and it functions quite well!
I would like to retrieve more info on whether any warnings or errors happen in 7Zip during the backup, but I can't quite get my head around the syntax and switches for reading out, it seems any adjustment I make to the RunWait call's string seems to break the backup or give unexpected repercussions! Hopefully its something silly I'm doing as I don't code very often.
Here is the working version:
; Compress the directories one by one in the zip using the listfile.... Local $iPID = RunWait(@ScriptDir & "\bin\7zG.exe a -mx" & $compressionQuality & " -v" & $compressSplitFileSize & " -wc:\temp " _ & $backupToLocation & "\" & $userDirectory & ".7z @bin\listfile.txt -x@bin\excludefile.txt", "", @SW_SHOWDEFAULT, $STDOUT_CHILD) Ultimately I would love to switch entirely to 7za.exe (standalone) so that I can read the progress percentage, current file being uploaded and any warnings or errors could be processed and output to the AutoIT script's GUI I've created rather than jumping in and out of two applications per se.
I'm trying to script an ellipse drawing algorithm in AutoIT for learning purposes.
I use an edit control to "draw" the ellipse with characters.
The code i have works kinda good but i would like to see if others around here know a better algorithm to do it..
I would like to be able to give the x, y and width, height arguments to the function and not have to start at the middle point and draw the ellipse around it.
side note, the ellipse glitches when it has to be 2 pixels high too..
func ellipsePlotPoints ($xc,$yc, $x,$y) pixel ($xc + $x, $yc + $y) pixel ($xc - $x, $yc + $y) pixel ($xc + $x, $yc - $y) pixel ($xc - $x, $yc - $y) endfunc func ellipse($xc,$yc, $a,$b) local $a2 = $a * $a local $b2 = $b * $b local $twoa2 = 2 * $a2 local $twob2 = 2 * $b2 local $p local $x = 0 local $y = $b local $px = 0 local $py = $twoa2 * $y ; Plot the initial point in each quadrant. ellipsePlotPoints ($xc,$yc, $x,$y) ; Region 1 $p = int($b2 - ($a2 * $b) + (0.25 * $a2)) while ($px < $py) $x+=1 $px += $twob2 if ($p < 0) then $p += $b2 + $px else $y-=1 $py -= $twoa2 $p += $b2 + $px - $py endif ellipsePlotPoints ($xc,$yc, $x,$y) wend ; Region 2 $p = int ($b2 * ($x+0.5) * ($x+0.5) + $a2 * ($y-1) * ($y-1) - $a2 * $b2) while ($y > 0) $y-=1 $py -= $twoa2 if ($p > 0) then $p += $a2 - $py else $x+=1 $px += $twob2 $p += $a2 - $py + $px endif ellipsePlotPoints ($xc,$yc, $x,$y) wend endfunc
I have a bit of code that works on my old Win10 PC, that fails on my new Win10 PC, and I think the only significant difference is the version of Autoit - old PC has 3.3.12, new has 3.3.14.
I couldn't find anything mentioned in the change logs though, so perhaps I'm wrong.
Anyway, the code to replicate my issue is:
Test('username', 'DOMAIN') ; THIS ERRORS: ;Test('localun', 'DOMAIN') ; THIS ERRORS: ;Test(' ', ' ') ; THIS ERRORS: ;Test('', '') ; THIS ERRORS: ;Test('localun', '') ; THIS ERRORS: ;Test('', 'DOMAIN') Func Test($un, $dom) $compName = 'PCNAME' $FullName = '.' $Description = '.' ; get the WIM object $objWMIService = ObjGet("winmgmts:\\" & $compName & "\root\cimv2") ; get default user full name and description $objAccount = $objWMIService.Get("Win32_UserAccount.Name='" & $un & "',Domain='" & $dom & "'") If IsObj($objAccount) Then $FullName = $objAccount.FullName $Description = $objAccount.Description EndIf ConsoleWrite($FullName & @CRLF) ConsoleWrite($Description & @CRLF) Return EndFunc
On my old PC this code will output just . and . for each of those line currently commented out. Which is fine.
On my new PC any of those commented out lines of code cause an error, and the script won't even compile.
$objAccount = $objWMIService.Get("Win32_UserAccount.Name='" & $un & "',Domain='" & $dom & "'") $objAccount = $objWMIService^ ERROR I'm very much a newb with the WMI stuff and objects, but it looks like the .Get property is failing when either $un or $dom aren't valid in v3.3.14, whereas in 3.3.12 the .Get would fail to return an object, which is then caught by the If statement.
Am I on track with this? Is there some new/better way to code the example so that 3.3.14 will compile it?
Ich hab ein Script für Windows Updates, dass nach dem OOBE aufgerufen werden soll. Run/RunOnce ist daher nicht möglich.
Stattdessen möchte ich das Script in den Autostart schreiben lasse. Wenn die OOBE beendet wird und der Administrator angemeldet wird, soll das Update-Script einmalig aufgerufen werden und sich anschl. selbst löschen.
Lang rede, kurzer Sinn:
Wie kann ich folgendes Script in den Autostart schreiben?
RunWait(@ComSpec & " /c " & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\UA\Scripts\win-updates.ps1 -MaxUpdatesPerCycle 100 -RestartRequired 1", "") Ich würde ungern eine BAT oder EXE reinkopieren, da ich es unsauber finde. Die müsste ja auch zusätzlich irgendwo liegen.
Good morning everyone
I worked a bit on a little project of mine, and I managed to do what I was trying to do, or, automate a quiz in AutoIt.
Now, everything works fine but, in order to achieve what I'm trying to achive, I'd like to make this script run faster.
I'll attach a portion of the code in order to let you understand what my script does.
$objIE_h1 = _IETagNameGetCollection($objIE, "h1") ; Take the text of the answer If @error Then ConsoleWrite("Errore durante la lettura degli h1 nella pagina. - Errore: " & @error & @CRLF) Else For $objElement In $objIE_h1 $strInnerText = $objElement.innerText Next Select Case StringInStr($strInnerText, "QUESTION") ; Here is the question ; PS4 PRO $objSpans = _IETagNameGetCollection($objIE, "span") ; Answers are stored here For $objElement In $objSpans If $i >= 4 Then $strAnswer = $objElement.innerText ; Take the text of the answer n° 0, 1, 2, 3 If StringInStr($strAnswer, "CORRECT ANSWER") Then ; If I match the correct answer, then, I have to click on the input with answer id = answer_i $j = $i - 4 $objInput = _IEGetObjById($objIE, "answer_" & $j) If @error Then ConsoleWrite("Errore durante la lettura della risposta #" & $i & " - Errore: " & @error & @CRLF) Else _IEAction($objInput, "click") If @error Then ConsoleWrite("Errore durante il click sull'elemento. - Errore: " & @error) Else ConsoleWrite($j & ") Risposta: " & $strAnswer & @CRLF) ExitLoop EndIf EndIf EndIf $i+=1 Else $i+=1 EndIf Next $i = 0 $j = 0 This is what my script does.
Questions are 20, in which I have 15 multiple choice question, 2 images ( on which I use _IEImgClick() ), and 3 text inputs ( a simple send with the text I have to enter ).
How can I make all of these, faster?
If I reach this goal, I've probably done one of my best goals in life, and I'd like to share my happiness with you, giving a huge donation to this fantastic community!
Thanks for your help