Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

If you have macros or EventGhost Configuration Tree items you wish to share this is the place to do it.
dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Wed Nov 06, 2019 11:13 am

Dependencies:
Desktop remote
Auto remote

So I've been trying to figure this out for ages right.
You'll obviously need to change up the config for your own needs, but It's possible!
Playing with this taught me how Escape modes work and what that little (u' ) is for!
(r is another mode, that was the part stumping me)


Paste this into EG to take a look.
You might not need to create new job folders like I do, but the possibilities are endless! :D


Fire off trigger "job gen" to start the generator's Desktop Remote.


Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP">
    <Folder Name="Generate newjob" XML_Guid="{9C0F06BA-108B-4DF7-B485-A0D85A6B3886}">
        <Macro Name="Generator Remote " XML_Guid="{591F3B01-7AC4-44EC-9ADA-A720224C0A5F}">
            <Event Name="*.job?gen" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action Name="Options Input remote" XML_Guid="{E9AD91CD-4E2D-4531-A3F3-D27F45C2D3FE}">
                EventGhost.PythonScript(u'egg = eg.globals\neg.plugins.DesktopRemote.CreateNew(100, 40, 3, 3, 4, (108, 108, 108), (255, 255, 255), (78, 78, 78), u\'0;-13;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', u\'Job Generator\', 0, True, True, True)\nc = 0\ntry:\n    egg.shortname \nexcept AttributeError:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_shortname\', \'label\': u\'Set Shortname\'})    \nelse:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_shortname\', \'label\': u\'{eg.globals.shortname}\'})\n    c = c + 1\n    \ntry:\n    egg.customer\nexcept AttributeError:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_customer\', \'label\': u\'Set Customer\'})    \nelse:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_customer\', \'label\': u\'{eg.globals.customer}\'})\n    c = c + 1\n\ntry:\n    egg.location\nexcept AttributeError:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_location\', \'label\': u\'Set Location\'})    \nelse:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_location\', \'label\': u\'{eg.globals.location}\'})    \n    c = c + 1\n\ntry:\n    egg.proper\nexcept AttributeError:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_proper\', \'label\': u\'Set Proper\'})    \nelse:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_proper\', \'label\': u\'{eg.globals.proper}\'})    \n    c = c + 1\n\ntry:\n    egg.vortex\nexcept AttributeError:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_vortex\', \'label\': u\'Set Vortex\'})    \nelse:\n    eg.plugins.DesktopRemote.AddButton({\'label_parse\': True, \'event_parse\': False, \'event\': u\'job_gen_input_vortex\', \'label\': u\'URL stored\'})    \n    c = c + 1\n\nif c != 5:\n    eg.plugins.DesktopRemote.Show(1400, 800, False)\nelse:\n    print "Entries Accepted. Running Generator" \n    eg.plugins.EventGhost.TriggerEvent(u\'job_gen_c5\', 0.0, None, False, False, False)\n    eg.plugins.DesktopRemote.Close()\n')
            </Action>
        </Macro>
        <Macro Name="Job Script generator" XML_Guid="{011F9B8E-34A1-4766-9467-79002BF5978B}">
            <Event Name="Main.job_gen_c5" XML_Guid="{5EB42F27-D595-43E5-8579-90CED7FC445E}" />
            <Action Name="Set Job to X generator" XML_Guid="{30027F1E-954E-4CEC-8304-F95B2BBD06AC}">
                EventGhost.PythonScript(u'egg = eg.globals\n#job folder storage directory\neg.globals.jobs = "C:\\\\Users\\\\Dan.Edens\\\\Desktop\\\\Tree\\\\Geo_tree\\\\Jobs\\\\"\nprint egg.shortname\nprint egg.customer\nprint egg.location\nprint egg.proper\nprint egg.vortex\n\nnewjob = """&lt;?xml version="1.0" encoding="UTF-8" ?&gt;\n&lt;EventGhost Version="WIP"&gt;\n    &lt;Macro Name="Set jobname to """+egg.proper+\'\\"\'+""" XML_Guid="{290A3A64-BA44-4565-B5DF-5EF55AA6D0D4}" Expanded="True"&gt;\n        &lt;Event Name="""+"\\""+"*.job?"+egg.shortname+"\\""+""" XML_Guid="{1DE92E4C-8131-4627-8D6B-5440D75132CF}" /&gt;\n        &lt;Action Name="Set Jobname """+egg.proper+\'\\"\'+""" XML_Guid="{4A169097-3A50-4385-80BA-21B2933B5ADC}"&gt;\n            EventGhost.PythonScript(u\'eg.globals.jobname = """+\'\\"\'+egg.shortname+\'\\"\'+""" \\\\neg.globals.jobcustomer = """+\'\\"\'+egg.customer+\'\\"\'+""" \\\\neg.globals.jobpath = eg.globals.jobs + """+\'\\"\'+egg.location+\'.\'+egg.proper+\'\\"\'+r\'+\\"\\\\\\\\\\"\'+"""\\\\neg.plugins.EventGhost.TriggerEvent(u\\\\\'Input.OK.rain var\\\\\', 0.0, None, False, False, False)\')\n        &lt;/Action&gt;\n    &lt;/Macro&gt;\n&lt;/EventGhost&gt;\n"""\negg.clip = newjob\neg.plugins.System.SetClipboard(u\'{eg.globals.clip}\')\neg.plugins.EventGhost.TriggerEvent(u\'job_gen_mkdir\', 0.0, None, False, False, False)')
            </Action>
        </Macro>
        <Macro Name="input shortname" XML_Guid="{180330FB-11F6-4155-BD00-B80B2B66C570}">
            <Event Name="*.job?gen?input?shortname" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action XML_Guid="{9829A739-F319-4152-843D-C04161213268}">
                AutoRemote.ShowInputDialog(u'Job Generator', u'Job Shortname and triger', u'', u'job_gen_shortname', False)
            </Action>
        </Macro>
        <Macro Name="input customer" XML_Guid="{180330FB-11F6-4155-BD00-B80B2B66C570}">
            <Event Name="*.job?gen?input?customer" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action XML_Guid="{9829A739-F319-4152-843D-C04161213268}">
                AutoRemote.ShowInputDialog(u'Job Generator', u'Customer', u'', u'job_gen_customer', False)
            </Action>
        </Macro>
        <Macro Name="input location" XML_Guid="{180330FB-11F6-4155-BD00-B80B2B66C570}">
            <Event Name="*.job?gen?input?location" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action XML_Guid="{9829A739-F319-4152-843D-C04161213268}">
                AutoRemote.ShowInputDialog(u'Job Generator', u'Location', u'', u'job_gen_location', False)
            </Action>
        </Macro>
        <Macro Name="input proper" XML_Guid="{180330FB-11F6-4155-BD00-B80B2B66C570}">
            <Event Name="*.job?gen?input?proper" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action XML_Guid="{9829A739-F319-4152-843D-C04161213268}">
                AutoRemote.ShowInputDialog(u'Job Generator', u'Folder/Proper name', u'', u'job_gen_proper', False)
            </Action>
        </Macro>
        <Macro Name="input vortex" XML_Guid="{180330FB-11F6-4155-BD00-B80B2B66C570}">
            <Event Name="*.job?gen?input?vortex" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action XML_Guid="{9829A739-F319-4152-843D-C04161213268}">
                AutoRemote.ShowInputDialog(u'Job Generator', u'Vortex URL', u'', u'job_gen_vortex', False)
            </Action>
        </Macro>
        <Macro Name="Catch shortname" XML_Guid="{918E3633-880D-4111-BB38-D13CB02A80A7}">
            <Event Name="Main.Input.OK.job_gen_shortname" XML_Guid="{324D353E-18E1-4C35-9D00-23488A2955C7}" />
            <Action Name="set payload to egg.shortname" XML_Guid="{4B11C55F-D88D-4D58-8B94-16FD1D506FD6}">
                EventGhost.PythonScript(u'eg.event.payload = eg.event.payload.replace(" ", "_")\neg.globals.shortname = eg.event.payload')
            </Action>
            <Action XML_Guid="{530B29C6-3437-4367-AC2A-942CC152E875}">
                EventGhost.TriggerEvent(u'job gen', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Catch Customer" XML_Guid="{0B01341D-0EDF-4157-A414-8D52C502C8FA}">
            <Event Name="Main.Input.OK.job_gen_customer" XML_Guid="{1561F7CA-3B96-4479-8671-13AB9A70D66A}" />
            <Action Name="set payload to egg.customer" XML_Guid="{4B11C55F-D88D-4D58-8B94-16FD1D506FD6}">
                EventGhost.PythonScript(u'eg.globals.customer = eg.event.payload')
            </Action>
            <Action XML_Guid="{530B29C6-3437-4367-AC2A-942CC152E875}">
                EventGhost.TriggerEvent(u'job gen', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Catch Location" XML_Guid="{349E7203-B5E5-410A-8446-03B785B90A02}">
            <Event Name="Main.Input.OK.job_gen_location" XML_Guid="{9307A1FB-429C-4FF0-895E-0DA08F5ED995}" />
            <Action Name="set payload to egg.location" XML_Guid="{4B11C55F-D88D-4D58-8B94-16FD1D506FD6}">
                EventGhost.PythonScript(u'eg.event.payload = eg.event.payload.replace(" ", "_")\neg.globals.location = eg.event.payload')
            </Action>
            <Action XML_Guid="{530B29C6-3437-4367-AC2A-942CC152E875}">
                EventGhost.TriggerEvent(u'job gen', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Catch Proper" XML_Guid="{9DC62E91-CB0D-404E-86FC-85EA5B852570}">
            <Event Name="Main.Input.OK.job_gen_proper" XML_Guid="{B99F1368-4AA1-4DB7-A434-3E80D65A063C}" />
            <Action Name="set payload to egg.proper" XML_Guid="{4B11C55F-D88D-4D58-8B94-16FD1D506FD6}">
                EventGhost.PythonScript(u'eg.event.payload = eg.event.payload.replace(" ", "_")\neg.globals.proper = eg.event.payload')
            </Action>
            <Action XML_Guid="{530B29C6-3437-4367-AC2A-942CC152E875}">
                EventGhost.TriggerEvent(u'job gen', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Catch vortex" XML_Guid="{9DC62E91-CB0D-404E-86FC-85EA5B852570}">
            <Event Name="Main.Input.OK.job_gen_vortex" XML_Guid="{B99F1368-4AA1-4DB7-A434-3E80D65A063C}" />
            <Action Name="set payload to egg.vortex" XML_Guid="{4B11C55F-D88D-4D58-8B94-16FD1D506FD6}">
                EventGhost.PythonScript(u'eg.globals.vortex = eg.event.payload')
            </Action>
            <Action XML_Guid="{530B29C6-3437-4367-AC2A-942CC152E875}">
                EventGhost.TriggerEvent(u'job gen', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Create new dir" XML_Guid="{6D4A5599-EC27-4621-B538-64C4EF66C7D1}">
            <Event Name="*.job?gen?mkdir" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action Name="Make Job directories" XML_Guid="{B3FE7D22-E513-49A9-A4A1-AFC8B0B02017}">
                EventGhost.PythonScript(u'import os\nfrom datetime import datetime\negg = eg.globals\negg.today = datetime.today()\nnewdir = egg.jobs+egg.location+"."+egg.proper\nprint newdir\nif not os.path.exists(newdir):\n        os.makedirs(newdir)\n        os.chdir(newdir)\n        os.makedirs("Website_setup")\n        os.makedirs("Reports")\n        os.makedirs("Photos")\n        os.chdir("Photos")\n        os.makedirs("Pre_con")\n        os.makedirs("Install")\n        os.makedirs("Repairs")\n        os.chdir(newdir)\n        os.makedirs("Documents")\n        os.chdir("Documents")\n        os.makedirs("Plans")\n        os.makedirs("Equipment_info")\n        os.chdir(newdir)\n        file = open(egg.proper+"_notes.txt", "w") \n        file.write("Job Folder created on "+str(egg.today)) \n        file.close()\n        print "New job created. Don\'t forget to paste new macro into Jobname folder"\n        ')
            </Action>
        </Macro>
    </Folder>
</EventGhost>

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

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by kgschlosser » Tue Nov 12, 2019 5:14 am

the r, u b, rb, ru are all string macros.


r = raw: no need to escape characters. This is very helpful when dealing with Windows paths where the \ you would have to escape.
so this.

r'C:\Program Files\SomeProgram'

and this
'C:\\Program Files\\SomeProgram'

are the same thing.
u = unicode: the english language uses the ascii table and has a character set that is 255 characters. there are 255 bit possibilities in a single byte. so one character = 1 byte. unicode extends this. If you take the Chinese language there are somewhere between 5000 and 7000 characters. this is not going to fit into a single byte. because a string is designed in a manner that one character = 1 byte it is not going to work. unicode allows a character to occupy more then a single byte of data. so when you want to reference a specific character it is going to work correctly. Now.. that being said.. There is also encoding schemes to deal with... that is a whole monkey fuck in it's self, I have problems with it still. because sometimes you have to encode it to latin then decode it to ascii.. It's a complete mess..

b = bytes: python 2 a string and bytes are the same. in python 3 a string and bytes are not the same, bytes is like what would be unicode in python 2

rb = raw bytes: combine raw and bytes together

ru = raw unicode: combine raw and unicode together

so the basic ho down is unless you are using string literals that are outside of the ascii table there is no reason for you to use the u or even the ru. If you are dealing with incoming data and you do not know what the data is going to contain in terms of characters you may be forced to use the u if trying to manipulate the incoming data in any way.
If you like the work I have been doing then feel free to Image

User avatar
Medy
Experienced User
Posts: 177
Joined: Sat Nov 15, 2014 8:33 pm
Location: Germany

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by Medy » Mon Nov 18, 2019 8:02 pm

Could you explain the use case for this stuff ?
Are you copyieng these templates across computers ?

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Wed Nov 20, 2019 6:48 pm

Okay so the specific use case isn't the bit worth having in your toolkit.
The cool bit is creating a macro with all it's parts out of variables.
It's a tool for setting up Eventghost macro templates.

It's tricky because you have to put the XML syntax of pasting a macro into eventghost, into a Eg python script, which contain "copy as python" versions of plugin actions.

Im busy at work but I'll get a couple examples in a few mins

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Wed Nov 20, 2019 6:51 pm

dan Edens wrote:
Wed Nov 20, 2019 6:48 pm
Okay so the specific use case isn't the bit worth having in your toolkit.
The cool bit is creating a macro with all it's parts out of variables.
It's a tool for setting up Eventghost macro templates.

It's tricky because you have to put the XML syntax of pasting a macro into eventghost, into a Eg python script, which contain "copy as python" versions of plugin actions.

Im busy at work but I'll get a couple examples in a few mins
So you could be creating a group of hotkeys like this for a specific program

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP">
    <Folder Name="Mouse group 1 - Main" id="1595" XML_Guid="{BC202AA4-C624-44D3-A9E6-17CEBFE5C9EB}" Expanded="True">
        <Macro Name="Under key" XML_Guid="{63D78999-5317-4B0E-886F-51C454D4977E}">
            <Event Name="Main.underkey" XML_Guid="{3F3A4844-C5D6-4DC6-A059-38D22D50B4CD}" />
            <Action Name="quake down" XML_Guid="{2D7A4D73-B679-4899-8567-207153015A7C}">
                EventGhost.TriggerEvent(u'quake_down', 0.0, None, False, False, False)
            </Action>
            <Action Enabled="False" XML_Guid="{77CD9EA2-3D2F-4ED0-8BF1-E1787AF0C281}">
                Window.SendKeys(u'none', False, 2)
            </Action>
        </Macro>
        <Macro Name="Side key 1" XML_Guid="{BC50F526-64A3-4C7A-9AC7-417CB94F24B4}">
            <Event Name="Main.sidekey1" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action Name="Launcher selector" Enabled="False" XML_Guid="{2D7A4D73-B679-4899-8567-207153015A7C}">
                EventGhost.TriggerEvent(u'launcher_selector', 0.0, None, False, False, False)
            </Action>
            <Action Name="job selector" XML_Guid="{2D7A4D73-B679-4899-8567-207153015A7C}">
                EventGhost.TriggerEvent(u'job_selector', 0.0, None, False, False, False)
            </Action>
            <Action Enabled="False" XML_Guid="{77CD9EA2-3D2F-4ED0-8BF1-E1787AF0C281}">
                Window.SendKeys(u'none', False, 2)
            </Action>
        </Macro>
        <Macro Name="Side key 2" XML_Guid="{BC50F526-64A3-4C7A-9AC7-417CB94F24B4}">
            <Event Name="Main.sidekey2" XML_Guid="{609DBD5B-5D81-45E0-BFE6-EC4CC31C5C26}" />
            <Action Name="payload desknote" Enabled="False" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'payload_desknote', 0.0, None, False, False, False)
            </Action>
            <Action Name="mb track" Enabled="False" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'mb track', 0.0, None, False, False, False)
            </Action>
            <Action Name="job_note_query" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'job_note_query', 0.0, None, False, False, False)
            </Action>
            <Action Enabled="False" XML_Guid="{77CD9EA2-3D2F-4ED0-8BF1-E1787AF0C281}">
                Window.SendKeys(u'none', False, 2)
            </Action>
        </Macro>
        <Macro Name="Side key 3" XML_Guid="{BC50F526-64A3-4C7A-9AC7-417CB94F24B4}">
            <Event Name="Main.sidekey3" XML_Guid="{609DBD5B-5D81-45E0-BFE6-EC4CC31C5C26}" />
            <Action Name="opend desknote" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'open_desknote', 0.0, None, False, False, False)
            </Action>
            <Action Name="none" Enabled="False" XML_Guid="{2D7A4D73-B679-4899-8567-207153015A7C}">
                EventGhost.TriggerEvent(u'qv input botcut', 0.0, None, False, False, False)
            </Action>
            <Action Enabled="False" XML_Guid="{77CD9EA2-3D2F-4ED0-8BF1-E1787AF0C281}">
                Window.SendKeys(u'{Home}', False, 2)
            </Action>
        </Macro>
        <Macro Name="Side key 4" XML_Guid="{BC50F526-64A3-4C7A-9AC7-417CB94F24B4}">
            <Event Name="Main.sidekey4" XML_Guid="{609DBD5B-5D81-45E0-BFE6-EC4CC31C5C26}" />
            <Action Name="egcommandline" Enabled="False" XML_Guid="{2D7A4D73-B679-4899-8567-207153015A7C}">
                EventGhost.TriggerEvent(u'qv?delete?selected?dates', 0.0, None, False, False, False)
            </Action>
            <Action XML_Guid="{77CD9EA2-3D2F-4ED0-8BF1-E1787AF0C281}">
                Window.SendKeys(u'{End}', False, 2)
            </Action>
            <Action Enabled="False" XML_Guid="{52527FDC-6FCF-4F7E-9B84-1537E6C28999}">
                Window.SetAlwaysOnTop(2)
            </Action>
        </Macro>
        <Macro Name=" XButton1" XML_Guid="{84A17B34-BFA0-43CF-9F33-F4377C5D6D0B}">
            <Event Name="Keyboard.Space" Enabled="False" XML_Guid="{9B04D3C7-B447-4A69-AE5C-A7891A47780B}" />
            <Event Name="Mouse.XButton1" XML_Guid="{0C1166BF-0591-4133-94AE-82E9E377221E}" />
            <Event Name="Keyboard.X" Enabled="False" XML_Guid="{8066B2CE-D37B-47B7-B831-09216215138F}" />
            <Action Name="launcher_selector" Enabled="False" XML_Guid="{51FA8B19-069E-46C0-BFCC-6E291DC6A83B}">
                EventGhost.TriggerEvent(u'launcher_selector', 0.0, None, False, False, False)
            </Action>
            <Action Name="open desknote" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'open_desknote', 0.0, None, False, False, False)
            </Action>
            <Action Enabled="False" XML_Guid="{030EDED9-54ED-43C2-86E9-2AFC8E6E3636}">
                EventGhost.PythonScript(u'eg.plugins.Mouse.MoveAbsolute(1891,50, 1, False, True)\neg.plugins.EventGhost.Wait(.2)\n#eg.plugins.Mouse.LeftDoubleClick()\neg.plugins.Mouse.LeftButton()\neg.plugins.EventGhost.Wait(.5)\n')
            </Action>
            <Action Enabled="False" XML_Guid="{08D93F02-F5C6-43B9-B76C-D9E5192EE784}">
                Window.SendKeys(u'{F2}{Left}{Ctrl+V}{Enter}', False, 2)
            </Action>
        </Macro>
        <Macro Name=" XButton2" XML_Guid="{63EE85E1-FE11-4293-B8AA-3BE80FBCE7D5}">
            <Event Name="Mouse.XButton2" XML_Guid="{9ED7F535-61CF-426F-A425-237F243D2497}" />
            <Action Enabled="False" XML_Guid="{3D345DD9-CA5B-47C0-8EDE-45E94121439A}">
                Window.SendKeys(u'{F2}', False, 2)
            </Action>
            <Action Name="job selector" XML_Guid="{2D7A4D73-B679-4899-8567-207153015A7C}">
                EventGhost.TriggerEvent(u'job_selector', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Middle key" XML_Guid="{63EE85E1-FE11-4293-B8AA-3BE80FBCE7D5}">
            <Event Name="Main.middlekey" XML_Guid="{B188C0B1-8220-4403-800F-CBA56DB8882C}" />
            <Action Name="win?tab" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'win?tab', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Gkey1" XML_Guid="{BC50F526-64A3-4C7A-9AC7-417CB94F24B4}">
            <Event Name="Main.gkey1" XML_Guid="{609DBD5B-5D81-45E0-BFE6-EC4CC31C5C26}" />
            <Action Name="wmp lib" Enabled="False" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'wmp lib', 0.0, None, False, False, False)
            </Action>
            <Action Name="mb addsong" Enabled="False" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'mb addsong', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Gkey2" XML_Guid="{BC50F526-64A3-4C7A-9AC7-417CB94F24B4}">
            <Event Name="Main.gkey2" XML_Guid="{609DBD5B-5D81-45E0-BFE6-EC4CC31C5C26}" />
            <Action Name="mb track" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'mb remote', 0.0, None, False, False, False)
            </Action>
            <Action Name="wmp toggle" Enabled="False" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'wmp toggle', 0.0, None, False, False, False)
            </Action>
            <Action Name="mb toggle" Enabled="False" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'mb toggle', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="Gkey3" XML_Guid="{BC50F526-64A3-4C7A-9AC7-417CB94F24B4}">
            <Event Name="Main.gkey3" XML_Guid="{609DBD5B-5D81-45E0-BFE6-EC4CC31C5C26}" />
            <Action Name="doze" Enabled="False" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'doze', 0.0, None, False, False, False)
            </Action>
            <Action Name="job selector" XML_Guid="{2D7A4D73-B679-4899-8567-207153015A7C}">
                EventGhost.TriggerEvent(u'job_selector', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="uff key" XML_Guid="{5EEA955A-8A67-431A-8C92-353785D86236}">
            <Event Name="Keyboard.UFF" Enabled="False" XML_Guid="{83B567ED-D160-4A7F-9404-638383E33645}" />
            <Action XML_Guid="{44EAE2B1-F0A8-4B2E-802F-34B9E3F3C92E}">
                EventGhost.JumpIfLongPress(1.0, XmlIdLink(1653))
            </Action>
            <Action Name="launcher" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'launcher selector', 0.0, None, False, False, False)
            </Action>
        </Macro>
        <Macro Name="uff long" id="1653" XML_Guid="{5EEA955A-8A67-431A-8C92-353785D86236}">
            <Action Name="launcher" XML_Guid="{88440690-5828-4B51-8983-1DE2BAA808BA}">
                EventGhost.TriggerEvent(u'job selector', 0.0, None, False, False, False)
            </Action>
        </Macro>
    </Folder>
</EventGhost>
This is kinda overkill here but I'm scatter brained atm lol, but You could have all of the Event Prefixes rename to what you want and paste it into EG ready to go without having to edit each object.

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Thu Nov 21, 2019 2:21 pm

Okay i found a good example.
So this is a little setup I use to watch my o very many modems

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP-2019.04.14-12.39.31">
    <Folder Name="Vm 1" XML_Guid="{F751A983-AD54-4817-8CDD-4660200CE00E}" Expanded="True">
        <Macro Name="Add Host river 1" XML_Guid="{EB6D675A-1050-4CC3-871B-B6E07D7804B9}" Expanded="True">
            <Event Name="*.boot?pings" Enabled="False" XML_Guid="{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}" />
            <Event Name="*.boot?vm1" Enabled="False" XML_Guid="{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}" />
            <Action XML_Guid="{6CFF5217-9B2B-40DC-9E66-C286DA4331BD}">
                PingPlugin.AddHost(u'166.252.xxx.xxx', u'vm1', 200, u'vm1.on', u'vm1.off', 4, 4)
            </Action>
        </Macro>
        <Macro Name="Ping once" XML_Guid="{A62E33DC-510A-44FB-9442-A0D364D7B1D0}" Expanded="True">
            <Event Name="*.ping?vm1" XML_Guid="{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}" />
            <Action XML_Guid="{A1A67003-0B50-49D7-A2EB-651CF3115191}">
                PingPlugin.OnePing(u'166.252.xxx.xxx', u'vm1', 200, True, u'vm1.on', u'vm1.off')
            </Action>
        </Macro>
        <Macro Name="Remove host" XML_Guid="{826732A4-524B-4D80-B081-F29CC6229725}" Expanded="True">
            <Event Name="Main.ping?stop" XML_Guid="{41707CBB-652C-4C82-BD70-BFB24891D04F}" />
            <Action XML_Guid="{295CD8F3-34E0-4643-9517-EC27DF50A664}">
                PingPlugin.RemoveHost(u'166.252.xxx.xxx')
            </Action>
        </Macro>
        <Macro Name="vm1 Online" XML_Guid="{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}" Expanded="True">
            <Event Name="Ping.vm1.on" XML_Guid="{58410FBC-8D3E-4E61-84FA-D40945BF2887}" />
            <Action Name="vm online " XML_Guid="{0933CE87-C494-408A-9415-B82C0A296E96}">
                EventGhost.PythonScript(u'eg.globals.name = "VM 1"\neg.globals.status = "Online"\neg.globals.tint = eg.globals.status\neg.plugins.AutoRemote.SendNotification(u\'APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw\', u\'Pixel\', u\'{eg.globals.name} {eg.globals.status}\', u\'\', u\'\', u\'\', u\'{eg.globals.name}\', u\'{eg.globals.name}\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\')\neg.plugins.EventGhost.ShowOSD(u\'{eg.globals.name} {eg.globals.status}\', u\'0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\neg.plugins.FileOperations.Write(2, u\'{eg.globals.name}+{eg.globals.status}\', u\'C:\\\\Users\\\\Lindapendant\\\\Desktop\\\\pinglog.txt\', 2, 0, False, True, False, \'cp1252\')')
            </Action>
        </Macro>
        <Macro Name="vm1 Offline" XML_Guid="{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}" Expanded="True">
            <Event Name="Ping.vm1.off" XML_Guid="{58410FBC-8D3E-4E61-84FA-D40945BF2887}" />
            <Action Name="vm offline " XML_Guid="{0933CE87-C494-408A-9415-B82C0A296E96}">
                EventGhost.PythonScript(u'eg.globals.name = "vm 1"\neg.globals.status = "Offline"\neg.globals.tint = eg.globals.status\neg.plugins.AutoRemote.SendNotification(u\'APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw\', u\'Pixel\', u\'{eg.globals.name} {eg.globals.status}\', u\'\', u\'\', u\'\', u\'{eg.globals.name}\', u\'{eg.globals.name}\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\', u\'\')\neg.plugins.EventGhost.ShowOSD(u\'{eg.globals.name} {eg.globals.status}\', u\'0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\neg.plugins.FileOperations.Write(2, u\'{eg.globals.name}+{eg.globals.status}\', u\'C:\\\\Users\\\\Lindapendant\\\\Desktop\\\\pinglog.txt\', 2, 0, False, True, False, \'cp1252\')')
            </Action>
        </Macro>
    </Folder>
</EventGhost>

Whenever I want to add a new device, I have to copy and paste an old one, and change the name and IP in every event and script, name, etc.
So this tool lets me plug the IP and Name as variables, and get an EG import-able macro tree generated in my clipboard, to paste straight into Eg.
Less clicky clacky

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

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by kgschlosser » Thu Nov 21, 2019 5:19 pm

ya know you could go over the top with it. Because EG monitors the clipboard it's not that hard to watch the clipboard for changes.

so if a specific marker was at the beginning of the clip data, kind of like "Hello Google" or "Alexa.." EG would know the clip data was for it and built the tree with only a simply copy..

so say you key up a test file that has

EG Add Modem: 192.168.1.1:56584

all you would have to do is to copy that single line. and watch your tree grow.

another option is to use the keyboard plugin and set up a key combination that would run a script to open a dialog where you enter the information that is needed and EG will then build the macros from there.

that can be done 2 ways

less complex
building the proper xml data and passing it to
eg.UndoHandler.Paste.PasteXml(eg.document.root, generated_xml_data)

more complex
or by individually creating the tree items and adding them to the tree


give this a try you are going to need to have the keyboard plugin installed and the key combination is ctrl+L (lower case)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc6">
    <Action XML_Guid="{0D6A4129-032F-4299-AF45-DAB5EFAB88A0}">
        EventGhost.PythonScript(u'\nxml_data_template = """&lt;?xml version="1.0" encoding="UTF-8" ?&gt;\n&lt;EventGhost Version="WIP-2019.04.14-12.39.31"&gt;\n    &lt;Folder Name="{name}" XML_Guid="{{F751A983-AD54-4817-8CDD-4660200CE00E}}" Expanded="True"&gt;\n        &lt;Macro Name="Add Host {name}" XML_Guid="{{EB6D675A-1050-4CC3-871B-B6E07D7804B9}}" Expanded="True"&gt;\n            &lt;Event Name="*.boot?pings" Enabled="False" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n            &lt;Event Name="*.boot?{name}" Enabled="False" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n            &lt;Action XML_Guid="{{6CFF5217-9B2B-40DC-9E66-C286DA4331BD}}"&gt;\n                PingPlugin.AddHost("{ip_address}", "{name}", 200, "{name}.on", "{name}.off", 4, 4)\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="Ping once" XML_Guid="{{A62E33DC-510A-44FB-9442-A0D364D7B1D0}}" Expanded="True"&gt;\n            &lt;Event Name="*.ping?{name}" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n                &lt;Action XML_Guid="{{A1A67003-0B50-49D7-A2EB-651CF3115191}}"&gt;\n                    PingPlugin.OnePing("{ip_address}", "{name}", 200, True, "{name}.on", "{name}.off")\n                &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="Remove host" XML_Guid="{{826732A4-524B-4D80-B081-F29CC6229725}}" Expanded="True"&gt;\n            &lt;Event Name="Main.ping?stop" XML_Guid="{{41707CBB-652C-4C82-BD70-BFB24891D04F}}" /&gt;\n            &lt;Action XML_Guid="{{295CD8F3-34E0-4643-9517-EC27DF50A664}}"&gt;\n                PingPlugin.RemoveHost("{ip_address}")\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="vm1 Online" XML_Guid="{{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}}" Expanded="True"&gt;\n            &lt;Event Name="Ping.{name}.on" XML_Guid="{{58410FBC-8D3E-4E61-84FA-D40945BF2887}}" /&gt;\n            &lt;Action Name="{name} Online " XML_Guid="{{0933CE87-C494-408A-9415-B82C0A296E96}}"&gt;\n                EventGhost.PythonScript(u\'eg.plugins.AutoRemote.SendNotification("APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw", "Pixel", "{name} Online", "", "", "", "{name}", "{name}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")\\\\neg.plugins.EventGhost.ShowOSD("{name} Online", "0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial", (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\\\\neg.plugins.FileOperations.Write(2, "{name} Online", "C:\\\\\\\\Users\\\\\\\\Lindapendant\\\\\\\\Desktop\\\\\\\\pinglog.txt", 2, 0, False, True, False, "cp1252")\')\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="{name} Offline" XML_Guid="{{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}}" Expanded="True"&gt;\n            &lt;Event Name="Ping.{name}.off" XML_Guid="{{58410FBC-8D3E-4E61-84FA-D40945BF2887}}" /&gt;\n            &lt;Action Name="{name} Offline " XML_Guid="{{0933CE87-C494-408A-9415-B82C0A296E96}}"&gt;\n                EventGhost.PythonScript(u\'eg.plugins.AutoRemote.SendNotification("APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw", "Pixel", "{name} Offline", "", "", "", "{name}", "{name}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")\\\\neg.plugins.EventGhost.ShowOSD("{name} Offline", "0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial", (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\\\\neg.plugins.FileOperations.Write(2, "{name} Offline", "C:\\\\\\\\Users\\\\\\\\Lindapendant\\\\\\\\Desktop\\\\\\\\pinglog.txt", 2, 0, False, True, False, "cp1252")\')\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n    &lt;/Folder&gt;\n&lt;/EventGhost&gt;"""\n\nimport wx\n\nclass Frame(wx.Frame):\n\n    def __init__(self):\n        wx.Frame.__init__(self, None, -1, size=(300, 200))\n\n        sizer = wx.BoxSizer(wx.VERTICAL)\n\n        st1 = wx.StaticText(self, -1, \'Name:\')\n        st2 = wx.StaticText(self, -1, \'IP Address:\')\n\n        self.name_ctrl = name_ctrl = wx.TextCtrl(self, -1, \'\')\n        self.ip_ctrl = ip_ctrl = wx.TextCtrl(self, -1, \'\')\n\n        name_sizer = wx.BoxSizer(wx.HORIZONTAL)\n        name_sizer.Add(st1, 0, wx.EXPAND | wx.ALL, 10)\n        name_sizer.Add(name_ctrl, 0, wx.EXPAND | wx.ALL, 10)\n\n        ip_sizer = wx.BoxSizer(wx.HORIZONTAL)\n        ip_sizer.Add(st2, 0, wx.EXPAND | wx.ALL, 10)\n        ip_sizer.Add(ip_ctrl, 0, wx.EXPAND | wx.ALL, 10)\n\n        button_sizer = wx.BoxSizer(wx.HORIZONTAL)\n        button_sizer.AddStretchSpacer(1)\n        ok_button = wx.Button(self, wx.ID_OK)\n        cancel_button = wx.Button(self, wx.ID_CANCEL)\n        \n        ok_button.Bind(wx.EVT_BUTTON, self.on_ok)\n        cancel_button.Bind(wx.EVT_BUTTON, self.on_cancel)\n        \n        button_sizer.Add(cancel_button, 0, wx.ALL, 10)\n        button_sizer.Add(ok_button, 0, wx.ALL, 10)\n        \n        def on_char(evt):\n            print name_ctrl.GetValue()\n            print evt.GetKeycode()\n            evt.Skip()\n            \n        name_ctrl.Bind(wx.EVT_CHAR, on_char)\n        \n        sizer.Add(name_sizer)\n        sizer.Add(ip_sizer)\n        sizer.AddSpacer(4)\n        sizer.Add(button_sizer)\n        self.SetSizer(sizer)\n    \n    def on_ok(self, evt):\n        name = self.name_ctrl.GetValue()\n        ip_address = self.ip_ctrl.GetValue()\n        xml_data = xml_data_template.format(name=name, ip_address=ip_address)\n\n        def do(data):\n            paste = eg.UndoHandler.Paste(eg.document)\n            paste.items = []\n\n            result = eg.actionThread.Func(paste.PasteXml)(\n                eg.document.root,\n                data\n            )\n            if result:\n                eg.document.AppendUndoHandler(paste)\n\n        wx.CallAfter(do, xml_data)\n        self.Hide()\n        self.Destroy()\n        evt.Skip()\n\n    def on_cancel(self, evt):\n        self.Hide()\n        self.Destroy()\n        evt.Skip()\n\nframe = Frame()\nframe.Show()')
    </Action>
