Sign in to follow this  
Followers 0
redndahead

Winbatch Vs Autoit Functions

4 posts in this topic




Au3's Round() is not the same as ceil or floor. To simulate Ceil(), use Int

$x = -Int(-$x)

To simulate Floor() use Int() instead.

$x = Int($x)

The keyword is ContinueLoop, not Continue, in AutoitV3.

Debug( mode [, init-string]) Turns the Debug mode on or off.

DebugData( string, string )    Writes data via the Windows OutputDebugString function to the default destination.

DebugTrace( mode, filename)    Creates and writes a line by line debugging file of each statement executed in a script.

Working on it :whistle:

For Decimals( #digits ), Round can specify the number of decimal places.

For DirChange(), use FileChangeDir().

For DirHome( ), use @HomeDrive and @HomePath

For DirGet(), use @WorkingDir instead.

For DiskInfo(), maybe use DriveGetType()?

for DisplayText(), maybe add TrayTip()

For FileRename(), use FileMove()

Don't some of the new features of WinGetTitle() do what FindWindow() does?

For GetExactTime, use TimerStart()/10

Goto was replaced with the selection structures as well as the loops.

For IsDefined(), use the new IsDeclared().

For LastError(), use @Error

Parts of MousePlay() can be handled by MouseMove()

For StrTrim(), use StringStripWS() instead.

For TimeWait(), shouldn't Sleep() also be in the list?

For WallPaper(), a UDF could do the same thing. (Give me a couple of minutes) B)

Yields is not necessary as it happens at the end of every line. (Not needed)


David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

For the wallpaper, it is easy to chance via registry, but it doesn't referesh until you open and close display properties, or reboot, so I ended up with some thing like this for a random wallpaper changer from my P drive:

It works, but is a bit slow. Envupdate() doesn't refresh it btw.

side note, I made a shortcut link to the display window, to ease in opening it. (C:\MYDISP~1.LNK)

AutoItSetOption("TrayIconHide", 1)
WinClose("wallpaper changer") 
AutoItWinSetTitle ("wallpaper changer") 
AutoItSetOption("ExpandEnvStrings", 0);1 = expand environment variables (similar to AutoIt v2)
AutoItSetOption("MouseCoordMode", 0);1 = absolute screen coordinates (default)
AutoItSetOption("PixelCoordMode", 0);1 = absolute screen coordinates (default)
AutoItSetOption("RunErrorsFatal", 0);0 = silent error (@error set to 1)
AutoItSetOption("SendKeyDelay", 10);Time in millseconds to pause (default=10).
AutoItSetOption("WinWaitDelay", 0);Time in millseconds to pause (default=250).
AutoItSetOption("WinDetectHiddenText", 0);1 = Detect hidden text
AutoItSetOption("WinTitleMatchMode", 1);2 = Match any substring in the title
$name2=1
$name=RegRead("HKEY_CURRENT_USER\Control Panel\desktop", "Wallpaper" ) 
clipput($name)
$file1 = "P:\"&FileFindFirstFile("P:\*.jpeg")
$y=Random( 0,71 )
for $x=0 to $y 
    If $y=0 Then 
  $file=$file1
  MsgBox(1,"wow","")
  ExitLoop
    EndIf
$file = "P:\"&FileFindNextFile("P:\*.jpeg")
if $file=$name then
$name2="P:\"&FileFindNextFile("P:\*.jpeg")
RegWrite("HKEY_CURRENT_USER\Control Panel\desktop", "Wallpaper", "REG_SZ", $name2)
EnvUpdate ( ) 
;msgbox(1,$name,$name2)
;exit
endif
next
RegWrite("HKEY_CURRENT_USER\Control Panel\desktop", "Wallpaper", "REG_SZ", $file)
Run(@ComSpec& " /c C:\MYDISP~1.LNK","",@SW_HIDE)
AutoItSetOption("MouseCoordMode", 0)
winwaitactive("Display Properties")
winwaitactive("Display Properties", "Themes")
ControlCommand ( "Display Properties", "", "SysTabControl321", "TabRight", "") 
winwaitactive("Display Properties", "List Of backgrounds")
winactivate("Display Properties")
while winactive("Display Properties")
winactivate("Display Properties")
sleep(5)
ControlClick ( "Display Properties", "List Of backgrounds", "Button4") 
wend
AutoItSetOption("MouseCoordMode", 1)
MouseMove($oldmouse[0],$oldmouse[1],0)
clipput($file)

BTW, doing a great job with this.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Thanks for the info I will add some of it later on when I have time. Certainly not today I start school at 9 and then work then on till 8:30 without a break. Yikes... I need to sit with my wife who is on bed rest for a bit. :whistle:

For Decimals( #digits ), Round can specify the number of decimal places.

This is meant more of showing how many decimal places. So to add zeros or to cut off numbers without rounding.

so If you wanted 1.1234567 to be to 5 decimal places it would show 1.12345

For DirChange(), use FileChangeDir().

This is a WinBatch Specific function. Winbatch doesn't use in there run a working directory. This is how you set a global working directory for the script. In our case we just set the directory in the run path.

For DirHome( ), use @HomeDrive and @HomePath

Again this one is different. It is the location that WinBatch is Installed.

For DirGet(), use @WorkingDir instead.

Again look at DirChange answer it is for that.

For DiskInfo(), maybe use DriveGetType()?

The type of info that it gives is not what DriveGetType gives.

for DisplayText(), maybe add TrayTip()

This is just a msgbox with a timeout variable. Or maybe a splashscreen

For FileRename(), use FileMove()

At best this is a UDF. They use the ability to get the info from a delimited list of values.

Don't some of the new features of WinGetTitle() do what FindWindow() does?

Yeah I think Larry sent me this one, but I havn't had time to look at what all the new features of WinGetTitle( ) are. B)

For GetExactTime, use TimerStart()/10

I thought timer start was a timer? This is more of the exact time of day it is.

Goto was replaced with the selection structures as well as the loops.

Yeah didn't explain it well but I will change it.

For IsDefined(), use the new IsDeclared().

Hmm I thought I changed this...Oh well I will do it again when I have time.

For LastError(), use @Error

Yes and no. Last error is more of a variable that is set by the user...It is a little different because @Error can be set by any function. Maybe I will have to read the description again of LastError( ).

Parts of MousePlay() can be handled by MouseMove()

That is why it is listed as a UDF. Because it will take more than one line of code.

For StrTrim(), use StringStripWS() instead.

Ahh didn't see the blanks portion. Thanks will do.

For TimeWait(), shouldn't Sleep() also be in the list?

I think you were off a row. :angry: This is set as a UDF.

For WallPaper(), a UDF could do the same thing.

Yes I will change to a UDF.

Yields is not necessary as it happens at the end of every line.  (Not needed)

This is more of a WinBatch Specific Function. Not necessary for our usage. It mainly counters another function that takes up sole processing power.

Thanks for all the info.

red

Share this post


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
Sign in to follow this  
Followers 0