Re: Keypress question

new topic     » goto parent     » topic index » view thread      » older message » newer message

don cole wrote:
> 
> Hello Sverybody,
> 
>    How can I simulate a keypress into my program?
> You know, a lot of computers go into screen saver or shut down after a period
> of time if no keypress is made. I would like to override this for store window
> displays. 
> 
> Don Cole

Isn't it simpler to just deactivate the screensaver?
You can do this by calling (using the win32lib syntax)
junk=w32Func(xSystemParametersInfo,{SPI_SETSCREENSAVEACTIVE,new_state,0,update_policy})

with <i>new_state</i> set to 0. Enable again by calling with <i>new_state</i>=1.
<i>update_policy</i> is either 0 (no user profile update), 1 (update profile)
 or 2 (update and broadcast). SPIF_INIUPDATE is defined as 1 and
 SPIF_SENDCHANGE as 2.
If you don't use win32lib, replace w32Func by c_func and wrap the API
 as follows:
constant
user32=open_dll("user32.dll")
,xSystemParametersInfo=define_c_func(user32,"SystemParametersInfoA",
                                      repeat(C_ULONG,4),C_ULONG)

Replace A by W on Unicode platforms.

The problem with sending a simulated mouse/keyboard events is that there is
 a setting to prevent these simulated events to affect the screensaver. If 
you are bent on simulating input, please read the doc to the SendInput()
 API function. In particular, Vista puts additional restrictions to this.

Last but not least, SPI_SETSCREENSAVEACTIVE is 17.

HTH
CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu