o
k
q
u
e
s
t
i
o
n
s
.
c
o
m

GetAsyncKeyState.... -

Hi
I am using GetAsyncKeyState to move players around in my game(same keyboard), but whenever one presses a key, the other players movement is interfered....how can I prevent this??

Code:
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000 ? 1 : 0)


#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000 ? 0 : 1)  


if(GetAsyncKeyState(VK_LEFT)){
	// Move player left
	player.x--;
	SetPixel(hdc,(player.x)+1, (player.y),RGB(255,255,255));
	SetPixel(hdc,player.x-=2, player.y,player.color);
	
}
if(GetAsyncKeyState(VK_RIGHT)){
	// Move player right
	player.x++;
	SetPixel(hdc,(player.x)-1, (player.y),RGB(255,255,255));
	SetPixel(hdc,player.x+=2, player.y,player.color);
}
if(GetAsyncKeyState(VK_UP)){
	// Move player up
	
	player.y--;
	SetPixel(hdc,(player.x), (player.y)+1,RGB(255,255,255));
	SetPixel(hdc,player.x, player.y-=2,player.color);
	if(player.y<=0){
		player.y = 500;
		SetPixel(hdc,(player.x), (0),RGB(255,255,255));
	}
}
if(GetAsyncKeyState(VK_DOWN)){
	// Move player down
	player.y++;
	SetPixel(hdc,(player.x), (player.y)-1,RGB(255,255,255));
	SetPixel(hdc,player.x, player.y+=2,player.color);
}

if(GetAsyncKeyState(0x41)){
	// Move player2 left
	player2.x--;
	SetPixel(hdc,(player2.x)+1, (player2.y),RGB(255,255,255));
	SetPixel(hdc,player2.x-=2, player2.y,player2.color);
	
}
if(GetAsyncKeyState(0x44)){
	// Move player2 right
	player2.x++;
	SetPixel(hdc,(player2.x)-1, (player2.y),RGB(255,255,255));
	SetPixel(hdc,player2.x+=2, player2.y,player2.color);
}
if(GetAsyncKeyState(0x57)){
	// Move player2 up
	
	player2.y--;
	SetPixel(hdc,(player2.x), (player2.y)+1,RGB(255,255,255));
	SetPixel(hdc,player2.x, player2.y-=2,player2.color);
	if(player2.y<=0){
		player2.y = 500;
		SetPixel(hdc,(player2.x), (0),RGB(255,255,255));
	}
}
if(GetAsyncKeyState(0x53)){
	// Move player2 down
	player2.y++;
	SetPixel(hdc,(player2.x), (player2.y)-1,RGB(255,255,255));
	SetPixel(hdc,player2.x, player2.y+=2,player2.color);
}

 

hot key help -
I've tried just about everything, but I can't get this code to work... Help Me! Please!!!!! Const VK_ESCAPE = &H1B Const VK_CONTROL = &H11 Const VK_SHIFT = &H10 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private


GetAsyncKeyState.... -
Hi I am using GetAsyncKeyState to move players around in my game(same keyboard), but whenever one presses a key, the other players movement is interfered....how can I prevent this?? Code: #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000 ? 1 : 0) #define K


GetAsyncKeyState() help -
for the function GetAsyncKeyState() how do you know what value it will return? like if i press a how do i get the number for a? ive tried ascii numbers but that doesnt work.


help me with my game :) -
my code is really poor and works kind of choppy but i'd like some help in making a simple side scrolling shooting game for visual basic... Option Explicit Private Declare Function GetAsyncKeyState Lib _ "user32" _ (ByVal vKey As Long) As


[2.0] VB6 to C# -
How does this if statement translate to C# (I dont get the And &H8000 ) Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer Private Sub Timer1_Timer() Dim keystate(1) As Integer keystate(0) = GetAsyncKeyState(vbKeyContr


Does GetAsyncKeyState Only Work With Letters/Numbers -
The following will work with all the letters and numbers but not with keys such as the comma, period or other keys like that. Any reasons? This Works: RetVal = GetAsyncKeyState(Asc("A")) If RetVal = KEY_PRESSED Then MsgBox "Yes!" This Does Not:


[VB] Insta Hotkey -
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer Private Sub Timer1_Timer() Dim keystate(1) As Integer keystate(0) = GetAsyncKeyState(vbKeyControl) keystate(1) = GetAsyncKeyState(vbKeyTab) If keyst


