The code I have brings up the chooser and paste the text that is being clicked. Right now the text being pasted is just a few words.
How do I paste the text into any text field in the form of a table like an image below? Is that even possible?

-- Focus the last used window.
local function focusLastFocused()
local wf = hs.window.filter
local lastFocused = wf.defaultCurrentSpace:getWindows(wf.sortByFocusedLast)
if #lastFocused > 0 then lastFocused[1]:focus() end
end
-- On selection, copy the text and type it into the focused application.
local chooser = hs.chooser.new(function(choice)
if not choice then focusLastFocused(); return end
hs.pasteboard.setContents(choice["subText"])
focusLastFocused()
hs.eventtap.keyStrokes(hs.pasteboard.getContents())
end)
chooser:choices({
{
["text"] = "Browser\n",
["subText"] = "<Insert text in tabular format>",
},
{
["text"] = "Device\n",
["subText"] = "<Insert text in tabular format>",
},
})
hs.hotkey.bind({"E"}, "E", function() chooser:show() end)
any ideas on how to do it?
Copy some table data from Apple Numbers or Excel, then use hs.pasteboard.getContents() to inspect it, to see how it works.
For example:
hs.pasteboard.setContents([[1 2 3
4 5 6
7 8 9
]])
...this seems to work in Numbers.
@latenitefilms It doesn't retain the tabular format when I paste it in any web pages. But it retains the format when I paste it in my machine's notepad. Is there a way to see the tabular format? Like the image posted above?
Any help?
I'm not exactly sure what you're trying to achieve? Where exactly are you pasting this data into? Into a website text field, or something like Google Sheets?
I am trying to paste it into JIRA text field(website text field).
I am trying to create a set of templates that the user can choose from and
paste it in the template instead of a copy paste.
On Sat 29. Jun 2019 at 01:36, Chris Hocking notifications@github.com
wrote:
I'm not exactly sure what you're trying to achieve? Where exactly are you
pasting this data into? Into a website text field, or something like Google
Sheets?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Hammerspoon/hammerspoon/issues/2120?email_source=notifications&email_token=AMMJ3Z4GLD5OTE4BA42B3BTP42OAFA5CNFSM4H3HLIQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3MI7I#issuecomment-506905725,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMMJ3ZZ6U3Q6KHPOMHSK343P42OAFANCNFSM4H3HLIQA
.
--
  Â
 https://www.facebook.com/hellofreshde Â
https://www.twitter.com/HelloFreshde Â
https://www.instagram.com/hellofreshde/Â Â https://blog.hellofresh.de/Â Â
https://app.adjust.com/ayje08?campaign=Hellofresh&deep_link=hellofresh%3A%2F%2F&post_deep_link=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature&fallback=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signatureÂ
HelloFresh App –
Download Now!
https://app.adjust.com/ayje08?campaign=Hellofresh&deep_link=hellofresh%3A%2F%2F&post_deep_link=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature&fallback=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature
We're active in:Â
US
https://www.hellofresh.com/?utm_medium=email&utm_source=email_signature |Â
 DE