</EventGhost>
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Thu Nov 21, 2019 8:13 pm

O god new toys yess! lol, I knew I should of been doing it that way but also half didn't know all the parts I needed to ask about, half no time as usual haha

I can't dig right now but madddd hyyyypppeeeeeeeee

Thanks dude your a life saver I'll let you know how it goes

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

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by kgschlosser » Thu Nov 21, 2019 11:44 pm

you would not think about the undo handler for adding items to the tree, It's kind of cooky if you ask me.

I didn't code that, the original author did I think.

I have spent many moons using that print statement to follow a data path through the program. I have since created a super aggressive debugging routine that spits out the calling function\class\method\module along with the file name and the line number of where the call originated from. along with the arguments passed if any and any return data as well. and it also does the same for the destination function. and it times how long the call took. It also works on properties and attributes\constants
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Fri Nov 22, 2019 8:25 pm

kgschlosser wrote:
Thu Nov 21, 2019 11:44 pm
you would not think about the undo handler for adding items to the tree, It's kind of cooky if you ask me.

I didn't code that, the original author did I think.

I have spent many moons using that print statement to follow a data path through the program. I have since created a super aggressive debugging routine that spits out the calling function\class\method\module along with the file name and the line number of where the call originated from. along with the arguments passed if any and any return data as well. and it also does the same for the destination function. and it times how long the call took. It also works on properties and attributes\constants
I spend alot of time adding and removing prints, That sounds dope can i check it out?

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Sat Nov 23, 2019 7:22 pm

