Open CoachSludge opened 7 months ago
What version of Windows are you running this on? I did some work on another script to update to AHK v2, so I'll do the same here. Might be a few days.
Win 10 and Kodi 20 wrote a crude python script to do the same until an actual fix is in order.
Thanks. I've got this started with practically a rewrite to Autohotkey v2. It opens Playnite and triggers the win hook to open Kodi after closing, but I'm on windows 11, so it would be cool if you could test afterwards. I still need to work out some conditions to handle desktop vs. fullscreen mode, but should have that sorted soon.
Ok, it's done. It's working pretty well for me. Could you give it a try and let me know? Install or update it from the repo, then go into the advanced settings and enable "Delete and update userdata scripts on next run" before running the add-on.
It still seems to be broken, is there a release planned for the fix?
Try installing it from the repo, which will pull down the latest version (v2.0). It's working for me and if it's working for others, then I'll create the release here. https://github.com/robbforce/kodi.repo.robbforce
@robbforce I realized that after I wrote. Using the repo's current code kind of resolved the issue. Sometimes it works and sometimes not, haven't found a pattern to the failure yet.
I was debugging the playnite-launcher.ahk
script without Kodi running, and it would launch Playnite as expected, but once Playnite was closed, it never fell into the PlayniteClosedEvent
handler to trigger OpenKodi
.
So consistent repro steps are:
playnite-launcher.ahk
script with
"<PATH_TO_PLAYNITE>\Playnite.FullscreenApp.exe"
"<PATH_TO_KODI>\kodi.exe"
"0"
"true"
"false"
"false"
""
0
You're running "PortableMode", right? Is Kodi installed in a folder that it has rights to? (not program files) Can you execute "path\kodi.exe -p" in a command prompt and confirm that Kodi launches?
Yes, portable.
Kodi's installed in a User folder. It runs fine. The Steam addon has no issues shutting it down or starting it up.
I also stated before that sometimes the Playnite addon will start Kodi back up but it's not consistent. In the case where it randomly worked I had Kodi running, started Playnite via the addon, Playnite started, I shut Playnite down, and a few seconds later Kodi would start. If I then tried that flow again, Kodi wouldn't start up again. So I figured I'd debug with the basics of starting Playnite via the script and see if there was an issue starting Kodi, but the close event for Playnite never triggered.
I'm not having any luck reproducing your issue. I made a copy of my Kodi folder and placed it in my user Documents folder, placed the playnite-launcher.exe in there, ran it in a cmd prompt with:
playnite-launcher.exe "<path_to_playnite>\Playnite.FullscreenApp.exe" "C:\Users\<user_name>\Documents\Kodi\kodi.exe" "0" "true" "false" "false" "" "0"
Playnite loaded, then I closed it and the portable Kodi loaded.
What version of Windows are you using? The above test was on Windows 10 and I developed/tested on Windows 11.
I'm on Windows 11.
Were you able to repeatedly open Playnite from Kodi, exit Playnite, and have Kodi start?
Do you know how to debug the Windows events? I want to see if any closing event is firing for Playnite.
I ran the script exe from the commandline a few times and it opened Playnite, opened Kodi consistently, then installed the plugin in the portable Kodi, and it still consistently opened Playnite, then re-opened Kodi multiple times in a row.
If you clone the repo or extract the plugin zip, in the resources\scripts folder there's a WinHook Event Monitor you can try. You'll get a lot noise, but might see the close event and the hWnd for Playnite. First thing to confirm is the hWnd and that the playnite script was able to find it for your Playnite app.
Then, near the top of playnite-launcher.ahk, there's adding the Winhook. Check that the event Id matches what you raise when closing Playnite. Right now it's looking for "0x8001 = EVENT_OBJECT_DESTROY". You can see the event IDs in the WinHook.ahk script. Let me know if another event is raised in the monitor when you close and maybe I can add another event listener for it.
Not sure what's going on, but it only seems to be firing AccessibleEvents.
Here are the last lines before Playnite closes. Haven't found anything that seems to map to your addon.
hWinEventHook | Event | hWnd | idObject | idChild | dwEventThread | dwmsEventTime | wClass | wTitle |
---|---|---|---|---|---|---|---|---|
11404427 | 8 | 16385164 | 0 | 0 | 10800 | 225806156 | HwndWrapper[Playnite.FullscreenApp.exe;;9684e74a-e4fb-4cb6-b6b2-e4973a5f2cd3 | |
11404427 | 32779 | 16385164 | 0 | 0 | 10800 | 225806171 | HwndWrapper[Playnite.FullscreenApp.exe;;9684e74a-e4fb-4cb6-b6b2-e4973a5f2cd3 | |
11404427 | 32779 | 2033032 | 0 | 0 | 10800 | 225806515 | HwndWrapper[Playnite.FullscreenApp.exe;;5550a7ab-fb6d-46cf-a16c-1327d6514f63 |
Those event constants do look like they're from that list, but we should see 32769 (Destroy) and it never shows up. Looking at the event monitor code, it takes the event as is, but it might be more useful to have it convert to the constants that are used when setting the hook: https://learn.microsoft.com/en-us/windows/win32/winauto/event-constants I went looking for other tools to check events and ended up here: https://accessibilityinsights.io/docs/windows/overview/ I'll give it a try later to see what events are triggered on close.
Something wrong in the ahk scripts?