• 1
  • 10
  • 11
  • 12(current)
  • 13
  • 14
  • 22
Release Execute user tasks for Kodi events (callbacks ver2)
Thanks I found the addon cron that works well for my needs.


Sent from my iPhone
Reply
Hi,
I try to run *.cmd script and hide the cmd window using VBScript and so far I fail. It looks like only the VBScript is launched and the *.cmd is ignored. I am using Windows 10 64b and Kodi 16.
The scripts I need to run on playback started and playback ended are:
start.vbs:
Code:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("start.cmd"), 0, True
start.cmd:
Code:
start "" "process.exe"
exit
stop.vbs:
Code:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("stop.cmd"), 0, True
stop.cmd:
Code:
taskkill /F /IM process.exe
exit
I hope you can help me!
Reply
(2016-09-03, 00:36)Magicool Wrote: Hi,
I try to run *.cmd script and hide the cmd window using VBScript and so far I fail. It looks like only the VBScript is launched and the *.cmd is ignored. I am using Windows 10 64b and Kodi 16.
The scripts I need to run on playback started and playback ended are:
start.vbs:
Code:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("start.cmd"), 0, True
start.cmd:
Code:
start "" "process.exe"
exit
stop.vbs:
Code:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("stop.cmd"), 0, True
stop.cmd:
Code:
taskkill /F /IM process.exe
exit
I hope you can help me!

If you run your vbs directly does it work? Are you using shell or are you handing off your vbs to wscript or cscript?
As I have stated many many many times in this thread, you need to post a link to your log post for any real help.
http://kodi.wiki/view/Add-on:Kodi_Callbacks#FAQs
Reply
I am seriously considering ignoring any posts without log links in the future.
It's obvious that no one looks at the previous posts in the thread or reading the wiki before asking a question.
Reply
Hi,
Thank you for the idea! Indeed if I select "Requires shell?" it works just fine.

I'll make sure to post a log next time I have a question/problem. Sorry about that!
Reply
Firstly massive thanks to @KenV99 for the addon

Ive been trying to find a way to run a python script on startup for a while Smile and now all sorted!

Im new to the more advanced side of kodi, commands and scripting in general so this may be a really dumb question or simple process, but I've read through the thread (what i understood of it!) and don't think its been discussed, so thought id ask!

Is it possible to make a Task/Event that executes a python script when i change which Home Menu Item I'm on, on the home screen? So if I'm on weather (for example) then change to another item it would execute.

thanks for reading and any advice or info would be much appreciated Smile
Reply
(2016-09-13, 05:54)dannyrobbo Wrote: Firstly massive thanks to @KenV99 for the addon

Ive been trying to find a way to run a python script on startup for a while Smile and now all sorted!

Im new to the more advanced side of kodi, commands and scripting in general so this may be a really dumb question or simple process, but I've read through the thread (what i understood of it!) and don't think its been discussed, so thought id ask!

Is it possible to make a Task/Event that executes a python script when i change which Home Menu Item I'm on, on the home screen? So if I'm on weather (for example) then change to another item it would execute.

thanks for reading and any advice or info would be much appreciated Smile

That may be difficult. The addon can certainly fire an event when you navigate to the Home Menu, but then it would need to be able to hook into the page events for the page to be able to know when you moved from item to item on the page.
Without actually editing the code for that page itself (for estuary skin on windows it would be: "C:\Program Files (x86)\Kodi\addons\skin.estuary\1080i\Home.xml"), I cannot think of a way of doing this.

Sorry.
Reply
(2016-03-27, 21:38)KenV99 Wrote:
(2016-03-27, 21:03)brazen1 Wrote: Hi.
Ran across your add-on and thought I'd give it a try. I seem to be having problems after spending a couple hours trying to config.

My goal is to enable Windows 10 Stereoscopic mode when playing back a 3D.iso and disable it when finished with playback.
I have working .bat files to enable and disable using Nvidia's nvstlink.exe.
I point to these .bat files using your player start and player end tasks and they indeed switch using Script as the type.
The problems are:

Stereoscopic MUST be enabled before playback actually begins. This bat has to take priority before KODI itself does otherwise KODI starts 3D mode switching incorrectly. I assume there is no way around this since the title has to be called 1st to trigger the add-on after numerous tries?
I assume that you are using the onPlaybackStarted event?
Then yes, there is no way to intercept that with this addon before it plays.
The only way I could see you doing this is writing python that immediately stops the file from playing, then does what you need and then restart it.
You might be able to do it from a batch file if you are adept at writing curl commands and you could then use the JSON-RPC.
(2016-03-27, 21:03)brazen1 Wrote: I've added "*3D.iso" to the variable but stereoscopic switches into 3D upon start of a 2D.mkv which makes no sense to me but I'm not a coder.
I don't know what you mean here. In playercorefactory.xml?
(2016-03-27, 21:03)brazen1 Wrote: Can you help me achieve what I'm trying to do?

