hydrofoam & GetASyncKeyState

Miscellaneous Forums/General Discussion/hydrofoam & GetASyncKeyState

*edited out*

On a more serious note (we need a topic eh ^_^)

GetASyncKeyState works fine on normal keys when the focus is on a TextArea.. except for keys like Esc and functionkeys. You need to press it, and then click somewhere before it works.. is there any to get around this?

Doesnt it work in complete disregard to windows, focus and anything at all?

not really..

Had the same issue earlier when pressing a button, thus giving it focus. Unfocusing works.. but the idea of the textarea is that I can still use keys like esc and function keys while typing. In this case I'm typing code/script, and want to use a key, like ESC, to parse/execute it. (which works! as long as I click somewhere after pressing esc)

Ofcourse it can be done by putting a button somewhere and create a hotkeyevent to it.. but that looses focus when you do stuff like alt-esc.

Aab is right, GetAsyncKeyState works without giving focus to something else.
; Parent Window
Local Desk_W = ClientWidth(Desktop()), Desk_H = ClientHeight(Desktop())
Parent = CreateWindow("Text Adventure Example by Eikon", Desk_W / 2 - 320, Desk_H / 2 - 240, 640, 480, 0, 1 + 2 + 4)
SetMinWindowSize Parent, 640, 480

; Menu
Const cnt_EXIT = 1

Menu = WindowMenu(Parent) 
File = CreateMenu("&File", 0, Menu)
CreateMenu "E&xit", cnt_EXIT, File
UpdateWindowMenu Parent

; Text Area
TArea = CreateTextArea(0, 0, 632, 400, Parent, 1)
SetGadgetLayout TArea, 2, 1, 2, 1

SetTextAreaText TArea, "You wake up cold and alone in a dank prison cell." + Chr$(10) + "What do you do?" + Chr$(10)

Font = LoadFont("Courier", 16, 0, 0, 0)
SetTextAreaFont TArea, Font              ; Font

SetTextAreaColor TArea, 0, 0, 0, 1     ; Back Color
SetTextAreaColor TArea, 0, 255, 255, 0 ; Fore Color

TField = CreateTextField(0, 402, 632, 32, Parent, 0)
SetGadgetFont TField, Font
SetGadgetLayout TField, 1, 1, 0, 1

ActivateGadget TField ; Set focus

AutoSuspend 1
SeedRnd MilliSecs()
Repeat

Select WaitEvent()	
	Case $803: End ; X Out
	
	Case $401 ; Gadget Event	
	Select EventData() 
		Case 13 ; Enter pressed
		SetTextAreaText TArea, TextAreaText(TArea) + TextFieldText(TField) + Chr$(10)
		SetGadgetText TField, "" ; Clear 

	End Select
	
	Case $1001 ; Menu Event
	If EventData() = cnt_EXIT Then End
	
End Select

For i = 0 To 256
	If GetAsyncKeyState(i) <> 0 Then Print i
Next
	
Forever


*edit*
Escape works fine in the TextField, but not in the TextArea. Definitely a B+ issue, I don't have this problem in Visual Basic. The function keys also seem to have a problem. Once another valid key is pressed, all the function key values previously pressed are printed all at once.

Maybe you could fake a valid keystroke with the keybd_event function at the right time to return all function keys pressed.

*edited out*

Re: Hydrofoam - Trying to get around the stated rules by posting non releated blitz stuff in a on topic thread is not acceptable, so I have edited this thread to ensure it is on topic. Please keep it that way, have a nice day!.

Give me a freakin break.

The hydrofoam isn't "technical in nature" enough for you? These forum rules are subjective bunk.

It doesn't have to be blitz related, read your own rules.

I have no comment... cuz shaggy will hang me by my noots.

Who wants to meet up over at www.codersworkshop.com? A sort of migration.

A sort of migration

And degradation at the same time. That's why it pains me to see this place run with such a heavy hand.