|
-
Jul 28th, 2000, 09:44 AM
#1
Thread Starter
New Member
Hello,
I'm very much a newcomer to visual basic. I would imagine that this request is API related, but apologise if it isn't.
I'm attempting to write an application which includes a time out feature if mouse moves or key presses are not made.
I'm intending to have an opening screen, which gives the option to open one of three separate applications.
If there is no activity within the chosen application, for a set period of time, I want it to be closed down and the opening screen shown again. Also, if the user chooses to return to the opening screen to open another application, the current application will close down.
Thanks,
Marcus.
-
Jul 28th, 2000, 11:23 AM
#2
Frenzied Member
This is Really Really Hard, you can't actually do it in VB alone, you have to write Some .dlls in C++ to do the detecting for you. I've never actually done it but if you're saying you're a newbie you might want to try some simpler things first. Unless someone's got some easy to use Hooking dlls you can use.
-
Jul 28th, 2000, 11:57 PM
#3
transcendental analytic
You mean that the mouse movement is the only thing you need to monitor? Then you could use Getcursorpos API to get the mouse position and WindowFromPoint API to detect if the mouse is over one of your foreign applications, you could monitor the movement by using a static variable to compare the last value with current
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 30th, 2000, 06:32 AM
#4
Fanatic Member
For Keyboard and MouseDown:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const ELAPSE = 5 ' Number of minutes before elapsation
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Static Keyless As Long
Dim Ctr As Integer
For i = 0 To 255
If GetAsyncKeyState(i) And &H8000 Then
'A key has been pressed
Ctr = 0
Else: Ctr = Ctr + 1
End If
Next:
If Ctr = 256 Then
'No Keys Have been pressed
Keyless = Keyless + 1
If Keyless = (10 * 60 * ELAPSE) Then
'No keys have been pressed for 5 minutes
End If
Else:
Keyless = 0
End If
End Sub
Phew! I've been doing VB for a couple of years and that was quite hard. I would aim for something a little, well, actually a lot less ambitious. Unless, of course, you are a genius who learnt Portugese in under two hours and can predict lightening, in which case feel free to learn C++.
-
Jul 30th, 2000, 06:43 AM
#5
Fanatic Member
For MouseMove:
Code:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const ELAPSE = 5 ' Number of minutes before elapsation
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Static ctr As Long, NoMove As Long
Static PrevPoint As POINTAPI
Dim NewPoint As POINTAPI
If ctr = 1 Then
Call GetCursorPos(NewPoint)
If NewPoint.x = PrevPoint.x And NewPoint.y = PrevPoint.y Then
NoMove = NoMove + 1
If NoMove = (10 * 60 * ELAPSE) Then
'Mouse hasn't moved for 5 minutes
End If
Else:
NoMove = 0
End If
ctr = 0
End If
Call GetCursorPos(PrevPoint)
ctr = ctr + 1
End Sub
This is the other half of the code, whihc I've just finished. But, how about a Hello World app? I little easier on the poor fingers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|