I'm on W10 using a variant of v.17 (afedchin's new 3D MVC build in the development thread)

This workaround may help Nvidia users be included in the upcoming KODI 3D MVC advancement and I'm eager to test if it can be accomplished.
Thanks for any assistance the community might offer.

This sounds promising - I've been looking at some of the Python instructions but have no idea where to begin, would like to do something similar where Kodi switches its video resolution when playing a 3D MVC MKV (in my case identified by a string in the filename), then changes back when playback ends. This would fix an issue I'm having with DSPlayer and madVR where my desktop resolution is 4K and the player resolution is 1080p24 but apparently Kodi is just showing the top left corner of the 4K image, upscaled to 1080p.

JSON commands for switching the resolution are here:

http://forum.kodi.tv/showthread.php?tid=200052

What I would need then (I think) is to use the callbacks addon to call a script on starting playback, check the filename to see if it contains a certain string and, if so, adjust the screen resolution prior to playback (and otherwise do nothing). On finishing playback / stopping, change the resolution back to the way it was before. Any thoughts on the best way to tackle this?
Reply
It all depends on what language you are most comfortable scripting in.
In python, you could retrieve the filename use any number of means to ascertain whether the filename contains the substring you designate for the type of video.
Then use: 'result = xbmc.executeJSONRPC(query)' where 'query' represents a properly formatted JSON command for the resolution switch.
Reply
(2016-10-26, 15:03)KenV99 Wrote: It all depends on what language you are most comfortable scripting in.
In python, you could retrieve the filename use any number of means to ascertain whether the filename contains the substring you designate for the type of video.
Then use: 'result = xbmc.executeJSONRPC(query)' where 'query' represents a properly formatted JSON command for the resolution switch.

Honestly I have no idea how to script (I know Excel fairly well and understand basic coding concepts but it's been years since I've taken a programming class or written any code). I found a script elsewhere in the forums to execute a JSON command and print out any errors, so I've adapted this to my needs. I'm able to get it to change the resolution, but then a yes/no dialog box comes up ("Save this resolution?") and I'm unable to get it to automatically click on 'yes' using a method that appears to work for other yes/no dialog boxes (unless I've just scripted this incorrectly). I added a couple of timers in the script since my projector and graphics card take a little while to switch modes so I wanted to account for this. I also need to add some code to check the filename before switching resolutions, but figured I'd solve for the basic functionality before getting into the if/then statements.

Any thoughts?

http://pastebin.com/FXD6SuCH
Reply
Great, just what I needed, thanks! Smile

I use it on LibreELEC with my RPi2 to disable the Bluetooth service when I start playback and enable it again after playback has finished. Because I use Bluetooth to play music from my phone to my RPi2 over my speakers I only need to have Bluetooth enabled whenever I'm not using Kodi. I could leave Bluetooth on at all times of course but I noticed the occasional choppy playback of 1080p content so that was not an option for me. You plugin gave me convenience of always having Bluetooth enabled whenever I need it without needing to enable it manually and without the drawback of playback getting choppy.

Thanks again!
Reply
How exactly can I use this to run a script or add-on on Kodi exit? What I am trying to do is run a script or add-on to clear cache/packages/thumbnails on exit or shutdown. Thanks Cool
Reply
Thank you very much for this addon!!! I used to have the "export to individual files" function to run at startup, which was awful because you have to wait for it to finish and it's like 3 seconds there that it's just a chore to the eyes. Now I run it after playback has started, but, and here's an idea: add the option to delay the task, and only start it after X amount of seconds have passed since the event has occurred. I bypassed this by running the built-in function from a Python script and adding time.sleep(5) to it, but since it's a portable install and I move it around a lot, I'd rather have this not depend on a .py script (could also be useful for other purposes, I imagine).
Reply
I have made an addon which I need to launch when a change in the file system is detected. Is it possible to do so?

Ok:
RunScript(script.***)

Now, does the file system watchdog work instantly or does it run in a schedule? Let's see if this works....
Reply
I'm trying to run a python script or batch script which uses python lib and it looks like the modules can't be found when running from within Kodi :
Code:
22:26:38 T:8640   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: No module named mymodulename
                                            Traceback (most recent call last):
                                              File "C:\Users\Name\scripts\filename.py", line 1, in <module>
                                                from mymodulename import ModuleImport
                                            ImportError: No module named mymodulename
                                            -->End of Python script error report<--
I installed it using 'pip install ... ' and on CMD it works fine ..
Should I install the module on Kodi environment somehow ?
Reply
  • 1
  • 10
  • 11
  • 12(current)
  • 13
  • 14
  • 22

Logout Mark Read Team Forum Stats Members Help
Execute user tasks for Kodi events (callbacks ver2)3