I actually do something similar with tasker, When I clip an address or a URL and a couple others, tasker knows where to put it for me. Setting this up to grow the tree is GENIUS i am going to go way over the top with this.

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Sat Nov 23, 2019 7:33 pm

Instead of building it a frame of it's own, I have used the Autoremote Input action to do Query for a number of other projects. I use one on my lctrl+lwin as a EG command line for just about everything. Lots of places have like if payload isn't set, show ARinput, than trigger the same event and take the if payload. having more than 1 field has been an issue so thanks for the example!

I couldn't get that frame you posted above to type into the fields. But I need to play around with it some more maybe I'll figure out why.
Attachments
2019-11-23 13_29_41-Window.png

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

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by kgschlosser » Sat Nov 23, 2019 8:05 pm

I wasn't sure if it was my system or not. But I had the same problem with not being able to type I it.

It was simply for example anywho. And it did get the point across about injecting the xml right into EG instead of having to monkey about with the clipboard.
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Sat Nov 23, 2019 11:15 pm

kgschlosser wrote:
Sat Nov 23, 2019 8:05 pm
I wasn't sure if it was my system or not. But I had the same problem with not being able to type I it.

It was simply for example anywho. And it did get the point across about injecting the xml right into EG instead of having to monkey about with the clipboard.
I had figured it wouldn't be possible without me having to paste it somewhere since i couldn't conceive of a way to give it a target location in the tree to insert into. the XmlIdLink(*) bit isn't practical. Doing it this way solves so many issues before they come up I love it.

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Sun Nov 24, 2019 12:08 am

