Healix / Gw2Launcher

Manages and allows for multiple Guild Wars 2 clients to be launched
MIT License
181 stars 24 forks source link

Automatic character select? #369

Open CedarD opened 1 year ago

CedarD commented 1 year ago

Would it be possible to have Gw2Launcher automatically select and launch a character from the character select screen? Even if it's only the first character on the list, that would be super convenient. I guess it's probably not possible since it hasn't done yet, but it's worth a try to see if it can be done.

Healix commented 1 year ago

It would be trivial to load the first character (press enter), but that would technically be against the rules. Auto selecting other characters requires visually searching for the name, so that's not really possible.

CedarD commented 1 year ago

Ah, yeah I figured the latter would be problematic. I assume that if not added to Gw2Launcher directly it could be done with something like autohotkey called in the launch options? Or would you have any suggestions on another software package that could be called and just press enter while focusing a specific window that's spawned below another? (Actually it looks like left and right arrow keys move the character selection box left and right.)

Caliban2017 commented 1 year ago

You can use AHK, the Script is really simple, which works for me:

WinWait "ahk_class" "ArenaNet_Gr_Window_Class" ControlSend "{Enter}",, "ahk_class" "ArenaNet_Gr_Window_Class"

Convert it to an Exe File and just put it in the Launch Options for GW2 in GW2Launcher and choose "when Char Select is loaded".

Load a specific Char is nearly impossible, like Healix said, you can not recognise the Char you want. You can not even use the Order of the Chars for that, because sometimes it is not reliable. But whit this Script you can always load the first Char in Line. Just log out on this Char to bring it in the Front.

CedarD commented 1 year ago

You can use AHK, the Script is really simple, which works for me:

WinWait "ahk_class" "ArenaNet_Gr_Window_Class" ControlSend "{Enter}",, "ahk_class" "ArenaNet_Gr_Window_Class"

Convert it to an Exe File and just put it in the Launch Options for GW2 in GW2Launcher and choose "when Char Select is loaded".

Load a specific Char is nearly impossible, like Healix said, you can not recognise the Char you want. You can not even use the Order of the Chars for that, because sometimes it is not reliable. But whit this Script you can always load the first Char in Line. Just log out on this Char to bring it in the Front.

Cool, thanks!

I tried just cutting and pasting that line and turning it into an executable. It generates an error when executed: Error: Expected a String but got a Func.

Not familiar enough with AHK yet, but I'm assuming it is choking on ControlSend {Enter}?

Edit: It seems to run without complaint when I set the executable version to v1. But it doesn't seem to actually load the character.

Caliban2017 commented 1 year ago

sorry, there is a Problem with the Formatting here. There is a Linebrake missing:

WinWait "ahk_class" "ArenaNet_Gr_Window_Class" ControlSend "{Enter}",, "ahk_class" "ArenaNet_Gr_Window_Class"

This should work and the Syntax is for v2.

CedarD commented 1 year ago

That compiled and seems to successfully run without complaint now with some exceptions. I don't call the script on my main account and having that instance running doesn't seem to interfere with the script as long as the first additional instance of any alt account runs the script executable while the window is focused. Any further subsequent alt accounts loaded will not auto select the character unless they are the only instance of GW2 running. (The main account window doesn't interfere of course.)

I have watched task manager and the script is called each time a new window is started, so that part of GW2Launcher is working without issue. Is the problem that the window class might be the same name? If that's so, I'd expect the presence of the main account instance running would interfere though. Also, not sure why the window must be focused/on top to run successfully. Are there some changes that can fix those problems? I have set GW2Launcher to give each window a unique title as per the "Identifier / account or display name" option, if that helps.

And thank you very much for helping me. Hopefully when all is said and done it will help others with alt accounts to deal with.

Healix commented 1 year ago

The class name is the same for all instances of GW2, so it will apply to whichever window it finds first. You can use ahk_id (or ahk_pid) instead, and simply have Gw2Launcher pass %handle% as the command line argument.

WinWait "ahk_id" A_Args[1] ControlSend "{enter}"

CedarD commented 1 year ago

Okay, lemme see. I went ahead and put in %handle%. When starting, AHK generated an error. I think it's expecting an array element that's not there? I tried reading up on the AHK site, but kind of can't make sense of it.

gw2launcher_options

ahk_error

Healix commented 1 year ago

That's GW2's arguments. You want it in the "optional command line arguments" for the program set to run after launching.

CedarD commented 1 year ago

Ah, sorry about that. I moved the %handle% argument to the other location and it works flawlessly. Thank you both for your patience and help!