<div>Hi Alain,</div><div><br></div><div>Good researching on the \226\128\162 bullet.</div><div><br></div>Ok if you are doing a lot of that, I've attached the current version 0.311 of my makeScript.js, you just have a new blank document open, cursor in editor, run 
makeScript.js and it walks through the skeleton of making QtScript, Python, or Lua script (if you allow the established shortcut keys that would be just <div>Alt N Alt S)<div><br></div><div>I used make a new script and copied and pasted your text (changed the title), and  under Xp when I ran the script ..</div>
<div><br></div><div><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">--[[TeXworksScript</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Title:  Trial &Lua</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Description: Encloses the current selection in a picture environment</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Author:  Alain Delmotte from Stefan Löffler & Jonathan Kew</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Version: 0.1</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Date: 2011-11-05</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Script-Type: standalone</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Context: TeXDocument</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Shortcut: Alt+T, Alt+Q</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">]]</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">
<br></p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; "></p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">txt = TW.target.selection</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">if (txt == nil) then txt = "" end</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">TW.target.insertText("\\begin{figure}[ht]\\centering\n\\includegraphics[width=\226\128\162cm]{\226\128\162}\n\\caption{" .. txt .. "}\n\\label{\226\128\162}\n\\end{figure}\n")</p>

<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">TW.target.selectRange(TW.target.selectionStart - string.len(txt) - 1, string.len(txt))</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; "></p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; "><br></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">The results under Xp were:</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">
<br></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">\begin{figure}[ht]\centering</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">\includegraphics[width=•cm]{•}</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">\caption{}</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">\label{•}</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">\end{figure}</p><div><br></div><div>Plus I can see in my case (Xp) see the accelerator key on the menu item, in my case an underlined L</div>
<div><br></div><div>Paul</div><br><div class="gmail_quote">On 5 November 2011 03:02, Alain Delmotte <span dir="ltr"><<a href="mailto:alain.delmotte@leliseron.org">alain.delmotte@leliseron.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi!<br>
<br>
I did translate all my Python scripts to Lua.<br>
<br>
I had a problem to insert the bullet (the one used for autocompletion).<br>
<br>
Under Lua it is created with "\226\128\162" in a string.<br>
For example the following code, to create a figure environment from an existing text for the caption, allows to move with Ctrl+Tab or Ctrl+Shift+Tab to the positions to fill in.<br>
========================<br>
--[[TeXworksScript<br>
Title: i&mage \figure<br>
Description: Encloses the current selection in a picture environment<br>
Author: Alain Delmotte from Stefan Löffler & Jonathan Kew<br>
Version: 0.1<br>
Date: 2011-11-01<br>
Script-Type: standalone<br>
Context: TeXDocument<br>
]]<br>
<br>
txt = TW.target.selection<br>
if (txt == nil) then txt = "" end<br>
TW.target.insertText("\\begin{<u></u>figure}[ht]\\centering\n\\<u></u>includegraphics[width=\226\<u></u>128\162cm]{\226\128\162}\n\\<u></u>caption{" .. txt .. "}\n\\label{\226\128\162}\n\\<u></u>end{figure}\n")<br>

TW.target.selectRange(TW.<u></u>target.selectionStart - string.len(txt) - 1, string.len(txt))<br>
=======================<br>
<br>
Remark the "\n" to insert a line feed as it looks like the string to be created should be in the same line (no CRLF in the middle)<br>
<br>
Also on the second line the & is to create an accelerator, but I haven't yet succeeded to use it with Windows 7!!!<br>
<br>
Regards,<span class="HOEnZb"><font color="#888888"><br>
<br>
Alain<br>
<br>
<br>
<br>
</font></span></blockquote></div><br></div></div>