Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Crazy Scripting : Hot Wallpaper Selector!


  • Please log in to reply
12 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Hot Wallpaper Selector!

Posted Image

Download : GUI@.exe [191k]

- Right now only BMP files can be used with this.
- Run it, and click on a thumbnail, the wallpaper will be set.
- By default it displays BMP pictures in Windows directory: C:\Windows
- You can pass a filepath parameter pointing to a different directory like:
Run, GUI@.exe "G:\Wallpaper" ; no trailing slash!!!

Regards, :)

Edit: Source code is below : http://www.autohotke... ... 4808#84808

This topic is related to - TipsNTricks: How to programmatically Tile/Cascade windows ?
kWo4Lk1.png

.AHK
  • Members
  • 657 posts
  • Last active: Nov 27 2008 04:10 AM
  • Joined: 26 Apr 2006
I like how the Selector GUI looks. Goyyah did you use the image resize option provided in AHK or some other method? Each image is a separate GUI right? I'm interested in knowing how you setup the layout like that. Does the script modify registry or use external DLL's?

By the way, could you provide a link to the script? Thanks.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Nice choice of wallpapers...
I didn't tried, because I already have an automatic wallpaper randomizer...
Just a remark: the path display doesn't look like useful (being all the same), perhaps you should use only the file name.
"no trailing slash!!!"... detect it and remove it if needed! :-)
What are the limits on wp number? Does it scroll or page?
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
ImageFilePath = %1%
IfEqual, ImageFilePath,, SetEnv,ImageFilePath,%A_WinDir%
Gui, Margin, 0, 0
Gui +LastFound
Loop, %ImageFilePath%\*.bmp 
  Gui, Add, Picture, x+1 w90 h-1 +0xCF0000 -0x80000 gSelect, %A_LoopFileLongPath%
Gui, Show, w640 h700 +Hide
DllCall( "TileWindows", uInt,WinExist(), Int,1, Int,0, Int,0, Int,0 )
Gui, Show, AutoSize, Hot Wallpaper Selector! Click on a thumbnail to select!
Return

Select:
MouseGetPos,,,,ClassNN,1
GuiControlGet, FileName,, %ClassNN%
 DllCall( "SystemParametersInfo", Int,20, Int,0, Str,FileName, Int,1 ) 
Return

GuiClose:
 ExitApp
Believe it.. Thats the code ... Hail Laszlo! :D

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear .AHK, :)

I like how the Selector GUI looks.

Thanks! :D

Goyyah did you use the image resize option provided in AHK or some other method?


No, this is different!

Each image is a separate GUI right?

No! Just seperate picture controls!

I'm interested in knowing how you setup the layout like that. Does the script modify registry or use external DLL's?
By the way, could you provide a link to the script? Thanks.

Sure.. I have posted the code :)

Regards, :)



Dear PhiLho, :)

Those are picture controls as you can see from the code..

Just a remark: the path display doesn't look like useful (being all the same), perhaps you should use only the file name.

I guess that can be done only with WinSetTitle!

"no trailing slash!!!"... detect it and remove it if needed!

That would result in 10% increase in the code size! ;)

What are the limits on wp number?

You have to tell me that! :roll: .. er.. I do not understand!

Does it scroll or page?

User32.dll\TileWindows tiles those controls within the GUI rectangle. While testing I found that 10-50 windows look good!

Do comment on the code! :D

Regards, :)


PS: This topic is related to - TipsNTricks: How to programmatically Tile/Cascade windows ?

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
wp = wallpaper...

I see, you use some clever tricks to let Windows and AHK do most of the hard job. Thus, you are more or less stuck with the long path in the title of each image.

I didn't knew you can add a title bar to a picture. You should explain what are the options you change: +0xCF0000 -0x80000
Analyzing this manually is annoying and prone to error (same values, different constants).

Likewise, I didn't knew the TileWindows function, even less that it worked on controls. Interesting for quick automatic layout.
I don't see the point of the AutoSize parameter, it does nothing, window remains at initial size.

Removing the trailing backslash:
ImageFilePath := RegExReplace(ImageFilePath, "\\$")
Short enough? :-)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear PhiLho, :)

wp = wallpaper...


Oh! I confused it with wp parameter (Positioning and Sizing of Controls)!
So the limit should be 5000 minimum, I guess!

I see, you use some clever tricks to let Windows and AHK do most of the hard job. Thus, you are more or less stuck with the long path in the title of each image.

I didn't knew you can add a title bar to a picture. You should explain what are the options you change: +0xCF0000 -0x80000
Analyzing this manually is annoying and prone to error (same values, different constants).


Sorry! I was very tired yesterday! ...
Tile/Cascade windows could not tile/cascade a control, So I flagged the controls with WS_TILEDWINDOW ( 0xCF0000 ) given in help as WS_OVERLAPPEDWINDOW. To remove the titlebar buttons I had to remove the WS_SYSMENU style ( -0x80000 )

Likewise, I didn't knew the TileWindows function, even less that it
worked on controls
. Interesting for quick automatic layout.