So this is what I ended up with for today.
it works GREAT.
I went with input name, than trigger second input for IP, keep it easy until I build a better input

I need to redo alot of it but i have the pieces i need.
like the log destination (in mine it goes to {eg.globals.logdir}+"pinglong.txt"

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP">
    <Folder Name="Ping generator" XML_Guid="{DB105D1D-C2CC-4734-97DB-58BD956AF449}" Expanded="True">
        <Macro Name="AutoRemote: Show input dialog: Ping generator" XML_Guid="{D114094A-EE54-4223-BBF5-6B31BF4C2C77}">
            <Event Name="*.ping?gen" XML_Guid="{837DD4E6-BA95-4AA5-8AD7-10057D70B555}" />
            <Action XML_Guid="{1BDCC727-2A0F-4A0F-8FC0-49B7DD4EA127}">
                AutoRemote.ShowInputDialog(u'Ping generator', u'Enter Device name', u'', u'pinggen', False)
            </Action>
        </Macro>
        <Macro Name="second query" XML_Guid="{219184AE-230E-4C39-B43B-7A1F8CF4FFEA}">
            <Event Name="*.pinggen" XML_Guid="{E379C7C3-7AA6-49EF-90F1-692886DB132A}" />
            <Action XML_Guid="{5BB19786-ED52-4BCB-B572-2874DA0686DB}">
                EventGhost.PythonScript(u'eg.globals.newpingname = eg.event.payload\n')
            </Action>
            <Action XML_Guid="{1BDCC727-2A0F-4A0F-8FC0-49B7DD4EA127}">
                AutoRemote.ShowInputDialog(u'Ping generator', u'Enter Ip address', u'', u'pinggen2', False)
            </Action>
        </Macro>
        <Macro Name="insert xml" XML_Guid="{1E0C566F-0DBC-4527-A49F-723238A255BF}">
            <Event Name="*.pinggen2" XML_Guid="{6CF467DC-572F-40EB-9487-E6E91E49DA13}" />
            <Action Name="Ping generator" XML_Guid="{0D6A4129-032F-4299-AF45-DAB5EFAB88A0}">
                EventGhost.PythonScript(u'\nxml_data_template = """&lt;?xml version="1.0" encoding="UTF-8" ?&gt;\n&lt;EventGhost Version="WIP-2019.04.14-12.39.31"&gt;\n    &lt;Folder Name="{name}" XML_Guid="{{F751A983-AD54-4817-8CDD-4660200CE00E}}" Expanded="True"&gt;\n        &lt;Macro Name="Add Host {name}" XML_Guid="{{EB6D675A-1050-4CC3-871B-B6E07D7804B9}}" Expanded="True"&gt;\n            &lt;Event Name="*.boot?pings" Enabled="False" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n            &lt;Event Name="*.boot?{name}" Enabled="False" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n            &lt;Action XML_Guid="{{6CFF5217-9B2B-40DC-9E66-C286DA4331BD}}"&gt;\n                PingPlugin.AddHost("{ip_address}", "{name}", 200, "{name}.on", "{name}.off", 4, 4)\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="Ping once" XML_Guid="{{A62E33DC-510A-44FB-9442-A0D364D7B1D0}}" Expanded="True"&gt;\n            &lt;Event Name="*.ping?{name}" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n                &lt;Action XML_Guid="{{A1A67003-0B50-49D7-A2EB-651CF3115191}}"&gt;\n                    PingPlugin.OnePing("{ip_address}", "{name}", 200, True, "{name}.on", "{name}.off")\n                &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="Remove host" XML_Guid="{{826732A4-524B-4D80-B081-F29CC6229725}}" Expanded="True"&gt;\n            &lt;Event Name="Main.ping?stop" XML_Guid="{{41707CBB-652C-4C82-BD70-BFB24891D04F}}" /&gt;\n            &lt;Action XML_Guid="{{295CD8F3-34E0-4643-9517-EC27DF50A664}}"&gt;\n                PingPlugin.RemoveHost("{ip_address}")\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="vm1 Online" XML_Guid="{{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}}" Expanded="True"&gt;\n            &lt;Event Name="Ping.{name}.on" XML_Guid="{{58410FBC-8D3E-4E61-84FA-D40945BF2887}}" /&gt;\n            &lt;Action Name="{name} Online " XML_Guid="{{0933CE87-C494-408A-9415-B82C0A296E96}}"&gt;\n                EventGhost.PythonScript(u\'eg.plugins.AutoRemote.SendNotification("APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw", "Pixel", "{name} Online", "", "", "", "{name}", "{name}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")\\\\neg.plugins.EventGhost.ShowOSD("{name} Online", "0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial", (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\\\\neg.plugins.FileOperations.Write(2, "{name} Online", "C:\\\\\\\\Users\\\\\\\\Dan.Edens\\\\\\\\Desktop\\\\\\\\pinglog.txt", 2, 0, False, True, False, "cp1252")\')\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="{name} Offline" XML_Guid="{{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}}" Expanded="True"&gt;\n            &lt;Event Name="Ping.{name}.off" XML_Guid="{{58410FBC-8D3E-4E61-84FA-D40945BF2887}}" /&gt;\n            &lt;Action Name="{name} Offline " XML_Guid="{{0933CE87-C494-408A-9415-B82C0A296E96}}"&gt;\n               EventGhost.PythonScript(u\'eg.plugins.AutoRemote.SendNotification("APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw", "Pixel", "{name} Offline", "", "", "", "{name}", "{name}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")\\\\neg.plugins.EventGhost.ShowOSD("{name} Offline", "0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial", (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\\\\neg.plugins.FileOperations.Write(2, "{name} Offline", "C:\\\\\\\\Users\\\\\\\\Dan.Edens\\\\\\\\Desktop\\\\\\\\pinglog.txt", 2, 0, False, True, False, "cp1252")\')\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n    &lt;/Folder&gt;\n&lt;/EventGhost&gt;"""\n\n\n#name = self.name_ctrl.GetValue()\n#ip_address = self.ip_ctrl.GetValue()\n\nname = eg.globals.newpingname\nip_address = eg.event.payload\nxml_data = xml_data_template.format(name=name, ip_address=ip_address)\n\ndef do(data):\n    paste = eg.UndoHandler.Paste(eg.document)\n    paste.items = []\n\n    result = eg.actionThread.Func(paste.PasteXml)(eg.document.root, data)\n    if result:\n        eg.document.AppendUndoHandler(paste)\n\nwx.CallAfter(do, xml_data)\n#evt.Skip()')
            </Action>
            <Action Name="orginal" Enabled="False" XML_Guid="{0D6A4129-032F-4299-AF45-DAB5EFAB88A0}">
                EventGhost.PythonScript(u'\nxml_data_template = """&lt;?xml version="1.0" encoding="UTF-8" ?&gt;\n&lt;EventGhost Version="WIP-2019.04.14-12.39.31"&gt;\n    &lt;Folder Name="{name}" XML_Guid="{{F751A983-AD54-4817-8CDD-4660200CE00E}}" Expanded="True"&gt;\n        &lt;Macro Name="Add Host {name}" XML_Guid="{{EB6D675A-1050-4CC3-871B-B6E07D7804B9}}" Expanded="True"&gt;\n            &lt;Event Name="*.boot?pings" Enabled="False" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n            &lt;Event Name="*.boot?{name}" Enabled="False" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n            &lt;Action XML_Guid="{{6CFF5217-9B2B-40DC-9E66-C286DA4331BD}}"&gt;\n                PingPlugin.AddHost("{ip_address}", "{name}", 200, "{name}.on", "{name}.off", 4, 4)\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="Ping once" XML_Guid="{{A62E33DC-510A-44FB-9442-A0D364D7B1D0}}" Expanded="True"&gt;\n            &lt;Event Name="*.ping?{name}" XML_Guid="{{96F3836B-99CC-49C0-AA8F-4C7D25E6C4FD}}" /&gt;\n                &lt;Action XML_Guid="{{A1A67003-0B50-49D7-A2EB-651CF3115191}}"&gt;\n                    PingPlugin.OnePing("{ip_address}", "{name}", 200, True, "{name}.on", "{name}.off")\n                &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="Remove host" XML_Guid="{{826732A4-524B-4D80-B081-F29CC6229725}}" Expanded="True"&gt;\n            &lt;Event Name="Main.ping?stop" XML_Guid="{{41707CBB-652C-4C82-BD70-BFB24891D04F}}" /&gt;\n            &lt;Action XML_Guid="{{295CD8F3-34E0-4643-9517-EC27DF50A664}}"&gt;\n                PingPlugin.RemoveHost("{ip_address}")\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="vm1 Online" XML_Guid="{{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}}" Expanded="True"&gt;\n            &lt;Event Name="Ping.{name}.on" XML_Guid="{{58410FBC-8D3E-4E61-84FA-D40945BF2887}}" /&gt;\n            &lt;Action Name="{name} Online " XML_Guid="{{0933CE87-C494-408A-9415-B82C0A296E96}}"&gt;\n                EventGhost.PythonScript(u\'eg.plugins.AutoRemote.SendNotification("APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw", "Pixel", "{name} Online", "", "", "", "{name}", "{name}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")\\\\neg.plugins.EventGhost.ShowOSD("{name} Online", "0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial", (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\\\\neg.plugins.FileOperations.Write(2, "{name} Online", "C:\\\\\\\\Users\\\\\\\\Lindapendant\\\\\\\\Desktop\\\\\\\\pinglog.txt", 2, 0, False, True, False, "cp1252")\')\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n        &lt;Macro Name="{name} Offline" XML_Guid="{{EC98C8A9-C2CA-42A3-8B6E-41F3853A0293}}" Expanded="True"&gt;\n            &lt;Event Name="Ping.{name}.off" XML_Guid="{{58410FBC-8D3E-4E61-84FA-D40945BF2887}}" /&gt;\n            &lt;Action Name="{name} Offline " XML_Guid="{{0933CE87-C494-408A-9415-B82C0A296E96}}"&gt;\n                EventGhost.PythonScript(u\'eg.plugins.AutoRemote.SendNotification("APA91bEdoLlyAUKL6RP1si7Mo25PaGVTxiG9XuNdKI9s1HsnfOOB0f2UOsndoDr2zZkvnYi7hMMBzZBCGlGXjEtHs1mjYeG_BqgDV_FmREao87vkDFvwAbq8SvlW97s7WFaISrDBNmcw", "Pixel", "{name} Offline", "", "", "", "{name}", "{name}", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "")\\\\neg.plugins.EventGhost.ShowOSD("{name} Offline", "0;-35;0;0;0;700;0;0;0;0;3;2;1;34;Arial", (53, 243, 5), (0, 0, 0), 6, (0, 200), 1, 4.0, None)\\\\neg.plugins.FileOperations.Write(2, "{name} Offline", "C:\\\\\\\\Users\\\\\\\\Lindapendant\\\\\\\\Desktop\\\\\\\\pinglog.txt", 2, 0, False, True, False, "cp1252")\')\n            &lt;/Action&gt;\n        &lt;/Macro&gt;\n    &lt;/Folder&gt;\n&lt;/EventGhost&gt;"""\n\nimport wx\n\nclass Frame(wx.Frame):\n\n    def __init__(self):\n        wx.Frame.__init__(self, None, -1, size=(300, 200))\n\n        sizer = wx.BoxSizer(wx.VERTICAL)\n\n        st1 = wx.StaticText(self, -1, \'Name:\')\n        st2 = wx.StaticText(self, -1, \'IP Address:\')\n\n        self.name_ctrl = name_ctrl = wx.TextCtrl(self, -1, \'\')\n        self.ip_ctrl = ip_ctrl = wx.TextCtrl(self, -1, \'\')\n\n        name_sizer = wx.BoxSizer(wx.HORIZONTAL)\n        name_sizer.Add(st1, 0, wx.EXPAND | wx.ALL, 10)\n        name_sizer.Add(name_ctrl, 0, wx.EXPAND | wx.ALL, 10)\n\n        ip_sizer = wx.BoxSizer(wx.HORIZONTAL)\n        ip_sizer.Add(st2, 0, wx.EXPAND | wx.ALL, 10)\n        ip_sizer.Add(ip_ctrl, 0, wx.EXPAND | wx.ALL, 10)\n\n        button_sizer = wx.BoxSizer(wx.HORIZONTAL)\n        button_sizer.AddStretchSpacer(1)\n        ok_button = wx.Button(self, wx.ID_OK)\n        cancel_button = wx.Button(self, wx.ID_CANCEL)\n        \n        ok_button.Bind(wx.EVT_BUTTON, self.on_ok)\n        cancel_button.Bind(wx.EVT_BUTTON, self.on_cancel)\n        \n        button_sizer.Add(cancel_button, 0, wx.ALL, 10)\n        button_sizer.Add(ok_button, 0, wx.ALL, 10)\n        \n        def on_char(evt):\n            print name_ctrl.GetValue()\n            print evt.GetKeycode()\n            evt.Skip()\n            \n        name_ctrl.Bind(wx.EVT_CHAR, on_char)\n        \n        sizer.Add(name_sizer)\n        sizer.Add(ip_sizer)\n        sizer.AddSpacer(4)\n        sizer.Add(button_sizer)\n        self.SetSizer(sizer)\n    \n    def on_ok(self, evt):\n        name = self.name_ctrl.GetValue()\n        ip_address = self.ip_ctrl.GetValue()\n        xml_data = xml_data_template.format(name=name, ip_address=ip_address)\n\n        def do(data):\n            paste = eg.UndoHandler.Paste(eg.document)\n            paste.items = []\n\n            result = eg.actionThread.Func(paste.PasteXml)(\n                eg.document.root,\n                data\n            )\n            if result:\n                eg.document.AppendUndoHandler(paste)\n\n        wx.CallAfter(do, xml_data)\n        self.Hide()\n        self.Destroy()\n        evt.Skip()\n\n    def on_cancel(self, evt):\n        self.Hide()\n        self.Destroy()\n        evt.Skip()\n\nframe = Frame()\nframe.Show()')
            </Action>
        </Macro>
    </Folder>
</EventGhost>

Post Reply