Posts: 12,072
Threads: 140
Joined: Dec 2002
Functions to run screensaver, set timeout, set desktop wallpaper,etc.
Moved from
Screen functions
and updated.
Attached Files
ScreenSaver & Wallpaper.qml (Size: 2.59 KB / Downloads: 1,688)
Posts: 473
Threads: 33
Joined: Aug 2007
Is it possible to adjust/set your screen resolution via QM?
EDIT* - Solved.
DisplaySettings(0 1280 1024)
Taking on Quick Macros one day at a time
Posts: 45
Threads: 10
Joined: Jul 2006
Hi Gindi,
I can't seem to get this to work. The old wallpaper goes away but I don't get a new one. Just a blank screen. I am on XP Pro and QM 2.3.1.2
Is this the correct syntax?
Macro
Macro
SetWallpaper ( "D:\work library\images\tiger woods.bmp" )
Posts: 12,072
Threads: 140
Joined: Dec 2002
Correct. Should work if it is bmp. Fails if jpg.
This is better version. Supports center/tile/stretch. Throws error if fails. Does not remove wallpaper if fails.
Function
SetWallpaper
;/
function $ wpFile [style] ;;style: 0 center, 1 tile, 2 stretch, 3 fit (Win7), 4 fill (Win7)
;Sets desktop wallpaper.
;wpFile - bmp file.
;;;Error if does not exist or is not bmp (Vista/7 also supports jpg).
;;;Use "" to remove wallpaper.
if ( ! empty ( wpFile))
, wpFile= _s.searchpath ( wpFile)
, if ( ! wpFile) end "file does not exist"
lpstr rk= "control panel\desktop"
;get current values to restore if fails
str _wp _tw _ws
rget _wp "wallpaper" rk; rget _tw "tilewallpaper" rk; rget _ws "wallpaperstyle" rk
;set style
lpstr rstyle( "0" ) rtile( "0" )
sel style& 255
, case 1 rtile= "1"
, case 2 rstyle= "2"
, case 3 if ( _winver>= 0x601 ) rstyle= "6"
, case 4 if ( _winver>= 0x601 ) rstyle= "10"
rset rstyle "wallpaperstyle" rk; rset rtile "tilewallpaper" rk
;set file
if ! SystemParametersInfo ( SPI_SETDESKWALLPAPER 0 wpFile 3 )
, ;when SPI fails, it removes wallpaper. Restore.
, rset _tw "tilewallpaper" rk; rset _ws "wallpaperstyle" rk
, SystemParametersInfo ( SPI_SETDESKWALLPAPER 0 _wp 3 )
, end ES_FAILED
Posts: 45
Threads: 10
Joined: Jul 2006
Posts: 1,769
Threads: 410
Joined: Feb 2003
I've been looking on the msdn site trying to find how I can mod the updatede Setwallpaper to take the new 'fill' and 'fit' settings as well.
does anyone know how I can do that?
Posts: 12,072
Threads: 140
Joined: Dec 2002
Function
SetDesktopWallpaper
;/
function $ wpFile [style] ;;style: 0 center, 1 tile, 2 stretch, 3 fit (Win7), 4 fill (Win7)
;Changes wallpaper.
;wpFile - image file.
;;;Tested only with .bmp.
;;;Empty string removes wallpaper.
ref __iactivedesktop "__iactivedesktop"
__iactivedesktop. IActiveDesktop ad._create ( CLSID_ActiveDesktop )
if ( empty ( wpFile)) _s= "" ; else _s.expandpath ( wpFile)
ad.SetWallpaper ( @ _s 0 )
style& 0xff
if ( style>= 3 and _winver< 0x601 ) style= 0
__iactivedesktop. WALLPAPEROPT o.dwSize= sizeof ( o)
o.dwStyle= style
ad.SetWallpaperOptions ( & o 0 )
ad.ApplyChanges ( __iactivedesktop. AD_APPLY_ALL )
err + end _error
IActiveDesktop available on all QM-supported Windows versions, but QM does not have definitions for it. Need this macro. Don't run, just create.
Macro
__iactivedesktop
def ADDURL_SILENT 0X0001
def AD_APPLY_ALL 0x00000007
def AD_APPLY_BUFFERED_REFRESH 0x00000010
def AD_APPLY_DYNAMICREFRESH 0x00000020
def AD_APPLY_FORCE 0x00000008
def AD_APPLY_HTMLGEN 0x00000002
def AD_APPLY_REFRESH 0x00000004
def AD_APPLY_SAVE 0x00000001
def AD_GETWP_BMP 0x00000000
def AD_GETWP_IMAGE 0x00000001
def AD_GETWP_LAST_APPLIED 0x00000002
type COMPONENT dwSize dwID iComponentType fChecked fDirty fNoScroll COMPPOS' cpPos @ wszFriendlyName[260 ] @ wszSource[2132 ] dwCurItemState COMPSTATEINFO' csiOriginal COMPSTATEINFO' csiRestored
type COMPONENTSOPT dwSize fEnableComponents fActiveDesktop
def COMPONENT_DEFAULT_LEFT 0xFFFF
def COMPONENT_DEFAULT_TOP 0xFFFF
def COMPONENT_TOP 0x3fffffff
type COMPPOS dwSize iLeft iTop dwWidth dwHeight izIndex fCanResize fCanResizeX fCanResizeY iPreferredLeftPercent iPreferredTopPercent
type COMPSTATEINFO dwSize iLeft iTop dwWidth dwHeight dwItemState
def COMP_ELEM_ALL 0x00007FFF
def COMP_ELEM_CHECKED 0x00000002
def COMP_ELEM_CURITEMSTATE 0x00004000
def COMP_ELEM_DIRTY 0x00000004
def COMP_ELEM_FRIENDLYNAME 0x00000400
def COMP_ELEM_NOSCROLL 0x00000008
def COMP_ELEM_ORIGINAL_CSI 0x00001000
def COMP_ELEM_POS_LEFT 0x00000010
def COMP_ELEM_POS_TOP 0x00000020
def COMP_ELEM_POS_ZINDEX 0x00000100
def COMP_ELEM_RESTORED_CSI 0x00002000
def COMP_ELEM_SIZE_HEIGHT 0x00000080
def COMP_ELEM_SIZE_WIDTH 0x00000040
def COMP_ELEM_SOURCE 0x00000200
def COMP_ELEM_SUBSCRIBEDURL 0x00000800
def COMP_ELEM_TYPE 0x00000001
def COMP_TYPE_CFHTML 4
def COMP_TYPE_CONTROL 3
def COMP_TYPE_HTMLDOC 0
def COMP_TYPE_MAX 4
def COMP_TYPE_PICTURE 1
def COMP_TYPE_WEBSITE 2
def DTI_ADDUI_DEFAULT 0x00000000
def DTI_ADDUI_DISPSUBWIZARD 0x00000001
def DTI_ADDUI_POSITIONITEM 0x00000002
def GADOF_DIRTY 0x00000001
interface # IADesktopP2 : IUnknown
, ReReadWallpaper()
, GetADObjectFlags( * lpdwFlags dwMask)
, UpdateAllDesktopSubscriptions()
, MakeDynamicChanges( IOleObject' pOleObj)
, {B22754E2-4574-11d1-9888-006097DEACF9}
interface # IActiveDesktop : IUnknown
, ApplyChanges( dwFlags)
, GetWallpaper( @* pwszWallpaper cchWallpaper dwFlags)
, SetWallpaper ( @* pwszWallpaper dwReserved)
, GetWallpaperOptions( WALLPAPEROPT * pwpo dwReserved)
, SetWallpaperOptions( WALLPAPEROPT * pwpo dwReserved)
, GetPattern( @* pwszPattern cchPattern dwReserved)
, SetPattern( @* pwszPattern dwReserved)
, GetDesktopItemOptions( COMPONENTSOPT* pco dwReserved)
, SetDesktopItemOptions( COMPONENTSOPT* pco dwReserved)
, AddDesktopItem( COMPONENT* pcomp dwReserved)
, AddDesktopItemWithUI( hwnd COMPONENT* pcomp dwReserved)
, ModifyDesktopItem( COMPONENT* pcomp dwFlags)
, RemoveDesktopItem( COMPONENT* pcomp dwReserved)
, GetDesktopItemCount( * lpiCount dwReserved)
, GetDesktopItem( nComponent COMPONENT* pcomp dwReserved)
, GetDesktopItemByID( dwID COMPONENT* pcomp dwReserved)
, GenerateDesktopItemHtml( @* pwszFileName COMPONENT* pcomp dwReserved)
, AddUrl( hwnd @* pszSource COMPONENT* pcomp dwFlags)
, GetDesktopItemBySource( @* pwszSource COMPONENT* pcomp dwReserved)
, {f490eb00-1240-11d1-9888-006097deacf9}
interface # IActiveDesktopP : IUnknown
, SetSafeMode( dwFlags)
, EnsureUpdateHTML()
, SetScheme( @* pwszSchemeName dwFlags)
, GetScheme( @* pwszSchemeName * lpdwcchBuffer dwFlags)
, {52502EE0-EC80-11D0-89AB-00C04FC2972D}
type IE4COMPONENT dwSize dwID iComponentType fChecked fDirty fNoScroll COMPPOS' cpPos @ wszFriendlyName[260 ] @ wszSource[2132 ]
def IS_FULLSCREEN 0x00000002
def IS_NORMAL 0x00000001
def IS_SPLIT 0x00000004
def IS_VALIDSIZESTATEBITS 0x00000007
def IS_VALIDSTATEBITS 0xC0000007
def SCHEME_CREATE 0x0080
def SCHEME_DISPLAY 0x0001
def SCHEME_DONOTUSE 0x0040
def SCHEME_EDIT 0x0002
def SCHEME_GLOBAL 0x0008
def SCHEME_LOCAL 0x0004
def SCHEME_REFRESH 0x0010
def SCHEME_UPDATE 0x0020
def SSM_CLEAR 0x0000
def SSM_REFRESH 0x0002
def SSM_SET 0x0001
def SSM_UPDATE 0x0004
type WALLPAPEROPT dwSize dwStyle
def WPSTYLE_CENTER 0
def WPSTYLE_CROPTOFIT 4
def WPSTYLE_KEEPASPECT 3
def WPSTYLE_MAX 5
def WPSTYLE_STRETCH 2
def WPSTYLE_TILE 1
Posts: 1,769
Threads: 410
Joined: Feb 2003
odd. I keep getting "access is denied" 0X80070005. anyone else get this?
Posts: 12,072
Threads: 140
Joined: Dec 2002
Here works even if QM process is not admin.
Try other AD_APPLY_x flags.
To see where exactly is the error, remove the err+ line.
Posts: 1,769
Threads: 410
Joined: Feb 2003
this line in SetDesktopWallpaper failed
Function
SetDesktopWallpaper
ad.ApplyChanges( __iactivedesktop. AD_APPLY_ALL )
with this error
Error (RT) in SetDesktopWallpaper: 0x80070005, Access is denied.
I have the __iactivedesktop macro made.
the SetWallpaper is the updated code above not the original in the qml file.
Posts: 12,072
Threads: 140
Joined: Dec 2002
Try other AD_APPLY_x flags. They are listed in MSDN but not documented.
Posts: 1,769
Threads: 410
Joined: Feb 2003
now I know what you mean. I tried it on my workstation with 2 monitors (same size) and it works. I exported the folder of macros out and imported them into my laptop with different sized screens and still get the error or nothing happens depending on which AD_APPLY I put into the SetDesktopWallpaper function.
could the problem be that the laptop is running 2 differently sized monitors?
Posts: 12,072
Threads: 140
Joined: Dec 2002
Fit and fill styles can be set through registry too. I updated SetWallpaper function, old version.