Why AHK controlsend with {Enter} not working? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lo4438
Posts: 53
Joined: 18 May 2022, 10:00

Why AHK controlsend with {Enter} not working?

Post by Lo4438 » 15 Aug 2022, 09:42

When i use controlsend a text, it's fine.
Please help to solve.
Many thanks.

Code: Select all

^5::
ControlSend, , {enter}, ahk_exe topgood.exe

Rohwedder
Posts: 7633
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Why AHK controlsend with {Enter} not working?

Post by Rohwedder » 15 Aug 2022, 10:15

Hallo,
Notepad accepts this controlsend,
try:

Code: Select all

^5::
ControlSend, , {enter}, ahk_exe notepad.exe
Return
If topgood.exe does not accept it then try it with window active, specification of the control and run script as admin.
E.g. for Notepad:

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Try Run *RunAs "%A_ScriptFullPath%"
^5::
WinActivate, ahk_exe notepad.exe
ControlSend, Edit1, {enter}, ahk_exe notepad.exe
Return

Lo4438
Posts: 53
Joined: 18 May 2022, 10:00

Re: Why AHK controlsend with {Enter} not working?

Post by Lo4438 » 15 Aug 2022, 10:37

Code: Select all

#SingleInstance, Force
If !A_IsAdmin
	Try Run *RunAs "%A_ScriptFullPath%"

^5::	


WinActivate, ahk_exe topgood.exe 
ControlSend, Edit1, {enter}, ahk_exe topgood.exe 
Return
Sorry Bro, your code still can't controlsend the {Enter} key

Rohwedder
Posts: 7633
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Why AHK controlsend with {Enter} not working?

Post by Rohwedder » 16 Aug 2022, 01:35

You have used ClassNN = Edit1.
https://www.autohotkey.com/docs/commands/ControlSend.htm
Control: Can be either ClassNN (the classname and instance number of the control) or the control's text, both of which can be determined via Window Spy.
If your target control is an edit control, as with Notepad, then try:

Code: Select all

^5::
Control, EditPaste, `r`n, Edit1, ahk_exe topgood.exe 
Return

Lo4438
Posts: 53
Joined: 18 May 2022, 10:00

Re: Why AHK controlsend with {Enter} not working?

Post by Lo4438 » 16 Aug 2022, 11:18

Rohwedder, thanks for your support. :)
Your command doesn't work on my script, i just use click on screen command .

SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Why AHK controlsend with {Enter} not working?  Topic is solved

Post by SOTE » 16 Aug 2022, 18:47

Lo4438 wrote:
15 Aug 2022, 10:37
Sorry Bro, your code still can't controlsend the {Enter} key
In order for people to help you, for your part, it's best to provide as much information as possible. Looking at this, I (and I'm sure others) have no idea about what topgood is. Maybe you can provide a screenshot of the program and your attempt? Did you try to use WindowSpy (or such similar programs) to get information about the window you are automating (maybe screenshot that too)? Send with WinExist()/WinActive() might be a little better. Just a few suggestions, if you still can't get it to work.

Lo4438
Posts: 53
Joined: 18 May 2022, 10:00

Re: Why AHK controlsend with {Enter} not working?

Post by Lo4438 » 17 Aug 2022, 09:25

SOTE, thanks for your suggestion.
WinActive command can fix my problem.

Code: Select all

^5::
WinActive, ahk_exe notepad.exe
ControlSend, , {enter}, ahk_exe notepad.exe
Return

Post Reply

Return to “Ask for Help (v1)”