Jump to content

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

How to select different tabs on a tabbed window (eg File/Menu)



  • Please log in to reply
7 replies to this topic
genepaton
  • Members
  • 28 posts
  • Last active: Aug 22 2013 02:03 AM
  • Joined: 04 Mar 2013

Hi guys,

 

Im using ControlGet to retrieve the text from a ComboBox but i can't get AutoHotkey to select the tab that the control is on.

I've got it working now by using MouseClick and providing the co-ordinates, but this looks very messy and unprofessional. The tabs are all located under the same ClassN name window.

WindowsSpy may be able detect the different titles of the tab (&Details as opposed to Details which the user can see) but i wouldn't know how to reference this.

 

(I tried posting a picture of the tabbed window here, but got a message that i can't share it  =( Its located at http://<a href="http...y TinyPic"></a>

 

 

Im also having difficulties making the script act on the retrieved text variable latter on in the scripts which you can see below as well.

#MaxThreadsPerHotkey 1
SetTitleMatchMode 1
#IfWinActive, Scheduling


#z:: 

WinActivate, Scheduling

Send, {ALTDOWN}ti{ALTUP}

WinWait, Checking
WinWaitActive, Checking, 
Control, ShowDropDown, ,ComboBox2, Checking
KeyWait, LButton, D
WinActivate, Checking,

MouseClick, left, 317, 110
  ;//MESSY, how to get it to select the Details tab without using MouseClick? 
  ;//I would like to have this Details tab under the Checking Window visible in the background

ControlGet, vPubPri, List, Focused, ComboBox11, Checkin ;//The text i would like to reference later
ControlClick, Button47, Checking

WinWaitActive, Registration,,15
  ;//Ok, this is another bugger. I would like to script to wait and see if the window Registration appears, if it doesn't and the user returns to the Scheduling screen and starts clicking around, it finishes and reloads the script.

;if ErrorLevel 1
;{
;    reload
;    return
;}

WinActivate, Registration
ControlSend, Edit15, Gary Persley, Registration

;//The below isn't working at all for some reason

If PubPro=FIRST
  {
  Control, ChooseString, INITIAL MEETING, ThunderRT6ComboBox14, Registration
  }
  else
  {  
  If PubPro=REVIEW
  Control, ChooseString, FOLLOW UP, ThunderRT6ComboBox14, Registration
  }

reload
return



#IfWinActive, Registration 
Esc::
reload
return
#IfWinActive 


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

i can't get AutoHotkey to select the tab that the control is on.
I've got it working now by using MouseClick and providing the co-ordinates, but this looks very messy and unprofessional. The tabs are all located under the same ClassN name window.


good question, i dont think i've seen a way to select a tab from another window. i know if you have your own tab on your own gui window, you can use GuiControl, Choose

the docs for Control,Choose only mention Combobox and Listbox. however there is Control, TabRight which you could try
http://www.autohotke...nds/Control.htm

otherwise maybe youll need to SendMessage the TCM_SETCURFOCUS message directly, there is an example on the Control page above
 

 

Im also having difficulties making the script act on the retrieved text variable latter on in the scripts which you can see below as well.

ControlGet, vPubPri.............


;//The below isn't working at all for some reason

If PubPro=FIRST
  {
  Control, ChooseString, INITIAL MEETING, ThunderRT6ComboBox14, Registration
  }
  else
  {  
  If PubPro=REVIEW
  Control, ChooseString, FOLLOW UP, ThunderRT6ComboBox14, Registration
  }

reload
return


it doesn't look like you have a PubPro variable anywhere before this, so you are comparing your potential values in a variable that doesn't exist.

in your ControlGet line you named your variable "vPubPri". the 'i' is probalby a typo, but you also don't need to put the 'v' prefix either. you only use that for the Gui command to assign variables to your Gui controls

genepaton
  • Members
  • 28 posts
  • Last active: Aug 22 2013 02:03 AM
  • Joined: 04 Mar 2013

Cool, thanks for clarifying the ControlGet, that was a typo and now i know i don't need to label the variable unless its a GUI statement....  But that still doesn't work =(

 

Also im completely lost with the TCM_SETCURFOCUS etc. I thought we were onto it with the Control, TabRight etc but it seems im not the only one having issues with this....

What is TCM_SETFOCUS and SETCURSOR etc???

 

 

UPDATE, you were correct, completely not understanding what 0x1330 does or even what it is, i put the following code in the script and it does exactly what we want. Now to just understand what we did....!?

SendMessage, 0x1330, 2,, SysTabControl324, Checking

good question, i dont think i've seen a way to select a tab from another window. i know if you have your own tab on your own gui window, you can use GuiControl, Choose

the docs for Control,Choose only mention Combobox and Listbox. however there is Control, TabRight which you could try
http://www.autohotke...nds/Control.htm

otherwise maybe youll need to SendMessage the TCM_SETCURFOCUS message directly, there is an example on the Control page above
 

 

it doesn't look like you have a PubPro variable anywhere before this, so you are comparing your potential values in a variable that doesn't exist.

in your ControlGet line you named your variable "vPubPri". the 'i' is probalby a typo, but you also don't need to put the 'v' prefix either. you only use that for the Gui command to assign variables to your Gui controls



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
✓  Best Answer

Cool, thanks for clarifying the ControlGet, that was a typo and now i know i don't need to label the variable unless its a GUI statement....  But that still doesn't work =(


then perhaps your ControlGet statement is failing for some reason. are you getting any value into your output variable at all? just do a MsgBox, PubPro=%PubPro% and see if you get any value
 

Also im completely lost with the TCM_SETCURFOCUS etc. I thought we were onto it with the Control, TabRight etc but it seems im not the only one having issues with this....
What is TCM_SETFOCUS and SETCURSOR etc???
 
 
UPDATE, you were correct, completely not understanding what 0x1330 does or even what it is, i put the following code in the script and it does exactly what we want. Now to just understand what we did....!?

SendMessage, 0x1330, 2,, SysTabControl324, Checking


TCM_SETCURFOCUS is simply a message that is built into windows that gets sent to Tab controls to change focus to a different tab. windows has a bunch of functions and messages that are used to interact with different aspects of the operating system. many of these functions are complex and require a lot of code. AHK attempts to simplify this for you and make things easier with shorter code. for example, the WinMove command in AHK simply 'wraps' the windows function for SetWindowPos

it just so happens that there is no such AHK command to send the TCM_SETCURFOCUS message to a tab. if there were, it seems logical that the creators of AHK would probably have named it Control, Choose like i mentioned earlier. but they obviously thought some people would need this and thats why the example is on the page for people to use.

so, to understand what we did, we just sent the message directly to the tab control ourselves. this is how AHK would have wrapped the command anyway, if it were in fact implemented (which it is not). when AHK would parse our script, if it encountered Control, Choose command, it would interpret that and probably execute something like SendMessage, 0x1330 etc.

the 0x1330 is just the constant value for the TCM_SETCURFOCUS message, translated into hexadecimal

genepaton
  • Members
  • 28 posts
  • Last active: Aug 22 2013 02:03 AM
  • Joined: 04 Mar 2013

then perhaps your ControlGet statement is failing for some reason. are you getting any value into your output variable at all? just do a MsgBox, PubPro=%PubPro% and see if you get any value
 

 

 

Hey, sorry for the delay in getting back to you, i really appreciate the help.

Using a MsgBox i get the entire combobox list instead of the Focused line.

Am i using the code right?

ControlGet, PubPro, List, Focused, ComboBox11, Checking

And thanks heaps for explaining the SetCurFocus. Obviously the hex 0x1330 never changes, but the SysTabControl can right? Im guessing that because the example given in the link you provided had different SysTabControl numbers.



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

Hey, sorry for the delay in getting back to you, i really appreciate the help.
Using a MsgBox i get the entire combobox list instead of the Focused line.
Am i using the code right?

ControlGet, PubPro, List, Focused, ComboBox11, Checking


hrm looking at the help file, it looks like you're using it correctly. maybe combo boxes don't have a "Focused" row. have you tried "Selected" instead?

And thanks heaps for explaining the SetCurFocus. Obviously the hex 0x1330 never changes, but the SysTabControl can right? Im guessing that because the example given in the link you provided had different SysTabControl numbers.


yeah the SysTabControl number can change depending upon the program you're trying to interact with. its unlikely the number will change in the same app between different instances of opening/closing it, however you should verify with Window SPy

genepaton
  • Members
  • 28 posts
  • Last active: Aug 22 2013 02:03 AM
  • Joined: 04 Mar 2013

hrm looking at the help file, it looks like you're using it correctly. maybe combo boxes don't have a "Focused" row. have you tried "Selected" instead?

 

I tried selected and got the same result, the message box shows;

 

PubPro=File1

  File2

  File3

 

Where as im trying to just get just the first line (the selected/focused one).



genepaton
  • Members
  • 28 posts
  • Last active: Aug 22 2013 02:03 AM
  • Joined: 04 Mar 2013

I might post a new thread and see if someone else has had any success with ControlGet.

 

Thanks for all your help!