<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[LA/QM forum - Help (QM)]]></title>
		<link>https://www.libreautomate.com/forum/</link>
		<description><![CDATA[LA/QM forum - https://www.libreautomate.com/forum]]></description>
		<pubDate>Sat, 19 Sep 2026 04:57:01 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Parameters of the GetEnvVar function]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7968</link>
			<pubDate>Mon, 07 Sep 2026 07:22:36 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7968</guid>
			<description><![CDATA[I need to make the second parameter of qmq's built-in function GetEnvVar optional.<br />
<br />
Below is ChatGPT's answer, but it always produces garbled text in actual use.<br />
Is there a better solution?<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">getEnv</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>function</span><span class='o'>&#36;</span> <span class='o'>&#36;</span>name [<span class='t'>str</span><span class='o'>&amp;</span>value] <br />
<br />
<span class='t'>str</span> R<br />
<span class='fq'>if</span><span class='p'>(</span><span class='fu'>GetEnvVar</span><span class='p'>(</span>name R<span class='p'>))</span><br />
<span class='i'>,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>&amp;</span>value<span class='p'>)</span><br />
<span class='i'>,,</span>value <span class='o'>=</span> R<br />
<span class='i'>,,</span>value.<span class='fq'>expandpath</span><br />
<span class='i'>,,</span><span class='fq'>ret</span> value<br />
<span class='i'>,</span><span class='fq'>else</span><br />
<span class='i'>,,</span>_s<span class='o'>=</span>R.<span class='fq'>expandpath</span><br />
<span class='i'>,,</span><span class='fq'>ret</span> _s</code></div></div><br />
Function <span style="font-weight: bold;" class="mycode_b">GetEnvVar</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;/</span><br />
<span class='fq'>function</span><span class='o'>&#36;</span> <span class='o'>&#36;</span>name <span class='t'>str</span><span class='o'>&amp;</span>value<br />
<br />
<span class='c'>;Gets an environment variable.</span><br />
<span class='c'>;Returns value if successful, 0 if failed.</span><br />
<br />
<span class='c'>;value - variable for value.</span><br />
<br />
<span class='c'>;Added in: QM 2.3.0.</span><br />
<br />
<br />
<span class='t'>int</span> n1<span class='p'>(</span><span class='n'>4</span><span class='p'>)</span> n2<br />
<span class='c'>;g1</span><br />
<span class='t'>BSTR</span> b.<span class='fq'>alloc</span><span class='p'>(</span>n1<span class='p'>)</span><br />
n2<span class='o'>=</span><span class='fd'>GetEnvironmentVariableW</span><span class='p'>(</span><span class='o'>@</span>name b n1<span class='p'>)</span><br />
<span class='fq'>if</span><span class='p'>(</span>n2<span class='o'>&gt;</span>n1<span class='p'>)</span> n1<span class='o'>=</span>n2<span class='p'>;</span> <span class='fq'>goto</span> g1<br />
<span class='fq'>if</span><span class='p'>(</span>n2<span class='p'>)</span> value.<span class='fq'>ansi</span><span class='p'>(</span>b<span class='p'>);</span> <span class='fq'>ret</span> value<br />
value.<span class='fq'>all</span></code></div></div>]]></description>
			<content:encoded><![CDATA[I need to make the second parameter of qmq's built-in function GetEnvVar optional.<br />
<br />
Below is ChatGPT's answer, but it always produces garbled text in actual use.<br />
Is there a better solution?<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">getEnv</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>function</span><span class='o'>&#36;</span> <span class='o'>&#36;</span>name [<span class='t'>str</span><span class='o'>&amp;</span>value] <br />
<br />
<span class='t'>str</span> R<br />
<span class='fq'>if</span><span class='p'>(</span><span class='fu'>GetEnvVar</span><span class='p'>(</span>name R<span class='p'>))</span><br />
<span class='i'>,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>&amp;</span>value<span class='p'>)</span><br />
<span class='i'>,,</span>value <span class='o'>=</span> R<br />
<span class='i'>,,</span>value.<span class='fq'>expandpath</span><br />
<span class='i'>,,</span><span class='fq'>ret</span> value<br />
<span class='i'>,</span><span class='fq'>else</span><br />
<span class='i'>,,</span>_s<span class='o'>=</span>R.<span class='fq'>expandpath</span><br />
<span class='i'>,,</span><span class='fq'>ret</span> _s</code></div></div><br />
Function <span style="font-weight: bold;" class="mycode_b">GetEnvVar</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;/</span><br />
<span class='fq'>function</span><span class='o'>&#36;</span> <span class='o'>&#36;</span>name <span class='t'>str</span><span class='o'>&amp;</span>value<br />
<br />
<span class='c'>;Gets an environment variable.</span><br />
<span class='c'>;Returns value if successful, 0 if failed.</span><br />
<br />
<span class='c'>;value - variable for value.</span><br />
<br />
<span class='c'>;Added in: QM 2.3.0.</span><br />
<br />
<br />
<span class='t'>int</span> n1<span class='p'>(</span><span class='n'>4</span><span class='p'>)</span> n2<br />
<span class='c'>;g1</span><br />
<span class='t'>BSTR</span> b.<span class='fq'>alloc</span><span class='p'>(</span>n1<span class='p'>)</span><br />
n2<span class='o'>=</span><span class='fd'>GetEnvironmentVariableW</span><span class='p'>(</span><span class='o'>@</span>name b n1<span class='p'>)</span><br />
<span class='fq'>if</span><span class='p'>(</span>n2<span class='o'>&gt;</span>n1<span class='p'>)</span> n1<span class='o'>=</span>n2<span class='p'>;</span> <span class='fq'>goto</span> g1<br />
<span class='fq'>if</span><span class='p'>(</span>n2<span class='p'>)</span> value.<span class='fq'>ansi</span><span class='p'>(</span>b<span class='p'>);</span> <span class='fq'>ret</span> value<br />
value.<span class='fq'>all</span></code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Free reg code not work]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7965</link>
			<pubDate>Wed, 02 Sep 2026 01:36:29 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1631">tohakepriben</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7965</guid>
			<description><![CDATA[Dear, sir.<br />
I entered free reg code as you mentoined in the webpage. But the evaluation period is still running. It has now been 30 days. What is the solution?<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1405" target="_blank" title="">qm.png</a> (Size: 9.13 KB / Downloads: 15)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Dear, sir.<br />
I entered free reg code as you mentoined in the webpage. But the evaluation period is still running. It has now been 30 days. What is the solution?<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1405" target="_blank" title="">qm.png</a> (Size: 9.13 KB / Downloads: 15)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Determining When a File Is Ready]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7964</link>
			<pubDate>Tue, 01 Sep 2026 05:10:31 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7964</guid>
			<description><![CDATA[When I copy files from another computer on the local LAN, the source file may still be being copied or downloaded (the file size is changing).<br />
<br />
The method in the code below may be too simplistic.<br />
<br />
Is there a more accurate way to determine whether the file is ready?<br />
<br />
I have seen similar code in a macro on a forum, but after trying many keywords, I still haven't found it.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Function6</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='t'>str</span> destFolder<span class='o'>=</span><span class='s'>"&#36;desktop&#36;&#92;T"</span><br />
<span class='fq'>mkdir</span> destFolder<br />
<br />
<span class='fu'>sub.netCopy</span><span class='p'>(</span><span class='s'>"&#92;&#92;PC001&#92;d&#92;S"</span> destFolder<span class='p'>)</span><br />
<br />
<span class='dir'>#sub</span> netCopy<br />
<span class='fq'>function</span> <span class='o'>~</span>srcFolder <span class='o'>~</span>dstFolder<br />
<span class='i'>,</span><span class='c'>;; Get full path list of .avi and .mp4 files</span><br />
<span class='i'>,</span><span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>str</span><span class='p'>)</span> a<br />
<span class='i'>,</span><span class='fu'>GetFilesInFolder</span> a srcFolder <span class='s'>"*.avi[]*.mp4"</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='t'>int</span> i<br />
<span class='i'>,</span><span class='fq'>for</span> i <span class='n'>0</span> a.<span class='fq'>len</span><br />
<span class='i'>,,</span><span class='t'>str</span> filePath <span class='o'>=</span> a[i]<br />
<span class='i'>,,</span><br />
<span class='i'>,,</span><span class='c'>;; Wait for file size to stabilize (max 60 seconds)</span><br />
<span class='i'>,,</span><span class='t'>int</span> prevSize <span class='o'>=</span> <span class='o'>-</span><span class='n'>1</span><br />
<span class='i'>,,</span><span class='t'>int</span> curSize<br />
<span class='i'>,,</span><span class='t'>int</span> waited <span class='o'>=</span> <span class='n'>0</span><br />
<span class='i'>,,</span><span class='fq'>rep</span><br />
<span class='i'>,,,</span><span class='t'>Dir</span> d.<span class='fu'>dir</span><span class='p'>(</span>filePath<span class='p'>)</span><br />
<span class='i'>,,,</span>curSize <span class='o'>=</span> d.<span class='fu'>FileSize</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span>prevSize <span class='o'>!=</span> <span class='o'>-</span><span class='n'>1</span> <span class='fq'>and</span> curSize <span class='o'>=</span> prevSize<span class='p'>)</span> <span class='fq'>break</span><br />
<span class='i'>,,,</span>prevSize <span class='o'>=</span> curSize<br />
<span class='i'>,,,</span>waited <span class='o'>+</span> <span class='n'>2</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span>waited <span class='o'>&gt;=</span> <span class='n'>60</span><span class='p'>)</span> <span class='fq'>break</span><br />
<span class='i'>,,,</span><span class='n'>2</span>   <span class='c2'>;; wait 2 seconds</span><br />
<span class='i'>,,</span><br />
<span class='i'>,,</span><span class='c'>;; Copy file (replace if target exists)</span><br />
<span class='i'>,,</span><span class='fq'>cop</span><span class='o'>-</span> filePath dstFolder</code></div></div>]]></description>
			<content:encoded><![CDATA[When I copy files from another computer on the local LAN, the source file may still be being copied or downloaded (the file size is changing).<br />
<br />
The method in the code below may be too simplistic.<br />
<br />
Is there a more accurate way to determine whether the file is ready?<br />
<br />
I have seen similar code in a macro on a forum, but after trying many keywords, I still haven't found it.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Function6</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='t'>str</span> destFolder<span class='o'>=</span><span class='s'>"&#36;desktop&#36;&#92;T"</span><br />
<span class='fq'>mkdir</span> destFolder<br />
<br />
<span class='fu'>sub.netCopy</span><span class='p'>(</span><span class='s'>"&#92;&#92;PC001&#92;d&#92;S"</span> destFolder<span class='p'>)</span><br />
<br />
<span class='dir'>#sub</span> netCopy<br />
<span class='fq'>function</span> <span class='o'>~</span>srcFolder <span class='o'>~</span>dstFolder<br />
<span class='i'>,</span><span class='c'>;; Get full path list of .avi and .mp4 files</span><br />
<span class='i'>,</span><span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>str</span><span class='p'>)</span> a<br />
<span class='i'>,</span><span class='fu'>GetFilesInFolder</span> a srcFolder <span class='s'>"*.avi[]*.mp4"</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='t'>int</span> i<br />
<span class='i'>,</span><span class='fq'>for</span> i <span class='n'>0</span> a.<span class='fq'>len</span><br />
<span class='i'>,,</span><span class='t'>str</span> filePath <span class='o'>=</span> a[i]<br />
<span class='i'>,,</span><br />
<span class='i'>,,</span><span class='c'>;; Wait for file size to stabilize (max 60 seconds)</span><br />
<span class='i'>,,</span><span class='t'>int</span> prevSize <span class='o'>=</span> <span class='o'>-</span><span class='n'>1</span><br />
<span class='i'>,,</span><span class='t'>int</span> curSize<br />
<span class='i'>,,</span><span class='t'>int</span> waited <span class='o'>=</span> <span class='n'>0</span><br />
<span class='i'>,,</span><span class='fq'>rep</span><br />
<span class='i'>,,,</span><span class='t'>Dir</span> d.<span class='fu'>dir</span><span class='p'>(</span>filePath<span class='p'>)</span><br />
<span class='i'>,,,</span>curSize <span class='o'>=</span> d.<span class='fu'>FileSize</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span>prevSize <span class='o'>!=</span> <span class='o'>-</span><span class='n'>1</span> <span class='fq'>and</span> curSize <span class='o'>=</span> prevSize<span class='p'>)</span> <span class='fq'>break</span><br />
<span class='i'>,,,</span>prevSize <span class='o'>=</span> curSize<br />
<span class='i'>,,,</span>waited <span class='o'>+</span> <span class='n'>2</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span>waited <span class='o'>&gt;=</span> <span class='n'>60</span><span class='p'>)</span> <span class='fq'>break</span><br />
<span class='i'>,,,</span><span class='n'>2</span>   <span class='c2'>;; wait 2 seconds</span><br />
<span class='i'>,,</span><br />
<span class='i'>,,</span><span class='c'>;; Copy file (replace if target exists)</span><br />
<span class='i'>,,</span><span class='fq'>cop</span><span class='o'>-</span> filePath dstFolder</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Get the list of all custom functions and member functions contained in a specified QM]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7962</link>
			<pubDate>Mon, 31 Aug 2026 14:03:53 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7962</guid>
			<description><![CDATA[I often share the source code of a certain function with friends, but that function contains many of my custom functions and member functions, which are scattered in different folders. Because of this, every time (or when updating later) it takes a lot of time to organize them, which is not convenient.<br />
I have tried using the shared folder method, but it still doesn't meet my needs.<br />
<br />
So, I want to get the list of all custom functions and member functions contained in a specified QM function, and then export them programmatically.<br />
<br />
I noticed that in the Make exe dialog shown below, there is an option to output this list to the output pane.<br />
<img src="https://i.ibb.co/tpmV58Jm/exe.png" loading="lazy"  alt="[Image: exe.png]" class="mycode_img" /><br />
<br />
If possible, could you share the source code of that feature? I want to try using ChatGPT to modify the code to achieve the functionality I need.<br />
Thank you very much.]]></description>
			<content:encoded><![CDATA[I often share the source code of a certain function with friends, but that function contains many of my custom functions and member functions, which are scattered in different folders. Because of this, every time (or when updating later) it takes a lot of time to organize them, which is not convenient.<br />
I have tried using the shared folder method, but it still doesn't meet my needs.<br />
<br />
So, I want to get the list of all custom functions and member functions contained in a specified QM function, and then export them programmatically.<br />
<br />
I noticed that in the Make exe dialog shown below, there is an option to output this list to the output pane.<br />
<img src="https://i.ibb.co/tpmV58Jm/exe.png" loading="lazy"  alt="[Image: exe.png]" class="mycode_img" /><br />
<br />
If possible, could you share the source code of that feature? I want to try using ChatGPT to modify the code to achieve the functionality I need.<br />
Thank you very much.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Add functions or folders to a .qml file]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7961</link>
			<pubDate>Sun, 30 Aug 2026 12:17:16 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7961</guid>
			<description><![CDATA[I want to modify the file named <span style="font-weight: bold;" class="mycode_b">System.qml</span> on the desktop to implement the following functions:<br />
(Copy the System.qml file from the QM installation directory to the desktop, and remove the file's read-only attribute.)<br />
<br />
1. Add a function named <span style="font-weight: bold;" class="mycode_b">FileCopy2</span> after the function named <span style="font-weight: bold;" class="mycode_b">FileCopy</span>. The function content is: "I am the newly added function FileCopy2";<br />
<br />
2. Create a folder named <span style="font-weight: bold;" class="mycode_b">__Add</span> under the folder named <span style="font-weight: bold;" class="mycode_b">priveate</span>, and add a function named <span style="font-weight: bold;" class="mycode_b">AddTest</span>. The function content is: "I am the newly added function AddTest".<br />
<br />
After the following qm code is executed, it shows success, but an error is reported when opening the file:<br />
<span style="font-weight: bold;" class="mycode_b">Failed to open file 'C:\Users\Administrator\Desktop\System.qml'. Error reading items: The file is corrupt</span><br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">qml_mod</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<br />
<span class='t'>str</span> dbfile<span class='o'>=</span><span class='s'>"&#36;desktop&#36;&#92;System.qml"</span><br />
<span class='t'>Sqlite</span> db.<span class='fu'>Open</span><span class='p'>(</span>dbfile<span class='p'>)</span><br />
<br />
<span class='c'>;; ===== 1. Add FileCopy2 function to File folder (pid=81) =====</span><br />
<span class='t'>SqliteStatement</span> chk<br />
chk.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT rowid FROM items WHERE name='FileCopy2' AND pid=81;"</span><span class='p'>)</span><br />
<span class='fq'>if</span> chk.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"FileCopy2 already exists, skip"</span><br />
<span class='i'>,</span>chk.<span class='fu'>Delete</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>chk.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert items record</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span><span class='s'>"INSERT INTO items (pid, ord, flags, name, trigger, icon, td, guid) VALUES (81, NULL, 16777218, 'FileCopy2', NULL, NULL, NULL, randomblob(16));"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;; Get the newly inserted rowid</span><br />
<span class='i'>,</span><span class='t'>SqliteStatement</span> tmp<br />
<span class='i'>,</span>tmp.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT last_insert_rowid();"</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='t'>int</span> newRowid <span class='o'>=</span> tmp.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert texts record, rowid must be the same</span><br />
<span class='i'>,</span><span class='t'>str</span> ftext<span class='o'>=</span><span class='s'>"[]I am the newly added function FileCopy2"</span><br />
<span class='i'>,</span>ftext.<span class='fu'>SqlEscape</span><br />
<span class='i'>,</span><span class='t'>str</span> sqlText<span class='o'>=F</span><span class='s'>"INSERT INTO texts (rowid, id, date, text) VALUES ({</span>newRowid<span class='s'>}, {</span>newRowid<span class='s'>}, NULL, '{</span>ftext<span class='s'>}');"</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span>sqlText<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"Added FileCopy2"</span><br />
<br />
<span class='c'>;; ===== 2. Create __Add folder under root private folder (id=952, pid=0) =====</span><br />
<span class='t'>SqliteStatement</span> chk2<br />
chk2.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT rowid FROM items WHERE name='__Add' AND pid=952;"</span><span class='p'>)</span><br />
<span class='fq'>if</span> chk2.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='t'>int</span> folderRowid <span class='o'>=</span> chk2.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"__Add folder already exists"</span><br />
<span class='i'>,</span>chk2.<span class='fu'>Delete</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>chk2.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert folder items record</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span><span class='s'>"INSERT INTO items (pid, ord, flags, name, trigger, icon, td, guid) VALUES (952, NULL, 131078, '__Add', NULL, NULL, NULL, randomblob(16));"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;; Get the newly inserted rowid</span><br />
<span class='i'>,</span><span class='t'>SqliteStatement</span> tmp2<br />
<span class='i'>,</span>tmp2.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT last_insert_rowid();"</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp2.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span>folderRowid <span class='o'>=</span> tmp2.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp2.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert empty texts record (folders also need one)</span><br />
<span class='i'>,</span><span class='t'>str</span> emptyText<span class='o'>=</span><span class='s'>""</span><br />
<span class='i'>,</span>emptyText.<span class='fu'>SqlEscape</span><br />
<span class='i'>,</span><span class='t'>str</span> sqlFolderText<span class='o'>=F</span><span class='s'>"INSERT INTO texts (rowid, id, date, text) VALUES ({</span>folderRowid<span class='s'>}, {</span>folderRowid<span class='s'>}, NULL, '{</span>emptyText<span class='s'>}');"</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span>sqlFolderText<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='o'>F</span><span class='s'>"Created __Add folder, rowid={</span>folderRowid<span class='s'>}"</span><br />
<br />
<span class='c'>;; ===== 3. Add AddTest function under __Add folder =====</span><br />
<span class='t'>SqliteStatement</span> chk3<br />
chk3.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='o'>F</span><span class='s'>"SELECT rowid FROM items WHERE name='AddTest' AND pid={</span>folderRowid<span class='s'>};"</span><span class='p'>)</span><br />
<span class='fq'>if</span> chk3.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"AddTest already exists"</span><br />
<span class='i'>,</span>chk3.<span class='fu'>Delete</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>chk3.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert items record</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span><span class='o'>F</span><span class='s'>"INSERT INTO items (pid, ord, flags, name, trigger, icon, td, guid) VALUES ({</span>folderRowid<span class='s'>}, NULL, 16777218, 'AddTest', NULL, NULL, NULL, randomblob(16));"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;; Get the newly inserted rowid</span><br />
<span class='i'>,</span><span class='t'>SqliteStatement</span> tmp3<br />
<span class='i'>,</span>tmp3.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT last_insert_rowid();"</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp3.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='t'>int</span> addRowid <span class='o'>=</span> tmp3.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp3.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert texts record</span><br />
<span class='i'>,</span><span class='t'>str</span> atext<span class='o'>=</span><span class='s'>"[]I am the newly added function AddTest"</span><br />
<span class='i'>,</span>atext.<span class='fu'>SqlEscape</span><br />
<span class='i'>,</span><span class='t'>str</span> sqlAddText<span class='o'>=F</span><span class='s'>"INSERT INTO texts (rowid, id, date, text) VALUES ({</span>addRowid<span class='s'>}, {</span>addRowid<span class='s'>}, NULL, '{</span>atext<span class='s'>}');"</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span>sqlAddText<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"Added AddTest"</span><br />
<br />
db.<span class='fu'>Close</span><br />
<span class='fq'>out</span> <span class='s'>"Operation completed, please reopen System.qml to verify."</span></code></div></div><br />
<img src="https://i.ibb.co/yBbxwbCc/1.png" loading="lazy"  alt="[Image: 1.png]" class="mycode_img" /><br />
<br />
<br />
<img src="https://i.ibb.co/0RtzsVHX/2.png" loading="lazy"  alt="[Image: 2.png]" class="mycode_img" />]]></description>
			<content:encoded><![CDATA[I want to modify the file named <span style="font-weight: bold;" class="mycode_b">System.qml</span> on the desktop to implement the following functions:<br />
(Copy the System.qml file from the QM installation directory to the desktop, and remove the file's read-only attribute.)<br />
<br />
1. Add a function named <span style="font-weight: bold;" class="mycode_b">FileCopy2</span> after the function named <span style="font-weight: bold;" class="mycode_b">FileCopy</span>. The function content is: "I am the newly added function FileCopy2";<br />
<br />
2. Create a folder named <span style="font-weight: bold;" class="mycode_b">__Add</span> under the folder named <span style="font-weight: bold;" class="mycode_b">priveate</span>, and add a function named <span style="font-weight: bold;" class="mycode_b">AddTest</span>. The function content is: "I am the newly added function AddTest".<br />
<br />
After the following qm code is executed, it shows success, but an error is reported when opening the file:<br />
<span style="font-weight: bold;" class="mycode_b">Failed to open file 'C:\Users\Administrator\Desktop\System.qml'. Error reading items: The file is corrupt</span><br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">qml_mod</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<br />
<span class='t'>str</span> dbfile<span class='o'>=</span><span class='s'>"&#36;desktop&#36;&#92;System.qml"</span><br />
<span class='t'>Sqlite</span> db.<span class='fu'>Open</span><span class='p'>(</span>dbfile<span class='p'>)</span><br />
<br />
<span class='c'>;; ===== 1. Add FileCopy2 function to File folder (pid=81) =====</span><br />
<span class='t'>SqliteStatement</span> chk<br />
chk.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT rowid FROM items WHERE name='FileCopy2' AND pid=81;"</span><span class='p'>)</span><br />
<span class='fq'>if</span> chk.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"FileCopy2 already exists, skip"</span><br />
<span class='i'>,</span>chk.<span class='fu'>Delete</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>chk.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert items record</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span><span class='s'>"INSERT INTO items (pid, ord, flags, name, trigger, icon, td, guid) VALUES (81, NULL, 16777218, 'FileCopy2', NULL, NULL, NULL, randomblob(16));"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;; Get the newly inserted rowid</span><br />
<span class='i'>,</span><span class='t'>SqliteStatement</span> tmp<br />
<span class='i'>,</span>tmp.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT last_insert_rowid();"</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='t'>int</span> newRowid <span class='o'>=</span> tmp.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert texts record, rowid must be the same</span><br />
<span class='i'>,</span><span class='t'>str</span> ftext<span class='o'>=</span><span class='s'>"[]I am the newly added function FileCopy2"</span><br />
<span class='i'>,</span>ftext.<span class='fu'>SqlEscape</span><br />
<span class='i'>,</span><span class='t'>str</span> sqlText<span class='o'>=F</span><span class='s'>"INSERT INTO texts (rowid, id, date, text) VALUES ({</span>newRowid<span class='s'>}, {</span>newRowid<span class='s'>}, NULL, '{</span>ftext<span class='s'>}');"</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span>sqlText<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"Added FileCopy2"</span><br />
<br />
<span class='c'>;; ===== 2. Create __Add folder under root private folder (id=952, pid=0) =====</span><br />
<span class='t'>SqliteStatement</span> chk2<br />
chk2.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT rowid FROM items WHERE name='__Add' AND pid=952;"</span><span class='p'>)</span><br />
<span class='fq'>if</span> chk2.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='t'>int</span> folderRowid <span class='o'>=</span> chk2.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"__Add folder already exists"</span><br />
<span class='i'>,</span>chk2.<span class='fu'>Delete</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>chk2.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert folder items record</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span><span class='s'>"INSERT INTO items (pid, ord, flags, name, trigger, icon, td, guid) VALUES (952, NULL, 131078, '__Add', NULL, NULL, NULL, randomblob(16));"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;; Get the newly inserted rowid</span><br />
<span class='i'>,</span><span class='t'>SqliteStatement</span> tmp2<br />
<span class='i'>,</span>tmp2.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT last_insert_rowid();"</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp2.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span>folderRowid <span class='o'>=</span> tmp2.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp2.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert empty texts record (folders also need one)</span><br />
<span class='i'>,</span><span class='t'>str</span> emptyText<span class='o'>=</span><span class='s'>""</span><br />
<span class='i'>,</span>emptyText.<span class='fu'>SqlEscape</span><br />
<span class='i'>,</span><span class='t'>str</span> sqlFolderText<span class='o'>=F</span><span class='s'>"INSERT INTO texts (rowid, id, date, text) VALUES ({</span>folderRowid<span class='s'>}, {</span>folderRowid<span class='s'>}, NULL, '{</span>emptyText<span class='s'>}');"</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span>sqlFolderText<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='o'>F</span><span class='s'>"Created __Add folder, rowid={</span>folderRowid<span class='s'>}"</span><br />
<br />
<span class='c'>;; ===== 3. Add AddTest function under __Add folder =====</span><br />
<span class='t'>SqliteStatement</span> chk3<br />
chk3.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='o'>F</span><span class='s'>"SELECT rowid FROM items WHERE name='AddTest' AND pid={</span>folderRowid<span class='s'>};"</span><span class='p'>)</span><br />
<span class='fq'>if</span> chk3.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"AddTest already exists"</span><br />
<span class='i'>,</span>chk3.<span class='fu'>Delete</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>chk3.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert items record</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span><span class='o'>F</span><span class='s'>"INSERT INTO items (pid, ord, flags, name, trigger, icon, td, guid) VALUES ({</span>folderRowid<span class='s'>}, NULL, 16777218, 'AddTest', NULL, NULL, NULL, randomblob(16));"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;; Get the newly inserted rowid</span><br />
<span class='i'>,</span><span class='t'>SqliteStatement</span> tmp3<br />
<span class='i'>,</span>tmp3.<span class='fu'>Prepare</span><span class='p'>(</span>db <span class='s'>"SELECT last_insert_rowid();"</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp3.<span class='fu'>FetchRow</span><br />
<span class='i'>,</span><span class='t'>int</span> addRowid <span class='o'>=</span> tmp3.<span class='fu'>GetInt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='i'>,</span>tmp3.<span class='fu'>Delete</span><br />
<span class='i'>,</span><span class='c'>;; Insert texts record</span><br />
<span class='i'>,</span><span class='t'>str</span> atext<span class='o'>=</span><span class='s'>"[]I am the newly added function AddTest"</span><br />
<span class='i'>,</span>atext.<span class='fu'>SqlEscape</span><br />
<span class='i'>,</span><span class='t'>str</span> sqlAddText<span class='o'>=F</span><span class='s'>"INSERT INTO texts (rowid, id, date, text) VALUES ({</span>addRowid<span class='s'>}, {</span>addRowid<span class='s'>}, NULL, '{</span>atext<span class='s'>}');"</span><br />
<span class='i'>,</span>db.<span class='fu'>Exec</span><span class='p'>(</span>sqlAddText<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='s'>"Added AddTest"</span><br />
<br />
db.<span class='fu'>Close</span><br />
<span class='fq'>out</span> <span class='s'>"Operation completed, please reopen System.qml to verify."</span></code></div></div><br />
<img src="https://i.ibb.co/yBbxwbCc/1.png" loading="lazy"  alt="[Image: 1.png]" class="mycode_img" /><br />
<br />
<br />
<img src="https://i.ibb.co/0RtzsVHX/2.png" loading="lazy"  alt="[Image: 2.png]" class="mycode_img" />]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[getRetCode in exe]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7959</link>
			<pubDate>Fri, 28 Aug 2026 10:13:16 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7959</guid>
			<description><![CDATA[The code of macro T1 can execute successfully in both qm and exe,<br />
<br />
but the code of macro T2 only executes successfully under qm and returns empty in exe.<br />
<br />
The purpose of creating the `gr` function is just to be more concise.<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">T1</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fu'>sub.gr</span><span class='p'>(</span>_s<span class='p'>);</span> <span class='fq'>mes</span> _s <span class='c2'>;;OK</span><br />
<br />
<span class='dir'>#sub</span> gr<br />
<span class='fq'>function</span> <span class='t'>str</span><span class='o'>&amp;</span>code<br />
<span class='fu'>getRetCode</span><span class='p'>(</span><span class='s'>""</span> code<span class='p'>)</span><br />
<br />
<span class='dir'>#ret</span><br />
hello</code></div></div><br />
Macro <span style="font-weight: bold;" class="mycode_b">T2</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fu'>gr</span><span class='p'>(</span>_s<span class='p'>);</span> <span class='fq'>mes</span> _s <span class='c2'>;;qm: OK    exe: NO</span><br />
<br />
<span class='dir'>#ret</span><br />
hello</code></div></div><br />
Function <span style="font-weight: bold;" class="mycode_b">gr</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>function</span> <span class='t'>str</span><span class='o'>&amp;</span>code<br />
<span class='fu'>getRetCode</span><span class='p'>(</span><span class='s'>""</span> code <span class='n'>2</span><span class='p'>)</span></code></div></div><br />
Function <span style="font-weight: bold;" class="mycode_b">getRetCode</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>function</span> <span class='o'>&#36;</span>macro <span class='t'>str</span><span class='o'>&amp;</span>code [context] <br />
<br />
<span class='dir'>#exe</span> addtextof <span class='s'>"&lt;script&gt;"</span><br />
<span class='dir'>#opt</span> nowarnings <span class='n'>1</span><br />
<span class='fq'>opt</span> noerrorshere <span class='n'>1</span><br />
<br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>macro <span class='fq'>or</span> <span class='p'>(</span>macro<span class='o'>&gt;=</span><span class='n'>0x10000</span> <span class='fq'>and</span> <span class='o'>!</span>macro[<span class='n'>0</span>]<span class='p'>))</span><br />
<span class='i'>,</span><span class='t'>int</span> iid<span class='o'>=+</span><span class='fq'>getopt</span><span class='p'>(</span>itemid <span class='o'>-</span><span class='fq'>iif</span><span class='p'>(</span>context context <span class='n'>2</span><span class='p'>))</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>iid<span class='o'>=</span><span class='fq'>qmitem</span><span class='p'>(</span>macro <span class='n'>1</span><span class='p'>);</span> <span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>iid<span class='p'>)</span> <span class='fq'>end</span> <span class='d'>ERR_MACRO</span><br />
code.<span class='fq'>getmacro</span><span class='p'>(</span>iid<span class='p'>)</span><br />
<br />
<span class='t'>int</span> n i<span class='o'>=</span><span class='fq'>findrx</span><span class='p'>(</span>code <span class='s'>"^#ret&#92;b.*[]"</span> <span class='n'>0</span> <span class='n'>8</span> _i<span class='p'>)</span><br />
<span class='fq'>if</span> i<span class='o'>&gt;=</span><span class='n'>0</span> <br />
<span class='i'>,</span>i<span class='o'>+</span>_i<span class='o'>-</span><span class='n'>2</span><br />
<span class='i'>,</span>code[i]<span class='o'>=</span><span class='n'>0</span><span class='p'>;</span> n<span class='o'>=</span><span class='fq'>numlines</span><span class='p'>(</span>code<span class='p'>)</span><span class='o'>-</span><span class='n'>1</span><span class='p'>;</span> code[i]<span class='o'>=</span><span class='n'>13</span><br />
<span class='i'>,</span>code.<span class='fq'>replace</span><span class='p'>(</span>_s.<span class='fq'>all</span><span class='p'>(</span>n <span class='n'>2</span> <span class='n'>10</span><span class='p'>)</span> <span class='n'>0</span> i<span class='p'>)</span> <br />
<span class='fq'>else</span> <span class='fq'>if</span> <span class='n'>0</span><span class='o'>=</span><span class='fq'>findrx</span><span class='p'>(</span>code <span class='s'>"^[ ;]*[/&#92;&#92;](?![/&#92;*]).*[]"</span> <span class='n'>0</span> <span class='n'>0</span> _i<span class='p'>)</span><br />
<span class='i'>,</span>code.<span class='fq'>remove</span><span class='p'>(</span><span class='n'>0</span> _i<span class='o'>-</span><span class='n'>2</span><span class='p'>)</span> <br />
<br />
code.<span class='fq'>trim</span></code></div></div>]]></description>
			<content:encoded><![CDATA[The code of macro T1 can execute successfully in both qm and exe,<br />
<br />
but the code of macro T2 only executes successfully under qm and returns empty in exe.<br />
<br />
The purpose of creating the `gr` function is just to be more concise.<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">T1</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fu'>sub.gr</span><span class='p'>(</span>_s<span class='p'>);</span> <span class='fq'>mes</span> _s <span class='c2'>;;OK</span><br />
<br />
<span class='dir'>#sub</span> gr<br />
<span class='fq'>function</span> <span class='t'>str</span><span class='o'>&amp;</span>code<br />
<span class='fu'>getRetCode</span><span class='p'>(</span><span class='s'>""</span> code<span class='p'>)</span><br />
<br />
<span class='dir'>#ret</span><br />
hello</code></div></div><br />
Macro <span style="font-weight: bold;" class="mycode_b">T2</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fu'>gr</span><span class='p'>(</span>_s<span class='p'>);</span> <span class='fq'>mes</span> _s <span class='c2'>;;qm: OK    exe: NO</span><br />
<br />
<span class='dir'>#ret</span><br />
hello</code></div></div><br />
Function <span style="font-weight: bold;" class="mycode_b">gr</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>function</span> <span class='t'>str</span><span class='o'>&amp;</span>code<br />
<span class='fu'>getRetCode</span><span class='p'>(</span><span class='s'>""</span> code <span class='n'>2</span><span class='p'>)</span></code></div></div><br />
Function <span style="font-weight: bold;" class="mycode_b">getRetCode</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>function</span> <span class='o'>&#36;</span>macro <span class='t'>str</span><span class='o'>&amp;</span>code [context] <br />
<br />
<span class='dir'>#exe</span> addtextof <span class='s'>"&lt;script&gt;"</span><br />
<span class='dir'>#opt</span> nowarnings <span class='n'>1</span><br />
<span class='fq'>opt</span> noerrorshere <span class='n'>1</span><br />
<br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>macro <span class='fq'>or</span> <span class='p'>(</span>macro<span class='o'>&gt;=</span><span class='n'>0x10000</span> <span class='fq'>and</span> <span class='o'>!</span>macro[<span class='n'>0</span>]<span class='p'>))</span><br />
<span class='i'>,</span><span class='t'>int</span> iid<span class='o'>=+</span><span class='fq'>getopt</span><span class='p'>(</span>itemid <span class='o'>-</span><span class='fq'>iif</span><span class='p'>(</span>context context <span class='n'>2</span><span class='p'>))</span><br />
<span class='fq'>else</span><br />
<span class='i'>,</span>iid<span class='o'>=</span><span class='fq'>qmitem</span><span class='p'>(</span>macro <span class='n'>1</span><span class='p'>);</span> <span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>iid<span class='p'>)</span> <span class='fq'>end</span> <span class='d'>ERR_MACRO</span><br />
code.<span class='fq'>getmacro</span><span class='p'>(</span>iid<span class='p'>)</span><br />
<br />
<span class='t'>int</span> n i<span class='o'>=</span><span class='fq'>findrx</span><span class='p'>(</span>code <span class='s'>"^#ret&#92;b.*[]"</span> <span class='n'>0</span> <span class='n'>8</span> _i<span class='p'>)</span><br />
<span class='fq'>if</span> i<span class='o'>&gt;=</span><span class='n'>0</span> <br />
<span class='i'>,</span>i<span class='o'>+</span>_i<span class='o'>-</span><span class='n'>2</span><br />
<span class='i'>,</span>code[i]<span class='o'>=</span><span class='n'>0</span><span class='p'>;</span> n<span class='o'>=</span><span class='fq'>numlines</span><span class='p'>(</span>code<span class='p'>)</span><span class='o'>-</span><span class='n'>1</span><span class='p'>;</span> code[i]<span class='o'>=</span><span class='n'>13</span><br />
<span class='i'>,</span>code.<span class='fq'>replace</span><span class='p'>(</span>_s.<span class='fq'>all</span><span class='p'>(</span>n <span class='n'>2</span> <span class='n'>10</span><span class='p'>)</span> <span class='n'>0</span> i<span class='p'>)</span> <br />
<span class='fq'>else</span> <span class='fq'>if</span> <span class='n'>0</span><span class='o'>=</span><span class='fq'>findrx</span><span class='p'>(</span>code <span class='s'>"^[ ;]*[/&#92;&#92;](?![/&#92;*]).*[]"</span> <span class='n'>0</span> <span class='n'>0</span> _i<span class='p'>)</span><br />
<span class='i'>,</span>code.<span class='fq'>remove</span><span class='p'>(</span><span class='n'>0</span> _i<span class='o'>-</span><span class='n'>2</span><span class='p'>)</span> <br />
<br />
code.<span class='fq'>trim</span></code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[get the ID of the menu item under the mouse cursor]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7957</link>
			<pubDate>Fri, 21 Aug 2026 03:52:05 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7957</guid>
			<description><![CDATA[The custom menu is displayed next to the system shell menu.<br />
<br />
When the F11 hotkey is pressed or the right mouse button is pressed,<br />
I need to obtain the ID of the menu item under the mouse cursor so that I can output the text of the menu item.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Menu_Edit</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">!v"" "#32768" /QM</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<span class='t'>int</span> h<span class='o'>=</span><span class='fu'>TriggerWindow</span><br />
<br />
<span class='c'>;if(MenuGetString(hwnd 1 &amp;_s)) out _s ;;Why is there no output?</span><br />
<br />
<span class='fq'>rep</span><br />
<span class='i'>,</span><span class='n'>0.1</span><br />
<span class='i'>,</span><span class='fq'>ifk</span><span class='p'>(</span>F11<span class='p'>)</span><br />
<span class='i'>,,</span><span class='t'>int</span> mh<span class='o'>=</span><span class='fq'>win</span><span class='p'>(</span><span class='lib'>mouse</span><span class='p'>);</span> <span class='fq'>out</span> mh<br />
<span class='i'>,,</span><span class='t'>int</span> iid<span class='o'>=</span><span class='n'>1</span> <span class='c2'>;;How to get the ID of the menu item under the mouse cursor?</span><br />
<span class='i'>,,</span><span class='t'>Acc</span> a.<span class='fu'>Find</span><span class='p'>(</span>h <span class='s'>"MENUITEM"</span> <span class='s'>""</span> <span class='s'>""</span> <span class='n'>0x1001</span> <span class='n'>3</span> iid<span class='p'>)</span><br />
<span class='i'>,,</span><span class='fq'>out</span> a.<span class='fu'>Name</span><br />
<span class='i'>,,</span><span class='fq'>key</span> Z           <span class='c2'>;; Esc</span><br />
<span class='i'>,,</span><span class='fq'>break</span></code></div></div><br />
Macro <span style="font-weight: bold;" class="mycode_b">Macro51</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">!v"" "#32768" /EXPLORER</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='t'>int</span> hwnd<span class='o'>=</span><span class='fu'>TriggerWindow</span><br />
<br />
<span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span> a<span class='p'>;</span> <span class='fq'>win</span><span class='p'>(</span><span class='s'>""</span> <span class='s'>"#32768"</span> <span class='s'>"explorer"</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> a<span class='p'>);</span> <span class='fq'>if</span><span class='p'>(</span>a.<span class='fq'>len</span><span class='o'>&gt;</span><span class='n'>1</span><span class='p'>)</span> <span class='fq'>ret</span><br />
<br />
<span class='fd'>SetTimer</span><span class='p'>(</span><span class='n'>0</span> <span class='n'>0</span> <span class='n'>100</span> <span class='o'>&amp;</span><span class='fu'>sub._Timer</span><span class='p'>)</span><br />
<span class='c'>;</span><br />
_s<span class='o'>=</span><br />
<span class='s'>;1 open docx</span><br />
<span class='s'>;2 open other</span><br />
_i<span class='o'>=</span><span class='fu'>ShowMenu</span><span class='p'>(</span>_s <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>8</span><span class='p'>)</span><br />
<span class='fq'>out</span> _i<br />
<br />
<br />
<span class='dir'>#sub</span> _Timer v<br />
<span class='fq'>function</span> u1 u2 timer u3<br />
<span class='fq'>if</span> <span class='o'>!</span><span class='fd'>IsWindowVisible</span><span class='p'>(</span>a[<span class='n'>0</span>]<span class='p'>)</span> <span class='o'>&amp;&amp;</span> <span class='o'>!</span><span class='p'>(</span><span class='fd'>RealGetKeyState</span><span class='p'>(</span><span class='n'>1</span><span class='p'>)</span> <span class='fq'>or</span> <span class='fd'>RealGetKeyState</span><span class='p'>(</span><span class='n'>2</span><span class='p'>))</span><br />
<span class='i'>,</span><span class='fd'>KillTimer</span> <span class='n'>0</span> timer<br />
<span class='i'>,</span><span class='fd'>EndMenu</span></code></div></div>]]></description>
			<content:encoded><![CDATA[The custom menu is displayed next to the system shell menu.<br />
<br />
When the F11 hotkey is pressed or the right mouse button is pressed,<br />
I need to obtain the ID of the menu item under the mouse cursor so that I can output the text of the menu item.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Menu_Edit</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">!v"" "#32768" /QM</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<span class='t'>int</span> h<span class='o'>=</span><span class='fu'>TriggerWindow</span><br />
<br />
<span class='c'>;if(MenuGetString(hwnd 1 &amp;_s)) out _s ;;Why is there no output?</span><br />
<br />
<span class='fq'>rep</span><br />
<span class='i'>,</span><span class='n'>0.1</span><br />
<span class='i'>,</span><span class='fq'>ifk</span><span class='p'>(</span>F11<span class='p'>)</span><br />
<span class='i'>,,</span><span class='t'>int</span> mh<span class='o'>=</span><span class='fq'>win</span><span class='p'>(</span><span class='lib'>mouse</span><span class='p'>);</span> <span class='fq'>out</span> mh<br />
<span class='i'>,,</span><span class='t'>int</span> iid<span class='o'>=</span><span class='n'>1</span> <span class='c2'>;;How to get the ID of the menu item under the mouse cursor?</span><br />
<span class='i'>,,</span><span class='t'>Acc</span> a.<span class='fu'>Find</span><span class='p'>(</span>h <span class='s'>"MENUITEM"</span> <span class='s'>""</span> <span class='s'>""</span> <span class='n'>0x1001</span> <span class='n'>3</span> iid<span class='p'>)</span><br />
<span class='i'>,,</span><span class='fq'>out</span> a.<span class='fu'>Name</span><br />
<span class='i'>,,</span><span class='fq'>key</span> Z           <span class='c2'>;; Esc</span><br />
<span class='i'>,,</span><span class='fq'>break</span></code></div></div><br />
Macro <span style="font-weight: bold;" class="mycode_b">Macro51</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">!v"" "#32768" /EXPLORER</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='t'>int</span> hwnd<span class='o'>=</span><span class='fu'>TriggerWindow</span><br />
<br />
<span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span> a<span class='p'>;</span> <span class='fq'>win</span><span class='p'>(</span><span class='s'>""</span> <span class='s'>"#32768"</span> <span class='s'>"explorer"</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> a<span class='p'>);</span> <span class='fq'>if</span><span class='p'>(</span>a.<span class='fq'>len</span><span class='o'>&gt;</span><span class='n'>1</span><span class='p'>)</span> <span class='fq'>ret</span><br />
<br />
<span class='fd'>SetTimer</span><span class='p'>(</span><span class='n'>0</span> <span class='n'>0</span> <span class='n'>100</span> <span class='o'>&amp;</span><span class='fu'>sub._Timer</span><span class='p'>)</span><br />
<span class='c'>;</span><br />
_s<span class='o'>=</span><br />
<span class='s'>;1 open docx</span><br />
<span class='s'>;2 open other</span><br />
_i<span class='o'>=</span><span class='fu'>ShowMenu</span><span class='p'>(</span>_s <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>8</span><span class='p'>)</span><br />
<span class='fq'>out</span> _i<br />
<br />
<br />
<span class='dir'>#sub</span> _Timer v<br />
<span class='fq'>function</span> u1 u2 timer u3<br />
<span class='fq'>if</span> <span class='o'>!</span><span class='fd'>IsWindowVisible</span><span class='p'>(</span>a[<span class='n'>0</span>]<span class='p'>)</span> <span class='o'>&amp;&amp;</span> <span class='o'>!</span><span class='p'>(</span><span class='fd'>RealGetKeyState</span><span class='p'>(</span><span class='n'>1</span><span class='p'>)</span> <span class='fq'>or</span> <span class='fd'>RealGetKeyState</span><span class='p'>(</span><span class='n'>2</span><span class='p'>))</span><br />
<span class='i'>,</span><span class='fd'>KillTimer</span> <span class='n'>0</span> timer<br />
<span class='i'>,</span><span class='fd'>EndMenu</span></code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Context Menu Trigger in QM]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7956</link>
			<pubDate>Mon, 17 Aug 2026 23:11:39 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7956</guid>
			<description><![CDATA[Previously I used a large number of "Shell menu" triggers. At first it was very convenient, but as the number grew, the following problems arose:<br />
1. QM portable version does not support it;<br />
2. Editing trigger functions is inconvenient;<br />
3. One function corresponds to only one shell menu;<br />
4. It can only be integrated into a certain position of the existing system menu, which is not intuitive enough, and the position of the menu items is inconvenient to modify.<br />
5. And many more...<br />
<br />
To solve the above problems, I wanted to implement in QM functionality similar to the LA trigger in the post below. I wrote the following code, but I ran into some problems:<br />
<a href="https://www.libreautomate.com/forum/showthread.php?tid=7925&amp;pid=38865#pid38865" target="_blank" rel="noopener" class="mycode_url">Context Menu Trigger</a><br />
1. How do I determine the currently selected file(s)? (I have seen similar code on the forum, but I haven't found it yet);<br />
2. Right-clicking on a menu item does not bring up "Edit menu item" (I have seen it pop up on some menu items);<br />
<br />
I found the source code of the <span style="font-weight: bold;" class="mycode_b">ExplorerFolder</span> function in LA. Is there a similar function in QM? I tried using AI to convert the code to QM, but had no luck.<br />
<a href="https://github.com/qgindi/LibreAutomate/blob/master/Au/Files%2C%20data/ExplorerFolder.cs" target="_blank" rel="noopener" class="mycode_url">https://github.com/qgindi/LibreAutomate/...rFolder.cs</a><br />
How convert the following <span style="font-weight: bold;" class="mycode_b">Get-ExplorerSelectedItems</span> PowerShell function into QM code?<br />
<br />
Thanks in advance for any suggestions and help.<br />
PS: I also thought about using LA to re-implement those QM features, but there are too many...<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Explorer_Menu</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">!v"" "#32768" /EXPLORER</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='t'>int</span> hwnd<span class='o'>=</span><span class='fu'>TriggerWindow</span><br />
<span class='fq'>out</span><br />
<span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span> a<span class='p'>;</span> <span class='fq'>win</span><span class='p'>(</span><span class='s'>""</span> <span class='s'>"#32768"</span> <span class='s'>"explorer"</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> a<span class='p'>);</span> <span class='fq'>if</span><span class='p'>(</span>a.<span class='fq'>len</span><span class='o'>&gt;</span><span class='n'>1</span><span class='p'>)</span> <span class='fq'>ret</span><br />
<br />
<span class='c'>;1.When one or more docx files are selected, The menu pops up</span><br />
<span class='fu'>sub.docx</span><br />
<br />
<span class='c'>;2.When one or more txt files are selected, The menu pops up</span><br />
<span class='c'>;sub.txt</span><br />
<br />
<span class='dir'>#sub</span> docx<br />
<span class='t'>str</span> docx<span class='o'>=</span><br />
<span class='s'>;1 docx Action1</span><br />
<span class='s'>;-</span><br />
<span class='s'>;2 docx Action2</span><br />
_i<span class='o'>=</span><span class='fu'>ShowMenu</span><span class='p'>(</span>docx <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>8</span><span class='p'>)</span><br />
<span class='fq'>out</span> _i<br />
<br />
<span class='dir'>#sub</span> txt<br />
<span class='t'>str</span> txt<span class='o'>=</span><br />
<span class='s'>;1 txt Action1</span><br />
<span class='s'>;-</span><br />
<span class='s'>;2 txt Action2</span><br />
_i<span class='o'>=</span><span class='fu'>ShowMenu</span><span class='p'>(</span>txt <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>8</span><span class='p'>)</span><br />
<span class='fq'>out</span> _i</code></div></div><br />
Powershell <span style="font-weight: bold;" class="mycode_b">Get-ExplorerSelectedItems</span> Code:<br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>function Get-ExplorerSelectedItems {<br />
&nbsp;&nbsp;&nbsp;&nbsp;[CmdletBinding()]<br />
&nbsp;&nbsp;&nbsp;&nbsp;param(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Parameter(ValueFromPipeline=&#36;true)]<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[int]&#36;Hwnd = 0,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[switch]&#36;OnlyFilesystem<br />
&nbsp;&nbsp;&nbsp;&nbsp;)<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#36;shell = New-Object -ComObject Shell.Application<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#36;windows = &#36;shell.Windows()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#36;results = [System.Collections.Generic.List[string]]::new()<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;foreach (&#36;win in &#36;windows) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;winHwnd = [int]&#36;win.HWND<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;Hwnd -ne 0 -and &#36;winHwnd -ne &#36;Hwnd) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;doc = &#36;win.Document<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;null -eq &#36;doc) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;selected = &#36;doc.SelectedItems()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;null -eq &#36;selected) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (&#36;i = 0; &#36;i -lt &#36;selected.Count; &#36;i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;item = &#36;selected.Item(&#36;i)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;null -eq &#36;item) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;path = &#36;item.Path<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ([string]::IsNullOrEmpty(&#36;path)) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;OnlyFilesystem -and &#36;path -notmatch '^[a-zA-Z]:[&#92;&#92;/]') {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;results.Add(&#36;path)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;} <br />
&nbsp;&nbsp;&nbsp;&nbsp;return &#36;results<br />
}<br />
Get-ExplorerSelectedItems -Hwnd 12345</code></div></div><br />
<br />
Below is the QM code generated by ChatGPT, and it will cause an error.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Get_ExplorerSelectedItems</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">F1</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<br />
<span class='t'>int</span> h<span class='o'>=</span><span class='fq'>win</span><br />
<br />
<span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>str</span><span class='p'>)</span> r<br />
<span class='fu'>sub.Get_ExplorerSelectedItems</span> r h<br />
<br />
<span class='fq'>out</span> r<br />
<br />
<span class='dir'>#sub</span> Get_ExplorerSelectedItems<br />
<span class='fq'>function</span> <span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>str</span><span class='p'>)</span><span class='o'>&amp;</span>results [<span class='t'>int</span><span class='p'>'</span>Hwnd] [flags]<br />
<span class='i'>,</span><span class='fq'>if</span><span class='p'>(</span><span class='fq'>getopt</span><span class='p'>(</span>nargs<span class='p'>)</span><span class='o'>=</span><span class='n'>1</span><span class='p'>)</span> Hwnd<span class='o'>=</span><span class='n'>0</span><br />
<br />
<span class='i'>,</span><span class='lib'>Shell32.</span><span class='t'>IShellDispatch5</span> sh.<span class='fq'>_create</span><span class='p'>(</span><span class='fq'>uuidof</span><span class='p'>(</span><span class='lib'>Shell32.</span><span class='t'>Shell</span><span class='p'>))</span><br />
<span class='i'>,</span><span class='t'>IShellWindows</span> windows<span class='o'>=</span>sh.<span class='fd'>Windows</span><br />
<span class='i'>,</span><span class='t'>int</span> count<span class='p'>;</span> windows.<span class='fd'>get_Count</span><span class='p'>(</span><span class='o'>&amp;</span>count<span class='p'>)</span><br />
<br />
<span class='i'>,</span><span class='t'>int</span> i<br />
<span class='i'>,</span><span class='fq'>for</span> i <span class='n'>0</span> count<br />
<span class='i'>,,</span><span class='lib'>Shell32.</span>IWebBrowserApp w<span class='o'>=</span>windows.<span class='fd'>Item</span><span class='p'>(</span>i<span class='p'>)</span><br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>w<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='t'>int</span> winHwnd<span class='o'>=</span>w.HWND<br />
<br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span>Hwnd <span class='fq'>and</span> winHwnd<span class='o'>!=</span>Hwnd<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='lib'>Shell32.</span><span class='t'>IShellFolderViewDual2</span> doc<span class='o'>=</span>w.Document<br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>doc<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='lib'>Shell32.</span><span class='t'>FolderItems</span> selected<span class='o'>=</span>doc.<span class='fd'>SelectedItems</span><span class='p'>()</span><br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>selected<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='t'>int</span> j<br />
<span class='i'>,,</span><span class='fq'>for</span> j <span class='n'>0</span> selected.<span class='fd'>Count</span><br />
<span class='i'>,,,</span><span class='lib'>Shell32.</span><span class='t'>FolderItem</span> item<span class='o'>=</span>selected.<span class='fd'>Item</span><span class='p'>(</span>j<span class='p'>)</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>item<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,,</span><span class='t'>str</span> path<span class='o'>=</span>item.<span class='fd'>Path</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='fq'>empty</span><span class='p'>(</span>path<span class='p'>))</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,,</span><span class='c'>;;;flags 1 = OnlyFilesystem</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span>flags<span class='o'>&amp;</span><span class='n'>1</span> <span class='fq'>and</span> <span class='o'>!</span><span class='fq'>matchw</span><span class='p'>(</span>path <span class='s'>"[a-zA-Z]:&#92;&#92;*"</span> <span class='n'>1</span><span class='p'>))</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,,</span>results[] <span class='o'>=</span> <span class='o'>F</span><span class='s'>"{</span>winHwnd<span class='s'>}`t{</span>path<span class='s'>}"</span><br />
<br />
<span class='fq'>ret</span></code></div></div>]]></description>
			<content:encoded><![CDATA[Previously I used a large number of "Shell menu" triggers. At first it was very convenient, but as the number grew, the following problems arose:<br />
1. QM portable version does not support it;<br />
2. Editing trigger functions is inconvenient;<br />
3. One function corresponds to only one shell menu;<br />
4. It can only be integrated into a certain position of the existing system menu, which is not intuitive enough, and the position of the menu items is inconvenient to modify.<br />
5. And many more...<br />
<br />
To solve the above problems, I wanted to implement in QM functionality similar to the LA trigger in the post below. I wrote the following code, but I ran into some problems:<br />
<a href="https://www.libreautomate.com/forum/showthread.php?tid=7925&amp;pid=38865#pid38865" target="_blank" rel="noopener" class="mycode_url">Context Menu Trigger</a><br />
1. How do I determine the currently selected file(s)? (I have seen similar code on the forum, but I haven't found it yet);<br />
2. Right-clicking on a menu item does not bring up "Edit menu item" (I have seen it pop up on some menu items);<br />
<br />
I found the source code of the <span style="font-weight: bold;" class="mycode_b">ExplorerFolder</span> function in LA. Is there a similar function in QM? I tried using AI to convert the code to QM, but had no luck.<br />
<a href="https://github.com/qgindi/LibreAutomate/blob/master/Au/Files%2C%20data/ExplorerFolder.cs" target="_blank" rel="noopener" class="mycode_url">https://github.com/qgindi/LibreAutomate/...rFolder.cs</a><br />
How convert the following <span style="font-weight: bold;" class="mycode_b">Get-ExplorerSelectedItems</span> PowerShell function into QM code?<br />
<br />
Thanks in advance for any suggestions and help.<br />
PS: I also thought about using LA to re-implement those QM features, but there are too many...<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Explorer_Menu</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">!v"" "#32768" /EXPLORER</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='t'>int</span> hwnd<span class='o'>=</span><span class='fu'>TriggerWindow</span><br />
<span class='fq'>out</span><br />
<span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span> a<span class='p'>;</span> <span class='fq'>win</span><span class='p'>(</span><span class='s'>""</span> <span class='s'>"#32768"</span> <span class='s'>"explorer"</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> a<span class='p'>);</span> <span class='fq'>if</span><span class='p'>(</span>a.<span class='fq'>len</span><span class='o'>&gt;</span><span class='n'>1</span><span class='p'>)</span> <span class='fq'>ret</span><br />
<br />
<span class='c'>;1.When one or more docx files are selected, The menu pops up</span><br />
<span class='fu'>sub.docx</span><br />
<br />
<span class='c'>;2.When one or more txt files are selected, The menu pops up</span><br />
<span class='c'>;sub.txt</span><br />
<br />
<span class='dir'>#sub</span> docx<br />
<span class='t'>str</span> docx<span class='o'>=</span><br />
<span class='s'>;1 docx Action1</span><br />
<span class='s'>;-</span><br />
<span class='s'>;2 docx Action2</span><br />
_i<span class='o'>=</span><span class='fu'>ShowMenu</span><span class='p'>(</span>docx <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>8</span><span class='p'>)</span><br />
<span class='fq'>out</span> _i<br />
<br />
<span class='dir'>#sub</span> txt<br />
<span class='t'>str</span> txt<span class='o'>=</span><br />
<span class='s'>;1 txt Action1</span><br />
<span class='s'>;-</span><br />
<span class='s'>;2 txt Action2</span><br />
_i<span class='o'>=</span><span class='fu'>ShowMenu</span><span class='p'>(</span>txt <span class='n'>0</span> <span class='n'>0</span> <span class='n'>0</span> <span class='n'>8</span><span class='p'>)</span><br />
<span class='fq'>out</span> _i</code></div></div><br />
Powershell <span style="font-weight: bold;" class="mycode_b">Get-ExplorerSelectedItems</span> Code:<br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>function Get-ExplorerSelectedItems {<br />
&nbsp;&nbsp;&nbsp;&nbsp;[CmdletBinding()]<br />
&nbsp;&nbsp;&nbsp;&nbsp;param(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Parameter(ValueFromPipeline=&#36;true)]<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[int]&#36;Hwnd = 0,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[switch]&#36;OnlyFilesystem<br />
&nbsp;&nbsp;&nbsp;&nbsp;)<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#36;shell = New-Object -ComObject Shell.Application<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#36;windows = &#36;shell.Windows()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#36;results = [System.Collections.Generic.List[string]]::new()<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;foreach (&#36;win in &#36;windows) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;winHwnd = [int]&#36;win.HWND<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;Hwnd -ne 0 -and &#36;winHwnd -ne &#36;Hwnd) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;doc = &#36;win.Document<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;null -eq &#36;doc) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;selected = &#36;doc.SelectedItems()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;null -eq &#36;selected) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (&#36;i = 0; &#36;i -lt &#36;selected.Count; &#36;i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;item = &#36;selected.Item(&#36;i)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;null -eq &#36;item) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;path = &#36;item.Path<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ([string]::IsNullOrEmpty(&#36;path)) { continue }<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (&#36;OnlyFilesystem -and &#36;path -notmatch '^[a-zA-Z]:[&#92;&#92;/]') {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#36;results.Add(&#36;path)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;} <br />
&nbsp;&nbsp;&nbsp;&nbsp;return &#36;results<br />
}<br />
Get-ExplorerSelectedItems -Hwnd 12345</code></div></div><br />
<br />
Below is the QM code generated by ChatGPT, and it will cause an error.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">Get_ExplorerSelectedItems</span> <span/><br />
Trigger <span style="font-weight: bold;" class="mycode_b">F1</span> &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:alert("Paste the bold text in the Trigger edit field on the toolbar in Quick Macros.");'><img src="images/qm/help.png" alt="Help - how to add the trigger to the macro" title="Help - how to add the trigger to the macro"/></a><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<br />
<span class='t'>int</span> h<span class='o'>=</span><span class='fq'>win</span><br />
<br />
<span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>str</span><span class='p'>)</span> r<br />
<span class='fu'>sub.Get_ExplorerSelectedItems</span> r h<br />
<br />
<span class='fq'>out</span> r<br />
<br />
<span class='dir'>#sub</span> Get_ExplorerSelectedItems<br />
<span class='fq'>function</span> <span class='t'>ARRAY</span><span class='p'>(</span><span class='t'>str</span><span class='p'>)</span><span class='o'>&amp;</span>results [<span class='t'>int</span><span class='p'>'</span>Hwnd] [flags]<br />
<span class='i'>,</span><span class='fq'>if</span><span class='p'>(</span><span class='fq'>getopt</span><span class='p'>(</span>nargs<span class='p'>)</span><span class='o'>=</span><span class='n'>1</span><span class='p'>)</span> Hwnd<span class='o'>=</span><span class='n'>0</span><br />
<br />
<span class='i'>,</span><span class='lib'>Shell32.</span><span class='t'>IShellDispatch5</span> sh.<span class='fq'>_create</span><span class='p'>(</span><span class='fq'>uuidof</span><span class='p'>(</span><span class='lib'>Shell32.</span><span class='t'>Shell</span><span class='p'>))</span><br />
<span class='i'>,</span><span class='t'>IShellWindows</span> windows<span class='o'>=</span>sh.<span class='fd'>Windows</span><br />
<span class='i'>,</span><span class='t'>int</span> count<span class='p'>;</span> windows.<span class='fd'>get_Count</span><span class='p'>(</span><span class='o'>&amp;</span>count<span class='p'>)</span><br />
<br />
<span class='i'>,</span><span class='t'>int</span> i<br />
<span class='i'>,</span><span class='fq'>for</span> i <span class='n'>0</span> count<br />
<span class='i'>,,</span><span class='lib'>Shell32.</span>IWebBrowserApp w<span class='o'>=</span>windows.<span class='fd'>Item</span><span class='p'>(</span>i<span class='p'>)</span><br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>w<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='t'>int</span> winHwnd<span class='o'>=</span>w.HWND<br />
<br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span>Hwnd <span class='fq'>and</span> winHwnd<span class='o'>!=</span>Hwnd<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='lib'>Shell32.</span><span class='t'>IShellFolderViewDual2</span> doc<span class='o'>=</span>w.Document<br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>doc<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='lib'>Shell32.</span><span class='t'>FolderItems</span> selected<span class='o'>=</span>doc.<span class='fd'>SelectedItems</span><span class='p'>()</span><br />
<span class='i'>,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>selected<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,</span><span class='t'>int</span> j<br />
<span class='i'>,,</span><span class='fq'>for</span> j <span class='n'>0</span> selected.<span class='fd'>Count</span><br />
<span class='i'>,,,</span><span class='lib'>Shell32.</span><span class='t'>FolderItem</span> item<span class='o'>=</span>selected.<span class='fd'>Item</span><span class='p'>(</span>j<span class='p'>)</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>item<span class='p'>)</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,,</span><span class='t'>str</span> path<span class='o'>=</span>item.<span class='fd'>Path</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='fq'>empty</span><span class='p'>(</span>path<span class='p'>))</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,,</span><span class='c'>;;;flags 1 = OnlyFilesystem</span><br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span>flags<span class='o'>&amp;</span><span class='n'>1</span> <span class='fq'>and</span> <span class='o'>!</span><span class='fq'>matchw</span><span class='p'>(</span>path <span class='s'>"[a-zA-Z]:&#92;&#92;*"</span> <span class='n'>1</span><span class='p'>))</span> <span class='fq'>continue</span><br />
<br />
<span class='i'>,,,</span>results[] <span class='o'>=</span> <span class='o'>F</span><span class='s'>"{</span>winHwnd<span class='s'>}`t{</span>path<span class='s'>}"</span><br />
<br />
<span class='fq'>ret</span></code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[File Trigger Cannot Monitor Files in Subfolders]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7950</link>
			<pubDate>Sun, 07 Jun 2026 01:33:06 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7950</guid>
			<description><![CDATA[I need to monitor files inside a folder named <span style="font-weight: bold;" class="mycode_b">T</span> on the desktop.<br />
If I drag and drop a folder named <span style="font-weight: bold;" class="mycode_b">A</span> (which contains a file named <span style="font-weight: bold;" class="mycode_b">A.txt</span>) into the <span style="font-weight: bold;" class="mycode_b">T</span> folder, the trigger does not work. Nothing is displayed in the Output panel, and neither the trigger type nor the file path is reported.<br />
The following video demonstrates the issue.<br />
<br />
<img src="https://i.ibb.co/G3pqCJty/demo.gif" loading="lazy"  alt="[Image: demo.gif]" class="mycode_img" />]]></description>
			<content:encoded><![CDATA[I need to monitor files inside a folder named <span style="font-weight: bold;" class="mycode_b">T</span> on the desktop.<br />
If I drag and drop a folder named <span style="font-weight: bold;" class="mycode_b">A</span> (which contains a file named <span style="font-weight: bold;" class="mycode_b">A.txt</span>) into the <span style="font-weight: bold;" class="mycode_b">T</span> folder, the trigger does not work. Nothing is displayed in the Output panel, and neither the trigger type nor the file path is reported.<br />
The following video demonstrates the issue.<br />
<br />
<img src="https://i.ibb.co/G3pqCJty/demo.gif" loading="lazy"  alt="[Image: demo.gif]" class="mycode_img" />]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Best way to apply the license to several computers?]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7948</link>
			<pubDate>Tue, 02 Jun 2026 14:21:27 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1625">chrisleon</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7948</guid>
			<description><![CDATA[I have several desktops/laptops I need to switch over to the new free registration license, what is the best way to apply the license to all of them?<br />
<br />
We are using 2.3.6.5 if it matters.]]></description>
			<content:encoded><![CDATA[I have several desktops/laptops I need to switch over to the new free registration license, what is the best way to apply the license to all of them?<br />
<br />
We are using 2.3.6.5 if it matters.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Get the main window handle by PID]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7935</link>
			<pubDate>Mon, 02 Mar 2026 10:35:59 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7935</guid>
			<description><![CDATA[I would like to obtain the main window handle using a PID. Is there a simple way to achieve this in QM?<br />
The following code does not work.<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">T</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<br />
<span class='t'>int</span> i<span class='o'>=</span><span class='n'>4696</span><br />
<span class='fq'>out</span> <span class='fq'>win</span><span class='p'>(</span><span class='s'>""</span> <span class='s'>""</span> <span class='s'>""</span> <span class='n'>0</span> <span class='o'>F</span><span class='s'>"threadId={</span>i<span class='s'>}"</span><span class='p'>)</span></code></div></div> <br />
PowerShell implementation code: <br />
<blockquote class="mycode_quote"><cite>Quote:</cite>(Get-Process -Id 4696).MainWindowHandle</blockquote>
]]></description>
			<content:encoded><![CDATA[I would like to obtain the main window handle using a PID. Is there a simple way to achieve this in QM?<br />
The following code does not work.<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">T</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>out</span><br />
<br />
<span class='t'>int</span> i<span class='o'>=</span><span class='n'>4696</span><br />
<span class='fq'>out</span> <span class='fq'>win</span><span class='p'>(</span><span class='s'>""</span> <span class='s'>""</span> <span class='s'>""</span> <span class='n'>0</span> <span class='o'>F</span><span class='s'>"threadId={</span>i<span class='s'>}"</span><span class='p'>)</span></code></div></div> <br />
PowerShell implementation code: <br />
<blockquote class="mycode_quote"><cite>Quote:</cite>(Get-Process -Id 4696).MainWindowHandle</blockquote>
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[_s.beg("_")]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7933</link>
			<pubDate>Sun, 01 Mar 2026 13:32:40 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1516">Davider</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7933</guid>
			<description><![CDATA[Why does the following code return 0?<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">Macro51</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>_s<span class='o'>=</span><span class='s'>"_54001"</span><span class='p'>;</span> <span class='fq'>out</span> _s.<span class='fq'>beg</span><span class='p'>(</span><span class='s'>"﻿_"</span><span class='p'>)</span></code></div></div>]]></description>
			<content:encoded><![CDATA[Why does the following code return 0?<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">Macro51</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>_s<span class='o'>=</span><span class='s'>"_54001"</span><span class='p'>;</span> <span class='fq'>out</span> _s.<span class='fq'>beg</span><span class='p'>(</span><span class='s'>"﻿_"</span><span class='p'>)</span></code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Long press trigger]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7929</link>
			<pubDate>Sat, 31 Jan 2026 11:27:26 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=152">don_AC64</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7929</guid>
			<description><![CDATA[Is it possible to set a long press key as a trigger? For example, I would like a macro to be executed only if I keep the "a" key pressed for one second or more.]]></description>
			<content:encoded><![CDATA[Is it possible to set a long press key as a trigger? For example, I would like a macro to be executed only if I keep the "a" key pressed for one second or more.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[ap._getactive not working anymore]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7877</link>
			<pubDate>Sun, 28 Sep 2025 11:51:06 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=102">artuur9</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7877</guid>
			<description><![CDATA[I have a macro that connects to powerpoint, first lines are:<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">pp_run_macro_direct</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;/exe 1</span><br />
<br />
<span class='fq'>typelib</span> PowerPoint <span class='s'>"&#36;program files&#36;&#92;Microsoft Office&#92;Office15&#92;MSPPT.OLB"</span><br />
PowerPoint.Application ap._getactive<span class='p'>;</span> <span class='fq'>err</span> <span class='fq'>end</span> <span class='s'>"failed to connect to PowerPoint. Try to run this macro in separate process as User."</span></code></div></div><br />
<br />
It used to work on my old laptop with windows 10. On my new laptop with windows 11 the macro compiles fine, and the exe is created, but running it triggers the 'failed to connect to powerpoint' message (and powerpoint is running). The typelib line does point to the right OLB file (it is powerpoint 2013). <br />
<br />
How can I find out what the problem is?]]></description>
			<content:encoded><![CDATA[I have a macro that connects to powerpoint, first lines are:<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">pp_run_macro_direct</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;/exe 1</span><br />
<br />
<span class='fq'>typelib</span> PowerPoint <span class='s'>"&#36;program files&#36;&#92;Microsoft Office&#92;Office15&#92;MSPPT.OLB"</span><br />
PowerPoint.Application ap._getactive<span class='p'>;</span> <span class='fq'>err</span> <span class='fq'>end</span> <span class='s'>"failed to connect to PowerPoint. Try to run this macro in separate process as User."</span></code></div></div><br />
<br />
It used to work on my old laptop with windows 10. On my new laptop with windows 11 the macro compiles fine, and the exe is created, but running it triggers the 'failed to connect to powerpoint' message (and powerpoint is running). The typelib line does point to the right OLB file (it is powerpoint 2013). <br />
<br />
How can I find out what the problem is?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[processing keystrokes without missing any]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7871</link>
			<pubDate>Wed, 10 Sep 2025 19:30:20 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=102">artuur9</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7871</guid>
			<description><![CDATA[I have a macro that performs an incremental search in a predefined list. It starts like this:<br />
<br />
<br />
rep<br />
    int vk=wait(5 KF)<br />
    ;;processing of pressed key (adding it to the search string, finding the search string in predefined list, <br />
    ;;displaying the found items via onscreendisplay, etc.<br />
    <br />
<br />
The macro works, but the problem is that when the user types too fast, not all pressed keys are registered by the vk=wait(5 KF) instruction, probably because the processing part takes longer than it takes for a fast typist to type the next keystroke. <br />
<br />
How can I prevent this and make sure all keys pressed by the user are registered?]]></description>
			<content:encoded><![CDATA[I have a macro that performs an incremental search in a predefined list. It starts like this:<br />
<br />
<br />
rep<br />
    int vk=wait(5 KF)<br />
    ;;processing of pressed key (adding it to the search string, finding the search string in predefined list, <br />
    ;;displaying the found items via onscreendisplay, etc.<br />
    <br />
<br />
The macro works, but the problem is that when the user types too fast, not all pressed keys are registered by the vk=wait(5 KF) instruction, probably because the processing part takes longer than it takes for a fast typist to type the next keystroke. <br />
<br />
How can I prevent this and make sure all keys pressed by the user are registered?]]></content:encoded>
		</item>
	</channel>
</rss>