Jump to content

Recommended Posts

Posted (edited)

Hi ppl, just made this simple one because sometimes i want to access the wallpaper directory to do some modifications on wallpapers, and in win 7 it's not as easy to go there as i would likem so i made this simple script, got any sugestions of improvement? They're welcome.

So here it goes, execute to open dir where the wallpaper you have displayed is:

#include <File.au3>
Local $Path, $szDrive, $szDir, $szFName, $szExt, $TestPath
$Path = RegRead("HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerDesktopGeneral", "WallpaperSource")
$TestPath = _PathSplit($Path, $szDrive, $szDir, $szFName, $szExt)
$Path = $szDrive & $szDir
;MsgBox(4096, "", $Path, 10)
ShellExecute ($Path)

Hope you like it and that it may become useful for someone.

EDIT: Removed the brackets as pointed out by guinness. Thanks, forgot that one.

AutoIt Wallpaper.au3

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

Local $sFilePath = RegRead('HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerDesktopGeneral', 'WallpaperSource')
$sFilePath = StringLeft($sFilePath, StringInStr($sFilePath, '', 2, -1) - 1)
MsgBox(4096, '', $sFilePath)
Ideally folders shouldn't return with a at the end, similar to how Windows and AutoIt macros are e.g. @ScriptDir.

Also you don't need to put brackets around variables e.g. $Path = ($szDrive & $szDir) should be $Path = $szDrive & $szDir

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Or a regular expression version (as I know you appreciated this last time.)

Local $sFilePath = RegRead('HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerDesktopGeneral', 'WallpaperSource')
$sFilePath = StringRegExpReplace($sFilePath, '^(.*).*', '1')
MsgBox(4096, '', $sFilePath)
Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Thank you Guinness, much simpler code, i couldn't find another way to do this, so i used that somewhat unnecessarily complicated way, get all bits individually, and then add just the ones i needed.

Your codes however puzzled me a bit, and i know this isn't the help section, but a small explanation would be appreciated. :)

$sFilePath = [url="http://www.autoitscript.com/autoit3/docs/functions/StringLeft.htm"]StringLeft[/url]($sFilePath, [url="http://www.autoitscript.com/autoit3/docs/functions/StringInStr.htm"]StringInStr[/url]($sFilePath, '', 2, -1) - 1)

Let's see if i get it, "StringLeft", dont know why. "StringInStr", check the string, search for "", 2 = not case sensitive, -1 = find first "" from right to left, then another -1 that i dont know what it does, but is related to the start position of the search, and "count" is left out. So it checks if there is a bracket in the Left part of the string?

$sFilePath = [url="http://www.autoitscript.com/autoit3/docs/functions/StringRegExpReplace.htm"]StringRegExpReplace[/url]($sFilePath, '^(.*).*', '1')

So in here we check the string, and look for the extension part, and replace by "1" ?

I gotta go learn more about these, but as i said before, im kinda newbie in this, and sometimes i dont quite get what to do with the examples in the help file.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

Look at StringInStr again in the help file, -1 starts looking from the right, default is left. StringInStr returns the location of the end , so StringInStr(...) - 1 is basically to trim the trailing . The help file does explain all this.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Ok Thank you Guinness, you, Sir. are very helpful.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

  On 10/18/2012 at 10:07 PM, 'careca said:

Ok Thank you Guinness, you, Sir. are very helpful.

One can only try to be.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
×
×
  • Create New...