I got the idea from the topic - Cascade Word files?. I do not have Word 97 installed, and thus this idea!

I don't see the point of the AutoSize parameter, it does nothing, window remains at initial size.


Are you sure?. The last column moves out of the GUI rectangle In Windows 2000 & XP for me!

Removing the trailing backslash:
ImageFilePath := RegExReplace(ImageFilePath, "\\$")
Short enough? :-)


Wow! I eagerly await the final release of AHK with built in RegEx! :D

Many Regards, :)

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

I don't see the point of the AutoSize parameter, it does nothing, window remains at initial size.


Are you sure?. The last column moves out of the GUI rectangle In Windows 2000 & XP for me!

You are right, without it, the rightmost controls are slightly truncated in my test case. Not obvious on first sight, but now that you mention it... :-)

With more images, they become smaller. I tried add the capability to resize the window, but to avoid resizing everything in real time, I activate the re-tiling with a hotkey:
;~ ImageFilePath = %1%
ImageFilePath = Images
IfEqual, ImageFilePath,, SetEnv,ImageFilePath,%A_WinDir%
Gui, Margin, 0, 0
Gui +Resize
pictOpt = x+1 w90 h-1 +0xCF0000 -0x80000 gSelect
Loop, %ImageFilePath%\*.bmp
  Gui, Add, Picture, %pictOpt%, %A_LoopFileLongPath%
Loop, %ImageFilePath%\*.png
  Gui, Add, Picture, %pictOpt%, %A_LoopFileLongPath%
Loop, %ImageFilePath%\*.jpg
  Gui, Add, Picture, %pictOpt%, %A_LoopFileLongPath%
Loop, %ImageFilePath%\*.gif
  Gui, Add, Picture, %pictOpt%, %A_LoopFileLongPath%
Gui, Show, w640 h700 +Hide
Gosub #c
Return

Select:
MouseGetPos,,,,ClassNN,1
GuiControlGet, FileName,, %ClassNN%
DllCall( "SystemParametersInfo", Int,20, Int,0, Str,FileName, Int,1 )
Return

#c::
Gui +LastFound
DllCall( "TileWindows", uInt,WinExist(), Int,1, Int,0, Int,0, Int,0 )
Gui, Show, AutoSize, Hot Wallpaper Selector! Click on a thumbnail to select!
Return

GuiClose:
GuiEscape:
ExitApp
But the controls might get a bit overlapped when too small.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

you are more or less stuck with the long path in the title of each image.


For more than one hour, I was meddling with different styles but unable to change the title.. But I have found a simple workaround:

SetWorkingDir, %A_Windir%
Gui, Margin, 0, 0 
Gui +LastFound 
Loop, *.Bmp 
  Gui, Add, Picture, x+1 w90 h-1 +0xCF0000 -0x80000 gSelect, %A_LoopFilename% 
Gui, Show, w640 h700 +Hide 
DllCall( "TileWindows", uInt,WinExist(), Int,1, Int,0, Int,0, Int,0 ) 
Gui, Show, AutoSize, Hot Wallpaper Selector! Click on a thumbnail to select! 
Return 

Select: 
MouseGetPos,,,,ClassNN,1 
GuiControlGet, FileName,, %ClassNN% 
 DllCall( "SystemParametersInfo", Int,20, Int,0, Str,FileName, Int,1 ) 
Return 

GuiClose: 
 ExitApp

Thanks for showing interest in this.. I will try your example in Win XP later!

Regards, :)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

Removing the trailing backslash:
ImageFilePath := RegExReplace(ImageFilePath, "\\$")
Short enough? :-)


MSDN Reference: Shell Path Handling Functions

wPath := A_WinDir
DllCall( "PathAddBackslashA", Int,&wPath )
MsgBox % wPath

It does the opposite of the RegExReplace example!
:)

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
You should do a VarSetCapacity of StrLen(wPath) + 1 before the call (might do nothing, as buffer can be already bigger, but safer), then either call with "Str", wPath, or do a VarSetCapacity(wPath, -1) after because of the latest changes on computing string lengths only when needed.
So it sorts of ruin the interest of this nice little function...
ImageFilePath := RegExReplace(ImageFilePath, "([^\\])$", "$1\")
Does nothing if backslash is already there.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

ImageFilePath := RegExReplace(ImageFilePath, "([^\\])$", "$1")
Does nothing if backslash is already there.


:shock:

Very nice!.. Thanks! :D

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

I didn't tried, because I already have an automatic wallpaper randomizer...

? Is it an external application or an ahk solution? Can you provide any further urls on this? I'm trying to experiment with "some semi-automatic wallpaper changes". Also some preprocessing of these "preselected wallpaper images" with dynamically overlayed text onto them might be interesting. Those texts could be anything, like
quotestodo listssource codesrandom text selections...That way the wallpaper could get a more "alive feeling" rather than always being the same. Yes and these text overlays might also change in certain time units. You could also define two separate time units for
wallpaper image changes and
wallpaper overlayed text changes