Script for sending Enter automatically after finishing the typing Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
soheill0098
Posts: 25
Joined: 01 Sep 2020, 12:28

Script for sending Enter automatically after finishing the typing

Post by soheill0098 » 11 Apr 2021, 12:41

I am using a dictionary program for PC. when I'm typing on the search bar of the application I should press Enter every time after I finish typing the word(s) so that the program search for the word. I want an autohotkey script for the application in order to automatically sending Enter after I finished typing the word. so the script should automatically send Enter after I didn't type for instance for 0.75 second at the end of typing ( I'm doing touch typing so I assume it takes less than a 0.75 second for me to press two buttons although the time might be adjustable). So can you please help me with this?
Thanks in advanced!

User avatar
mikeyww
Posts: 7020
Joined: 09 Sep 2014, 18:38

Re: Script for sending Enter automatically after finishing the typing

Post by mikeyww » 11 Apr 2021, 13:02

Code: Select all

#InstallKeybdHook
lag := 500
Loop {
 WinWaitActive, ahk_exe notepad.exe
 Sleep, lag
 SoundBeep, 1500
 SetTimer, Check, 100
 WinWaitNotActive
 SetTimer, Check, Off
 SoundBeep, 1000
}
Check:
last := typing, typing := A_TimeIdleKeyboard < lag
If !last || typing
 Return
Send {Enter}
SoundBeep, 1700
Return

soheill0098
Posts: 25
Joined: 01 Sep 2020, 12:28

Re: Script for sending Enter automatically after finishing the typing

Post by soheill0098 » 11 Apr 2021, 13:13

mikeyww wrote:
11 Apr 2021, 13:02

Code: Select all

#InstallKeybdHook
lag := 500
Loop {
 WinWaitActive, ahk_exe notepad.exe
 Sleep, lag
 SoundBeep, 1500
 SetTimer, Check, 100
 WinWaitNotActive
 SetTimer, Check, Off
 SoundBeep, 1000
}
Check:
last := typing, typing := A_TimeIdleKeyboard < lag
If !last || typing
 Return
Send {Enter}
SoundBeep, 1700
Return
Thanks, but unfortunately it didn't work.

User avatar
mikeyww
Posts: 7020
Joined: 09 Sep 2014, 18:38

Re: Script for sending Enter automatically after finishing the typing

Post by mikeyww » 11 Apr 2021, 13:17

Change "notepad" to match your own program.

soheill0098
Posts: 25
Joined: 01 Sep 2020, 12:28

Re: Script for sending Enter automatically after finishing the typing

Post by soheill0098 » 11 Apr 2021, 13:30

mikeyww wrote:
11 Apr 2021, 13:17
Change "notepad" to match your own program.
I did but still doesn't work( it worked in notepad)

It is a screen shot of windows spy for the application should I use "Oxford Advanced Learner's Dictionary" after Winactivate, ?

Also I wrote the script under

Code: Select all

#IfWinActive Oxford Advanced Learner's Dictionary
Maybe that caused the problem.
Attachments
2021-04-11 21_57_02-Window Spy.png
2021-04-11 21_57_02-Window Spy.png (22.45 KiB) Viewed 202 times

User avatar
mikeyww
Posts: 7020
Joined: 09 Sep 2014, 18:38

Re: Script for sending Enter automatically after finishing the typing  Topic is solved

Post by mikeyww » 11 Apr 2021, 13:38

#IfWinActive works only for hotkeys & hotstrings. You could try the following.

Code: Select all

#InstallKeybdHook
lag := 500
Loop {
 WinWaitActive, Oxford Advanced Learner
 Sleep, lag
 SoundBeep, 1500
 SetTimer, Check, 100
 WinWaitNotActive
 SetTimer, Check, Off
 SoundBeep, 1000
}
Check:
last := typing, typing := A_TimeIdleKeyboard < lag
If !last || typing
 Return
Send {Enter}
SoundBeep, 1700
Return

soheill0098
Posts: 25
Joined: 01 Sep 2020, 12:28

Re: Script for sending Enter automatically after finishing the typing

Post by soheill0098 » 11 Apr 2021, 14:03

mikeyww wrote:
11 Apr 2021, 13:38
#IfWinActive works only for hotkeys & hotstrings. You could try the following.

Code: Select all

#InstallKeybdHook
lag := 500
Loop {
 WinWaitActive, Oxford Advanced Learner
 Sleep, lag
 SoundBeep, 1500
 SetTimer, Check, 100
 WinWaitNotActive
 SetTimer, Check, Off
 SoundBeep, 1000
}
Check:
last := typing, typing := A_TimeIdleKeyboard < lag
If !last || typing
 Return
Send {Enter}
SoundBeep, 1700
Return
Thank you very much! I opened another file and put the script and it works now! but is it possible to do it somehow without the annoying beep beep sounds? Also it sends Enter several times instead of one time.

User avatar
mikeyww
Posts: 7020
Joined: 09 Sep 2014, 18:38

Re: Script for sending Enter automatically after finishing the typing

Post by mikeyww » 11 Apr 2021, 14:08

You can certainly delete the beep lines.

You might want to increase the lag.

soheill0098
Posts: 25
Joined: 01 Sep 2020, 12:28

Re: Script for sending Enter automatically after finishing the typing

Post by soheill0098 » 11 Apr 2021, 15:02

mikeyww wrote:
11 Apr 2021, 14:08
You can certainly delete the beep lines.

You might want to increase the lag.
You are right! It was stupid of me! :) :D

soheill0098
Posts: 25
Joined: 01 Sep 2020, 12:28

Re: Script for sending Enter automatically after finishing the typing

Post by soheill0098 » 13 Apr 2021, 09:37

@mikeyww I'm using the script for my application and realized that at about %10 of the times it doesn't send Enter automatically. I tried Sendinput too but that didn't help. So do you think it is possible to improve it or using alternative script ? Sorry for disturbing you sir.

Post Reply

Return to “Ask For Help”