A forced keydown() ?

BlitzMax Forums/BlitzMax Beginners Area/A forced keydown() ?

sandav(Posted 2006) [#1]
Is it possible to make it so that BlitzMax forces a key to be keydown? For example, I want the program to "push" the "Enter" key down without the user manually pushing the "Enter" key. I've seen programs that make the mouse automatically "click" over and over again, and i was just wondering if BlitzMax could do something like that with the keyboard.


tonyg(Posted 2006) [#2]
Just manually set the variable which holds whether the enter key was pressed down...
Graphics 640 , 480
st=MilliSecs()+5000
While Not KeyHit(key_escape)
	 DrawText "Press enter key" , 0 , 0
	 If KeyDown(key_enter) enterkey = 1
	 If MilliSecs() > st
	    If enterkey=0 DrawText "Lazy git, I'll do it for you",0,30
	 	enterkey = 1
	 EndIf
	 If enterkey DrawText "Enter key pressed",0,40
	 Flip
Wend

or have I misunderstood?


degac(Posted 2006) [#3]
No Sandav wants to 'send to the event queue' a keydown event...probably it is necessary to handle with this subsystem...I'm at work at the moment so I can't help!


tonyg(Posted 2006) [#4]
Not sure how you determined that but how about this...
Graphics 640 , 480
While Not KeyHit(key_escape)
	If MilliSecs() > displayfor Cls
	PollEvent()
	Select EventID()
		Case EVENT_KEYDOWN
			Select EventData()
				Case  KEY_ENTER
					DrawText "Enter key pressed" , 0 , 0
					displayfor=MilliSecs()+1000
			End Select
	End Select
	If KeyHit(KEY_SPACE) 
		sim_keydown:TEvent = CreateEvent(EVENT_KEYDOWN , , KEY_ENTER)
		PostEvent(sim_keydown)
	EndIf
	Flip
Wend




CS_TBL(Posted 2006) [#5]
It's all about your architecture!

What about this: Make sure your application works without any GUI at all! Control the complete application using messages sent from a script orso. So a message could contain some code for 'functionality #1' and somewhere else you link a certain button to this functionality. When you execute that message you send out an event like EVENT_BUTTONCHANGE. Then due all the eventhook things the actual button will see that he's the chosen one, and will readout the functionality #1 state and change accordingly so.

So uhm (still with me? :P) this way you can have your functionality by either pressing a button or performing a script. By seperating this functionality from the GUI implementation you're somewhat multi-platform compatible. As in, the only thing you need to code on a not-supported platform is the interface, the functionality is still the same, as scripts don't change.

ok, dinner-time ^_^


kfprimm(Posted 2006) [#6]
bbSystemEmitOSEvent? Can't get it to work yet...