GetAsyncKeyState() Problem... -
Hi, Guys! How can I set false all the GetAsyncKeyState() keys? Sometimes I get some True values... I want something like reseting all keys... Thank you, Arie. (mag.up.co.il)


Api help -
OK, I need help With this Api.. This Api Called GetAsyncKeyState will check the status the key I want. But I dont know How to tell it to check the Arrow Keys. Whats the Name for them ( IE. GetAsyncKeyState (VK_Q)) Some help please?


The GetAsyncKeyState API Call - Usefull Info -
For every one who uses the GetAsyncKeyState API call: I found out the VB's KeyCodeConstants are the same as the VK_* constants.


GetAsyncKeyState in services -
You could use the winapi GetAsyncKeyState in VB6 and VB7, but you can't use them in services(It will give no return value, It does not work). Why, I dont get any Exception or something?


Getasynckeystate not responding to keyboard -
Heres a weird problem, GetAsyncKeyState api will not respond to any keyboard key presses on my comp for some reason, though i can use it on mouse clicks. Anyone know why? Or, anyone know of another way i can tell when a key is pressed outside of the form?


Collission Detection -
I have to lines on a form.... Line1 is "standing up", line1 is laying down. I'm moving Line2 towards line1, and want to detect thwn the "tip" of Line2 touches Line1.. I have the following code: Code: Private Declare Function GetAsyncKeyState Lib "u


GetAsyncKeyState vs. GetKeyState -
Hello, I found a function that checks the state of CapsLock key. But I couldnt understand it. - What is the difference between GetAsyncKeyState and GetKeyState? - Why was the while loop used here? - What is the working principle of those codes? Thanks in advance. Code:


A timer in a dll -
Well I got a dll that is attached to a process now how do I have a timer check for keypresses using getasynckeystate? I know vb and C# but this is first time using C++ really. I know the basic syntax but its the commands i dont know. So what im asking is how do i add a timer and how


GetAsyncKeyState (mismatch error) -
I get a mismatch error when I try to do this: Code: Private Sub Timer1_Timer() If GetAsyncKeyState(vbKeyControl) And GetAsyncKeyState(vbKey1) Then 'do stuff End If End Sub Why do you think I keep getting this error? Is there an alternative code I can use?


Help me find error in my code -
Ok its a key Logger..... Keep in mind i can't use "public" in declarations because i have vb3 In general as a function I have Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer In the form1 load event... I have Sub Form_L


GetAsyncKeyState [resolved] -
Is there anyway to trick this into thinking the button is pressed when its not? I am trying to send mouse clicks + enter strokes to an application and its not working, the code is good, but the application is catching it and ignoring it... I think it might be using something like GetA


Return 0 -
Hey, how would I go about returning a 0 when using GetAsyncKeyState to detect a keypress? If GetAsyncKeyState(vbKeyInsert) Then KeyAscii = 0 SendKeys "{DELETE}", True End If doesn't work


Handle KeyDown and KeyUp -
Hi im making a small D3D sample, where i accelerate a ball using the arrow keys. I accelerate using GetAsyncKeystate, and i then want it to deaccelerate when i release the forward key, but how would i go about this? Tried using GetAsyncKeystate, but even if i hold the button down, it


GetAsyncKeyState(ö) -
Hi! Does someone know the GetAsyncKeyState char for Ö ? My friend need help! in a program its writed the code is 192, but that code didn't work for my friend! We've search in google in like 30 min now and haven't found yet! he say that Å and Ä is working :S and its has code 22


[2005] how do i use "GetAsyncKeyState" API. -
hi all, i am facing problem in using this API "GetAsyncKeyState" can any body please give some coding or some important hints regarding this problem, how could i use it, because i did all possible search but unable to find. please help me............ regards


Using GetAsyncKeyState() ... -
Hi, I have a question, How can I use the GetAsyncKeyState() function to do a one pressing key like i'll press space and it will work just once but i'm still holding the space bar. it will do it again when i'll release the space bar and then press it again. How can I do it? Any co


Programmer in need of help here. -
Hi, I am presently doing this information system on Math. I used the GetAsyncKeyState function to be able to get the keys that the user presses. the problem here is that whenever the timer (where I put the getasynckeystate function) is enabled, it does the events that should be done


