Problem to select tab

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
brandonhotkey
Posts: 113
Joined: 03 Nov 2013, 05:46

Problem to select tab

24 Jun 2015, 08:28

Why the selectTab(tabName) fails to select the tab "Units"? It is non-ahk Window.

Code: Select all

SetTitleMatchMode, 2
/* 
Try to get tabs dynamically if Window is active
If it fails, then set static array
*/
if (!AOKTS_tabNames)
  {  
  If WinActive(AOKTS_app_1)
    AOKTS_tabNames := ControlGetTabs("SysTabControl321", "A")
  if (!AOKTS_tabNames)
    If WinActive(AOKTS_app_2)
      AOKTS_tabNames := ControlGetTabs("SysTabControl321", "A")
  
  if (!AOKTS_tabNames)
    If WinActive, AOK Trigger Studio
      AOKTS_tabNames := ControlGetTabs("SysTabControl321", "A")

  if (!AOKTS_tabNames)
    AOKTS_tabNames:=["Info/Messages", "Players", "Global Victory", "Disables", "Map/Terrain", "Units", "Triggers"]  
  } 
getTabName(id){
  global
  if (!IsObject( AOKTS_tabNames ))
    msgBox, Error: AOKTS_tabNames
  return AOKTS_tabNames[id]
}
checkTabName(tabName){
  global
  if (!IsObject( AOKTS_tabNames ))
    msgBox, Error: AOKTS_tabNames
  ControlGet, TabNum, Tab,, SysTabControl321, A
  return tabName == AOKTS_tabNames[TabNum] ? 1 : 0
}
selectTab(tabName){
  global
  if (!IsObject( AOKTS_tabNames ))
    msgBox, Error: AOKTS_tabNames
  for tabNum,name in AOKTS_tabNames
    if (name==tabName) 
      break
  SendMessage, 0x1330, %tabNum%,, SysTabControl321, A
  msgBox,%tabNum% 
  SendMessage, 0x130C, %tabNum%,, SysTabControl321, A
  msgBox,%tabNum%
}
Note: ControlGetTabs is here http://www.autohotkey.com/board/topic/7 ... olgettabs/ to get the array dynamically. The array is present.

I have selected "Triggers" (tabNum 7). The msgbox displays 6, and 6 is correct, but the tabNum 6 was not selected. It stays on the Triggers tab.

Code: Select all

if (!checkTabName("Units"))  
     selectTab("Units")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Joey5, Nerafius, Rohwedder, Tvlao and 133 guests