Ok thanks to venna I now have a timer working on my login form which when I go to another form the counter still ticks over.
Now I've been working on a way of detecting when the mouse has been moved so that I can set a value, say to 1 when it is moved and then the timer gets to 60x5 (5 mins) it sets a value to 1 and then if they're both one then log off / unload / close db etc.
Here's what I got: -
-
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
-
Private Type POINTAPI
-
X As Long
-
Y As Long
-
End Type
-
Dim DeltaX As Integer
-
Dim DeltaY As Integer
-
Dim StartPos As POINTAPI
-
Dim logintime As Variant
-
On form_load - ' these should be set when the screen saver is in setup mode
-
DeltaX = 100 ' adjust this for x sensitivity level
-
DeltaY = 100 ' adjust this for y sensitivity level
-
Call GetCursorPos(StartPos)
Then in each frame or tab - Private Sub SSTab1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Dim NewPos As POINTAPI
-
Call GetCursorPos(NewPos)
-
Dim CheckX As Integer
-
Dim CheckY As Integer
-
CheckX = Abs(NewPos.X - StartPos.X)
-
CheckY = Abs(NewPos.Y - StartPos.Y)
-
If CheckX > DeltaX Or CheckY > DeltaY Then
-
MouseMove = 1
-
End If
This is really annoying having to put it in each frame and form etc
Is there a way of just dragging a frame all over your form ... making it see-though and then putting that code in for just that frame?
11 2309
anyone out there ? i come in peace :)
anyone out there ? i come in peace :)
Is there another approach you could take? For instance, since you're doing an API call to check the cursor position, I guess it really isn't dependent on any particular control, or even your form. So what if you had a timer which checks it... oh, say ten times a second, and just sets a flag when it changes or something?
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
If this is what you want to do : If your Application is running but Idle for few mins, then you want to come out..
Then do this :
Keep a project-level variable (add a .Bas module ) and declare this Public MyCount As Integer
And in MouseMove event and KeyPress event of all the Forms give : MyCount = 0
In Main form's Timer1_Timer Event: MyCount = MyCount + 1
If MyCount >= 300 Then
End
End If
Sorry if I have not understood properly.
Regards
Veena
the problem with what i have atm is that i have to have that code in every frame.
I have a form with a sstab on it consisisting of 8 tabs ( 8th isnt used atm but will) in each tab ther is a number of frames generally 2-4
so would i have to put that code in each tab and each frame on each tab or can i just put it under the whole forms mouse event ?
------------------------------------------
I see what u meen veena
if that works then it would be much much simpler, ill give it a go now :D
thx both for your replies.
Instead of using a mouseMove event, it would be easier to check if the user is actually using the form. You will already have the code in place for what each control is supposed to do, just reset the timer inside each of those subroutines.
Better yet, write one function/subroutine that resets anything to do with the timer and re-use it that way. That's one aspect of programming: code reuse. :>
Instead of using a mouseMove event, it would be easier to check if the user is actually using the form. You will already have the code in place for what each control is supposed to do, just reset the timer inside each of those subroutines.
Better yet, write one function/subroutine that resets anything to do with the timer and re-use it that way. That's one aspect of programming: code reuse. :>
so in every text box, command button, etc i would have to do something like
call mousemoved
Private Sub mousemoved()
mousetimer = 0
or just "mousetimer = 0"
------------------------
I tried out
MouseMove event and KeyPress event of all the Forms give : mousetimer = 0
this didnt work for the sstabs so i put it in the sstabs mousemove event but if the mouse is over a frame or picture etc it doesnt work.
So ill have to put it in every frame, picture, etc? ( like i said above? )
ther must be a simpler way than this long winded putting code in every frame, picture and that cant it be done in a module or something ?
Perhaps there's some way you could intercept the mouse-move messages that Windows sends to your application? I know Windows works by sending a constant stream of message around, and you can send them with the SendMessage API function. Maybe you can detect them as well.
Otherwise, have you considered the timer/API solution I mentioned? Do you just need to know whether the user is doing anything? Or does it need to be specific to your application?
i dont care what the user is doing :D just that s/hes there, which is generally known when they move their mouse.
Well, there you go then. Just check the actual mousepointer position every however-often, and if it changes, the user is active. Don't know how you'll tell when they use the keyboard, though, unless they are definitely using your application. In that case, turn on KeyPreview property of each form, so it gets to see the keys first.
Well, there you go then. Just check the actual mousepointer position every however-often, and if it changes,
Yes as i said above then i have to put that code in evey frame / tab / form / picture ... ther must be a simpler way :S
Yes as i said above then i have to put that code in evey frame / tab / form / picture ...
No, I don't mean to receive MouseMove events. I mean just have a timer somewhere which uses the API call periodically to ask Windows for the absolute position of the mousepointer. Then it won't matter which form has the focus, or even whether your application is visible, or anything.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tim Mulholland |
last post by:
i posted this a while ago and never got a response, but i'm still having
problems, so i thought i'd see if anyone had any sudden realizations this
time
Thanks in advance!
Tim
I have...
|
by: Sam Sungshik Kong |
last post by:
Hello!
If I understand correctly, MouseMove event is triggered when the mouse moves
(ie when point changes).
I, however, found out that it's triggered even if the mouse is not moving.
What I...
|
by: Crucifix |
last post by:
Hello,
I'm writing a small C# app, and part of what I'm trying to do
involves the dragging of PictureBox controls on a form. Unfortunately,
MouseMove seems to be behaving very oddly, causing...
|
by: TyBreaker |
last post by:
I'm writing a screen saver using Visual Studio 2005 (Basic) and I have a
Form which contains a PictureBox. I have two events, Click and
MouseMove that I'd like to cause the program to end (see...
|
by: Rob |
last post by:
This is a curious problem. It seems like it should be quite easy. Of course
a timer is used to determine when form should be closed, but how do you
consistently reset the timer when the mouse is...
| |
by: Jakub Ćukomski |
last post by:
hi. i've got a problem as follows, to which i can't find a solution to:
i've got two divs, which are completely independent of each other
(neither is a parent of child of another).
they're...
|
by: info |
last post by:
Hello everybody,
I hope you can help me with my problem. I want to add the mousemove
event to a class that doesn't have it (specifically it is the
nationalinstruments.ui.xycursor from measurement...
|
by: since |
last post by:
How do I in IE prevent the onclick action from being fired when I am done dragging?
have tried "window.event.cancelBubble = true", for onmouseup , onmousedown, and onmousemove handlers. The onclick...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |