AutoHotkey Community

It is currently May 25th, 2012, 7:52 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: June 10th, 2007, 12:45 pm 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
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

_________________
Image 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 June 10th, 2007, 7:53 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 10th, 2007, 5:58 pm 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
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. :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 10th, 2007, 6:51 pm 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
ClassID ? Uppps, sorry. I mixed this up :?
I mean ControlID.
Image

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.

_________________
Image Stefan

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2007, 8:26 am 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2007, 9:33 pm 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
Thanks YMP, i will see if i can manage this.

_________________
Image Stefan

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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Maestr0, MilesAhead, Yahoo [Bot] and 71 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group