Alt+ TAB problem

BlitzMax Forums/MaxGUI Module/Alt+ TAB problem

TAS(Posted 2014) [#1]
Windows 7:
Using the ALT+TAb keys to switch to another program followed by returning to the original Blitzmax program leaves EVENTMOD() equal to 4. Pressing and releasing the ALT key resets EVENTMOD() to zero. The return to Blitzmax program does generate a EVENT_APPRESUME and EVENT_WINDOWACTIVATE which I use to return focus to the canvas. Is there a way to reset Eventmod() at this time also?
CreateEvent() can be used to test the value of EventMod() but doesn't reset it
Right now I'm stuck with notifying the user that he needs to press the alt key himself


TomToad(Posted 2014) [#2]
What happens is you release the ALT key after the window looses focus so the program never recieves the keyup event. You could always send the event to windows manually

Only works on Windows, don't know how to do it on Mac or Linux:
SuperStrict
Import maxgui.drivers
Extern "win32"
	Function keybd_event(bVk:Byte, bScan:Byte, dwFlags:Int, Extra:Int Ptr = Null)
End Extern



Global Window:TGadget = CreateWindow("Test",10,10,800,600)
Global Panel:TGadget = CreatePanel(0,0,ClientWidth(Window),ClientHeight(Window),Window,PANEL_ACTIVE)

Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
			End
		Case EVENT_KEYDOWN
			If EventMods() = 4 Then Print "Alt key pressed"
			Print "Key pressed = "+EventData()
		Case EVENT_WINDOWACTIVATE
			DebugLog "I am here"
			keybd_event($12,KEY_LALT,$02)
			
	End Select
Forever



TAS(Posted 2014) [#3]
Thanks! That worked perfectly.