Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/20/2013 in all areas

  1. Shaggi

    Console.au3 UDF

    Sup, This isn't really an advanced UDF, but implements a couple of functions and features, with the idea of substituting the original functions like ConsoleWrite() and ConsoleWriteError() and the seriously sketchy ConsoleRead() lol. Public functions: Cout()Cin()Getch()Cerr()system()RegisterConsoleEvent()The motive for writing this was the missing ability to read user input from consoles in AutoIt, known as std::cin >> in C++. The UDF's design allows quick and simple access to the functions, without startup / shutdown and handle passing - all this is automatically taken care of. Some users may have know, that you cannot open a console if the script is running from SciTE - this UDF handles that problem, so you can open an console while running scripts through SciTE. Features: Dynamically opens and closes consolesUse the STDOUT, STDERR and STDIN streams like in other languages.Print coloured/styled textAccess the command interpreter through the console.Uses unicode.Register console events.The UDF is designed to work standalone and to have minimal overhead (> 0.1 ms for writing a coloured string)The UDF supports my style of scripting. I hate long names so standard UDF naming like _Console_WriteConsoleW() is abbreviated to Cout() for now. I also hate having to start up certain UDF's by calling funcs etc., so this is handled first time you call a function. Handles are controlled globally and closed when needed, so you don't need to pass them around lol. Why would anyone need this? Good question. I guess this mainly goes out to people with a bit of nostalgia in them. I personally like the feel of a console. Picture: Changelog: 25-06-2012 Fixed system() to allow case sensitive text.25-06-2012 Fixed typo's.Changed frequent dllcalls to use dllcalladdress for speed.Added RegisterConsoleEvent - functions can be registrered to be called on certain events, like closure of console. This can be used to mimic OnAutoItExit behaviour, that wont be called in case of bad closure.Various optimizations.09-07-2011 Added Getch() function.Better error handling all around.Put back color attribute constants as they are more symbolic imo.Decreased the standard size of Cin allocation (bit harsh to allocate 2 kb memory each time) - it's now changed to 128 chars.05-06-2011 Added color constants thanks to Warmonger.16-03-2011 Fixed Cin() bug.Cin() isn't returning a trailing CRLF anymore.Fixed startup function, so it should run from SciTE now.15-03-2011 - Initial release.NotesI know Matt Diesel was/is working on large, similar UDF, however i wanted something simpler and easier to use. This is the result. Thoughts? Console.au3
    1 point
  2. willichan

    Continue after reboot

    I have seen a few requests for the ability to continue a script after a reboot. I do this all the time, especially during holiday shutdown each year when I have a laundry list of tasks to perform on all systems. I have had as many as 40+ tasks, many of which reboot themselves, or won't continue if they see another installation that has not reboot yet (gotta love Microsoft). Here is the shell script that I used to get it done. Version 1 ------ Here's my new version. Some people had trouble remembering not to skip numbers, or to keep them in order, so this one puts it all in an array, so you don't have to manually keep track of task IDs. Version 2 ------ MSUpdates Module --Edit-- Added Version 2 of script modified log path in Version 2 (see posts 5&6) Added MSUpdates module
    1 point
  3. This is a equivalent to the LogicalBitShift() function: For $i = 0 To 32 ConsoleWrite(Int(-1 * 0x80000000 / (2^$i)) & @LF) Next Br, UEZ
    1 point
  4. You could copy the file in question to another folder, and then check to see if it's been changed, if it has, replace it with the back up file. Look at FileCopy, FileGetTime, or to be really sure it hasn't changed look at _Crypt_HashData and compare the file hashes to each other.
    1 point
  5. 1 point
  6. Melba23

    TRYING TO Freeze FILE..?

    notime, Remember being told not to use bold font yesterday? Well, here is today's reminder - please STOP IT! And what is this "Deep Freeze" that you speak of? M23
    1 point
  7. Define freeze, as in what exactly are you trying to do to this file. Also, is there a problem with your Shift key? You keep randomly capitalizing letters where they shouldn't be capitalized.
    1 point
  8. 1 point
  9. ohhhhhhhhh yeah ! Thanks again
    1 point
  10. #include <File.au3> $file_database = @ScriptDir & "\email_database.txt" $file_found = @ScriptDir & "\found_email_database.txt" Global $open_file_found = FileOpen($file_found, 1) Local $found_email_number = 0 For $i = 0 To _FileCountLines($file_database) $line = FileReadLine($file_database, $i) If StringInStr($line, "@gmail") Then $found_email_number += 1 FileWriteLine($open_file_found, $line) EndIf Next FileClose($open_file_found) If $found_email_number > 0 Then MsgBox(0, "Done", "Found " & $found_email_number & " email.") Else MsgBox(0, "Error", "No email found.") EndIf Tested and working well. Hi!
    1 point
  11. Perhaps something like this: For $i = 0 To 32 ConsoleWrite(LogicalBitShift(0x80000000 ,$i) & @LF) Next Func LogicalBitShift($dVal, $iShift) If $iShift > 0 And BitAND($dVal, 0x80000000) = 0x80000000 Then $dVal = BitShift($dVal, 1) $dVal = BitXor($dVal, 0x80000000) $iShift -= 1 EndIf Return BitShift($dVal, $iShift) EndFunc
    1 point
  12. Most of the tools need you to have a file saved as a *.au3 file before you can activate them, even if the file is empty as long as it's been saved the tools show up in the Tools menu.
    1 point
  13. Juvigy

    Excel worksheet copy

    Small example from me: $sFile2 = "11.xls" $sFile1 = "22.xls" $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.WorkBooks.Open("c:\11.xls") $oExcel.WorkBooks.Open("c:\22.xls") $oExcel.Application.Workbooks($sFile1).Sheets("Sheet1").Select ;or you acn use sheet number $oExcel.Application.Workbooks($sFile1).Sheets(1).Select $oExcel.Application.ActiveWorkbook.Sheets("Sheet1").Copy(Default, $oExcel.Application.Workbooks($sFile2).Sheets("Sheet1")) You can easily modify it.
    1 point
  14. Jos

    Continue Script after reboot

    here is a model script I use for installs that take multiple reboots and requier elevated rights: ; pgm name DEMO.AU3 $Userid = "Administrator" $Psw = "adminpsw" ; Remove autologin params from registry to clean up SetAutoLogon("Off", "") ; ; retrieve param $param1 = "" If $CmdLine[0] > 0 Then $param1 = $CmdLine[1] EndIf ; Act on it Select Case $param1 = "" ; run your programs with admin account if needed in the first step RunAsSet($Userid, @ComputerName, $Psw) ; ; *** put your stuff here for step1 *** RunWait("notepad.exe step1.txt") ; SetAutoLogon("On", "step1") Shutdown(6) Case $param1 = "step1" ; is already logged on with admin account ; ; *** put your stuff here for step2 *** RunWait("notepad.exe step2.txt") ; SetAutoLogon("On", "step2") Shutdown(6) Case $param1 = "step2" ; logoff the admin account ; *** put your stuff here for step3 *** RunWait("notepad.exe step3.txt") ; just logoff Shutdown(0) Exit EndSelect Exit ; ; Func SetAutoLogon($sw, $step) If $sw = "On" Then ; set the registry to start this program again after reboot RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "Demo", "REG_SZ", @ScriptFullPath & " " & $step) RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AutoAdminLogon", "REG_SZ", "1") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultDomainName", "REG_SZ", EnvGet("LOGONSERVER")) RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", $Userid) RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", $Psw) EndIf ; If $sw = "Off" Then ; Remove the registrykey to start this program again after reboot RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "Demo") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "AutoAdminLogon", "REG_SZ", " ") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultDomainName", "REG_SZ", " ") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultUserName", "REG_SZ", " ") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\", "DefaultPassword", "REG_SZ", " ") EndIf EndFunc ;==>SetAutoLogon
    1 point
×
×
  • Create New...