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
.
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 :thumb:
But if you just want to program it, then i cant help you about screensavers. =/
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:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If Shift = vbAltMask And KeyCode = vbKeyTab Then
Shell "notepad" 'provide full path to your program instead
End If
End Sub
NOTE: making a screen saver is completely different issue.
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?
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:
Private Declare Function SetCapture Lib "user32" ( _
ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
Private Sub Form_Load()
SetCapture Me.hwnd
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.
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:
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
Private Sub Form_Load()
SetCapture Me.hwnd
ReleaseCapture
Me.KeyPreview = True
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 69 Then '69 stands for the key "e"
Shell "notepad"
End If
End Sub
If the Form is in background or is minimized it doesn't work. www.ironmodders.ch.vu
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