SendKeys - Forum

Forum Navigation
You need to log in to create posts and topics.

SendKeys

I want to send keys (Ctrl + N) to another application. I try whith a "+" and whithout but nothing works. Could you help me ?

SendKeys "C:\Program Files (x86)\WinJump 2014\WinJump2014.exe" "{CtrlDn}+{N}"

Try this:

SendKeys "C:\Program Files (x86)\WinJump 2014\WinJump2014.exe" "{CtrlDn}{N}"

 

Thanks a lot for your quick answer.

But it doesn't work. I don't why.

I can control the application with single key like {F6} but {CtrlDn}{N} doesn't work ! But it works when I do it directly in the application by the keyboard !

An idea ?

@jerome-bruet

I can control the application with single key like {F6} but {CtrlDn}{N} doesn't work !

1) As stated here ... https://winhelp.visualneo.com/Applications.html#SENDKEYS ...

{ShiftDn} {ShiftUp} {CtrlDn} {CtrlUp} {AltDn} {AltUp}

These keys must always be used in pairs. For example, if you use {ShiftDn} you must remember to follow it with a {ShiftUp} code, otherwise your keyboard will behave as if the Shift key is stuck in the down position.

2) As shown in the example on this same page ...

SendKeys "notepad.exe" "Hello world{Enter}{AltDn}FP{AltUp}"

... regular text does not have to be placed inside curly brackets.

So try ...

{CtrlDn}N{CtrlUp}

Thanks !

It doesn't work ! But thank you :) !

 

@jerome-bruet

It doesn't work !

1) See if you can send the same keys to notepad.exe; note that if you do a Ctrl+N on a just opened notepad.exe, nothing will be visibly different, but if you do it while there is an unsaved text in the current space, you will be asked if you wanted to save this first.

2) Perhaps this is a timing issue i.e. if you are attempting to send this key combo immediately after the Run command, the SendKeys command may be serviced BEFORE this program is fully loaded and ready to accept keys.

You might want to wait a while until this program is fully loaded (either x seconds or temporarily have a separate button to send the keys after you can confirm that this program is ready to accept user input).

3) If you are interested in further investigating this anomaly ...

a) what does Ctrl+N do within this program ?

b) what does F1 do within this program ?

Thanks. I'll try all these points.

 

The results :

1) See if you can send the same keys to notepad.exe; note that if you do a Ctrl+N on a just opened notepad.exe, nothing will be visibly different, but if you do it while there is an unsaved text in the current space, you will be asked if you wanted to save this first.

>> It's open a new notepad but it isn't ask to save the first one
>> If I do a Ctrl+S, it works and it asks to save the new one
So Ctrl+S works

2) Perhaps this is a timing issue i.e. if you are attempting to send this key combo immediately after the Run command, the SendKeys command may be serviced BEFORE this program is fully loaded and ready to accept keys.

You might want to wait a while until this program is fully loaded (either x seconds or temporarily have a separate button to send the keys after you can confirm that this program is ready to accept user input).

>> I had tested this way but I don't think that can be the reason because if I do another action like {F6} it works well

3) If you are interested in further investigating this anomaly ...

a) what does Ctrl+N do within this program ?
>>It works. It do what the program must do

b) what does F1 do within this program ?
>>Nothing.

@jerome-bruet

Since I don't have WinJump2014.exe (and hence I do not know how it responds to the Ctrl+N user input), I did some tests using notepad.exe

I observed some strange behavior that I thought of sharing with you (and the VisualNEOWin community); of course, this may or may not happen with WinJump2014.exe, but here goes ...

a) as mentioned before, if I press the N key while holding down the Ctrl key ...

- if the data space is empty, nothing happens
- if the data space has some content, it asks me if the current data should be saved first (in other words, it attempts to service the New File request in the same space)

b) on the other hand, when I attempt to send {CtrlDn}N{CtrlUp}, it starts a new copy of notepad.exe; this is evidenced by the fact that when I move the mouse pointer over the notepad icon in the task bar, I see 2 copies.

If I send these keys bbbb{CtrlDn}N{CtrlUp}aaaa ... then the first (existing) copy accepts bbbbaaaa while a second copy is empty.

So, the response is different depending on the source of the Ctrl+N key combo.

I do not know if this anomaly arises from the SendKeys command, Windows (I am using version 10) or notepad.exe

And of course I do not know how WinJump2014.exe responds; this was the reason for my earlier enquiry about what WinJump2014.exe does with this key combo ... you might check the task bar after invoking the SendKeys command ... perhaps your program is designed not to start a second copy ?

b) what does F1 do within this program ?
>>Nothing.

LOL, I meant F6 (you mentioned that sending the key code for F6 worked as expected).

Unless you can share details of the response of your program to Ctrl+N and F6, I am afraid I have run out of ideas.

@jerome-bruet

LATE BREAKING NEWS ... notepad.exe treats Ctrl+n different than Ctrl+N (or Ctrl+Shift+n) ... i.e. open new file in same program vs. in new copy of program.

It is consistent with what happens when you SendKeys {CtrlDn}n{CtrlUp} vs. {CtrlDn}N{CtrlUp} ... so you might try and use the lowercase n.

luishp and alangonzalez91 have reacted to this post.
luishpalangonzalez91

Yesssss ! It works ! It was due to the capital letter {CtrlDn}n{CtrlUp} vs. {CtrlDn}N{CtrlUp}

Thanks a lot !

alangonzalez91 has reacted to this post.
alangonzalez91