Working with the Clipboard
-
- Posts: 6
- Joined: Mon May 13, 2013 2:55 pm
Working with the Clipboard
Hey, new member here! I've been using Eventghost 0.4.1.r1600 for a few days now and am starting to get the hang of the basics, but I'm getting stuck with scripting, specifically with the system clipboard. The action System.ClipboardChanged and the Copy string to clipboard action is about the only way I can see to interact with it, but I would like to be able to retrieve the data from the clipboard in order to show, transfer, or modify it. Can anyone help me with the basics here?
Thanks in advance.
Thanks in advance.
-
- Posts: 6
- Joined: Mon May 13, 2013 2:55 pm
Re: Working with the Clipboard
More specifically, I am trying to sync clipboards among my phone, tablet, and desktop. Using Tasker and Autoremote, I have the clipboards synced between the phone and tablet, and using the Autoremote plugin for Eventghost the desktop will receive clipboard changes from both devices. I have not yet discovered how to push the contents of the clipboard from the desktop to the phone and tablet though.
What I have so far is:
Event: System.ClipboardChanged
Action: AutoRemote: Sending clpbd=:={eg.system.clipboard} to Mobile
where "clpbd" is the parameter I have specified between the devices and "eg.system.clipboard" was a guess at where the clipboard contents would be stored. Of course it is not stored there. I am going to assume at this point that there is not a simple EG command for this, and instead it will need to be a python script. Does anyone have a resource I could look at for retrieving the clipboard contents?
What I have so far is:
Event: System.ClipboardChanged
Action: AutoRemote: Sending clpbd=:={eg.system.clipboard} to Mobile
where "clpbd" is the parameter I have specified between the devices and "eg.system.clipboard" was a guess at where the clipboard contents would be stored. Of course it is not stored there. I am going to assume at this point that there is not a simple EG command for this, and instead it will need to be a python script. Does anyone have a resource I could look at for retrieving the clipboard contents?
-
- Posts: 6
- Joined: Mon May 13, 2013 2:55 pm
Re: Working with the Clipboard
Ok, I guess I just won't use Eventghost to do this. Thanks anyway guys.
Re: Working with the Clipboard
A google search returned some results, of which the following worked for some simple text copy-paste examples:
It is interesting to read the comments on the following URL's:
http://stackoverflow.com/questions/1011 ... rom-python
http://stackoverflow.com/questions/5796 ... 97#4203897
Several people described the win32clipboard as 'massive' or 'overkill' and some of the comments hint to encoding problems, so I don't know how efficient this python script would be in daily use.
Code: Select all
import win32clipboard
# get clipboard data
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
print data
http://stackoverflow.com/questions/1011 ... rom-python
http://stackoverflow.com/questions/5796 ... 97#4203897
Several people described the win32clipboard as 'massive' or 'overkill' and some of the comments hint to encoding problems, so I don't know how efficient this python script would be in daily use.
-
- Posts: 6
- Joined: Mon May 13, 2013 2:55 pm
Re: Working with the Clipboard
Thanks for the response!
I see that "data" is being defined within script as the clipboard contents, but I wonder how to get that as a variable which I can use throughout EG, such as with ShowOSD?
I see that "data" is being defined within script as the clipboard contents, but I wonder how to get that as a variable which I can use throughout EG, such as with ShowOSD?
-
- Posts: 6
- Joined: Mon May 13, 2013 2:55 pm
Re: Working with the Clipboard
Thanks again for the help, piert! That turned out to be just what I needed to finally figure this out.
With the payload thus defined, I can show it on screen and pass it along to my other devices with AutoRemote. I'm still not well-versed in Python, but the pieces are starting to fall into place.
Code: Select all
import win32clipboard
# get clipboard data
win32clipboard.OpenClipboard()
eg.event.payload = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
Re: Working with the Clipboard
Glad it helped.
As for the variables issues, you could make use of variables by means of eg.globals (http://www.eventghost.org/docs/scripting.html) or you might search the forum for the term persistent variables, which is a way of keeping the state of variables consistent after a restart of Eventghost (if I am not mistaken; not using it myself).
As for the variables issues, you could make use of variables by means of eg.globals (http://www.eventghost.org/docs/scripting.html) or you might search the forum for the term persistent variables, which is a way of keeping the state of variables consistent after a restart of Eventghost (if I am not mistaken; not using it myself).
-
- Posts: 3
- Joined: Sun Jun 09, 2013 9:59 pm
Re: Working with the Clipboard
hi Red!
I'm curious about what command you used to send to the clipboard contents from the computer to the phone...
i'm doing basically the same thing but am apparently not quite as smart as you...
what message did you send via autoremote?
I'm curious about what command you used to send to the clipboard contents from the computer to the phone...
i'm doing basically the same thing but am apparently not quite as smart as you...
what message did you send via autoremote?
-
- Posts: 3
- Joined: Sun Jun 09, 2013 9:59 pm
Re: Working with the Clipboard
basically i'm asking can you give me a fairly detailed walkthrough of what you did...
just call me stupid...
i managed to capture the json string i need to the computer clipboard--through an event ghost python script--but i need to relay that string to tasker to parse it (i am stupid, you know...)
the point is that i can easily manipulate a text string with tasker... but first i have to get it to the phone...
i would dearly love to hear if you have managed to do that, and if so how did you send the clipboard contents so that autoremote recognizes them...
just call me stupid...
i managed to capture the json string i need to the computer clipboard--through an event ghost python script--but i need to relay that string to tasker to parse it (i am stupid, you know...)
the point is that i can easily manipulate a text string with tasker... but first i have to get it to the phone...
i would dearly love to hear if you have managed to do that, and if so how did you send the clipboard contents so that autoremote recognizes them...
-
- Posts: 6
- Joined: Mon May 13, 2013 2:55 pm
Re: Working with the Clipboard
I apologize for not getting back with you sooner, Sam. I didn't see that you had posted.
Basically I set up two different macros in EventGhost on my pc, and two different profiles in Tasker on my phone. I've posted the code below. The python script is what you saw in my post above.
IN EVENTGHOST
clip_send
...(Event) System.ClipboardChanged
...(Action) Python Script
...(Action) Show OSD: eg.event.payload
...(Action) Autoremote: Sending clpbd=:={eg.event.payload} to Phone
clip_rcv
...(Event) AutoRemote.Message.clpbd
...(Action) Copy string to clipboard: {eg.event.payload.arcomm}
...(Action) Show OSD: {eg.event.payload.arcomm}
...(Action) Wait 10.0 sec
IN TASKER ON PHONE
Profile: Receive Clipboard
...(Event) Autoremote clpbd
...(Action) clp_rcv
Profile: Send Clipboard
...(Event) Variable Set %CLIP
...(Action) clp_send
Task: clip_rcv
...Set Clipboard: Text %copy
...Flash: Text %copy
...Wait: 10 sec
Task: clip_send
...Variable Set: Name %COPY to %Clip
...Autoremote Message: Configuration Recipient:Eventghost Message:clipbd=:=%CLIP
...Wait: 10 sec
Basically here's what's happening:
If the clipboard contents on the pc changes, EventGhost runs the python script to set the clipboard contents into eg.event.payload and then shoots that attached to the parameter "clpbd" to the phone. When the phone receives a message including the paramter "clpbd" it runs the task clip_rcv, which sets the payload to its own clipboard and flashes up a copy for you to see that it worked. The same thing happens in reverse if the clipboard on the phone changes.
The reason for the 10 second wait is because the tasks are triggered by the clipboard changing. So if you copy something on the pc, it will shoot it to the phone, which will shoot it back to the pc, and so on. I have the devices delivering to my tablet as well, so the clipboard would ricochet around between all the devices forever. The wait keeps the device from receiving a new message immediately after sending the first one, and keeps that from happening.
Hope this helps you! Good luck!
Basically I set up two different macros in EventGhost on my pc, and two different profiles in Tasker on my phone. I've posted the code below. The python script is what you saw in my post above.
IN EVENTGHOST
clip_send
...(Event) System.ClipboardChanged
...(Action) Python Script
...(Action) Show OSD: eg.event.payload
...(Action) Autoremote: Sending clpbd=:={eg.event.payload} to Phone
clip_rcv
...(Event) AutoRemote.Message.clpbd
...(Action) Copy string to clipboard: {eg.event.payload.arcomm}
...(Action) Show OSD: {eg.event.payload.arcomm}
...(Action) Wait 10.0 sec
IN TASKER ON PHONE
Profile: Receive Clipboard
...(Event) Autoremote clpbd
...(Action) clp_rcv
Profile: Send Clipboard
...(Event) Variable Set %CLIP
...(Action) clp_send
Task: clip_rcv
...Set Clipboard: Text %copy
...Flash: Text %copy
...Wait: 10 sec
Task: clip_send
...Variable Set: Name %COPY to %Clip
...Autoremote Message: Configuration Recipient:Eventghost Message:clipbd=:=%CLIP
...Wait: 10 sec
Basically here's what's happening:
If the clipboard contents on the pc changes, EventGhost runs the python script to set the clipboard contents into eg.event.payload and then shoots that attached to the parameter "clpbd" to the phone. When the phone receives a message including the paramter "clpbd" it runs the task clip_rcv, which sets the payload to its own clipboard and flashes up a copy for you to see that it worked. The same thing happens in reverse if the clipboard on the phone changes.
The reason for the 10 second wait is because the tasks are triggered by the clipboard changing. So if you copy something on the pc, it will shoot it to the phone, which will shoot it back to the pc, and so on. I have the devices delivering to my tablet as well, so the clipboard would ricochet around between all the devices forever. The wait keeps the device from receiving a new message immediately after sending the first one, and keeps that from happening.
Hope this helps you! Good luck!
Re: Working with the Clipboard
Hi!
I've managed to get my computer's clipboard synced to my other devices, but not the other way around...
Any help appreciated!
I've managed to get my computer's clipboard synced to my other devices, but not the other way around...
I can't find any action with the above function!...(Action) Copy string to clipboard: {eg.event.payload.arcomm}
Any help appreciated!
Re: Working with the Clipboard
I guess I was a bit tired, I did have that option...so now I have my instances of EG setup, left to do is the Tasker and AutoRemote part, but I'm not quite sure what you have done...Recieving Clipboard from EG to Tasker is no problem, but the sending I don't really understand how you have done.
Care to explain a bit more...
Thanks!
Care to explain a bit more...
Thanks!
-
- Experienced User
- Posts: 50
- Joined: Thu Oct 10, 2013 9:43 pm
Re: Working with the Clipboard
I'm struggling as well to make this work. I've listed my Tasker related Profiles/Tasks below. It seems there's a command missing to make the Tasker Profiles aware of what the 'clipboard' is.
Profile: Receive Clipboard (195)
State: AutoRemote [ Configuration:clpbd ]
Enter: Anon (196)
A1: Perform Task [ Name:clip_rcv Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]
clip_rcv (197)
A1: Set Clipboard [ Text:%Copy Add:Off ]
A2: Flash [ Text:%Copy Long:On ]
A3: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
Profile: Send Clipboard (202)
Event: Variable Set [ Variable:%Clip Value:* ]
Enter: Anon (203)
A1: Perform Task [ Name:clip_send Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]
clip_send (198)
A1: Variable Set [ Name:%Copy To:%Clip Do Maths:Off Append:Off ]
A2: AutoRemote Message [ Configuration:Recipient: HAF922EG
Message: clpbd=:=%Clip Package:com.joaomgcd.autoremote Name:AutoRemote Message ]
A3: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
-Scott
Profile: Receive Clipboard (195)
State: AutoRemote [ Configuration:clpbd ]
Enter: Anon (196)
A1: Perform Task [ Name:clip_rcv Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]
clip_rcv (197)
A1: Set Clipboard [ Text:%Copy Add:Off ]
A2: Flash [ Text:%Copy Long:On ]
A3: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
Profile: Send Clipboard (202)
Event: Variable Set [ Variable:%Clip Value:* ]
Enter: Anon (203)
A1: Perform Task [ Name:clip_send Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]
clip_send (198)
A1: Variable Set [ Name:%Copy To:%Clip Do Maths:Off Append:Off ]
A2: AutoRemote Message [ Configuration:Recipient: HAF922EG
Message: clpbd=:=%Clip Package:com.joaomgcd.autoremote Name:AutoRemote Message ]
A3: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
-Scott
-
- Experienced User
- Posts: 50
- Joined: Thu Oct 10, 2013 9:43 pm
Re: Working with the Clipboard
Here's what I got working, and discovered '%CLIP' is what Tasker identity's as systems clipboard.cableghost wrote:I'm struggling as well to make this work. I've listed my Tasker related Profiles/Tasks below. It seems there's a command missing to make the Tasker Profiles aware of what the 'clipboard' is.
clip_send (198)
A1: Variable Set [ Name:%Copy To:%Clip Do Maths:Off Append:Off ]
A2: AutoRemote Message [ Configuration:Recipient: HAF922EG
Message: clpbd=:=%Clip Package:com.joaomgcd.autoremote Name:AutoRemote Message ]
A3: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
-Scott
clip_send (198)
A1: Variable Set [ Name:%Copy To:%CLIP Do Maths:Off Append:Off ]
A2: Flash [ Text:Clipboard sent Long:On ]
A3: AutoRemote Message [ Configuration:Recipient: [EventGhost AutoRemote Action Item] Message: clpbd=:=%Copy Package:com.joaomgcd.autoremote Name:AutoRemote Message ]
A4: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]