Results 1 to 3 of 3

Thread: Make like a screen saver but not at the same time????

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    15

    Exclamation

    Hi I have an app that goes full screen after the mouse has not been moved for about 5mins..

    It works but it you happen to be typing for that time then it fires up..

    Is there any way to hock into the windows Idle time.. e.g. no mouse moving and no keys presed?

    I dont want to make my app into a screen saver because it can not work that way.

    Thanks,

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    You could use the getasynckeystate api call to detect if any of the common keys are pressed. (check every second). you don't have to check for every key. Personally, i would just check for the space bar, arrow keys, mouse buttons, and the wheel of fortune favorites: rstlne
    If you check for keypresses every 100 millisec or so, you are almost gauranteed to hit a pressed key.
    To try this sample, be sure to copy the relavent api delcarations into the module you put this in. Also it is better to use gettickcount. I used the timer for simplicity of example.
    Code:
    submain()
      dim settime as long
      settime = timer
      do
        if iskeypressed(vbkeylbutton) then settime = timer
        if iskeypressed(vbkeyspace) then settime = timer
        if iskeypressed(vbkeyR) then settime = timer
        if iskeypressed(vbkeyE) then settime = timer
        'continue for the other letters
      loop until timer - settime >= 5000 '5 seconds(?)
      call activatescrnsaver()
    exit sub
    
    put in a module with declarations:
    Function IsKeyPressed(VBKey As Long) As Boolean
       Dim KeyState As Integer
       KeyState = GetAsyncKeyState(VBKey)
       
       If KeyState And &H8000 = &H8000 Then
         IsKeyPressed = True: Debug.Print VBKey
       Else
         IsKeyPressed = False
       End If
    End Function
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    By the way, if that code is too unruly, i have code for directx that will send an event to vb whenever a key is pressed. The above code is smaller. However, you could argue that the directx code is more efficient.

    If you want it, post here.
    It was written for directx7, but might work on a lower one (its not like i'm making 3-d rotating representations of a key you press )
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width