AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Possible?: ControlID instead of ClassNN?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Stefan



Joined: 30 Jul 2004
Posts: 72
Location: Deutschland (sorry for my english)

PostPosted: Sun Jun 10, 2007 12:45 pm    Post subject: Possible?: ControlID instead of ClassNN? Reply with quote

Hi community,

i have an App with 3 combo boxes and this each with an Edit.

The visible Box i see and want to access to i call here FieldOne etc.

FieldOne = ID1 = Combo1 with Edit1
FieldTwo = ID2 = Combo2 with Edit2
FieldThree = ID3 = Combo3 with Edit3


----------------------
In my script i have to refer to an Field like
e.g. to FieldOne and i use Edit1 to access this FieldOne:

ControlFocus, Edit1,xyz
ControlSend, Edit1, {BS}, xyz
ControlSendRaw, Edit1

... OK so far.
----------------------

But the user can arrange this combo filed's in the window
and Combo1/Edit1 is suddenly bundled the FieldTwo.
And the FieldOne have now the Combo/Edit instance 3 behind.

But the ClassID stay the same to the field
no matter what Combo/Edit instance is behind:
FieldOne = ID1
FieldTwo = ID2
FieldThree = ID3

-----------------------

So here is the question:
can i use the ClassID instead of the ClassNN to access an Field?

ControlFocus, ClassID1,xyz
ControlSend, ClassID1, {BS}, xyz
ControlSendRaw, ClassID1


Thanks for any help
_________________
Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”


Last edited by Stefan on Sun Jun 10, 2007 7:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 265
Location: Russia

PostPosted: Sun Jun 10, 2007 5:58 pm    Post subject: Reply with quote

What is ClassID? Window handle? But they are different each time you launch an application. So you are probably talking about something else. At least I could not find this term in the AHK help. Rolling Eyes
Back to top
View user's profile Send private message
Stefan



Joined: 30 Jul 2004
Posts: 72
Location: Deutschland (sorry for my english)

PostPosted: Sun Jun 10, 2007 6:51 pm    Post subject: Reply with quote

ClassID ? Uppps, sorry. I mixed this up Confused
I mean ControlID.


I have found out that the Control and the Edit don't call
Combo1 and Edit1
but what i saw was Combo instance 1 and Edit instance 1 (the same for 2 and 3)

In the pic the Expression box is one times the first instance of an Combo
and so called Combo1
and an another time launched as third instance and so called Combo3.


That means if i arrange the combo boxes they are launched
in an different order
and so they are called 1,2 and 3 in the order the launched.

So i can't refer to Combo1 or Edit1 in my script.
Because the user could arrange his combos in an other style
and my script would fail.

But the ControlID is always the same.
So can i refer to an ControlID?
I found nothing in the help with "ControlFocus" or "ControlSend"
If i am unclear again please ask.

--
Edit:
I forgot: i have seen an "ahk_ID" but don't understood if this could be used.
_________________
Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”
Back to top
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 265
Location: Russia

PostPosted: Mon Jun 11, 2007 8:26 am    Post subject: Reply with quote

OK, now I see what it may be. So called 'child-window identifier'. As far as I remember, AHK commands don't use it to operate on controls. So first you have to translate it either into the ClassNN or window handle of the target control. The 'ahk_id' prefix is used with window handles.

I've tried to play with it and found it not so simple. The handle I was getting belonged not to the Edit control but either to the combobox itself or to its parent.

This code may work or not, just try it for test. It retrieves the list of controls' handles from a window and finds the one whose ControlID is 4. Then it takes its child, if any, and the child of the child, and so on till there are no childs any more. The final handle will hopefully be the one of the target Edit.
Code:

F11::
  WinGet, List, ControlListHwnd, WinTitle   ; Specify the title of your window.
  Loop, Parse, List, `n
    If DllCall("GetDlgCtrlID", "UInt", A_LoopField)=4
    {
      FieldOne:=A_LoopField
      Break
    }
  If not FieldOne
  {
    Msgbox, ControlID not found.
    Return
  }
  Loop
  {
    Child:=DllCall("GetWindow", "UInt", FieldOne, "UInt", 5)
    If Child
      FieldOne:=Child
    Else
      Break
  }
  ControlSend,, Hello world{!}, ahk_id %FieldOne%   ; The Edit's name is omitted
                                                     ; because it's treated as a
                                                     ; window, by its handle.
Return
Back to top
View user's profile Send private message
Stefan



Joined: 30 Jul 2004
Posts: 72
Location: Deutschland (sorry for my english)

PostPosted: Mon Jun 11, 2007 9:33 pm    Post subject: Reply with quote

Thanks YMP, i will see if i can manage this.
_________________
Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group