Here's something thats a little funny that deals with Inkey and the Mouse cursor.
Mouse and Inkey In Console Screen Mode 0.
If I make an area of my screen Mouse click on sensitive and when I left click on that area, the program is instructed to do something. That works alright.
Now if I by accident happen to have my Mouse cursor resting on that sensitive area, and I start typing something in an another area of the Screen below it using Inkey$, the Mouse sensitive area becomes activated as if I clicked the Left Mouse button. I have to make sure where my mouse arrow is resting before I can start typing.
Now if I type something above that sensitive area, it doesn't do that. It will go ahead and put the characters on the screen without clicking the left mouse button when I hit a key.
This is happening to me in XP Home, Windowed, Console mode 0.
Where the Arrows are
-
- Posts: 165
- Joined: May 27, 2005 14:14
- Location: Marshall, Oklahoma, USA
- Contact:
I tried this and I have no change in the button state when pressing keys.
But you mention a sensitive area, so I guess your code is more complicated than mine....Code, please?
Code: Select all
do
getmouse x,y,w,b
locate 1,1
print x,y,w,b
k$=inkey$
loop until k$=chr$(27)
-
- Posts: 165
- Joined: May 27, 2005 14:14
- Location: Marshall, Oklahoma, USA
- Contact:
Place the mouse cursor in the little box and start hitting on different keys. To me, it acts the save as clicking on it with the left mouse button.
Code: Select all
Sub GetKeys (Keynumber As Integer, k As String, Rgt As Integer, _
Lft As Integer, cRow As Integer, cCol As Integer)
Dim buttons As Integer
Keynumber=0 : Rgt=0 : Lft=0 : cRow=0 : cCol=0
Locate 1, 1, 0
Do
GetMouse cCol, cRow,, buttons
If buttons And 1 Then lft = 1 : Exit Sub
If buttons And 2 Then Rgt = 1 : Exit Sub
k = Inkey$
Sleep 1
Loop While k = ""
If Asc(k) > 31 And Asc(k) < 127 Then
keynumber = Asc(k)
ElseIf Asc(k) = 27 Then
keynumber = 27
ElseIf Asc(k) = 8 Then
keynumber = 8
ElseIf Asc(k) = 9 Then
keynumber = 9
ElseIf Asc(k) = 13 Then
keynumber = 13
Else
keynumber = Cvi(k +k+ k+k) : Sleep 10 'Fm examples
End If
End Sub
Color 8, 7
For x% = 10 To 13
Locate x%, 20 : Print Space$(20) ' Color Mouse clicking area
Next
Do
GetKeys Kn%, Ky$ , Rt%, Lt%, row%, col%
Color 7, 0
Ke$ = UCase$(Ky$)
If lt% <> 0 Or Ke$ <> "" Then
If Ke$ = "B" Or (Row% > 8 And Row% < 14 And Col% > 19 And Col% < 41) Then ' check if mouse in area
Print " You clicked on Mouse area "
Sleep 1000 : Locate 1, 1 : Color 7, 0 : Print Space$(30)
Else
Locate 20, 20
Print "You hit the "; Ke$; " Key"
End If
End If
Loop Until Kn% = 27
follow this path
Ke$ = UCase$(Ky$)
If lt% <> 0 Or Ke$ <> "" Then
If Ke$ = "B" Or (Row% > 8 And Row% < 14 And Col% > 19 And Col% < 41) Then ' check if mouse in area
Print " You clicked on Mouse area "
Sleep 1000 : Locate 1, 1 : Color 7, 0 : Print Space$(30)
Else
Locate 20, 20
Print "You hit the "; Ke$; " Key"
End If
End If
=)
Ke$ = UCase$(Ky$)
If lt% <> 0 Or Ke$ <> "" Then
If Ke$ = "B" Or (Row% > 8 And Row% < 14 And Col% > 19 And Col% < 41) Then ' check if mouse in area
Print " You clicked on Mouse area "
Sleep 1000 : Locate 1, 1 : Color 7, 0 : Print Space$(30)
Else
Locate 20, 20
Print "You hit the "; Ke$; " Key"
End If
End If
=)
-
- Posts: 165
- Joined: May 27, 2005 14:14
- Location: Marshall, Oklahoma, USA
- Contact:
Hello Michael,
This is only a shorten example to show what it was doing.
Adding the Lt% to the Ke$ line does the trick, but.......
I was trying to get by with one Lt in the place of 12 Lts, since I have 12 buttons with character Hotkeys in case somebody didn't like using the Mouse.
But, it does work that way, thanks.
I coded it the same way with another compiler and it didn't cause those effects. So I thought it might be something that somebody would want to fix.
Later.......Jerry Fielden
This is only a shorten example to show what it was doing.
Adding the Lt% to the Ke$ line does the trick, but.......
I was trying to get by with one Lt in the place of 12 Lts, since I have 12 buttons with character Hotkeys in case somebody didn't like using the Mouse.
But, it does work that way, thanks.
I coded it the same way with another compiler and it didn't cause those effects. So I thought it might be something that somebody would want to fix.
Later.......Jerry Fielden
I guess you didn't understand my post. Because of the "or", execution will always fall through. Just a little change in logic:
I assumed by your example that you intended to have "B" as a mouse button key.
Code: Select all
Ke$ = UCase$(Ky$)
If (lt% <> 0 Or Ke$ = "B") And (Row% > 8 And Row% < 14 And Col% > 19 And Col% < 41) Then ' check if mouse in area
Print " You clicked on Mouse area "
Sleep 1000 : Locate 1, 1 : Color 7, 0 : Print Space$(30)
ElseIf Ke$ <> "" Then
Locate 20, 20
Print "You hit the "; Ke$; " Key"
End If
I assumed by your example that you intended to have "B" as a mouse button key.
-
- Posts: 165
- Joined: May 27, 2005 14:14
- Location: Marshall, Oklahoma, USA
- Contact: