Prevent the Shortcut from Writing to the Text Field.

Get help with using AutoHotkey and its commands and hotkeys
hasantr
Posts: 86
Joined: 05 Apr 2016, 14:18

Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 01:09

NumLock+Any Number. Sample(NumLock+5) = 2015/

I am sending a text to the text writing field. But I had to use Backspace. Because the shortcut key also writes to the text field. Backspace can cause problems.
How can I handle it? I want a solution to not write the shortcut to the text field instead of Backspace or Ctrl + Z.


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

hasantr
Posts: 86
Joined: 05 Apr 2016, 14:18

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 06:02


In short, I do not want to write letter using this command. But he writes. I have to delete it with backspace.
MannyKSoSo
Posts: 198
Joined: 28 Apr 2018, 21:59

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 06:59

You could do this

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Edit:
V: Visible. Normally, the user's input is blocked (hidden from the system). Use this option to have the user's keystrokes sent to the active window.
hasantr
Posts: 86
Joined: 05 Apr 2016, 14:18

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 07:50

Thank you. Everything is so easy.

There is a problem. "V:Visible" I can not write anything without .
MannyKSoSo
Posts: 198
Joined: 28 Apr 2018, 21:59

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 07:55

What are you trying to write with the Visible option?
hasantr
Posts: 86
Joined: 05 Apr 2016, 14:18

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 13:57

MannyKSoSo wrote:What are you trying to write with the Visible option?

Anything.
and then my keyboard does not work anymore.

There is no problem using the V: option, but then it sends the printed key.
MannyKSoSo
Posts: 198
Joined: 28 Apr 2018, 21:59

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 14:08

So I think the problem is with the loop and the gosub back to the start of that loop. If you just have it only as a hot key like in my example my keyboard works, then when I want to send that key I just hold it down and hit the number. As I am typing this I have the script running, and when I press and hold the numpad and press 3 I get this 2013/ and can type afterwards. Make sure you are encoding to the right format as well. Personally I use UTF-8-BOM for my scripts.
hasantr
Posts: 86
Joined: 05 Apr 2016, 14:18

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 15:15

MannyKSoSo wrote:So I think the problem is with the loop and the gosub back to the start of that loop. If you just have it only as a hot key like in my example my keyboard works, then when I want to send that key I just hold it down and hit the number. As I am typing this I have the script running, and when I press and hold the numpad and press 3 I get this 2013/ and can type afterwards. Make sure you are encoding to the right format as well. Personally I use UTF-8-BOM for my scripts.


The problem was a numerical mouse. :)
https://support.microsoft.com/en-us/hel ... se-pointer

I turned off the numeric mouse completely.

Thank you. Thanks to your help.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

hasantr
Posts: 86
Joined: 05 Apr 2016, 14:18

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 15:29

Can I check if the cursor is in the text field?

if(cursorOnTextArea)
{
Send,"Ahk Ahk Ahk..."
}
MannyKSoSo
Posts: 198
Joined: 28 Apr 2018, 21:59

Re: Prevent the Shortcut from Writing to the Text Field.

13 Jul 2018, 17:00

You can look up the the focus control https://autohotkey.com/docs/commands/Co ... tFocus.htm specific for ControlGetFocus which you can get a loop for something like this

Code: [Select all] [Download] GeSHi © Codebox Plus

ControlGetFocus, OutputVar, Untitled - Notepad
if ErrorLevel
MsgBox, The target window doesn't exist or none of its controls has input focus.
else
MsgBox, Control with focus = %OutputVar%

However this doesn't do the specific text field. If its a custom ahk gui its easier to do, but if you are on a website trying to input information then I think (could be wrong) use a ComObject to check if you have a text field focused. Other than that I'm unsure you can know if its in a text field. A possible work around could be a tab through different text field after the first one selected (if there are multiple text fields you need to input information).

Edit: #If MouseIsOver("ahk_class (TextField)") would probably be the best bet looking at it more, but its still a more complex problem knowing if you have your cursor over a text box.
hasantr
Posts: 86
Joined: 05 Apr 2016, 14:18

Re: Prevent the Shortcut from Writing to the Text Field.

14 Jul 2018, 18:01

MannyKSoSo wrote:You can look up the the focus control https://autohotkey.com/docs/commands/Co ... tFocus.htm specific for ControlGetFocus which you can get a loop for something like this

Code: [Select all] [Download] GeSHi © Codebox Plus

ControlGetFocus, OutputVar, Untitled - Notepad
if ErrorLevel
MsgBox, The target window doesn't exist or none of its controls has input focus.
else
MsgBox, Control with focus = %OutputVar%

However this doesn't do the specific text field. If its a custom ahk gui its easier to do, but if you are on a website trying to input information then I think (could be wrong) use a ComObject to check if you have a text field focused. Other than that I'm unsure you can know if its in a text field. A possible work around could be a tab through different text field after the first one selected (if there are multiple text fields you need to input information).

Edit: #If MouseIsOver("ahk_class (TextField)") would probably be the best bet looking at it more, but its still a more complex problem knowing if you have your cursor over a text box.



It was a little complicated for me.
Thank you for everything.

Return to “Ask For Help”

Who is online

Users browsing this forum: dot64, Gibbons, wryyymuda and 77 guests