Program don't recognize keystrokes

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
AgentOrange
Newbie
Posts: 7
Joined: Tue Jun 29, 2010 1:43 am

Program don't recognize keystrokes

Post by AgentOrange » Fri Oct 19, 2012 8:05 pm

Hi!
I have a problem with keystrokes. For example, I'm trying to make a macro to press enter, type "Hello", and press enter again, but the program recipient does not receive the keystrokes. The program is a game called ***. I was testing, but almost no keys function. Probe with enter, shit, ctrl, F1, F2, etc.. No way.
It's strange, because with another program called ********, works well but does not have imaging capabilities.
I leave a simple code example:

Code: Select all

SetFocus>***
WaitReady>0
Press Enter
wait>1
SendText>Hello!
wait>1
Press Enter
Sorry for my english and thanks.
Last edited by AgentOrange on Mon Nov 05, 2012 8:15 pm, edited 2 times in total.

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Hello

Post by PepsiHog » Sat Oct 20, 2012 1:55 am

@AgentOrange,

Good code, but instead try this.(Or something like it)

Code: Select all

SetFocus>ImperiumAO 1.4.9
Wait>5
Press Enter
wait>1
SendText>Hello!
wait>1
Press Enter
Wait 5 seconds is probably too long. But this is only for testing. Unless your running a 286. I hope not. :lol:

Good Luck,
PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

AgentOrange
Newbie
Posts: 7
Joined: Tue Jun 29, 2010 1:43 am

Post by AgentOrange » Sat Oct 20, 2012 2:23 am

Thanks for your answer.
The program detects the "Hello!" but not the Enter key. The same applies to other special keys such as Shift, Ctrl, F1, F2, etc..

It's strange

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Hello

Post by PepsiHog » Sat Oct 20, 2012 2:45 am

@AgentOrange,

I typed in the name and didn't get back a specific game. What game is it? Is it online or is it retail? Do you have a link?

PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

AgentOrange
Newbie
Posts: 7
Joined: Tue Jun 29, 2010 1:43 am

Post by AgentOrange » Sat Oct 20, 2012 2:55 am

Yes, it's a online game. The name is ** and the link is [url]http://www.**.com.ar/en/[/url]
Last edited by AgentOrange on Tue Oct 30, 2012 6:11 pm, edited 1 time in total.

AgentOrange
Newbie
Posts: 7
Joined: Tue Jun 29, 2010 1:43 am

Post by AgentOrange » Sat Oct 20, 2012 5:40 pm

I do not know if this helps, but in the program I previously used to send keystrokes, if I put simply did not work. To work properly should put:

(,0)
(,0)
And the same for other keys like Shift, Ctrl, or Fs

I've tried to put Press Enter and Release Enter, but does not work.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Oct 20, 2012 6:34 pm

You can do this with keybd_event. Search the forums for keybd_event for examples.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

AgentOrange
Newbie
Posts: 7
Joined: Tue Jun 29, 2010 1:43 am

Post by AgentOrange » Sat Oct 20, 2012 7:13 pm

I tried with the following code I found on the forum, but it does not work:

Code: Select all

SetFocus>**
WaitReady>0

Let>VK_control=13
Let>ExtendedKey=1
Let>KeyUp=2

Press Enter
LibFunc>user32.dll,keybd_event,r,VK_control,0,ExtendedKey,0
Wait>0.5
Release Enter
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_control,0,FLAGS,0

SendText>Hello!

Press Enter
LibFunc>user32.dll,keybd_event,r,VK_control,0,ExtendedKey,0
Wait>0.5
Release Enter
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_control,0,FLAGS,0
Last edited by AgentOrange on Tue Oct 30, 2012 6:12 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Oct 20, 2012 9:01 pm

Here you are using KeyBd Event to send control and release control but not Enter. I thought the idea is that you use keybd_event to send/release the Enter key as well.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

AgentOrange
Newbie
Posts: 7
Joined: Tue Jun 29, 2010 1:43 am

Post by AgentOrange » Sat Oct 20, 2012 10:26 pm

Is not 13 ​​the code for the Enter key?
I've also tried the following, without success:

Code: Select all

SetFocus>**
WaitReady>0

Let>VK_RETURN=13
Let>ExtendedKey=1
Let>KeyUp=2

Press Enter
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,ExtendedKey,0
Wait>0.5
Release Enter
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,FLAGS,0

SendText>Hello!

Press Enter
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,ExtendedKey,0
Wait>0.5
Release Enter
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,FLAGS,0
Last edited by AgentOrange on Tue Oct 30, 2012 6:12 pm, edited 1 time in total.

AgentOrange
Newbie
Posts: 7
Joined: Tue Jun 29, 2010 1:43 am

Post by AgentOrange » Mon Oct 22, 2012 2:54 pm

I think the problem is the speed at which you press the enter key. With this code, not work very well, but at least recognize the enter key occasionally. I do not understand why it does not work with keybd_event. Is there any other way to control the speed similar to KeyDown or KeyUp?

Code: Select all

Label>Start
    Press ENTER * 200
    Wait>0.5
Goto>Start
EDIT:
Someone would have an example using SendMessage, PostMessage or SendInput instead of keybd_event?

Thanks

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Tue Nov 27, 2012 5:32 am

"sendtext" will try and press enter after the text is sent wich can cause problems instead try using "send" also sometimes you need to have a slight wait after the send before the enter is pressed
it looks like your issue is that.
i don't see why you would need to hold down the enter button
you could probably remove the wait>0.5 in between the press and release of enter
it looks like you just bringing up the chat bar and sending the text after its typed

link for vk_keys :
http://www.mjtnet.com/vkcodes.htm

here is how i would do it

Code: Select all

SetFocus>**


Let>VK_RETURN=13
Let>ExtendedKey=1
Let>KeyUp=2

Press Enter
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,ExtendedKey,0
wait>0.5
Release Enter
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,FLAGS,0


Send>Hello!
wait>0.5

Press Enter
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,ExtendedKey,0
wait>0.5
Release Enter
Let>FLAGS={%ExtendedKey% OR %KeyUp%}
LibFunc>user32.dll,keybd_event,r,VK_RETURN,0,FLAGS,0

if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts