How to determine classsNN of a control by its color or by its location in autohotkey?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

12 Nov 2015, 02:58

thanks dear @just me. You are really very helpful and kind to others. you are genius!!!!!! thanks brother...
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

12 Nov 2015, 03:11

OK, let's try again using pure AHK as sinkface suggested:

Code: Select all

#IfWinActive, Finacle - Microsoft Internet Explorer ; create a context-sensitive hotkey
F1::
PixelSearch, Px, Py, 131, 302, 214, 316, 0xCEFFCE, 3, Fast RGB
If (ErrorLevel = 0) { ; found
   ; The following commands use the Last Found Window set by #IfWinActive
   ControlText := ""
   WinGet, CL, ControlList
   Loop, Parse, CL, `n
   {
      ClassNN := A_LoopField
      If (SubStr(ClassNN, 1, 4) <> "Edit") ; skip if not an edit control
         Continue
      ControlGet, Vis, Visible, , %CLassNN%
      If !(Vis) ; skip hidden controls
         Continue
      ControlGetPos, CX, CY, CW, CH, %ClassNN%
      If (Px >= CX) && (Py >= CY) && (Px <= (CX + CW)) && (Py <= (CY + CH)) {
         ControlGetText, ControlText, %ClassNN%
         Break
      }
   }
   If (ControlText) {
      MsgBox, 0, Found Text!, %ControlText%
      ; Send %ControlText%}
   }
   Else
      MsgBox, 0, Sorry!, This one doesn't work!
}
Return
*untested*
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

12 Nov 2015, 03:30

Thanks dear @just me. You are real helpful and kind to others. I appreciate your enthusiasm to help others. Thanks a lot brother..
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

12 Nov 2015, 08:11

Dear @just me, I regret to say that these codes are also not working. when i run these codes after opening the finalce window it show the msgbox Sorry!, This one doesn't work!
But anyway, I appreciate your intention to help. I am sure you will certainly figure out its solution. Thanks a lot dear sir.
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

13 Nov 2015, 08:14

Hi dear @just me, is there something else that we can do to solve this problem. I am waiting for your kind reply. Thanks a lot dear..
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

13 Nov 2015, 09:08

Hi manoj,

I have no clue, but I guess there's a problem with the coordinates. Here's another test (activate the window, move the mouse onto the control, and hit F1):

Code: Select all

#NoEnv
F1::
   MouseGetPos, Px, Py, WinID, ClassNN
   MouseGetPos, , , , CtlID, 2
   WinGetTitle, WinTitle, ahk_id %WinID%
   WinGetClass, WinClass, ahk_id %WinID%
   WinGetClass, CtlClass, ahk_id %CtlID%
   ControlGetPos, CX, CY, CW, CH, , ahk_id %CtlID%
   ControlGetText, CtlText, , ahk_id %CtlID%
   ParentID := DllCall("GetParent", "Ptr", CtlID "UPtr")
   WinGetTitle, ParentTitle, ahk_id %ParentID%
   WinGetClass, ParentClass, ahk_id %ParentID%
   Msg := "Window ID: " . (WinID + 0) . "`n"
        . "Title: " . Title . "`n"
        . "Class: " . Title . "`n`n"
        . "Control ID: " . (CtlID + 0) . "`n"
        . "ClassNN: " . ClassNN . "`n"
        . "Class: " . Class . "`n"
        . "Text: " . CtlText . "`n`n"
        . "Parent ID: " . ParentID . "`n"
        . "Title: " . ParentTitle . "`n"
        . "Class: " . ParentClass
   MsgBox, 0, Result, %Msg%
Return
What does the MsgBox show for you?
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

13 Nov 2015, 09:28

I'm not sure if it would be a good idea changing the path you're on with "Just Me"
but there might be another way, using Microsoft Active Accessibility, can you try using this program http://www.ranorex.com/support/user-gui ... x-spy.html to see if it can get the text you're looking for, or http://autohotkey.com/board/topic/77888 ... 012-09-20/ Accessible Info Viewer by jethrow
if so then it might get easier.
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

16 Nov 2015, 03:29

just me wrote:Hi manoj,

I have no clue, but I guess there's a problem with the coordinates. Here's another test (activate the window, move the mouse onto the control, and hit F1):

Code: Select all

#NoEnv
F1::
   MouseGetPos, Px, Py, WinID, ClassNN
   MouseGetPos, , , , CtlID, 2
   WinGetTitle, WinTitle, ahk_id %WinID%
   WinGetClass, WinClass, ahk_id %WinID%
   WinGetClass, CtlClass, ahk_id %CtlID%
   ControlGetPos, CX, CY, CW, CH, , ahk_id %CtlID%
   ControlGetText, CtlText, , ahk_id %CtlID%
   ParentID := DllCall("GetParent", "Ptr", CtlID "UPtr")
   WinGetTitle, ParentTitle, ahk_id %ParentID%
   WinGetClass, ParentClass, ahk_id %ParentID%
   Msg := "Window ID: " . (WinID + 0) . "`n"
        . "Title: " . Title . "`n"
        . "Class: " . Title . "`n`n"
        . "Control ID: " . (CtlID + 0) . "`n"
        . "ClassNN: " . ClassNN . "`n"
        . "Class: " . Class . "`n"
        . "Text: " . CtlText . "`n`n"
        . "Parent ID: " . ParentID . "`n"
        . "Title: " . ParentTitle . "`n"
        . "Class: " . ParentClass
   MsgBox, 0, Result, %Msg%
Return
What does the MsgBox show for you?


Dear @just me, you are really a great man. I show my gratefulness towards your excellence and fervor to help me. Dear sir when I run these codes putting the mouse pointer over the specific control then it shows a msgbox with the following detail-

Window ID: 66136
Title:
Class:
Control ID: 2950040
ClassNN: Editl0
Class:
Text: 03201000600208
Parent ID: 3277756
Title:
Class: SunAwtCanvas

Please tell me what to do further. Thanks a lot sir..
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

16 Nov 2015, 03:35

Sorry, there were some typos in the test script. Would you please repeat the test?

Code: Select all

#NoEnv
F1::
   MouseGetPos, Px, Py, WinID, ClassNN
   MouseGetPos, , , , CtlID, 2
   WinGetTitle, WinTitle, ahk_id %WinID%
   WinGetClass, WinClass, ahk_id %WinID%
   WinGetClass, CtlClass, ahk_id %CtlID%
   ControlGetPos, CX, CY, CW, CH, , ahk_id %CtlID%
   ControlGetText, CtlText, , ahk_id %CtlID%
   ParentID := DllCall("GetParent", "Ptr", CtlID "UPtr")
   WinGetTitle, ParentTitle, ahk_id %ParentID%
   WinGetClass, ParentClass, ahk_id %ParentID%
   Msg := "Window ID: " . (WinID + 0) . "`n"
        . "Title: " . WinTitle . "`n"
        . "Class: " . WinClass . "`n`n"
        . "Control ID: " . (CtlID + 0) . "`n"
        . "ClassNN: " . ClassNN . "`n"
        . "Class: " . CtlClass . "`n"
        . "Text: " . CtlText . "`n`n"
        . "Parent ID: " . ParentID . "`n"
        . "Title: " . ParentTitle . "`n"
        . "Class: " . ParentClass
   MsgBox, 0, Result, %Msg%
Return
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

16 Nov 2015, 05:15

just me wrote:Sorry, there were some typos in the test script. Would you please repeat the test?

Code: Select all

#NoEnv
F1::
   MouseGetPos, Px, Py, WinID, ClassNN
   MouseGetPos, , , , CtlID, 2
   WinGetTitle, WinTitle, ahk_id %WinID%
   WinGetClass, WinClass, ahk_id %WinID%
   WinGetClass, CtlClass, ahk_id %CtlID%
   ControlGetPos, CX, CY, CW, CH, , ahk_id %CtlID%
   ControlGetText, CtlText, , ahk_id %CtlID%
   ParentID := DllCall("GetParent", "Ptr", CtlID "UPtr")
   WinGetTitle, ParentTitle, ahk_id %ParentID%
   WinGetClass, ParentClass, ahk_id %ParentID%
   Msg := "Window ID: " . (WinID + 0) . "`n"
        . "Title: " . WinTitle . "`n"
        . "Class: " . WinClass . "`n`n"
        . "Control ID: " . (CtlID + 0) . "`n"
        . "ClassNN: " . ClassNN . "`n"
        . "Class: " . CtlClass . "`n"
        . "Text: " . CtlText . "`n`n"
        . "Parent ID: " . ParentID . "`n"
        . "Title: " . ParentTitle . "`n"
        . "Class: " . ParentClass
   MsgBox, 0, Result, %Msg%
Return

Ok dear @just me. When I run these codes then the following msgbox appear with these values-

Window ID: 66136
Title: Finacle - Microsoft Internet Explorer
Class: IEFrame
Control ID: 1836162
ClassNN: Edit 10
Class: Edit
Text: 07721100000004
Parent ID: 4719834
Title:
Class: SunAwtCanvas

Now what to do next sir. Thanks a lot sir..
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

16 Nov 2015, 06:13

Well, I don't know. Now it's clear why WindowFromPoint found a window of class SunAwtCanvas. But the script using the control list to identify the control should work (at least I cannot find a mistake). All positional values should use the same relative coordinate mode. I added a MsgBox to show the control list and removed the visibility check. Would you try it again, please?

Code: Select all

#IfWinActive, Finacle - Microsoft Internet Explorer ; create a context-sensitive hotkey
F1::
PixelSearch, Px, Py, 131, 302, 214, 316, 0xCEFFCE, 3, Fast RGB
If (ErrorLevel = 0) { ; found
   ; The following commands use the Last Found Window set by #IfWinActive
   ControlText := ""
   WinGet, CL, ControlList
   MsgBox, %CL%
   Loop, Parse, CL, `n
   {
      ClassNN := A_LoopField
      If (SubStr(ClassNN, 1, 4) <> "Edit") ; skip if not an edit control
         Continue
      ; ControlGet, Vis, Visible, , %CLassNN%
      ; If !(Vis) ; skip hidden controls
         ; Continue
      ControlGetPos, CX, CY, CW, CH, %ClassNN%
      If (Px >= CX) && (Py >= CY) && (Px <= (CX + CW)) && (Py <= (CY + CH)) {
         ControlGetText, ControlText, %ClassNN%
         Break
      }
   }
   If (ControlText) {
      MsgBox, 0, Found Text!, %ControlText%
      ; Send %ControlText%}
   }
   Else
      MsgBox, 0, Sorry!, This one doesn't work!
}
Return
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

17 Nov 2015, 03:02

just me wrote:Well, I don't know. Now it's clear why WindowFromPoint found a window of class SunAwtCanvas. But the script using the control list to identify the control should work (at least I cannot find a mistake). All positional values should use the same relative coordinate mode. I added a MsgBox to show the control list and removed the visibility check. Would you try it again, please?

Code: Select all

#IfWinActive, Finacle - Microsoft Internet Explorer ; create a context-sensitive hotkey
F1::
PixelSearch, Px, Py, 131, 302, 214, 316, 0xCEFFCE, 3, Fast RGB
If (ErrorLevel = 0) { ; found
   ; The following commands use the Last Found Window set by #IfWinActive
   ControlText := ""
   WinGet, CL, ControlList
   MsgBox, %CL%
   Loop, Parse, CL, `n
   {
      ClassNN := A_LoopField
      If (SubStr(ClassNN, 1, 4) <> "Edit") ; skip if not an edit control
         Continue
      ; ControlGet, Vis, Visible, , %CLassNN%
      ; If !(Vis) ; skip hidden controls
         ; Continue
      ControlGetPos, CX, CY, CW, CH, %ClassNN%
      If (Px >= CX) && (Py >= CY) && (Px <= (CX + CW)) && (Py <= (CY + CH)) {
         ControlGetText, ControlText, %ClassNN%
         Break
      }
   }
   If (ControlText) {
      MsgBox, 0, Found Text!, %ControlText%
      ; Send %ControlText%}
   }
   Else
      MsgBox, 0, Sorry!, This one doesn't work!
}
Return
Thanks a lot dear brother @just me for your great support. Dear sir when I run these codes then first it showed me a blank msgbox, and when I clicked on ok button in that blank msgbox then it again showed a msgbox saying- This one doesn’t work!



Dear sir @just me could I ask you one more question if you do not mind? My question is this-

I have an excel sheet and I want that the last cell which must contain any value of column k should be converted into a variable. For this i tried to use these codes-

Code: Select all

     
xl := ComObjActive("Excel.Application")
return
 F1::
row := 1          ; starting row
while c := xl.range("K" row++).value
            var1 := c
MsgBox % var1
return
    
 

these codes are working fine, but there is a bit problem in the codes as when any blank cell encounters or if zero encounters in column k then the msgbox not appears for the last value in column k. In other words as there are values from k1 to k10 and I press f1 key then the value of k10 is shown in msgbox (so far it is working good), and now I leave k11 blank or leave it with zero and enters value in k12 then I press f1 key then it does not show the value of k12 in stead it shows the value of k10 again in msgbox. I want when it encounters any blank cell or zero in column k then it should also skip that cell and should go to next cell if there is any value in next cell. Similarly if it encounters multiple blank cells or zeros in column k then it should also skip all those blank cells and zeros and go to that cell which has any value immediately after multiple blank cells or zeros. So kindly help me fixing this problem too. Thanks a lot sir. Waiting for your kind reply.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

17 Nov 2015, 03:33

Hello manoj,

that's strange. The first empty MsgBox means that WinGet didn't find any control. On the other hand, MouseGetPos does find the window as well as the control. I don't know why this happens. Normally, I don't deal with web/java applications. So I give up at this point.

