My ultimate wish is to allow users using a touchscreen desktop (an All-in-one computer without mouse or keyboard) to navigate on a website that uses tooltips. Using a mouse, hovering over a tooltip opens it, the tooltip contains links that can be clicked. Using a touchscreen, there is no hover, only 'touches'/clicks. In both cases the page will be displayed on the same OS using the same browser, once the user has a mouse, the other time the user has a touchscreen.
So I need to distinguish between the two: a desktop computer with a mouse and a touchscreen desktop computer without a mouse. Modernizr touch tests (http://modernizr.github.com/Modernizr/touch.html) fail completely on a touchscreen desktop (http://shop.lenovo.com/us/landing_pages/thinkcentre/2010/m90z). Sniffing the UA or browser does not work either.
(After a fair amount of searching, all the detection tries to distinguish different versions of mobile phones or tablets, browsers, UAs... Not desktop touchscreens that are running on the same OS using the same browser.)
Any ideas?
Add event listeners touchstart and mousemove to your page, then wait the user starts to interact with your page. If the first event is mousemove, then user operates with mouse, so it is probably a desktop, otherwise this is a touch-screen.
$(document).on('touchstart.desktopDetect mousemove.desktopDetect', function(ev) {
window.IS_TOUCHSCREEN_DEVICE = (ev.type == 'touchstart');
$(document).off('.desktopDetect');
});
Check working example here:
https://jsfiddle.net/evpozdniakov/uvb51cnm/embedded/result/
Related
One nice ascpect about MIDI is that one can route it explicitly to some app - unlike regular input devices like your run of the mill mouse or keyboard.
Is there a similar way to use a Wacom pen tablet exclusively with one app that doesn't even have a visible window resource (Windows 10)? I'd like to repurpose it as a jog dial for video editing and need to intercept the device data in order to simulate specific key presses or mouse movements.
Here is what I'm currently working with:
https://github.com/Wacom-Developer/wacom-device-kit-windows/tree/master/Wintab%20ScribbleDemo
https://developer-docs.wacom.com/intuos-cintiq-business-tablets/docs/wintab-reference#logcontext
The scribble demo works fine out of the box. Setting g_penMovesSystemCursor = false makes the system cursor ignore the tablet, but only as long as the demo's window is in focus. I want the system cursor to always ignore the tablet input and the demo to always receive the wacom events.
Well, I guess this answers it:
How can my application have exclusive access to all tablet pen events?
You must force your application to be the front-most (foreground) app.
https://developer-docs.wacom.com/intuos-cintiq-business-tablets/docs/wintab-faqs#how-can-my-application-have-exclusive-access-to-all-tablet-pen-events
Bummer. Such a simple and useful thing for an input device, and it's not supported.
Background
I'm implementing a simple WIN32 application consist of a window.
The user may show/hide the window using a special hotkey. I register the hotkey using RegisterHotKey and respond to WM_HOTKEY
Problem
if user plays a game and accidentally (or not accidentally) press the hotkey combination, then my window pops up and as a result the game is minimized.
Question
Is there a (native) way to know that the user is in gaming mode, or any other special mode, that I could disable the hotkey response
Note
I would also like if windows would make this a feature while I play games. For example don't respond to WinKey+D while I'm in gaming mode.
You can use the SHQueryUserNotificationState function to determine whether the user is playing a full screen D3D game. It will report QUNS_RUNNING_D3D_FULL_SCREEN.
I've made a simple click bot to automatically play an android game on my Windows PC. It currently identifies when certain things change on the screen then moves the mouse and clicks the correct button.
Currently I am using the following win32api functions to achieve this:
Win32api.SetCursorPos(Position)
Win32api.mouse_event(winn32con.MOUSEEVENTF_LEFTDOWN,0,0)
Win32api.mouse_event(winn32con.MOUSEEVENTF_LEFTUP,0,0)
These work great however when I use the bot it takes over my computer's mouse and I basically have to let it run. Is there anyway I could simulate a click without it actually using my mouse, or is there a way I could isolate the bot on one of my other screens and be able to work freely on the other?
There is a lib specific for deal with user interaction components and periferics: pyautogui
Here, is a short and easy to try documentation for performing/simulating mouse click DOWN & UP
https://pyautogui.readthedocs.org/en/latest/mouse.html#the-mousedown-and-mouseup-functions
I am developing an application for Windows 7 devices and I'm using an embedded web browser (webkit). Normally touching an edit control on a tablet device causes a little keyboard icon to appear. However, since my edit control is in the browser, it's not a real window with an hwnd and Window's doesn't bring up the icon you can click on to bring up the on screen keyboard.
Is there an API I can use to cause the little keyboard icon to appear as it normally would when focus goes to an edit control?
I tried searching MSDN, no success.
I looked at the Windows keyboard API. No dice.
I tried running OSK.exe. This could bring up multiple instances of the keyboard and it's just sloppy. I want to get the same effect a user would get when tapping a windows edit control so the UI is consistent.
There must be an API that can bring up that on screen keyboard.
Thanks.
David
Not sure if you have this answered already. I have been looking at doing a similar thing although it is a part of a larger application and the keyboard is rarely used (but nevertheless had to be supported). I assigned a shortcut key (right click Win 7 on screen keyboard application and choose Properties. In the shortcut tab, assign any shortcut you'd like). When I touch a SurfaceTextEdit control, I emulate the shortcut key from my C++ code using SendInput(). I know this is a hack, but it worked well for me because I rarely used the onscreen keyboard in my application.
I'm writing an application for Mac OS X 10.6 and later in C++. One part of the application needs to simulate mouse movement and mouse clicks. I do this currently by posting CGEvent objects using CGEventPost(kCGHIDEventTap, event);.
This works, for the most part - I can simulate mouse movement and clicks just fine, but it seems to fail in some areas. For example:
In Mozilla Firefox and Safari, I can click on all the menus, but cannot click on a link within a website. When I try, the link is highlighted, but the browser never follows the link. However, I can right-click on a link, select "open link in new tab", and everything works as expected. Solved - creating the mouse event using CGEventCreateMouseEvent(...) makes the event work within web browser.
I can click on the "Dashboard" icon to brink up the dashboard, but I cannot click on the "i" button on any of the dashboard widgets. Similarly, clicking on any of the search results from the spotlight search widget doesn't work either.
This inconsistency is along application boundaries. What might be the cause?
What you need to do to convince these applications that you have in fact generated a click is to explicitly set the value of the "click state" field on the mouse up event to 1 (it defaults to 0). The following code will do it:
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 1);
It also has to be set to 1 for the mouse down, but by using CGEventCreateMouseEvent() rather than CGEventCreate() that gets done for you.
I have tested this and it works in the 'i' buttons in the dashboard and the Spotlight search results.
(As an aside, if you were simulating a double click you would need to set the click state to 2 for both the mouse down and mouse up events of the second click.)
Most menus are activated with the mouseDown event. Hyperlinks are followed after the mouseUp event. The "i" button only works when the mouse has been clicked but not a long time.
All this seem to show that you have a timing problem, try several pressed timing.
Use OSXVnc. I see they use CGPostMouseEvent() instead of CGPostEvent().
I have written how to do it in the blog post Python Mouse Click and Move Mouse on Apple Mac OS X Snow Leopard 10.6.x.