https://www.hellofresh.de/?utm_medium=email&utm_source=email_signature | Â
UK
https://www.hellofresh.co.uk/?utm_medium=email&utm_source=email_signatureÂ
|Â Â NL
https://www.hellofresh.nl/?utm_medium=email&utm_source=email_signature | Â
AU
https://www.hellofresh.com.au/?utm_medium=email&utm_source=email_signatureÂ
|Â Â BE
https://www.hellofresh.be/?utm_medium=email&utm_source=email_signature | Â
AT https://www.hellofresh.at/?utm_medium=email&utm_source=email_signatureÂ
|Â Â CH
https://www.hellofresh.ch/?utm_medium=email&utm_source=email_signature |Â
CA https://www.hellofresh.ca/?utm_medium=email&utm_source=email_signatureÂ
|Â LU
https://www.hellofresh.lu/?utm_medium=email&utm_source=email_signature |Â
NZ
https://www.hellofresh.co.nz/?utm_medium=email&utm_source=email_signature
www.HelloFreshGroup.com
https://www.hellofreshgroup.com/?utm_medium=email&utm_source=email_signatureÂ
We are hiring around the world – Click here to join us
https://www.hellofresh.com/jobs/?utm_medium=email&utm_source=email_signature
--
https://www.hellofresh.com/jobs/?utm_medium=email&utm_source=email_signature
HelloFresh SE, Berlin (Sitz der Gesellschaft) | Vorstände: Dominik S.
Richter (Vorsitzender), Thomas W. Griesel, Christian Gärtner | Vorsitzender
des Aufsichtsrats: Jeffrey Lieberman | Eingetragen beim Amtsgericht
Charlottenburg, HRB 182382 B | USt-Id Nr.: DE 302210417
CONFIDENTIALITY
NOTICE:Â This message (including any attachments) is confidential and may
be privileged. It may be read, copied and used only by the intended
recipient. If you have received it in error please contact the sender (by
return e-mail) immediately and delete this message. Any unauthorized use or
dissemination of this message in whole or in parts is strictly prohibited.
I don't have a Jira account to test with, but why don't you try copying a table in Jira then inspecting it to see what it looks like in the Pasteboard?
I think it uses that regular HTML tags like td, tr etc. but as far as I
know I was not able to find a way to format text in Hammerspoon like this
On Sat 29. Jun 2019 at 07:13, Chris Hocking notifications@github.com
wrote:
I don't have a Jira account to test with, but why don't you try copying a
table in Jira then inspecting it to see what it looks like in the
Pasteboard?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Hammerspoon/hammerspoon/issues/2120?email_source=notifications&email_token=AMMJ3Z4MO3CL6LW2MJUSW7LP43VQLA5CNFSM4H3HLIQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3RVEQ#issuecomment-506927762,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMMJ3Z22LCMSSGHY6SDXWGTP43VQLANCNFSM4H3HLIQA
.
--
  Â
 https://www.facebook.com/hellofreshde Â
https://www.twitter.com/HelloFreshde Â
https://www.instagram.com/hellofreshde/Â Â https://blog.hellofresh.de/Â Â
https://app.adjust.com/ayje08?campaign=Hellofresh&deep_link=hellofresh%3A%2F%2F&post_deep_link=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature&fallback=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signatureÂ
HelloFresh App –
Download Now!
https://app.adjust.com/ayje08?campaign=Hellofresh&deep_link=hellofresh%3A%2F%2F&post_deep_link=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature&fallback=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature
We're active in:Â
US
https://www.hellofresh.com/?utm_medium=email&utm_source=email_signature |Â
 DE
