Re: Keypress question

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

CChris wrote:
> 
> 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)
> }}}
<eucode>
>
> junk=w32Func(xSystemParametersInfo,{SPI_SETSCREENSAVEACTIVE,new_state,0,update_policy})
> </eucode>
{{{

> 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:
> }}}
<eucode>
> constant
> user32=open_dll("user32.dll")
> ,xSystemParametersInfo=define_c_func(user32,"SystemParametersInfoA",
>                                       repeat(C_ULONG,4),C_ULONG)
> </eucode>
{{{

> 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

Thank you CChris,

I'm testing your code.

Windows XP Control Panel - Display - Screen Saver Allows you to set the wait
time up to 9999 minuets max. This is about seven days which is sufficient for my
purposes. Doesn't you code do about the same thing but longer?

I am using this code on a lot of different computers. My main concern is that
some computers go into hibernate mode and turn off the screen. To change this
setting you have to go into the bios of each computer. This I don't want to do. I
want to do it with code if possible. I have one computer I have set the Screen
Save wait time to 9999 mins. after about 5 mins. the screen goes blank. I know I
could probably go into the bios and change this. Again I don't want to have to do
this with every different type of computer. I have Dells, Compaq, Hewlett Packard
and generic computers I put in my store window. Will your code work on all bios
if they are set to hibernate?

Thank you for your help.


Don Cole

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

Search



Quick Links

User menu

Not signed in.

Misc Menu