Results 1 to 7 of 7

Thread: A programm that works in backgroud, has to open a screensaver, if I press a key

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    18

    A programm that works in backgroud, has to open a screensaver, if I press a key

    At our big eaveningshow there's one sequence where a matrixscreensaver has to apear. The screen is beamed onto a big wall, so there can't be something of windows, like the little thing, that aperas then you press alt+tab, and there can't be a mousepointer.
    The easyest way for me, the manager of the computer and the beamer, is to code something that makes the screensaver apear if I press a key and makes it disapear when I press an other key.

    I don't have an idea how to begin programming that thing.

    Does someone have an idea how to do a programm like that?
    (I don't want to programm a screensaver, just a programm to starts and ends the screensaver)


    www.ironmodders.ch.vu

    .
    Last edited by Brainhacker12; Mar 26th, 2005 at 12:44 PM.

  2. #2
    Lively Member
    Join Date
    Mar 2005
    Posts
    109

    Re: A programm that works in backgroud, has to open a screensaver, if I press a key

    just download a screensaver maker. I recommend 123 Screensaver Maker. It rockz

    But if you just want to program it, then i cant help you about screensavers. =/

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: A programm that works in backgroud, has to open a screensaver, if I press a key

    Screen saver is just another program so if you want to launch it upon pressing some key combination then here is a sample:
    VB Code:
    1. Private Sub Form_Load()
    2.     Me.KeyPreview = True
    3. End Sub
    4.  
    5. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    6.     If Shift = vbAltMask And KeyCode = vbKeyTab Then
    7.         Shell "notepad" 'provide full path to your program instead
    8.     End If
    9. End Sub
    NOTE: making a screen saver is completely different issue.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    18

    Re: A programm that works in backgroud, has to open a screensaver, if I press a key

    If the application got the focus your solution works very good. But that's not the thing I wanted.

    The application have to work in tha background. and so the application won't have the focus.

    Any ideas how to do it, if the programm don't have the focus?

  5. #5
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Re: A programm that works in backgroud, has to open a screensaver, if I press a key

    You don't actually need focus, just have that program running invisibly (me.hide). Then, you could either have a timer or something checking for a certain keystroke (getasynckeystate API) or you could do this:

    VB Code:
    1. Private Declare Function SetCapture Lib "user32" ( _
    2.      ByVal hwnd As Long) As Long
    3.      
    4. Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
    5. Private Sub Form_Load()
    6. SetCapture Me.hwnd
    7. End Sub

    With that method anywhere you click will be taken as a click to the form, just be sure to releasecapture when you're done. There are a whole ton of other methods you could use too, but those seem to be pretty good from my viewpoint.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    18

    Re: A programm that works in backgroud, has to open a screensaver, if I press a key

    I don't know if I'm to stupide or what's going on. But these codes don't work.

    VB Code:
    1. Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    2. Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
    3.  
    4. Private Sub Form_Load()
    5.     SetCapture Me.hwnd
    6.     ReleaseCapture
    7.     Me.KeyPreview = True
    8. End Sub
    9.  
    10. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    11.     If KeyCode = 69 Then '69 stands for the key "e"
    12.         Shell "notepad"
    13.     End If
    14. End Sub

    If the Form is in background or is minimized it doesn't work. www.ironmodders.ch.vu

  7. #7
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: A programm that works in backgroud, has to open a screensaver, if I press a key

    Use a keyboard hook. If you have a callback function, you can treat it like an event. API-Guide has a good example of how to do this, as does Codeguru.

    http://www.codeguru.com/Cpp/W-P/syst...cle.php/c5699/

    [EDIT]
    The Codegure example is C, below is the VB example:

    http://www.developer.com/net/vb/article.php/1502401
    Last edited by Comintern; Mar 28th, 2005 at 09:08 AM. Reason: Whoops!

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