https://www.hellofresh.de/?utm_medium=email&utm_source=email_signature | Â
UK
https://www.hellofresh.co.uk/?utm_medium=email&utm_source=email_signatureÂ
|Â Â NL
https://www.hellofresh.nl/?utm_medium=email&utm_source=email_signature | Â
AU
https://www.hellofresh.com.au/?utm_medium=email&utm_source=email_signatureÂ
|Â Â BE
https://www.hellofresh.be/?utm_medium=email&utm_source=email_signature | Â
AT https://www.hellofresh.at/?utm_medium=email&utm_source=email_signatureÂ
|Â Â CH
https://www.hellofresh.ch/?utm_medium=email&utm_source=email_signature |Â
CA https://www.hellofresh.ca/?utm_medium=email&utm_source=email_signatureÂ
|Â LU
https://www.hellofresh.lu/?utm_medium=email&utm_source=email_signature |Â
NZ
https://www.hellofresh.co.nz/?utm_medium=email&utm_source=email_signature
www.HelloFreshGroup.com
https://www.hellofreshgroup.com/?utm_medium=email&utm_source=email_signatureÂ
We are hiring around the world – Click here to join us
https://www.hellofresh.com/jobs/?utm_medium=email&utm_source=email_signature
--
https://www.hellofresh.com/jobs/?utm_medium=email&utm_source=email_signature
HelloFresh SE, Berlin (Sitz der Gesellschaft) | Vorstände: Dominik S.
Richter (Vorsitzender), Thomas W. Griesel, Christian Gärtner | Vorsitzender
des Aufsichtsrats: Jeffrey Lieberman | Eingetragen beim Amtsgericht
Charlottenburg, HRB 182382 B | USt-Id Nr.: DE 302210417
CONFIDENTIALITY
NOTICE:Â This message (including any attachments) is confidential and may
be privileged. It may be read, copied and used only by the intended
recipient. If you have received it in error please contact the sender (by
return e-mail) immediately and delete this message. Any unauthorized use or
dissemination of this message in whole or in parts is strictly prohibited.
Copy a table in Jira, then use hs.pasteboard.typesAvailable() to have a look at what's available on the Pasteboard.
You might be able to use hs.styledtext to do what you want to do. Have a look at hs.pasteboard.writeObjects().
Ok let me check and post my findings
On Sat 29. Jun 2019 at 07:24, Chris Hocking notifications@github.com
wrote:
Copy a table in Jira, then use hs.pasteboard.typesAvailable()
http://www.hammerspoon.org/docs/hs.pasteboard.html#typesAvailable to
have a look at what's available on the Pasteboard.You might be able to use hs.styledtext to do what you want to do. Have a
look at hs.pasteboard.writeObjects()
http://www.hammerspoon.org/docs/hs.pasteboard.html#writeObjects.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Hammerspoon/hammerspoon/issues/2120?email_source=notifications&email_token=AMMJ3ZZHHIBZO5FCPB3E74LP43W2XA5CNFSM4H3HLIQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY3R2AQ#issuecomment-506928386,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMMJ3ZYAOA6OQN75O7UXVYLP43W2XANCNFSM4H3HLIQA
.
--
  Â
 https://www.facebook.com/hellofreshde Â
https://www.twitter.com/HelloFreshde Â
https://www.instagram.com/hellofreshde/Â Â https://blog.hellofresh.de/Â Â
https://app.adjust.com/ayje08?campaign=Hellofresh&deep_link=hellofresh%3A%2F%2F&post_deep_link=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature&fallback=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signatureÂ
HelloFresh App –
Download Now!
https://app.adjust.com/ayje08?campaign=Hellofresh&deep_link=hellofresh%3A%2F%2F&post_deep_link=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature&fallback=https%3A%2F%2Fwww.hellofresh.com%2Fapp%2F%3Futm_medium%3Demail%26utm_source%3Demail_signature
We're active in:Â
US
https://www.hellofresh.com/?utm_medium=email&utm_source=email_signature |Â
 DE
