#include "windows.bi"
dim as integer x,y,button
reset (0)
do
getmouse x,y,,button
print x, y, button
sleep 100
loop
I wrote an editor that accepts redirected input. After reading STDIN I call reset (0) to close it and allow keyboard input. But then mouse input no longer works. The above code illustrates the problem. If you comment out reset (0) then getmouse works. Is this a bug? Should I use setconsolemode to enable mouse input again? Thanks in advance.
dim as integer x,y,button
reset(0)
do
if getmouse(x,y,,button) then
print "error: get mouse !"
else
print x, y, button
end if
sleep 100
loop while asc(inkey())<>27
I forgot to mention that this is a console app, that is, I'm running it in a "dos box".
With the reset (0) in, x and y remain zero, or y goes negative. Both buttons return 0. And right click brings up the "mark, copy, paste" menu, suggesting that the console is in the wrong state.
I'm running windows 7 and compiling with 64 bit Freebasic 1.05 for windows.
Yes, "QuickEdit Mode" unchecked is necessary for using mouse but not sufficient after calling 'Reset(0)'.
'Reset(0)' disables the mouse without modifying the "QuickEdit Mode" setting.
I attempted to use GetConsoleMode to look at the mode variable. It was zero before and after reset (0). So I wonder what reset (0) is doing to disable the mouse?
With Win 10, and putting a proper closure with your code (loop until len(inkey):sleep)
Then unchecking quick edit, in the console properties, all is well, reset or not, afterwards.
In fact the change is permanent and the console remains (quick edit unchecked) no matter how you run the console afterwards, and even after a shut down.