Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

what does ClassNN represent



  • Please log in to reply
6 replies to this topic
tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
I have actually been wondering this for a very long time

WHat precisely is a CLassNN
for instance within Notepad is Edit1 the controls ID

I ask because someone said they have all the id's of controls in an application but they dont want to edit the app instead make an autoinstaller with ahk

Could i take the control ID's from the actual source code of the app and write automation? without ever having the app?
Never lose.
WIN or LEARN.

Drugwash
  • Members
  • 1078 posts
  • Last active: May 24 2016 04:20 PM
  • Joined: 07 Sep 2008
Grab some free C/C++ code from CodeProject or elsewhere and look at resource.h and <project name>.rc (or anything close to that). You'll see controls like IDC_EDIT1, IDC_COMBO1, IDC_SCROLLBAR1, IDB_BITMAP1 and so on in the rc file, while in the header you'll see:
#define IDC_EDIT1 1013
#define IDC_COMBO1 1016
#define IDC_SCROLLBAR1 1018
#define IDB_BITMAP1 129
(values randomly taken from Yuri Goltsman's CFCtrlDemo)

The latter are control IDs while the former are control classes. The class is the "type" of control (Edit/ComboBox/Scrollbar/Bitmap) as the compiler knows it. The ID is an (arguably) arbitrary (incremental) value given by the compiler to each resource, to keep track of them throughout the code.

If I'm wrong, someone please correct me.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
✓  Best Answer
ClassNN comes from the (Windows API) window class and the index of the control, which is based on the number of controls of that class found while enumerating. Control identifiers are unfortunately irrelevant, and the window class is not something the compiler is aware of.

Edit1 is the first Edit control. Edit is a system class, and is not directly equivalent to the AutoHotkey Gui control type; for instance, while "Edit" is used by both AutoHotkey and Windows, AutoHotkey's Text and Picture controls both use the system class "Static". This also applies to "class names" in frameworks such as MFC (C++) or Windows Forms (.NET).

Could i take the control ID's from the actual source code of the app and write automation? without ever having the app?

Control identifiers can be of some use, but only with some messages (like WM_COMMAND) and Windows API functions. Note that this is only if the application actually uses these (numeric) identifiers with the Windows API. (I think they are set via SetWindowLong.)

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
Thank you Lexikos
I knew it would in the end be an answer provided by you or Chris
possibly Sean

lots of reading material for me thanks for the links as well
Never lose.
WIN or LEARN.

jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006

Control identifiers can be of some use, but only with some messages (like WM_COMMAND)

How can AHK discover a control's identifier?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Possibly:
MsgBox % DllCall("GetWindowLong", "uint", hwnd, "int", GWL_ID:=-12)


jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
That seems to work. I'll play with it more tomorrow. I should've mentioned I'm working with controls in an AHK Gui, if that makes any difference.