API for checking up and down arrow?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.

Does anyone remember/know what API commands to use to check for pressing an up or down arrow?

I'd rather not use the PB keyboard function because that requires an up-to-date DirectX installed and a lot of people who test my programs do not have that and of course it crashes.

/me falls out of the chair asleep. (IRC talk)

Thanks to anyone who remembers:)

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Does anyone remember/know what API commands to use to check for pressing an up or down arrow?

Code: Select all

GetAsyncKeyState_(#VK_UP) ; Clear up key buffer.
GetAsyncKeyState_(#VK_DOWN) ; Clear down key buffer.
;
; And to check their state during runtime:
If GetAsyncKeyState_(#VK_UP)=-32767 ; Up arrow pressed.
If GetAsyncKeyState_(#VK_DOWN)=-32767 ; Down arrow pressed.

PB - Registered PureBasic Coder

Edited by - PB on 11 June 2002 01:55:17
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Why not using AddKeyboardShortcut(Window, #PB_Shortcut_Up) ?

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

I tested it and it is the right way to do it now ... good and useful.

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> I tested it and it is the right way to do it now

Using the API is not a "wrong" way, you know.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
Why not using AddKeyboardShortcut(Window, #PB_Shortcut_Up) ?

Fred - AlphaSND
A. I don't know where to put it (no example).
B. I don't know the syntax to check it.

I need to generate an up and down arrow event in a ListIconGadget so that I can go to some code. Where do I put that above code, how do I check it??


Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
> Does anyone remember/know what API commands to use to check for pressing an up or down arrow?

Code: Select all

GetAsyncKeyState_(#VK_UPARROW) ; Clear up key buffer.
GetAsyncKeyState_(#VK_DOWNARROW) ; Clear down key buffer.
;
; And to check their state during runtime:
If GetAsyncKeyState_(#VK_UPARROW)=-32767 ; Up arrow pressed.
If GetAsyncKeyState_(#VK_DOWNARROW)=-32767 ; Down arrow pressed.

PB - Registered PureBasic Coder
Thanks PB, but I get "Constant not found" for those two.

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Thanks PB, but I get "Constant not found" for those two.

Sorry, they're meant to be #VK_UP and #VK_DOWN (I typed them from memory and
while half-asleep). I've fixed my example above to reflect this. BTW, all
these constants are found in the Win32API.doc file, if you have it. If not,
it's here (143k): http://www.mvps.org/vb/code/Win32api.zip

PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
> Thanks PB, but I get "Constant not found" for those two.

Sorry, they're meant to be #VK_UP and #VK_DOWN (I typed them from memory and
while half-asleep). I've fixed my example above to reflect this. BTW, all
these constants are found in the Win32API.doc file, if you have it. If not,
it's here (143k): http://www.mvps.org/vb/code/Win32api.zip

PB - Registered PureBasic Coder
Thanks PB, works like a duck's bottom in water :):)

Fangles
Post Reply