Plugin Development

If you have a question or need help, this is the place to be.
Post Reply
cvben
Posts: 38
Joined: Wed Jun 07, 2017 8:30 pm

Plugin Development

Post by cvben » Fri Jan 05, 2018 3:37 am

So I've been thinking about a project for myself to create an eventghost plugin toward some end. I'll probably do something with a program, lets say ShareX, an excellent screenshot utility for example. Lacking a tutorial on this I have been dredging through the included plugins and seeing how they do what they are doing. Exploring modules, imports, methods, etc. I have looked a bit into utilizing named pipes and it seems graspable (who knows if I'm getting it yet, but I'll keep at it). I'm just looking for general tips, what modules to look at, strategy, pitfalls. It sounds like a lot I now, but youtube videos, online tutorials, books to buy, and simple sage advice is much appreciated.

I think more than anything what I am wondering is how to "observe" the various threads, processes, methods of a program. From there I can poke and prod, hopefully learning something along the way.

Honestly, this sounds like a hassle reading over it, but like I said, even an "atta boy" might do :)

User avatar
kgschlosser
Site Admin
Posts: 5498
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Plugin Development

Post by kgschlosser » Fri Jan 05, 2018 7:41 am

Hey ya gotta start somewhere. It is ambitious i'll give you that.

As far as integrating with a piece of software make sure it has the ability to be controlled from some external means. This can be done in several ways. It can be done with a named pipe, or a TCP socket. I have seen some programs use the Windows Notification system. Older programs may use dde. You have to figure out what it uses if any at all.

As far as a screenshot plugin. I would suggest using the ImageGrab library and the PIL (Pillow) library. these come pre installed into EG and can handle just about every single type of image You also have the ability to manipulate the image, resizing, sharpness, contrast. a whole mess of things. PIL is pretty easy to use.

Download PyCharm Community Edition It's a python IDE.

If you want to use pyCharm you are going to need to have python installed. I just keyed up this script you can run from inside of EG. you need to paste this into a PythonScript action and then run the action.

What this script is going to do is it will download and install stackless Python 2.7 and then upgrade the modules installers. after that it will install any modules that EG uses and it will make a copy of your EG installation (only the core python files) into the site-packages folder of the python install. This will get you up and running for developing and eliminate most errors that may show up in the IDE. there are a bunch that are still going to show up but this is going to minimize them.

I have not tested this code so I do not know if it will run without error.

WARNING!
IF YOU HAVE PYTHON INSTALLED DO NOT USE THIS SCRIPT.
IT WILL CAUSE YOU PROBLEMS WITH YOU EXISTING INSTALLATION.

Code: Select all


import threading

def run():
    import eg
    import requests
    import tempfile
    import os
    from subprocess import Popen
    from shutil import copytree, rmtree
    
    
    stackless_url = 'http://www.stackless.com/binaries/python-2.7.12150-stackless.msi'
    stackless_args = '" /quiet /passive /qn /norestart'
    stackless_install_path = r'c:\StacklessPython27'

    new_stackless_path = raw_input(
        'Enter New path to install Python into.\n'
        'Or leave blank to use the default of\n'
        '{0}\n'.format(stackless_install_path)
    )

    if new_stackless_path:
        stackless_install_path = new_stackless_path

    stackless = requests.get(stackless_url).content
    tmp_dir = tempfile.mkdtemp()

    stackless_installer = os.path.join(tmp_dir, 'python-2.7.12150-stackless.msi')
    
    with open(stackless_installer, 'w') as f:
        f.write(stackless)

    p = Popen(
        'msiexec /I "{0}" {1} "{2}"'.format(
            stackless_installer,
            stackless_args,
            stackless_install_path
        )
    )
    stdout, stderr = p.communicate()
    print stdout
    
    rmtree(tmp_dir)

    scripts_dir = os.path.join(stackless_install_path, 'scripts')
    pip = os.path.join(scripts_dir, 'pip')

    p = Popen(
        '"{0}" install --upgrade setup_tools'.format(pip)
    )
    stdout, _ = p.communicate()
    print stdout


    p = Popen(
        '"{0}" --upgrade pip'.format(os.path.join(scripts_dir, 'easy_install'))
    )
    stdout, _ = p.communicate()
    print stdout


    mods = [
        'agithub-2.1-py2-none-any.whl',
        'broadlink-0.5-py2-none-any.whl',
        'CommonMark-0.7.4-py2.py3-none-any.whl',
        'comtypes-1.1.3-py2-none-any.whl',
        'ctypeslib-0.5.6-cp27-none-any.whl',
        'future-0.16.0-py2-none-any.whl',
        'gevent-1.2.2-cp27-cp27m-win32.whl',
        'greenlet-0.4.12-cp27-cp27m-win32.whl',
        'Jinja2-2.8.1-py2.py3-none-any.whl',
        'Pillow-4.3.0-cp27-cp27m-win32.whl',
        'pycrypto-2.6.1-cp27-cp27m-win32.whl',
        'pycurl-7.43.0-cp27-none-win32.whl',
        'pywin32-221-cp27-cp27m-win32.whl',
        'qrcode-5.3-py2.py3-none-any.whl',
        'requests-2.18.4-py2.py3-none-any.whl',
        'Sphinx-1.5.6-py2.py3-none-any.whl',
        'tornado-4.5.2-cp27-cp27m-win32.whl',
        'websocket-0.2.1-py2-none-any.whl'
    ]

    for mod in mods:
        mod = 'http://eventghost.net/build_modules/' + mod

        p = Popen('"{0}" install {1}'.format(pip, mod))
        stdout, _ = p.communicate()
        print stdout

    copytree(
        os.path.join(eg.mainDir, 'eg'),
        os.path.join(stackless_install_path, 'Lib', 'site-packages', 'eg')
    )

t = threading.Thread(target=run)
t.daemon = True
t.start()
If you like the work I have been doing then feel free to Image

Post Reply