+ 1

Cursor position in C++

can you help me with setting the cursor position in C++?

18th Nov 2018, 2:16 PM
Amirali Gorji
Amirali Gorji - avatar
7 Antworten
+ 2
If you mean move the cursor in the console window then check out these windows functions: https://docs.microsoft.com/en-us/windows/console/getstdhandle ( you would need the STD_OUTPUT_HANDLE ) and https://docs.microsoft.com/en-us/windows/console/setconsolecursorposition which requires the previous handle as an argument, together with the coordinates. If you mean move the mouse cursor outside the console window, check out: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setcursorpos Also don't forget to include the <windows.h> header. If you need an example, just ask. :)
18th Nov 2018, 7:20 PM
Dennis
Dennis - avatar
+ 1
Check XWarpPointer of X11 library(i think its not for windows)
18th Nov 2018, 2:43 PM
Bebida Roja
Bebida Roja - avatar
+ 1
Awais Ahmed Nope, you can only access that through the operating system's API. The standard library provides no such functionality.
20th Apr 2020, 10:36 AM
Dennis
Dennis - avatar
0
thanks, but I use Windows
18th Nov 2018, 2:44 PM
Amirali Gorji
Amirali Gorji - avatar
0
Does windows.h also counts in c++ standard library? What if program has the linux environment
20th Apr 2020, 10:09 AM
Awais Ahmed
Awais Ahmed - avatar
0
Awais Ahmed windows.h is not part of the standard. For linux there is: https://en.m.wikipedia.org/wiki/Unistd.h
20th Apr 2020, 10:28 AM
Dennis
Dennis - avatar
0
Is it possible to control the cursor by only using C++ standard library? Without any external library
20th Apr 2020, 10:30 AM
Awais Ahmed
Awais Ahmed - avatar