Also, I don't use Excel any more. But I believe that newer versions of Excel provide a property/method to get the used range of a sheet. If you get it, you can use it as a limit for the loop on column K.
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

17 Nov 2015, 08:56

just me wrote:Hello manoj,

that's strange. The first empty MsgBox means that WinGet didn't find any control. On the other hand, MouseGetPos does find the window as well as the control. I don't know why this happens. Normally, I don't deal with web/java applications. So I give up at this point.

Also, I don't use Excel any more. But I believe that newer versions of Excel provide a property/method to get the used range of a sheet. If you get it, you can use it as a limit for the loop on column K.

You are really a great man dear brother just me. I have become a great fan of yours. Really the zest and excitement which you have to help others are rare. However we could not figure out the solution of the problem but one thing is clear that you have the great and extreme knowledge of autohotkey and programming. Moreover I myself have learnt a lot from you. I hope you will keep helping to learn autohotkey to the newbies like me. I request you to give me your email address so that I can ask you a question directly (don't worry I will do it in very rare case). God bless you. Thanks a lot. Hats off to you. :salute: :salute: :salute: :salute: :salute: :salute: :salute:
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

22 Nov 2015, 05:25

just me wrote:Hello manoj,

that's strange. The first empty MsgBox means that WinGet didn't find any control. On the other hand, MouseGetPos does find the window as well as the control. I don't know why this happens. Normally, I don't deal with web/java applications. So I give up at this point.

Also, I don't use Excel any more. But I believe that newer versions of Excel provide a property/method to get the used range of a sheet. If you get it, you can use it as a limit for the loop on column K.

Dear @just me, I have tried a lot to retrieve the specific control’s id without moving mouse pointer to the specific control, but still I am unsuccessful to retrieve it. Dear sir, meanwhile I noticed that the content of the control whose id I wish to retrieve, always have 14 numeric digit no. Therefore, can’t it be done that the control whose content has 14 numeric digit no, that control’s classNN should be retrieved via winget command? For example something like this-

Code: Select all

#IfWinActive, Finacle - Microsoft Internet Explorer ; create a context-sensitive hotkey
F1::
PixelSearch, Px, Py, 131, 302, 214, 316, 0xCEFFCE, 3, Fast RGB
If (ErrorLevel = 0) { ; found
   ; The following commands use the Last Found Window set by #IfWinActive
   ControlText := ""
   WinGet, CL, ControlList, Finacle - Microsoft Internet Explorer  ;sir here we were missing the title of the window that’s why we were getting first empty msgbox
   MsgBox, %CL%
   Loop, Parse, CL, `n
   {
      ClassNN := A_LoopField
      If (SubStr(ClassNN, 1, 4) <> "Edit") ; skip if not an edit control
         Continue
;here it should be something like if classNN has 14 numeric digit then retrieve the classNN of that A_Loopfield.
So kindly help me once more to do that as it can never complete without your guidance. Thanks a lot sir.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

22 Nov 2015, 06:10

Hello manoj!

Code: Select all

WinGet, CL, ControlList, Finacle - Microsoft Internet Explorer  ;sir here we were missing the title of the window that’s why we were getting first empty msgbox
This should not happen because #IfWinActive sets the "Last Found" Window which will be used if the title is omitted.

Does the first MsgBox show controls for you if you add the title, and if so, which controls?
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

23 Nov 2015, 00:57

just me wrote:Hello manoj!

Code: Select all

WinGet, CL, ControlList, Finacle - Microsoft Internet Explorer  ;sir here we were missing the title of the window that’s why we were getting first empty msgbox
This should not happen because #IfWinActive sets the "Last Found" Window which will be used if the title is omitted.

Does the first MsgBox show controls for you if you add the title, and if so, which controls?
Yes dear just me, now it is showing the long list of controls in the first msgbox and it is also showing the content of control in second msgbox. Earlier it was not working at all and now codes are working like magic.
First msgbox is showing the list of control like this-
Workewl
ReBarwmldow32l
Toobarwsndow32l
ToobsWVdow322
Workew2
Toolbswrdow323
workerw3
msct!s_statusbar32l
msctlsjrogess32 1
ATL: 6627748011
1DM Dov*doad Panel controler class 1
shel DocObyect View I
Internet Explorer-Server 1
Java Pug-m Control window 1
SunAw#Framel
SunAwACawas 1
SunAMCawas2
SunAwkCanvas3
SunAwkcawas4
Sun4w*Cawas5
SunAw4LtheI 1
SunAMLthel2
SunAw4Lthel3
SunAw#Label4
SunAwLabel5
SunAw4Ltel6
Edit 1
SunAw4Ltel7
Edit2
SunAMtabel8
Edit3
5unA’Aiabe
Edit4
SunAw4Label 10
Edits
SunAwftabell 1
Edito
SunAMLthell2
Combo8oxl
Buttonl
SunAvkLabell3
SunAwtabell4
SunAwtCanvas6
SunAwkCanwas7
SunAwttabel15
SunAMLabel 16
SunAw#Lthell7
SunAwtLthell8
SunAwkCawas8
5un4w4Cawas9
SunAww45crollPane 1
Sun4wkcanwas 10
SunAw4ScroWane2
5unAw4Camvas 11
SunAwtCswas 12

List is much long
And the second msgbox is showing the content of that specific control.
Now what should we do? Please guide me further. Thanks a lot sir..
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

23 Nov 2015, 03:55

Hello manoj,

since you got it working, remove that first MsgBox and use it. The value of interest is stored in ControlText. I don't know what you want to do with it.
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

23 Nov 2015, 05:10

just me wrote:Hello manoj,

since you got it working, remove that first MsgBox and use it. The value of interest is stored in ControlText. I don't know what you want to do with it.
THANKS A LOT DEAR SIR JUST ME....YOU ARE REALLY genius......I will try to modify the codes according to my need....I appreciate your excellence.....ultimately you made it possible :superhappy: :superhappy: ....thanks a lot brother once again.... :salute:
manoj aggarwal

Re: How to determine classsNN of a control by its color or by its location in autohotkey?

24 Nov 2015, 03:10

just me wrote:Hello manoj!

Code: Select all

WinGet, CL, ControlList, Finacle - Microsoft Internet Explorer  ;sir here we were missing the title of the window that’s why we were getting first empty msgbox
This should not happen because #IfWinActive sets the "Last Found" Window which will be used if the title is omitted.

Does the first MsgBox show controls for you if you add the title, and if so, which controls?

Dear just me now the codes are working fine but i am facing a little problem, as i want that when i press f1 it should first activate the finacle window. but it is not activating it. the final codes which i am using are these-

Code: Select all

#IfWinActive, Finacle - Microsoft Internet Explorer ; create a context-sensitive hotkey
f1::
IfWinNotActive, Finacle - Microsoft Internet Explorer, , WinActivate, Finacle - Microsoft Internet Explorer, 
WinWaitActive, Finacle - Microsoft Internet Explorer,  ; added here winactivate command for activating finacle window first, but it is not working
sleep 100
PixelSearch, Px, Py, 197, 299, 232, 320, 0xACA899, 3, Fast RGB
If (ErrorLevel = 0) { ; found
   ; The following commands use the Last Found Window set by #IfWinActive
   ControlText := ""
   WinGet, CL, ControlList
   
   Loop, Parse, CL, `n
   {
      ClassNN := A_LoopField
      If (SubStr(ClassNN, 1, 4) <> "Edit") ; skip if not an edit control
         Continue
      ; ControlGet, Vis, Visible, , %CLassNN%
      ; If !(Vis) ; skip hidden controls
         ; Continue
      ControlGetPos, CX, CY, CW, CH, %ClassNN%
      If (Px >= CX) && (Py >= CY) && (Px <= (CX + CW)) && (Py <= (CY + CH)) {
         ControlGetText, ControlText, %ClassNN%
         Break
      }
   }
}  
      
      ; Send %ControlText%
sleep 100
send {SHIFT DOWN}
sleep 100
send {F3}
sleep 100
send {SHIFT UP}
sleep 100
loop 
{
coordmode, pixel, screen
imagesearch, foundx, foundy, 0,0,1360,768, c:\Documents and Settings\Administrator\Desktop\f1.bmp
if errorlevel=0
break
if errorlevel=1
continue
}

send acli{ENTER}
sleep 100
loop 
{
coordmode, pixel, screen
imagesearch, foundx, foundy, 0,0,1360,768, c:\Documents and Settings\Administrator\Desktop\acli.bmp
if errorlevel=0
break
if errorlevel=1
continue
}

sleep 100
send %ControlText%
sleep 100
mousemove 0,0

return
#IfWinActive
i tried to add winactivate command at the starting of the codes to activate finacle window first, but it is not working. yes, when i remove

Code: Select all

#IfWinActive, Finacle - Microsoft Internet Explorer
from the top of the codes and the buttom line

Code: Select all

#IfWinActive
then it activates the finacle window but then it does not retrieve the content of the specific control. the codes are working perfect while keeping the finacle window active. kindly help me and tell me how can i first activate the finacle window and the use the codes. thanks a lot sir...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Hugh Jars, Mateusz53, MrDoge, peter_ahk and 375 guests