AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AutoBackground - change background based on monitor config

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
3tones



Joined: 14 Dec 2004
Posts: 45
Location: Minneapolis, MN

PostPosted: Fri Sep 08, 2006 4:00 am    Post subject: AutoBackground - change background based on monitor config Reply with quote

I have a laptop with a docking station at work. When docked, there is a second monitor to extend my desktop. Ryan over at http://www.digitalblasphemy.com has been gracious enough to provide awesome dual and triple monitor backgrounds, but when I am down to one monitor on my laptop, I miss all the "action" of the background. So I wrote this script. If my display changes the script will pick the background accordingly. It's pretty simple, but I havn't seen anything like it.

Code:

;AutoBackground
;tom at 3shizzletones.com (take out the shizzle)
;   http://www.3tones.com
;
;Built with AutoHotKey v1.0.44.10 and tested on Windows XP
;   http://www.autohotkey.com
;
;9/21/06
;added style function
;change method of changing background to using a dllcall

;check background on login
WM_DISPLAYCHANGE(0,0)

OnMessage(0x7E, "WM_DISPLAYCHANGE")
  return
 
WM_DISPLAYCHANGE(wParam, lParam)
  {
  ;WM_DISPLAYCHANGE is triggered any time a change is made to the display settings
  ;get the monitor count
  SysGet, mc, MonitorCount

  if mc = 1
    {
    ;if 1 monitor, use this background
    background_file = C:\Documents and Settings\user\My Documents\My Pictures\serenade.bmp
    ;set tile and style accordingly
    SetWallpaperStyle("Tiled")
    ;set background file
    DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, background_file, UInt, 2)
    }
  else if mc = 2
    {
    ;if 2 monitors, use this background
    background_file = C:\Documents and Settings\user\My Documents\My Pictures\reverie2x.bmp
    ;set tile and style accordingly
    SetWallpaperStyle("Tiled")
    ;set background file
    DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, background_file, UInt, 2)
    }
  }
 
  SetWallpaperStyle(style)
  {
    ;for tiled,    use TileWallpaper=1 WallpaperStyle=0
    ;for centered, use TileWallpaper=0 WallpaperStyle=0
    ;for strech,   use TileWallpaper=0 WallpaperStyle=2
    if style=Tiled
      {
      RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper, 1
      RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle, 0
      }
  else if style=Centered
      {
      RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper, 0
      RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle, 0
      }
  else if style=Streched
      {
      RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper, 0
      RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle, 2
      }
  }


Last edited by 3tones on Thu Sep 21, 2006 8:18 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Veovis



Joined: 13 Feb 2006
Posts: 390
Location: Utah

PostPosted: Sat Sep 09, 2006 10:44 pm    Post subject: Reply with quote

Awesome! Thank you so much! to buy a program that does excactly this is like 20 dollars and is so frivilous to manage... where as this gives perfect control of what i want and its so easy. Thanks!
_________________

"Power can be given overnight, but responsibility must be taught. Long years go into its making."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
3tones



Joined: 14 Dec 2004
Posts: 45
Location: Minneapolis, MN

PostPosted: Sun Sep 10, 2006 3:38 am    Post subject: Reply with quote

Veovis wrote:
Awesome! Thank you so much! to buy a program that does excactly this is like 20 dollars and is so frivilous to manage... where as this gives perfect control of what i want and its so easy. Thanks!


Glad I could help. I have one more mod... I need to make it check the monitors and set the background on login. I often log out and suspend my laptop when I undock it. This should be as simple as having it run the check/set routine when the script is first run.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
aCkRiTe



Joined: 21 Jul 2006
Posts: 517

PostPosted: Sun Sep 10, 2006 4:52 am    Post subject: Reply with quote

just on a whim tonight i thought of making a wallpaper/background changer script and im in the process of doing so, then i come in to the fourm to look around and i see this! Laughing not excatly what im trying to do, but along the same line. anyways i wanted to let you know about this
Code:

; Example: Change the desktop wallpaper to the specified bitmap (.bmp) file.

DllCall("SystemParametersInfo", UInt, 0x14, UInt, 0, Str, A_WinDir . "\winnt.bmp", UInt, 2)


this is under the dllcall command. i was going about it the same way you were then i came across this after doing about and hour and a half of researching on the web and in the help file. Mad hope this might be of help to ya...
Back to top
View user's profile Send private message
3tones



Joined: 14 Dec 2004
Posts: 45
Location: Minneapolis, MN

PostPosted: Thu Sep 21, 2006 8:15 pm    Post subject: Reply with quote

aCkRiTe, thanks for the suggestion. I have updated my first post with the changes. What is your background script going to do? I was thinking of adding a gui to mine and also having it change background based on time.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
aCkRiTe



Joined: 21 Jul 2006
Posts: 517

PostPosted: Thu Sep 21, 2006 8:35 pm    Post subject: Reply with quote

well i found that bit in the manual and though it might help, thats just if your using bitmap images though. since i wanted to be able to use any image type i ended up going through the registry in my script like you did. look in the scripts section and you should see mine in there. i posted it fairly recently. let me know what ya think.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group