Inkey issue in console on rmb

General FreeBASIC programming questions.
UEZ
Posts: 972
Joined: May 05, 2017 19:59
Location: Germany

Re: Inkey issue in console on rmb

Post by UEZ »

I'm on this path:

Code: Select all

#Include "windows.bi"

Sub SetConsoleSize(cols As Long, lines As Long)
    Shell "MODE CON: COLS=" + Str(cols) + "LINES=" + Str(lines)
End Sub

Dim Shared As HWINEVENTHOOK gHook

Sub HandleWinEvent(hook As HWINEVENTHOOK, Event As DWORD, hwnd As HWND, idObject As Long, idChild As Long, dwEventThread As DWORD, dwmsEventTime As DWORD)
	Select Case Event
		Case EVENT_SYSTEM_MENUPOPUPSTART
			? "Popup menu was called. How to disable it?"
	End Select
End Sub

Dim As DWORD cmode
Dim As HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE)
GetConsoleMode(hInput, @cmode)
SetConsoleMode(hInput, ENABLE_EXTENDED_FLAGS Or (cmode And Not ENABLE_QUICK_EDIT_MODE))
SetConsoleSize(90, 8)

? "Press right mouse bottom"
Dim As Long iPosCursor = Csrlin
Dim As String key


gHook = SetWinEventHook(EVENT_SYSTEM_MENUPOPUPSTART, EVENT_SYSTEM_MINIMIZEEND, Null, @HandleWinEvent, 0, 0, WINEVENT_OUTOFCONTEXT Or WINEVENT_SKIPOWNPROCESS)

Dim As MSG msg
While True
	If PeekMessage(@msg, 0, 0, 0, PM_REMOVE) Then
		TranslateMessage(@msg)
		DispatchMessage(@msg)
	Endif
	If Len(Inkey()) Then Exit While
	Sleep(10)
Wend

UnhookWinEvent(ghook)

SetConsoleMode(hInput, cmode)

? "Done"
Sleep
I need to figure out how to access to the popup menu. GetSystemMenu() is only for the menu when you click on the icon on the left upper corner.
hhr
Posts: 206
Joined: Nov 29, 2019 10:41

Re: Inkey issue in console on rmb

Post by hhr »

ENABLE_MOUSE_INPUT may help, perhaps
ENABLE_EXTENDED_FLAGS Or (cmode And (Not ENABLE_QUICK_EDIT_MODE Or Not ENABLE_MOUSE_INPUT)))
Look at
https://gist.github.com/rururutan/5998a ... 974868fcc3
UEZ
Posts: 972
Joined: May 05, 2017 19:59
Location: Germany

Re: Inkey issue in console on rmb

Post by UEZ »

hhr wrote:ENABLE_MOUSE_INPUT may help, perhaps
ENABLE_EXTENDED_FLAGS Or (cmode And (Not ENABLE_QUICK_EDIT_MODE Or Not ENABLE_MOUSE_INPUT)))
Look at
https://gist.github.com/rururutan/5998a ... 974868fcc3
Unfortunately not - when I click on rmb the popup menu appears and when I paste the clipboard then console executes the chars.

Edit:

this works partially, popup menu is not visible:

Code: Select all

SetConsoleMode(hStdIn, ENABLE_EXTENDED_FLAGS Or (cmode Xor (Not ENABLE_QUICK_EDIT_MODE Or Not ENABLE_MOUSE_INPUT)))
but when I have e.g. "q" in the clipboard then the char will still be send to the console.
Post Reply