Keypress outside form -
I am trying to figure out how to code my program to notice when the "E" key is pressed outside of the form. How do i do this I am kind of lost. I have tried the following so far..... What value do i put in for "e" i read its a numeric value and i found the virtual


GetAsyncKeyState -
I`m using this code to wait for a click from the user to pause and continue the program. On some PC's it doesnt work, any idea why ? also how do i detect if its clicked on a particular form ? Public Sub Wait4Click() Dim press As Boolean press = False Do DoEve


Detect Double-Click on external program -
I am trying to detect a double-click on an external program but the following is not working. Timer1.interval = 1 Code: Option Explicit Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Const WM_LBUTTONDBLCLK = &am


Keylogger for anti theft app -
I made an anti theft application for my laptop. If i report it stolen online it'll log on to a website and the IP will be logged. I want to add a keylogger to it so i can find out more easily who is in possession of my laptop. When i use the GetAsyncKeystate and the for i 32 to 1


Does GetAsyncKeyState work in Vista and VB6 -
Does the function GetAsyncKeyState still work in Vista with VB6? I know there are issues with sending keys but how about reading them even from other apps? I was wanting to use it and have my VB6 run in the background and check the keys typed. When certain ones are typed, have it perfo


User-defined hotkey. -
How can I do this? I have a label the the hotkey (e.g. "Alt + F1) The label changes to whatever the user defines as the hotkey.. It can be "Ctrl + Alt + Shift + A" or whatever's on the keyboard. I'm using GetAsyncKeyState since it is able to get key presses wit


Left and Right Control keys. -
I need to know the diff between the left and right control keys. Hey and if I can get the anwser for the left and right on the alt and shift that would great! This is what I have... Help? Private Sub Timer1_Timer() Dim ctl As Boolean Dim dwn As Boolean If GetAsyn


HighScore, getting the users name -
I'm witing a highscore table for a game I'm making, and I've run in to a problem... Whenever I press a key the game quits... I get this error message: "First-chance exception in Game.exe: 0xC0000005: Access Violation." I have no idea what this means... Code: void HighSco


Clicking with mouse using keyboard -
I want to click with my mouse using my keyboard. That means when I press a key it clicks. I'm using this to move the mouse Code: Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Private Declare Function GetCursorPos Lib "use


Problem with GetAsyncKeyState API -
I have this function: Private Function KeyPressed(iKey As Integer) As Boolean If GetAsyncKeyState(iKey) < 0 Then KeyPressed = True Else KeyPressed = False End If End Function I call this function in the lost_focus event of a text box, that is ina use


More synchronic than GetAsyncKeyState -
Hi again! Some time ago, I asked for windows equivalent for dos Inkey$. I was warned about GetAsyncKeyState API function and I would like to thank you. But in Get... I must to determine if any of the key is pressed. Inkey$ always contains the pressed key - it is quicklier, and at the


SendMessageLong [ Please ...] -
(.DLL file) VB Code: Public Function DisableKeys()Dim Ret As LongRet = FindWindow("Window", vbNullString)If Ret <> 0 ThenMsgBox "Can't Find Window"Exit FunctionEnd If If GetAsyncKeyState(vbKeyF1) Or GetAsyncKeyState(vbKeyF2) Or GetAsyncK


GetAsyncState: how to avoid key-pressing -
In the Timer event I've this line of code: If GetAsyncKeyState(13) <> 0 Then Msgbox "You press it." The problem is that if I press the key as everybody do, it occurs few times at least, instead of 1. I did the same trial in this way: If GetAsyncKeyState(13) <


GetAsyncKeyState or a better way -
I am trying to get a grasp on writing a keystroke logger. Private Sub Listen1_Listen() For i = 32 To 256 x = GetAsyncKeyState(i) If x = -32767 Then Text1.Text = Text1.Text + Chr(i) End If So basically my understand is this will then watch or check for the key pressed last? o


help with VK keys -
Hey, first of all, is VK key the best way to go? I use it in C++ a litte, seems to work. Anyways, heres what I have, isn't working. Dim checkkeys As Boolean Private Declare Function GetAsyncKeyState _ Lib "user32" (ByVal vKey As Long) As Integer Private Sub Form_Load(


SendKeys and pausing -
I wanted to create a macro for my friend that can press the F1 - F12 buttons every two seconds once the "Insert" key is pressed in his game. The problem I am having is when i run the following code, my computer freezes up: Public Sub DoKeys1() If GetAsyncKeyState(vbKeyIns