with SystemParametersInfo, I found only one discussion in the forum.
Detailed parameters:
http://msdn2.microsoft.com/en-us/library/ms724947.aspx
How can I use SystemParametersInfo in MS? Can anyone show an example calling SystemParametersInfo to change the desktop wallpaper?
Oh,it shall be a function in user32.dll
Thanks!
SystemParametersInfo
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Like this:
Let>SPI_SETDESKWALLPAPER=20
Let>BitmapFile=c:\pics\mybackground.bmp
LibFunc>User32,SystemParametersInfoA,r,SPI_SETDESKWALLPAPER,0,BitmapFile,0
To remove:
Let>SPI_SETDESKWALLPAPER=20
LibFunc>User32,SystemParametersInfoA,r,SPI_SETDESKWALLPAPER,0,,0
Let>SPI_SETDESKWALLPAPER=20
Let>BitmapFile=c:\pics\mybackground.bmp
LibFunc>User32,SystemParametersInfoA,r,SPI_SETDESKWALLPAPER,0,BitmapFile,0
To remove:
Let>SPI_SETDESKWALLPAPER=20
LibFunc>User32,SystemParametersInfoA,r,SPI_SETDESKWALLPAPER,0,,0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Can you help with this one too?
Hi Marcus,
I need a little help with SYSTEMPARAMETERSINFO, I'm trying to use the GETSCREENSAVERRUNNING parameter, with no success.
I've checked my version of MacroScheduler, and I've found several sites that explain the function, including the API site that you recommend. Lastly, I plagiarized the code that you posted earlier in this thread.
So, here's what I've come up with:
1) All API site has W95 only "SCREENSAVERRUNNING", so this site may not be quite up to date on this function.
2) Windows site http://support.microsoft.com/kb/315725 says that my "IPV_Param" must be a BOOLEAN variable, I don't know how to specify that.
3) SPI_GETSCREENSAVERRUNNING needs to take on a value of &H72, or 114, or "r"
So, my code is supposed to simply loop until the screensaver is running. It doesn't - even when I step through the code, it acts rather surprisingly, and I'm not sure what to make of it. I've tried several flavors of this code, checking for value of x_3, etc., but I just cannot make it work.
I've resisted the urge to try it in VB scripting, I'd like to stay within the confines of the LibFunc statement if I can.
Can you help me figure this one out? Also, I'd like to understand the purpose of x and how it is supposed to interact with the function... I am thinking that IPV_Param sees to return the answer to the question. Clearly, I'm lost.
Tx,
George
I need a little help with SYSTEMPARAMETERSINFO, I'm trying to use the GETSCREENSAVERRUNNING parameter, with no success.
I've checked my version of MacroScheduler, and I've found several sites that explain the function, including the API site that you recommend. Lastly, I plagiarized the code that you posted earlier in this thread.
So, here's what I've come up with:
This one is a little more problematic, here's why:Let>x=0
Label>Start
Wait>1
Let>IPV_Param = -1
Let>SPI_GETSCREENSAVERRUNNING = 114
LibFunc>User32,SystemParametersInfoA,x,SPI_GETSCREENSAVERRUNNING,0,IPV_Param,0
IF>x=0
Goto>Start
ELSE
// do something
ENDIF
MESSAGEMODAL>x
1) All API site has W95 only "SCREENSAVERRUNNING", so this site may not be quite up to date on this function.
2) Windows site http://support.microsoft.com/kb/315725 says that my "IPV_Param" must be a BOOLEAN variable, I don't know how to specify that.
3) SPI_GETSCREENSAVERRUNNING needs to take on a value of &H72, or 114, or "r"
So, my code is supposed to simply loop until the screensaver is running. It doesn't - even when I step through the code, it acts rather surprisingly, and I'm not sure what to make of it. I've tried several flavors of this code, checking for value of x_3, etc., but I just cannot make it work.
I've resisted the urge to try it in VB scripting, I'd like to stay within the confines of the LibFunc statement if I can.
Can you help me figure this one out? Also, I'd like to understand the purpose of x and how it is supposed to interact with the function... I am thinking that IPV_Param sees to return the answer to the question. Clearly, I'm lost.
Tx,
George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey
Screensavers!
I just read this:
Second, oh, woe is me!
I want to detect the existence of a running screensaver, and NOT shake the mouse or shut the screensaver down, instead, I would just like to detect a running screensaver, and if it is running, then go back to sleep quietly and undetected until the next time I run. Is there an undocumented feature that would allow me to do this?
Tx,
George
First, is that why my code doesn't seem to work? Because by the time I check to see if the screensaver is running, it is no longer running?A Note About Screensavers
Screensavers usually stop successful detection of other windows. Consequently if a script that needs to setfocus or wait for windows to appear is run while a screensaver is active it may not work correctly.
To get round this Macro Scheduler temporarily disables screensaving just before it runs a script and re-enables screensaving when the script completes. It also attempts to determine if a screensaver is currently active and if so closes it down. However, there are many different implementations of screensavers which operate in different ways, making their detection and close down a rather unreliable process. To try to ensure that Macro Scheduler is successful in closing an active screensaver it briefly moves the mouse back and forth before running the script.
This should work in most cases. However, if you find that Macro Scheduler is unable to stop your screensaver, then the most reliable method of making sure that a scheduled macro runs properly is to simply disable screensaving altogether.
Second, oh, woe is me!

Tx,
George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I don't think you're going to get SystemParametersInfoA working with SPI_GETSCREENSAVERRUNNING in Macro Scheduler because it requires a pointer to a bool. LibFunc can only cope with integers and strings right now because there's no concept of pointers, bools, structures etc in Macro Scheduler.
Yes, Macro Scheduler currently attempts to stop a screen saver when a macro is scheduled (though this is not currently effective in Vista). Otherwise the macro may not work. An option to allow you to switch this off is on the to do list.
Yes, Macro Scheduler currently attempts to stop a screen saver when a macro is scheduled (though this is not currently effective in Vista). Otherwise the macro may not work. An option to allow you to switch this off is on the to do list.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Git 'er done?
Luckily, the target machine uses Vista! I need to get on the Vista machine to test this, because XP always returns "no screensaver", but what do you think for the Vista? I tried a little more plagiarizing:
George
Tx,VBSTART
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND
//set the wait time
Wait>10
Label>begin
// which screensaver are we running?
RegistryReadKey>HKEY_CURRENT_USER,Control Panel\Desktop,scrnsave.exe,v_name
//check if screensaver process is running
VBEval>IsProcessRunning(v_name),screensaver
If>screensaver=0,finish
If>screensaver>0,snooze
Label>finish
MessageModal>do whatever I have to do if the screensaver is not running
Label>snooze
MessageModal>end macro, wait for next scheduled occurence
George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Good call. Not quite. But this works:
For testing purposes my example beeps while the screen saver is running.
Code: Select all
VBSTART
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND
Label>start
RegistryReadKey>HKEY_CURRENT_USER,Control Panel\Desktop,scrnsave.exe,v_name
Separate>v_name,\,v_parts
Let>v_proc=v_parts_%v_parts_count%
VBEval>IsProcessRunning("%v_proc%"),IsSS
If>IsSS>0
PlayWav>Chimes.wav
Endif
Wait>1
Goto>start
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?