if you are inactive on gmail, by not moving your mouse for a while, it changes your chat status to orange which means idle. but when you start moving the mouse again it turns it back to green meaning active. how does it know when you are moving your mouse?
without checking, I'd say this is done with an onmousemove event handler attached to the whole document.
You can attach an "onmousemove" event to the Javascript "document" object, which is triggered every time the mouse moves across the browser window. It's a simple task to reset a timer whenever this happens, and if the timer goes off without any movement detected, it will set your status to "idle". When the onmousemove function is next called, it will set your status back to "available".
Example with full code: http://www.codeguru.com/forum/archive/index.php/t-433956.html
Related
This is an Excel VBA Project (because someone edited the title) and I need to clarify what this post is about.
I am writing code that walks/works through VBA Code Modules to list procedures as well as controls on UserForms and list how/what procedures call each other.
I was trying to simulate jiggling of a userform control, at run time, on a Userform in the VBA Editor's Designer window, to notify the user that this particular control, was selected, with the mouse on the ListItem/Node of ListView/TreeView on a modeless userform.
It's complicated to describe in words, so I attached a GIF.
In the GIF, it can be seen, in the Immediate pane, that code execution paused after executing the MouseDown and ItemClick events in the ListView, because I didn't release the pressed Left Mouse Button (LMB).
So I guess the sequence of events in ListViews is like:
MouseDown
ItemClick
Pause
MouseUp
Click.
And, thus, I put my jiggle routine code in ItemClick event of the ListView.
However, when I try to do the same thing with TreeView, I found that the code execution paused right after MouseDown event of the TreeView, if I didn't release the LMB, without going on to execute the NodeClick event, as it did with ListView and it's MouseDown Event.
Since I placed my jiggle code in TreeView NodeClick event handler, which has not occured yet, there was no jiggle effect.
But upon release of the LMB, the control's jiggle effect was quite immediate for the eye to catch, as the code execution continues after the pause at the end of MouseDown event, nonstop, up to the end of MouseUp Event.
This sequence of events can be seen in the Immediate window's output as shown in the GIF below.
It is also evident here that the code execution paused after MouseDown event was handled, if the left mouse button was held down, without going on to NodeClick Event, as it did in ListView.
MouseDown
Pause
NodeClick
MouseUp
Click.
So, the situation was laid out as above.
I tried to place the jiggle code into the MouseDown Event.
However, since I need the SelectedItem from the TreeView to get my jiggle code working, it's like I needed the NodeClick Event anyway.
I tried to examine the SelectedItem/selected-Node of the TreeView in the MouseDown Event but unfortunately, it only returned the previous SelectedItem/selected-Node rather than the Node on which the MouseDown Event just occured, which makes sense in itself, because SelectedItem is not yet set to new Node as NodeClick Event has not occured yet.
I thought that if only I can get the Node under the mouse at the time of MouseDown Event by using HitTest, I could use that Node as the SelectedItem in my jiggle code.
Another obstacle arises, in that, the TreeView HitTest function uses X,Y as Singles which appear to be in ?Twips rather than Pixels, I may be required to use magic numbers=88,90 and the magical TwipsPerPixel function and recalculate it for different monitors and resolutions.
So, I searched for a different solution.
PS:Being a Myanmar, I have a duty to promote awareness that there's a Revolution occuring right now in Myanmar against a cruel military coup and would like to plead you guys to please support the people of Myanmar. Thank you.
I found the different solution in the form of a custom-made HitTest function, using the SendMessage API call to the TreeView, rather than using the TreeView's default HitTest function, available here.
The code sample there, was allowed to be used freely but not to be published on any website as mentioned in their copyright disclaimer.
So I guess I cannot share the code snippet here but I believe it's ok to share the link to that site.
I had to modify, the code mentioned there, a bit, to return the Node but not the handle to the Node as returned in their function.
I used that function because it uses Pixels as X,Y coordinates rather than the ?Twips that VBA uses.
Similar function for ListViews can also be found elsewhere if one googles hard enough.
So, it works like a charm and the control is jiggling now, inside the MouseDown Event, without using NodeClick event.
I think that the bottom line here, is:
ListViews and TreeViews differ in handling mouseclick events in that ListViews seem to consider ItemClick Event as part of the MouseDown Event sequence and TreeViews consider NodeClick Event as separate from MouseDown Event
I have no idea about the reasoning behind this but suspect that it may be in their origins
I wrote up this Question+Answer post to help fellow VBA programmers with the ItemClick vs. NodeClick Event sequence discrepancy and also to let them know that there is a better HitTest routine out there, which can be used without having to convert mouse coordinates in pixels.
This whole VBA project is part of my VBA Project Info tool (with Code Obfuscator and Visual Codeflow tools) with the barebone-basic Alpha RC version available on GitHub.
Remarks: I cannot, for the life of me, find the official description of MouseClick Event sequences of ListViews and TreeViews anywhere. Thus, had to resort to debug.print "1.TV_MouseDown" stuff.
PS:Being a Myanmar, I urge y'All to please support the Myanmar Spring Revolution.
Vive la Myanmar Révolution!!!
I've made a Node/AutoHotKey script to control two computers with one mouse. I've made the cursor disappear on the first computer when using the second computer (https://www.autohotkey.com/boards/viewtopic.php?t=6167), but the mouseover event is still firing of course.
What I mean is simply if you hover over some icons on the desktop you will see tooltips, and so on.
I'm using a graphics tablet (absolute positioning), the cursor position gets captured and sent to the second computer.
I've found this method:
Found it here: https://www.autohotkey.com/boards/viewtopic.php?t=33128 (Also from the documentation: https://www.autohotkey.com/docs/commands/BlockInput.htm)
BlockInput, MouseMove ;to disable mouse interaction
BlockInPut, MouseMoveOff ;to enable mouse interaction
But it blocks mousemove completely, so that the cursor stops moving at all.
Is there any way to programmatically disable/enable mouseover (so that buttons don't change their color and tooltips don't appear, but AutoHotKey could still capture cursor position) event globally on Windows without blocking mousemove?
We are automating a web application using UFT/QTP. The issue is that UFT works only on those web objects which are seen in browser window part. If any object/element is at the bottom of the page and require scroll down in window to be seen. UFT is not able to work on those objects. We have written code to page down to work on those objects. It works fine. But sometimes when page is very lengthy and we don't know at what position that object will be like in middle of the page, or far bottom of the page etc. In that case, only page down does not work. Is there any way that we can make the object visible on the basis of object properties? That means we can bring object in front of the window.
If your scrolling pageup or pagedown code is already working, why don't you use a loop...
Set obj = Browser(..).page(..).Link(..) ' use your object
While obj.getROProperty("visible") = False
'Scroll code
Wend
UFT doesn't depend on whether the object is in view or not. If an object is scrolled out of view UFT will automatically scroll it into view before performing any action upon it (e.g. Click).
The behaviour you're describing may be caused by the fact that the web site dynamically adds objects to the DOM when the page is scrolled. If this is the case then UFT has no way to know what will cause the object to be added to the DOM and you have to scroll for it they you've been doing.
Sorry I couldn't bring better news :(
I had once faced a similar issue. For me, changing the Replaytype setting to mouse events worked.
Try changing the ReplayType to Mouse events just before performing any operation(say clicking the object) as shown below:
Settings.WebPackage("ReplayType") = 2 'Changes to mouse/device events mode
'Perform the Click Operation here
Settings.WebPackage("ReplayType") = 1 'Change back to Browser events mode
Additional information on ReplayType:
This setting allows us to change the way mouse operations should
happen on AUT. It can be either browser events or mouse event.
Browser event is similar to DOM events using the Browser methods,
wheras Mouse event simulate the actual user action either from
keyboard or mouse. For example if you click on a button when
ReplayType is Mouse, you will notice that mouse pointer moves to the
location of button and fires the event, but in case of browser event it
doesn’t.
Values of replaytype can be:
1 – Event
2 – Mouse
By default it is set to Event i.e 1
I have this weird problem. I'm writing a GUI app in Qt and I have a crash during a drag and drop operation. If I run this app in a debugger, then when this crash occurs and the app breaks into the debugger, the mouse cursor gets stuck in "drag and drop mode" and I can't click on anything until the app is killed. How can i get around that?
Your app crashes in a GUI thread. Try to move the operations you are doing there to a new thread.
On your DragDrop event:
start a new thread doing your job
return from your event without waiting for results
I have the same issue.
I found that when a breakpoint was hit when mouse is dragging or mouseDown, GUI will get stuck and mouse will become unable to response.
For example:
A. Drag&Drop
1) Eclipse SWT: create Drag and Drop for a control
2) set breakpoint within dragging
B. Mouse Down & Mouse Up
1) use mouse down / mouse up to implement behavior of Drag&Drop
2) set breakpoint to dragging action/mouse moving
The mouse will stuck when breakpoint occurred, no matter which DnD happened.
To get mouse back, I'll need to use CTRL+ALT+F1 and use command to kill my process.
Perhaps working in VM or remote desktop can get rid of it.
When I'm testing my app on a mouse-driven device, I'm seeing a couple of odd highlight issues that I would like to try and resolve.
The first occurs when I call up the app bar, hover the mouse over a button (at which point the button goes grey) and then press Escape to dismiss the app bar. If I then call up the app bar again, the button has stayed grey, even if the mouse isn't over it, and remains in that state until I move the mouse over it and then away again.
I can't immediately see a property of the button that I can reset to clear that state when the app bar gets dismissed.
The other oddity I'm seeing is that sometimes the first item in the list on the page will get a box drawn around it:
This seems to happen when the app bar is being dismissed. I'm guessing that this is because the item is in a particular state that causes the box to appear but I'm not sure what state or how to clear it. The box does not appear during normal use of my app.
Thanks for any clarification or solutions you can provide.
I found a simple way to workaround this issue. In the code for Clicked/Tapped set Visibility of the button:
CreateNewDatabase.Visibility = Visibility.Collapsed;
CreateNewDatabase.Visibility = Visibility.Visible;
It will reset button state to Normal.
Hope this helps!
So, the issue is that the VisualState for the Button is being set to PointedOver, and then not being unset (because your mouse isn't leaving the bounds of the control and therefore triggering a PointerExited event). What this means is that you'll have to manually set the VisualState of the Button if you want it to change in this manner. You could do it on AppBar's Closed event. Basically, do a recursive check of all Children of the Content property of the AppBar using the VisualTreeHelper. Check to see if the Child is a Button. If it is, set its VisualState using VisualStateManager.GoToState().
I've also figured out what was causing the black box around the button - it is to indicate that the button has Focus.
The rather strange thing is that I'm not really sure why that specific button is getting focus or how a user is supposed to give focus to a button without it just randomly happening so, until I figure that out, I've decided to comment out the Focus state support from the Visual Manager XAML used in the default GridView item style.