daonlyfreez
Joined: 16 Mar 2005 Posts: 755 Location: Berlin
|
Posted: Wed Aug 03, 2005 7:58 pm Post subject: Screensaver/Desktop control library attempt (incomplete) |
|
|
Too bored maybe, but I decided to create a nice library for the 'eye candy' of every WinOS, the desktop and screensavers.
I thought it would be easy, but I was wrong.
What I wanted: easy calls for screensaver control and the desktop, meaning, the icons and wallpaper, and the taskbar and traybar maybe too...
Good learning experience for DllCall it turned out to be, and SendMessage too...
Setting with DllCall (as an equivalent of SendMessage) might work, but getting data...
I have no clue... Example:
Getting/setting the icons on the desktop seems to be impossible, for it needs to write into the memoryspace of the desktop a structure that I cannot set... all way over my head anyway
But already a 'simple' call of SPI_GETSCREENSAVEACTIVE gave me headaches...
But well, here is the first code, please give attention to the things I cannot get to work, and test the rest (I test on 2k only sofar)
I took the liberty of posting this 'already' in this part of the forum, though its not complete. More code to come...
| Code: | /* *** Screensaver library
wanted:
#SSRun("") ; 1=run current,, 0=stop running screensaver, path=runs the screensaver path
#SSCon("") ; 1=configure current, 0=opens the 'Display Properties window at the screensaver tab, path=opens the configuration screen of the screensaver path
#SSSet("") ; 1=enable,0=disable,path=sets the screensaver to path
#SSGet("") ; 1=returns the state (-1=disabled, 0=enabled, 1=running), 0=returns the path of the currently enabled/running screensaver
#SSIns("") ; 1=installs,0=deinstalls
working:
#SSRun("")
#SSCon("")
#SSSet("")
(#SSGetCur() <- gets path to current ss, used by other functions)
*/
; test calls
;#SSGet(0)
;#SSGet(1)
#SSGet(s)
{
; s = return path to current screensaver
if s = 0
{
RegRead, cs, HKEY_CURRENT_USER, Control Panel\Desktop, SCRNSAVE.EXE
if errorlevel = 1
{
MsgBox, 0, Error, There was a problem reading from the registry
Exit
}
return cs
}
; s = return state of screensaver
if s = 1
{
;???
;BOOL IsActive;
;if (!SystemParametersInfo( SPI_GETSCREENSAVEACTIVE, 0, &IsActive, 0
IsActive = 0
res1 := dllcall("SystemParametersInfo", UInt, 0x0010, UInt, IsActive, UInt, 0, UInt, 0)
; res2 := dllcall("SystemParametersInfo", UInt, 0x0072, UInt, 0, UInt, 0, UInt, 0)
; res3 := dllcall("SystemParametersInfo", UInt, 0x000E, UInt, 0, UInt, 0, UInt, 0)
msgbox, IsActive: %IsActive%`nres1:`n%res1%`nres2:`n%res2%`nres3:`n%res3%`nerrorlevel:%errorlevel%
; IsActive:
; res1: 1
}
}
; ---------------- working
; test calls
;#SSSet("C:\WINNT\bubbles.scr") ; set
;#SSSet("C:\WINNT\cyclone.scr") ; set other
;#SSSet("C:\WINNT\acyclone.scr") ; non existant
;#SSSet("") ; empty
;#SSSet(0) ; disable
;#SSSet(1) ; enable
#SSSet(s)
{
; s = 1 -> enable
if s = 1
{
DllCall("SystemParametersInfo", UInt, 0x0011, UInt, TRUE, UInt, 0, UInt, 0x0002)
return
}
; s = 0 -> disable
if s = 0
{
DllCall("SystemParametersInfo", UInt, 0x0011, UInt, FALSE, UInt, 0, UInt, 0x0002)
return
}
; s = other -> might be path
filegetversion, v, %s%
if FileExist(s) and ((v != "") or (InStr(FileExist(s),"D") = 0)) and (s contains scr)
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, SCRNSAVE.EXE, %s%
if errorlevel = 1
{
MsgBox, 0, Error, There was a problem writing to the registry
Exit
}
#SSSet(1)
}
; s = something else -> error
else
{
msgbox, 0, Error - Bad input., Either the path to screensaver is incorrect, or the input is empty`n`ninput: %s%`n`n... quitting
exit
}
}
; test calls
;#SSRun(1)
;#SSRun("C:\WINNT\bubbles.scr")
#SSRun(s)
{
; s = run current
; would work too, but no errorcheck: SendMessage, 0x112, 0xF140, 0,, Program Manager
if s = 1
{
cs := #SSGet(0)
if cs !=
{
run, %cs% /S,, UseErrorLevel
if errorlevel = ERROR
{
msgbox, 0, Error, The path to the active screensaver is incorrect:`n`n%cs%
exit
}
}
else
{
msgbox, 0, Error, No active screensaver, or none specified, therefore you cannot start the screensaver.
exit
}
}
; s = stop
if s = 0
Send, {ESC} ; should be extended, proc/winkill?
; s = path
filegetversion, v, %s%
if FileExist(s) and ((v != "") or (InStr(FileExist(s),"D") = 0)) and (s contains scr)
{
run, %s% /S,, UseErrorLevel
if errorlevel = ERROR
{
msgbox, 0, Error, There was a problem running the following screensaver:`n`n%s%
exit
}
}
}
;#SSCon("C:\WINNT\cyclone.scr")
;#SSCon("C:\WINNT\bubbles.scr")
;#SSCon("")
#SSCon(s)
{
if s = 0
{
run, control desk.cpl`,Display Properties`,1,, UseErrorLevel
if errorlevel = ERROR
{
msgbox, 0, Error, Could not open the Display Properties control panel
exit
}
}
if s = 1 ; open configuration window of current
{
cs := #SSGetCur()
if cs !=
{
run, %cs% /C,, UseErrorLevel
if errorlevel = ERROR
{
msgbox, 0, Error, The path to the active screensaver is incorrect:`n`n%cs%
exit
}
}
else
{
msgbox, 0, Error, No active screensaver, or none specified, therefore you cannot open the configuration screen.
exit
}
}
if s != ; might be a path
{
;if s contains .scr ...
if (s contains scr) and (if InStr(FileExist(s),D) = 1)
{
run, %s% /C,, UseErrorLevel
if errorlevel = ERROR
{
msgbox, 0, Error, The path to the selected screensaver is incorrect:`n`n%s%
exit
}
}
else
{
msgbox, 0, Error, Bad path
exit
}
}
; s = something else -> error
else
{
msgbox, 0, Error - Bad input., Either the path to screensaver is incorrect, or the input is empty`n`ninput: %s%`n`n... quitting
exit
}
}
;cs := #SSGetCur()
;msgbox, %cs%
#SSGetCur()
{
RegRead, cs, HKEY_CURRENT_USER, Control Panel\Desktop, SCRNSAVE.EXE
if errorlevel = 1
{
MsgBox, 0, Error, There was a problem reading from the registry
Exit
}
return cs
}
|
_________________ (sorry, homesite offline atm) |
|