https://www.hellofresh.de/?utm_medium=email&utm_source=email_signature | Â
UK
https://www.hellofresh.co.uk/?utm_medium=email&utm_source=email_signatureÂ
|Â Â NL
https://www.hellofresh.nl/?utm_medium=email&utm_source=email_signature | Â
AU
https://www.hellofresh.com.au/?utm_medium=email&utm_source=email_signatureÂ
|Â Â BE
https://www.hellofresh.be/?utm_medium=email&utm_source=email_signature | Â
AT https://www.hellofresh.at/?utm_medium=email&utm_source=email_signatureÂ
|Â Â CH
https://www.hellofresh.ch/?utm_medium=email&utm_source=email_signature |Â
CA https://www.hellofresh.ca/?utm_medium=email&utm_source=email_signatureÂ
|Â LU
https://www.hellofresh.lu/?utm_medium=email&utm_source=email_signature |Â
NZ
https://www.hellofresh.co.nz/?utm_medium=email&utm_source=email_signature
www.HelloFreshGroup.com
https://www.hellofreshgroup.com/?utm_medium=email&utm_source=email_signatureÂ
We are hiring around the world – Click here to join us
https://www.hellofresh.com/jobs/?utm_medium=email&utm_source=email_signature
--
https://www.hellofresh.com/jobs/?utm_medium=email&utm_source=email_signature
HelloFresh SE, Berlin (Sitz der Gesellschaft) | Vorstände: Dominik S.
Richter (Vorsitzender), Thomas W. Griesel, Christian Gärtner | Vorsitzender
des Aufsichtsrats: Jeffrey Lieberman | Eingetragen beim Amtsgericht
Charlottenburg, HRB 182382 B | USt-Id Nr.: DE 302210417
CONFIDENTIALITY
NOTICE:Â This message (including any attachments) is confidential and may
be privileged. It may be read, copied and used only by the intended
recipient. If you have received it in error please contact the sender (by
return e-mail) immediately and delete this message. Any unauthorized use or
dissemination of this message in whole or in parts is strictly prohibited.
Unfortunately I couldn't find anything that can support html tables
@mde-hf I'd suggest you start by finding a way to do this without Hammerspoon - ie an app or website you can manually copy text from, that pasting it into Jira works.
Once you have that, copy again from the website and then in the Hammerspoon Console, run hs.inspect(hs.pasteboard.allContentTypes()) and see what types the source app/site is advertising.
Hopefully that will give some hints as to which type it is that Jira is able to ingest correctly. Once you have that, use hs.pasteboard.readDataForUTI() to get the raw data for that type, and that ought to be a string you can use to figure out how you should format the data for the templates. Then your hs.chooser selection callback can use hs.pasteboard.writeDataForUTI() to write the correctly formatted data to the pasteboard, with the UTI that will work with Jira.
Does that make sense?
(If there isn't already an existing way for this to work outside of Hammerspoon, then you're in a much more complex situation and we'd need to explore further how you want this to work)
@cmsj Thank you so much for the help and it worked in figuring out the content type, which is "Markdown Tables" from https://www.tablesgenerator.com/markdown_tables.
But I am stuck on how to proceed further? When I paste it in the console, it throws me an error. Is there any examples for using markdown tables in hammerspoon?
Try something like this:
local eventtap = require("hs.eventtap")
local chooser = require("hs.chooser")
local completionFn = function(result)
if result and result.code then
hs.eventtap.keyStrokes(result.code)
end
end
local exampleCode = [[| Tables | Are | Cool |
|----------|:-------------:|------:|
| col 1 is | left-aligned | $1600 |
| col 2 is | centered | $12 |
| col 3 is | right-aligned | $1 |]]
local function getChoices()
return {
{
["text"] = "Example 1",
["subText"] = "This is a markdown table example.",
["code"] = exampleCode,
},
{
["text"] = "Example 2",
["subText"] = "This is a markdown table example.",
["code"] = exampleCode,
},
}
end
codeChooser = chooser.new(completionFn):choices(getChoices):show()
@latenitefilms Thank you! But, It doesn't really work as I have tried doing it in a similar way. :(
This is how it is pasted inside JIRA

Most helpful comment
@mde-hf I'd suggest you start by finding a way to do this without Hammerspoon - ie an app or website you can manually copy text from, that pasting it into Jira works.
Once you have that, copy again from the website and then in the Hammerspoon Console, run
hs.inspect(hs.pasteboard.allContentTypes())and see what types the source app/site is advertising.Hopefully that will give some hints as to which type it is that Jira is able to ingest correctly. Once you have that, use
hs.pasteboard.readDataForUTI()to get the raw data for that type, and that ought to be a string you can use to figure out how you should format the data for the templates. Then yourhs.chooserselection callback can usehs.pasteboard.writeDataForUTI()to write the correctly formatted data to the pasteboard, with the UTI that will work with Jira.Does that make sense?