Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Paste clipboard in Windows Command

If you have a question or need help, this is the place to be.
Post Reply
drobor
Posts: 2
Joined: Sun Nov 27, 2016 12:25 am

Paste clipboard in Windows Command

Post by drobor »

Hi i'm trying to do this for few hours but without luck

i wanna automate procces of program youtube-dl (cmd program for downloading youtube video)
command line go like this
C:\youtube-dl.exe https://www.youtube.com/watch?v=jQx3GVqDWlU

can eventghost, when i copy link, to do all this for me
i managed to make script to capture clipboard in variable (i'm not sure that variable part is good)

import win32clipboard

# get clipboard data
win32clipboard.OpenClipboard()
eg.globals.myVar = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()

and then with python command i printed that variable

print eg.globals.myVar

i saw in eventghost log that everything is ok. but in the next action when i wrote command line i didnt get any results

C:\youtube-dl.exe eg.globals.myVar

so please tell me where i'm doing wrong?
Also side question..my youtube-dl.exe is on desktop and when i do cmd operation outside eventghost video will download in desktop, but when i do command line operation in eventghost, my video will download in eventghost folder in appdata, roaming if i remember. how to change that so video can download where i want?
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Paste clipboard in Windows Command

Post by jonib »

drobor wrote:i saw in eventghost log that everything is ok. but in the next action when i wrote command line i didnt get any results

C:\youtube-dl.exe eg.globals.myVar

so please tell me where i'm doing wrong?
When you need to access Python variables you need to use curly braces, like this:

Code: Select all

C:\youtube-dl.exe {eg.globals.myVar}
jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
drobor
Posts: 2
Joined: Sun Nov 27, 2016 12:25 am

Re: Paste clipboard in Windows Command

Post by drobor »

Its working now.. one more thing, is it possible to make an event that will trigger that macro..
so when clipboard change eventghost will read url and if url have in words like "youtube" or "watch" it will make an event that will trigger my macro
do i need python script for this, do i need that words to put in new variable?
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

Re: Paste clipboard in Windows Command

Post by eirik226 »

drobor wrote:Its working now.. one more thing, is it possible to make an event that will trigger that macro..
so when clipboard change eventghost will read url and if url have in words like "youtube" or "watch" it will make an event that will trigger my macro
do i need python script for this, do i need that words to put in new variable?
When you copy something an event is triggered in eventghost - you could use that. Unsure about the URL part tho
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Paste clipboard in Windows Command

Post by jonib »

drobor wrote:Its working now..
Great
one more thing, is it possible to make an event that will trigger that macro..
so when clipboard change eventghost will read url and if url have in words like "youtube" or "watch" it will make an event that will trigger my macro
do i need python script for this, do i need that words to put in new variable?
Just remembered I had this test code:

Code: Select all

import win32clipboard
import re

# get clipboard data
win32clipboard.OpenClipboard()
result2 = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()

if re.match(r"https?://www\.youtube\.com/watch\?v=",result2,re.IGNORECASE):
    eg.TriggerEvent(u'FoundURL', payload=result2)
It checks the clipboard to see if it a youtube URL, if it is then triggers an event. "result2" contains the data from the clipboard.

Create a macro, put the code in a "Python script" action and add a "System.ClipboardChanged" event.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
Post Reply