Winactivate is good. but is there a Tabactivate thing?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tatagi
Posts: 181
Joined: 23 Aug 2018, 11:17

Winactivate is good. but is there a Tabactivate thing?

09 Sep 2020, 15:47

I am using text editing program called Akelpad and it offers user tab function which is the main reason I use it.

and I have a code like this.

Code: Select all

!a::
run C:\Users\Westlife\Downloads\autohotkey\text.txt, , max
return

so if I press hotkey alt + a , the OS opens text.txt file in akelpad.(akelpad is already set as default txt opening application)

it works with no problem, but I want to go one step further for convenience which is:

If the text.txt file is already open(I mean exist, no matter if it is focused or not), the same hotkey should activate akelpad and show the text.txt file tab.

in this case, the following code doesn't work because it activates editor's last opened tab. not good.

Code: Select all

!a::
ifwinexist, ahk_class AkelPad4
winactivate, ahk_class AkelPad4
else
run C:\Users\Westlife\Downloads\autohotkey\text.txt, , max
return
so I tried again

Code: Select all

!a::
ifwinexist, AkelPad - [C:\Users\Westlife\Downloads\autohotkey\text.txt]
winactivate, AkelPad - [C:\Users\Westlife\Downloads\autohotkey\text.txt]
else
run c:\users\westlife\downloads\autohotkey\text.txt, , max
return
doesn't work again, it only checks if the application exists or not, not if text.txt file tab exists, so it just reruns file.

is there something like iftabexist or tabactivate ( I guess not), or anything that does the same thing or workaround?

thx, regard.
lexikos
Posts: 9678
Joined: 30 Sep 2013, 04:07
Contact:

Re: Winactivate is good. but is there a Tabactivate thing?

10 Sep 2020, 04:33

@tatagi No. If the program uses a standard tab control (class name SysTabControl32), it is trivial to select a specific tab by index - use SendMessage as demonstrated in the documentation for Control TabLeft. It is possible (but non-trivial) to retrieve the names of tabs, such as to find the index of one with a given name. However, that is only for standard tab controls. I do not know what AkelPad uses. You may confirm with Window Spy.

@BoBo That will not help for any of the inactive tabs.
OpalMonkey
Posts: 18
Joined: 23 Jan 2014, 03:02

Re: Winactivate is good. but is there a Tabactivate thing?

11 Sep 2020, 03:05

Just a thought, but maybe launching the file using command line parameters for Akelpad could work?

I haven't tested this with AkelPad, just Notepad++, so take it for what it's worth.

Code: Select all

!a::
run C:\PathToAkelPad\AkelPad.exe "C:\Users\Westlife\Downloads\autohotkey\text.txt", , max
return
Changing PathToAkelPad to the actual path to where you have it installed.

If the file isn't already open, this should open it normally. If the file is already open, depending on the behaviour of AkelPad, various things could happen. What I'm hoping for is that it would open the window and jump to the already existing tab. This is how it functions in Notepad++, and I would expect it's the typical behaviour. Though it could open a duplicate tab, force the file to be reloaded from disk (overriding any unsaved changes), or something else. So I'd say test with caution to make sure how it behaves.

It looks like there is an AkelPad\AkelFiles\Docs\AkelHelp-<lang>.htm file that gives a rundown of the available command line parameters. I don't see anything that jumps out as useful here, but as I said, I've never used AkelPad.

This is assuming you're using AkelPad 4.9.8. That's the version I checked the help file for, so other versions could be different. However, this should be very standard behaviour.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, j4byers, ntepa and 124 guests