getmouse fails after reset (0)

Windows specific questions.
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

getmouse fails after reset (0)

Postby nedman47 » Mar 11, 2017 7:09

Code: Select all

#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.
D.J.Peters
Posts: 8107
Joined: May 28, 2005 3:28
Contact:

Re: getmouse fails after reset (0)

Postby D.J.Peters » Mar 11, 2017 9:25

No problem here what is your OS 32/64-bit Windows xp,vista,7,8,10 ?

Joshy

Code: Select all

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
SARG
Posts: 1118
Joined: May 27, 2005 7:15
Location: FRANCE

Re: getmouse fails after reset (0)

Postby SARG » Mar 11, 2017 9:38

What is exactly the issue ?

I didn't see a difference with or without reset instruction.

However the scrolling changes the y value becoming negative. And when the mouse is out the console y should not change but not the case.
fxm
Posts: 9794
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Postby fxm » Mar 11, 2017 9:48

I get the same problem as nedman47 (under Win7, 32-bit and 64-bit).
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

Re: getmouse fails after reset (0)

Postby nedman47 » Mar 11, 2017 9:57

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.
MrSwiss
Posts: 3569
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: getmouse fails after reset (0)

Postby MrSwiss » Mar 11, 2017 11:33

I get the same problem as nedman47 (under Win10 - 64, 32-bit and 64-bit compiler, versions: 1.05.0/1.06.0 - 2017-03-01).

But, this also happens without: Reset() or Reset(0)

Also tested: Screen 0 (forcing console)

GetMouse() & Console issue/conflict???
dodicat
Posts: 6628
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: getmouse fails after reset (0)

Postby dodicat » Mar 11, 2017 12:19

Win 10
64/32 bit
Same as Mr Swiss, mouse doesn't register x,y co ordinates, buttons or wheel values.
With or without reset()

The only thing, when the numbers scroll off the page the mouse y values start to decrement themselves, even if the mouse is off the console.

Code: Select all

 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0             0             0
 0            -1             0
 0            -2             0
 0            -3             0
 0            -4             0
 0            -5             0
 0            -6             0
 0            -7             0
 0            -8             0
 0            -9             0
 0            -10            0
 0            -11            0
 0            -12            0
 0            -13            0
 0            -14            0
 0            -15            0
 0            -16            0
 
fxm
Posts: 9794
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Postby fxm » Mar 11, 2017 12:33

To enable the mouse in the console window, uncheck "QuickEdit Mode" in console properties.
MrSwiss
Posts: 3569
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: getmouse fails after reset (0)

Postby MrSwiss » Mar 11, 2017 13:11

fxm is correct, this fixes the issue, but you'll have to do it, on the "FB invoked" Console.

Reason: it is not a global setting ... (aka: *local setting*, not relevant to all Console-Windows)
fxm
Posts: 9794
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Postby fxm » Mar 11, 2017 14:00

From main menu for command window, you can also configure the "defaults" (above the "properties").
(the "defaults" are applied at console invocation)
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

Re: getmouse fails after reset (0)

Postby nedman47 » Mar 11, 2017 14:08

I never had "quick edit mode" checked, so it does not fix the issue for me.
fxm
Posts: 9794
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Postby fxm » Mar 11, 2017 14:36

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.
nedman47
Posts: 62
Joined: Dec 05, 2006 15:35

Re: getmouse fails after reset (0)

Postby nedman47 » Mar 11, 2017 16:12

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?
fxm
Posts: 9794
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: getmouse fails after reset (0)

Postby fxm » Mar 11, 2017 16:24

Except by reassigning a new console window, I could not find another solution to re-enable the mouse after a 'Reset(0)'.
dodicat
Posts: 6628
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: getmouse fails after reset (0)

Postby dodicat » Mar 11, 2017 16:54

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.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest