Using ClassNN

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Using ClassNN

Post by Felix Siano » 27 May 2023, 15:57

Is it possible to use ClassNN to perform a certain function? Every program has a text box called ClassNN. I would like to click with the left mouse button on the given ClassNN and perform the ^v. it's possible?

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 27 May 2023, 16:32

Felix Siano wrote: Every program has a text box called ClassNN.
Not every program has those text box controls. And the control is not called ClassNN. Some have a text box control which have a ClassNN name (where Class is the type of control and NN is the particular number), but the ClassNN is how the actual control name is referred to. You can find out the actual ClassNN name using the Window Spy tool.

Felix Siano wrote: I would like to click with the left mouse button on the given ClassNN and perform the ^v. it's possible?
You could have a script continuously check the control that has focus of the active window, and when it has a certain ClassNN, the script could send ^v.

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 27 May 2023, 16:37

using Whatsapp as an example: ClassNN: ApplicationFrameInputSinkWindow1 this is the name of the conversations search box. Can you do it?

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 28 May 2023, 07:47

I don't have WhatsApp installed, but here's an example using Notepad. It pastes the clipboard when its text entry control whose ClassNN is "Edit1" is clicked:

Code: Select all

#Requires AutoHotkey v2.0

#HotIf WinActive("ahk_exe notepad.exe") && ControlGetClassNN(ControlGetFocus("ahk_exe notepad.exe")) = "Edit1"
~LButton up::Send "^v"

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 28 May 2023, 20:01

It worked here!! THANK YOU VERY MUCH! I've been trying to do this for a long time! YOU ARE GREAT!

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 28 May 2023, 20:25

Perfect! You are great! It worked here.
But can you use Send with %Clipboard%?
Put what's on the clipboard.

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 28 May 2023, 20:33

In v2, it’s not Send %Clipboard%. It’s Send A_Clipboard. Everything is expressions, and the name of the clipboard variable has changed. Yes, you can send it if you want. I don’t know why you would want to do that instead of pasting. It’s more reliable.

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 28 May 2023, 20:51

There is a ClassNN that only accepts the send with the text that is in the transfer area. That's why it has to be Send A_Clipboard instead of Send "^v"

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 31 May 2023, 11:51

Code: Select all

#Requires AutoHotkey v2.0

#HotIf WinActive("ahk_exe notepad.exe") && ControlGetClassNN(ControlGetFocus("ahk_exe notepad.exe")) = "Edit1"
RButton up::Send "^v"
Hello again, is it possible to add a left mouse click before the ^V?


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 31 May 2023, 12:05

Code: Select all

RButton up::Send "{Click}^v"

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 19 Jun 2023, 22:59

Could you give me one more help? I'm trying to use it in the program, but the error. I will try to send the prints
Attachments
SAVE_20230620_245506.jpg
SAVE_20230620_245506.jpg (20.09 KiB) Viewed 1296 times
IMG_20230620_005728.jpg
IMG_20230620_005728.jpg (33.49 KiB) Viewed 1296 times

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 20 Jun 2023, 02:37

I’m not sure since you haven’t shown the whole line of code. I would try a script that just does this and nothing else and see what it says:

Code: Select all

MsgBox WinExist("ahk_exe NFe.exe")

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 20 Jun 2023, 07:26

Code: Select all

#Requires AutoHotkey v2.0

#HotIf WinActive("ahk_exe NF.exe") && ControlGetClassNN(ControlGetFocus("ahk_exe NF.exe")) = "TcxGroupBox1"
~LButton up::Send "^v"
This is the complete code.


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 20 Jun 2023, 08:03

You didn't reproduce the process name correctly. You have NF.exe and you showed it's NFe.exe. I don't know why it would be different than what the error message showed you had before.

Please use [code][/code] tags when posting code.

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 20 Jun 2023, 08:32

forgiveness! The code that gives the error is correct. I made a mistake sending you

#Requires AutoHotkey v2.0

#HotIf WinActive("ahk_exe NFe.exe") && ControlGetClassNN(ControlGetFocus("ahk_exe NFe.exe")) = "TcxGroupBox1"
~LButton up::Send "^v"

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 20 Jun 2023, 08:59

I'm sorry. I will use

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 20 Jun 2023, 09:18

Did you try this suggestion?
boiler wrote:
20 Jun 2023, 02:37
I would try a script that just does this and nothing else and see what it says:

Code: Select all

MsgBox WinExist("ahk_exe NFe.exe")

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 21 Oct 2023, 20:53

Is it possible to use the window title together with ClassNN:?
I used it as below. But it only works on: ahk_exe ***.exe
And a way to ignore the error I sent you earlier? I tried to read the documentation but it's difficult. The translation is not very good. Would you help me?

Code: Select all

#Requires AutoHotkey v2.0
~LButton::
{
SetTitleMatchMode(2)
If (WinActive("ahk_exe ApplicationFrameHost.exe") && ControlGetClassNN(ControlGetFocus("ahk_exe ApplicationFrameHost.exe")) = "ApplicationFrameInputSinkWindow1")
if RegExMatch(A_Clipboard, "^\d{5,6}$"){
Send(A_Clipboard)
}
}
Attachments
clans.png
clans.png (30.95 KiB) Viewed 778 times

User avatar
boiler
Posts: 16774
Joined: 21 Dec 2014, 02:44

Re: Using ClassNN

Post by boiler » 21 Oct 2023, 23:05

No, if the ClassNN of some control is ApplicationFrameHost, then you don’t use it in a WinTitle parameter as ahk_exe ApplicationFrameHost.exe or any other way. Why would you try to use that anyway? Use only the information from the top section of Window Spy for the WinTitle parameter.

Make sure you have correct code before you try ignoring error messages. Right now, the error messages are your friend because it’s telling you when you are doing things wrong like what your just posted.

Also, you’re making it very confusing by showing a Window Spy example that has title and control info totally different than what’s in your code, so it’s not possible to advise you what to use because I can’t tell which actually matches the window and control of interest.

Felix Siano
Posts: 84
Joined: 23 Apr 2023, 13:03

Re: Using ClassNN

Post by Felix Siano » 21 Oct 2023, 23:32

sorry. I didn't pay attention to the error of the image and the code being different.
I use Google Translate to interact and everything becomes more difficult to understand and clear my doubts.

Post Reply

Return to “Ask for Help (v2)”