Timer Executes Arrow Up Key-Possible?

D

Detailz

Guest
hi,how is everyone? Im good thanx for askin.. :)

anyways..

I was wondering if it is possible to create a timer activated by right click and execute the arrow up key in 1.5 seconds after the right click. Any response would be great on if its possible, the difficulty, and the what exactly i have to know to accomplish this task. Thank you very much for your input :)
 

Sintoras

Shaaakaa!
Reaction score
45
I could probably tell you if I knew what programming language you want to use. VB? C++? C#? Java?You want to program it, don't you?

It isn't hard to do, very easy on VB.net.

What you need to know to understand it is a little knowledge of the language you write the code in


Oh, and by the way, do you want the arrow key activated for the prgram or for anohter program?
 
D

Detailz

Guest
thanx for your help...

the arrow key will be used for another application. actually a drag racing game and it will help me achieve a better RT.

ok if that isnt hard..will it still be as easy to add a variable? cuz as i stage in different areas i will need to be able to adjust the timing from the right click to the function. i was gonna do it my self but if anyone is willing to help it would be greatly appreciated being i currently know nothing about programming.
also..im not lookin to spend any money on this project since it just for a game so is there any free programs to use?

If you were me, what language would u use,tools,and is there a nice tutorial site
to point me in the right direction? Thank you very much for all the help.
 

Sintoras

Shaaakaa!
Reaction score
45
I would use C++/C# to do this but as I'm not very good at C++,it would take me a while to figure it out.

C++ is the most widespread professional language, but alsoone of the more complicated.

If you want to start to program you might want to start with the language VB.net or with Python. They are easier languages but not quite as powerful.

I'd go with Dev-C++ or Microsoft Visual C++ 2008 Express Edition as a C++ IDE(Integrated Development Environment, used to compile and write code)

For VB.net use Microsoft Visual Basic 2008 Express Edition.

All the above are free but powerful.

There are masses of tutorials on the web so just use google.

I'll have a go at what you would like to have. What is the programs name you want to send the Up-Arrow Key to? And ydo you wnat it to execute the timer whenever you right click or only when the program which activates the timer is active. I hope I have expressed myself clearly :D
 
D

Detailz

Guest
well, ima keep the name of the game off the forum for fear of persecution :) but if your familiar with drag racing there is a Tree (4 stage light) it goes

Yellow
Yellow
Yellow
Green

with half a second in between each light. it is much easier to hit the first light perfect than it is to time it perfect for the green light. this will help greatly with consistancy in races making it easier to get a good reaction time. .500 is perfect and my internet connection is 56k so with lag its nearly impossible to compete with others running .512 time after time. the left click is the gas button and the up arrow key is the shift gears. so i start a full throttle and hit the arrow up key when close to the green light.

it would be perfect if the right click activated a timer of 1.5 seconds leaving the remaing .5 a variable to ajust to my computer specs and give room for user error. and thank you very much for attempting this. it would save me loads of time in homework :) i will IM you the name of the program i need this for but i dont want to draw any attention to my self if you know what i mean. again thank you
 

Sintoras

Shaaakaa!
Reaction score
45
As I said I'll try my best but if this game is online, no matter how quick the program simulates the click, your internet connection is still a barrier, slowing it down.

If you want to try this on your own, then look up the key words Key Hooking, thats what you're looking for. And simulating key presses.

In c++, this is how you simulate a key down press and send it to a program. Just change Game Name to whatever the window is called.

All you have to do is add the right click event and the timer which is easier.

Code:
#include <windows.h>

using namespace std;

int main()
{
HWND Parent = FindWindow(NULL,"Dev-C++ 4.9.9.2");
HWND Child = FindWindowEx(Parent,NULL,NULL,NULL);
SendMessage(Child, WM_LBUTTONDOWN, 0,0);
}

Correct me if I'm wrong, haven't had time to test it.
 
D

Detailz

Guest
hey thanks...i will certainly give it a shot 2..there is a user Vs computer part to the game also which dosent lag and this would be my main use for it.
 
D

Detailz

Guest
hmm...ya...


i been looking but havent found the resources i need to apply the WM_RBUTTONDOWN to a timer to activate the Key Up

if you could assist me a little bit more to accomplish this rediclious task ide be ever so greatful. thanx
 
D

Detailz

Guest
ok i got the timer..but..i cant apply the key up function...i did some reading but i cant get it to work..this is what i got.

#include <windows.h>


using namespace std;

int main()
{
HWND Parent = FindWindow(NULL,"*****"(beta)");
HWND Child = FindWindowEx(Parent,NULL,NULL,NULL);
SendMessage(Child, WM_RBUTTONDOWN, 0,0);

::Sleep(1000); //Timer

}
now for the last line i have tried to add

SendMessage(Child, WM_KeyUp, 0,0);

but i get the error
`WM_Keyup' undeclared (first use this function)

what am i doin wrong?
 
D

Detailz

Guest
ok cool.. thanx i got one more problem tho..

the program dosent wait for me to right click...it opens then closes i need it to wait until i right click is the program wrong?

cuz it looks like it simulates a right click waits then simulates a key up..

well i guess i got one more...its not sending the key up to the window..

is there a different way to approach this?
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
If the above post is all your program does, it's pretty normal it exits (almost) immediately. You're missing the main event/message loop.

See here for a brief description of the correct approach. Alternative: look around in your VisualStudio examples or books like Charles Petzold's Programming Windows.
 
D

Detailz

Guest
is this why it dosent send the function to the window or is that a whole problem in its self?
lol sorry if im frustrating anyone with all my questions but i honestly dont understand
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
is this why it dosent send the function to the window or is that a whole problem in its self?
Are you sure you're sending your messages to the right window handle? What about other keys, are they accepted by that program? And last but not least: you should check the return values of your function calls. If they return an error, there's no chance it will ever work without changing your code.

Given you're trying to mess with a game, it may read the keystrokes through a completely different way, like through the DirectX API.
 
D

Detailz

Guest
umm ya..has to be the right handle..ive tried every variation including .exe the exact name of it in the process list everything...i understand the the loop function somewhat ,thatx for the reference. my main focus is getting it to recognize key strokes.. is directX api difficult? from an experinced view. with this alone im very discouraged and dont think i could handle anything to much more complicated without hitting the books pretty hard.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top