Windows Console API Mouse Event Just Goes To Select Mode - c++

I am using Windows 10, while key events work okay. The problem is with mouse events clicking in the console sort of just automatically assumes I am trying to select and thus goes into select mode. I am not sure if there is something in the API to turn this off.
Update: Anyone who wants to solve this here is a link to the solution SOLUTION

Mouse selection mode was one of the console improvement features introduced in Windows 10. It can be turned on/off from console parameters. Note that if you want to disable it for your application you can configure console parameters for shortcut.

Related

How to lock Windows 7 into a single program with C++?

I have been working on an app in Visual Studio 2015 (C++). It's a kiosk app for my school's tech support. Basically, it's a support site that will run in a kiosk. I need to figure out how to lock windows so it only runs that program. It would also be helpful to run the program in fullscreen mode. Keep in mind that all of the kiosks run Windows 7.
Set registry key
HKCU SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Shell="c:\path\to\whatever.exe"
Disallow task manager via security of taskmgr.exe (add a deny read + deny execute to the binary)
Set autologn:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
DefaultUserName = whatever
DefaultPassword = whatever
Have a boot disk handy. The only way to reverse this is to boot the boot disk and undo one of the steps after mounting the appropriate hive.
you can create your program with main window in full screen mode and popup:
hWnd = CreateWindowEx(WS_EX_CLIENTEDGE|WS_EX_APPWINDOW|WS_EX_TOPMOST,
lpClsName,
"MDI Project under Visual C++ WINAPI",
WS_BORDER|WS_POPUP,
...);// add the remaining parameters
and find taskmgr.exe and hide it and start menu button and hide them also:
hTaskBar = ::FindWindow ("Shell_TrayWnd", "");
hStart = ::FindWindowEx(GetDesktopWindow(), NULL, "Button", "Start");
ShowWindow(hTaskBar, SW_HIDE);
ShowWindow(hStart, SW_HIDE);
so your program looks like easycafe or handycafe
I actually switched from C++ to C#, so I'm gonna explain my answer with C#.
I used a keyboard hook library to capture keyboard input and block all non-letter/number input so alt-f4, alt-tab etc. would not work. I then determined a closing sequence of characters using another keyboard hook (LWin+C+Home+F12+PrtSc).
As for Ctrl-Alt-Del, that cannot be disabled (as far as I know) because it is a system function, so I just left that as it is.
I also got the bounds of the screen and set the size of the window to the maximum screen size at application launch, as well as whenever the app is resized or moved. This essentially makes it so the app covers the task bar, and the bar with the close and minimize buttons is also covered, but if someone found a way to move it it would immediately go back to it's full size.
I also set up autologin as was detailed in a previous answer, but I just didn't do it through code.

Prevent a Windows app from stealing the focus

I have created a windows application in C++ and I want to make so whenever I run it, it doesn't steal focus from whichever window is currently focused(or maybe steal the focus and give it back right away). I'm not creating any window so i'm not sure how to change the window style, my program runs in the background.
I couldn't find any answer that worked for C++, is there any way I can do this?
When you start your application by clicking on the EXE or shortcut, Windows Explorer takes focus, not your app. The only way to start your app and not let Windows Explorer take focus is to start your program when Windows starts, via registry key.
Make sure you use the extended style WS_EX_NOACTIVATE when using CreateWindowEx().
See the Microsoft Docs for CreateWindowEx.

Qt - c++ simulate keypress

I'm trying to create a simple bot in Qt and need therefor a way of simulating keyboard presses OUTSIDE the Qt application itself.
I've successfully made this possible by using the "old" keybd_event
keybd_event(Qt::Key_A,0,0, 0); // Pressing the 'A-button"
and that works out fine. But i can't make it when i'm trying to execute a 'select all' command which needs two buttons to be pressed at once.
As i researched the problem on Google i was refereed to the 'SendInput' function with the message 'This function (keybd_event) has been superseded. Use SendInput instead.'
The problem now is that I've little knowledge of windows API and especially in the contex of "Qt" and would like guidance on how to get started.
keybd_event is actually not Qt function, but part of Windows Api.
Both keybd_event and SendInput allow you to send press event and release event. If you want to send combination ctrl+A you should send events as follows:
press Ctrl -> press A -> release A -> release Ctrl
If you want to use keybd_event, you need to call it 4 times subsequently, if you want to use SendInput, you can make an array of 4 events.
You should use keyboard codes from Windows API to simulate keyboard events, while Qt's codes may coincide with Microsoft's.
Also you should understand that this solution has nothing to do with Qt, it Windows specified.
You just found all links to docs you would need, I think you should start studing it and ask more concrete questions, if you would have any problems.

How to bring up the on screen keyboard using C++ in Windows 7 tablet devices?

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.

How to catch Keyboard and mouse events?

I want to create an application. This application has to do something when a user presses special keys on keyboard or/and uses scroll wheel. This application is a service. It has no windows. I want to catch any keyboard or mouse events which were designed with other applications.
For example, you are watching TV by 3rd party application. If you press Ctrl + Shift and use scroll wheel my application changes the volume.
I use Windows 7 x64 and Visual Studio 2008.
You can call SetWindowsHookEx() to be notified when various events occur. You probably want to use the keyboard hook and the mouse hook to watch for mouse events.
If your application is a true Win32 service, then on Vista and beyond, the application won't receive keyboard or mouse events - to close a security hole (search for "shatter attack"), Microsoft isolated all services to prevent them from interacting with the user.
You'll need to have your application run in the session with the interactively logged on user.
You can use the RAW INPUT method, It is more reliable than GetAsyncKeyState etc.
I wrote this article on Code Project that may be of use to you.
There is both C# and a MASM source code versions available.