Jump to content

How to get result from script into copy to clipboard


Recommended Posts

Hi all,

Love Alfred (v4.3.2 [1221]) but I tried a long time to calculate px to vw with an alfred workflow (before2-3). Script is working but my {query} in the copy to clipboard is always empty.

But if I have only one argument and split it, then it is working (after2). But it is a little bit strange, is there a solution with 2 args? Thank yo so much!

 

 

 

 

 

before2.png

before3.png

after2.png

Link to comment

It’s very difficult to say what’s wrong with code you can’t run, but you almost certainly don’t want print(). That adds a newline. Either use sys.stdout.write() or from __future__ import print_function and print('%.1f' % result, end='')

 

Link to comment

Yes I changed it:

 

import sys

px, vw = map(float, sys.argv[1].split('/'))

result = (px/vw) * 100
if result == int(result):
  sys.stdout.write('%d' % result)
else:
  sys.stdout.write('%.1f' % result)

 

But still do not know, why I cannot have 2 arguments, it only works with one.

Edited by Michelle
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...