With this little function you can use keys as a switch.You can use it to open/close windows or activate and deactivate ability or whatever you need with just one key.Replace text lines with your own code.
`Setup Display
sync on : sync rate 0
load dll "user32.dll",1
Sw=call dll(1,"GetSystemMetrics",0)
Sh=call dll(1,"GetSystemMetrics",1)
delete dll 1
set display mode Sw,Sh,32,1
set window off
backdrop on
autocam off
`Keystate function array
dim StateOfKeys(200,1)
dim KeyFlag(200)
global KeyFlag as integer
do
UpdateKeystate()
for i = 1 to 200
if StateOfKeys(i,1)
inc KeyFlag(i)
if KeyFlag(i) = 1
text 0,0,"ON"
endif
endif
next i
for i = 1 to 200
if StateOfKeys(i,1)
if KeyFlag(i) = 2
text 0,20,"OFF"
KeyFlag(i) = 0
endif
endif
next i
sync
loop
Function UpdateKeystate()
For x = 1 to 200
If Keystate(x)=1
If StateOfKeys(x,0)=0
StateOfKeys(x,1)=1
StateOfKeys(x,0)=1
else
StateOfKeys(x,1)=0
Endif
else
StateOfKeys(x,0)=0
Endif
Next x
Endfunction
Coding is My Kung Fu!
And My Kung Fu is better than Yours!