<?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 - QM extensions]]></title>
		<link>https://www.libreautomate.com/forum/</link>
		<description><![CDATA[LA/QM forum - https://www.libreautomate.com/forum]]></description>
		<pubDate>Mon, 04 May 2026 01:12:06 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Function WinSetOnTop (or not and/or activate, size it, move it to POS and/or Monitor)]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7885</link>
			<pubDate>Mon, 20 Oct 2025 07:46:18 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1594">MSCHINDI</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7885</guid>
			<description><![CDATA[To set dialog windows that normally do not have this Feature in QM (e.g. Input box, OpenSaveDialog...)  - or if you wish also for other existing windows - if you do not want to use - in this case - the built-in routines (e.g.: act, CenterWindow, MoveWindowToMonitor, mov, Zorder ...) here...<br />
<br />
I originally needed it in the company - to put QM dialogues always in the foreground, and to move them...<br />
<br />
Insert the function before the actual dialog call - and specify its title...<br />
<br />
The function also works for other existing Windows (see Firefox example...)<br />
<br />
The special thing:<br />
The function calls itself again as mac - so that the calling program can continue running and display the following dialog...<br />
<br />
Examles:<br />
Simply with a Windows title as parameter:<br />
;WinSetOnTop "Title" ;(Topmost with Activation and Center on Monitor with the mouse pointer is default)<br />
or<br />
<span style="text-decoration: line-through;" class="mycode_s">;NOT setontop with -2 Firefox (Nothing or NULL = setontop) and mov Windows to 100 200 and primary Monitor<br />
;WinSetOnTop "Mozilla Firefox* - *" "MozillaWindowClass" -2 100 200 -3<br />
;detto with setontop and moves the window on the monitor #2 (Short Title without Class Parameters - also works!)<br />
;WinSetOnTop "*Firefox*" "" 0 0 0 -2 (or -1 0 0 2)</span><br />
<br />
Update now: <br />
Additional specification of window size change, activation (or not) and maximization possible<br />
<br />
function# ~Title [~Class] [Topmost] [Activate] [left] [top] [width] [height] [Center]<br />
   WinSetOnTop "Title" "Class" [NOT/TOPMOST] [NOT/ACTIVATE] [x] [y] [width] [height] [NOT/CENTER/Monitor#]<br />
   Topmost: HWND_TOPMOST(HWND)=-1 (or 0 = Standard) or HWND_NOTOPMOST(HWND)=-2 (=Parameters von MS SetWindowPos)<br />
   Activate: (&gt;-1 = Standard), -1 or (more negativ - test it ;-) = NOT ACTIVATE<br />
   if you wish to "MOVE" to x AND y position then minimum VALUE = 1 (or -1...!) NOT 0<br />
   if only x = 0  or nothing = Center VERTICAL on Monitor with the mouse pointer<br />
   if only y = 0  or nothing = Center HORIZONTAL on Monitor with the mouse pointer<br />
   if x and y = -1 NOT Center - keeps the screen orientation<br />
   if x and/or y is negativer as -1 - offset from screen right and/or bottom.<br />
   if width and heigh = -1 POS window and max it at the end (original size)<br />
   if x, y, width and heigh = -1  max the window at the end (original POS and size)<br />
   if x = 0 and y = 0 and Move = 0 or nothing or -1 = Center on Monitor with the mouse pointer<br />
   if x = 0 and y = 0 and Move &lt;&gt; 0 = Center on Monitor with Center Parameter:<br />
   1-30 Monitor#, -1 mouse, -2 active window, -3 primary, or window handle<br />
   <br />
   Examles:<br />
   WinSetOnTop "Title"   (Topmost Active with Center on Monitor with the mouse pointer is default)<br />
   WinSetOnTop "w"   (Topmost with Activation and Center on Monitor with the mouse pointer is default)<br />
   WinSetOnTop F"*{w}*"   (detto only Part of Windows)<br />
   Setontop with -1 Firefox (or NULL = setontop) and Center and Active on Monitor with the mouse pointer<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" (Nothing or 0 or or -1)<br />
   detto with moves the window on the primary monitor<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" 0 0 0 0 0 0 -3 or or -1 0 0 0 0 0 -3)<br />
   detto Windows inactive<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" 0 -1 0 0 0 0 -3 or or -1 0 0 0 0 0 -3)<br />
   NOT setontop (with -2) Firefox and moving and resizing and not activation on Monitor#1<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" -2 -2 100 200 400 400 1<br />
   detto with moves the window on the monitor with the mouse pointer<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" -2 -2 100 300 400 400 -1 (or Nothing or 0)<br />
   detto with Center (x and y = 0)<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" -2 -2 0 0 400 400 -1 (or Nothing or 0)<br />
   detto with setontop, activation Center and no size change , moves the window to the monitor #2<br />
   WinSetOnTop "*Firefox*" "" 0 0 0 0 0 0 2 (or -1 0 0 0 0 0 2)<br />
   detto with setontop and moves the window on the monitor with the mouse pointer<br />
   WinSetOnTop "*Firefox*" "" 0 -1 0 0 0 0 0 (or Nothing or 0)<br />
   The same as<br />
   WinSetOnTop "*Firefox*"<br />
<br />
See integrated function Help too...<br />
<br />
Have fun with it!!!<br />
<br />
wfg. from Schindi aus Austria<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1389" target="_blank" title="">WinSetOnTop.qml</a> (Size: 8 KB / Downloads: 80)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[To set dialog windows that normally do not have this Feature in QM (e.g. Input box, OpenSaveDialog...)  - or if you wish also for other existing windows - if you do not want to use - in this case - the built-in routines (e.g.: act, CenterWindow, MoveWindowToMonitor, mov, Zorder ...) here...<br />
<br />
I originally needed it in the company - to put QM dialogues always in the foreground, and to move them...<br />
<br />
Insert the function before the actual dialog call - and specify its title...<br />
<br />
The function also works for other existing Windows (see Firefox example...)<br />
<br />
The special thing:<br />
The function calls itself again as mac - so that the calling program can continue running and display the following dialog...<br />
<br />
Examles:<br />
Simply with a Windows title as parameter:<br />
;WinSetOnTop "Title" ;(Topmost with Activation and Center on Monitor with the mouse pointer is default)<br />
or<br />
<span style="text-decoration: line-through;" class="mycode_s">;NOT setontop with -2 Firefox (Nothing or NULL = setontop) and mov Windows to 100 200 and primary Monitor<br />
;WinSetOnTop "Mozilla Firefox* - *" "MozillaWindowClass" -2 100 200 -3<br />
;detto with setontop and moves the window on the monitor #2 (Short Title without Class Parameters - also works!)<br />
;WinSetOnTop "*Firefox*" "" 0 0 0 -2 (or -1 0 0 2)</span><br />
<br />
Update now: <br />
Additional specification of window size change, activation (or not) and maximization possible<br />
<br />
function# ~Title [~Class] [Topmost] [Activate] [left] [top] [width] [height] [Center]<br />
   WinSetOnTop "Title" "Class" [NOT/TOPMOST] [NOT/ACTIVATE] [x] [y] [width] [height] [NOT/CENTER/Monitor#]<br />
   Topmost: HWND_TOPMOST(HWND)=-1 (or 0 = Standard) or HWND_NOTOPMOST(HWND)=-2 (=Parameters von MS SetWindowPos)<br />
   Activate: (&gt;-1 = Standard), -1 or (more negativ - test it ;-) = NOT ACTIVATE<br />
   if you wish to "MOVE" to x AND y position then minimum VALUE = 1 (or -1...!) NOT 0<br />
   if only x = 0  or nothing = Center VERTICAL on Monitor with the mouse pointer<br />
   if only y = 0  or nothing = Center HORIZONTAL on Monitor with the mouse pointer<br />
   if x and y = -1 NOT Center - keeps the screen orientation<br />
   if x and/or y is negativer as -1 - offset from screen right and/or bottom.<br />
   if width and heigh = -1 POS window and max it at the end (original size)<br />
   if x, y, width and heigh = -1  max the window at the end (original POS and size)<br />
   if x = 0 and y = 0 and Move = 0 or nothing or -1 = Center on Monitor with the mouse pointer<br />
   if x = 0 and y = 0 and Move &lt;&gt; 0 = Center on Monitor with Center Parameter:<br />
   1-30 Monitor#, -1 mouse, -2 active window, -3 primary, or window handle<br />
   <br />
   Examles:<br />
   WinSetOnTop "Title"   (Topmost Active with Center on Monitor with the mouse pointer is default)<br />
   WinSetOnTop "w"   (Topmost with Activation and Center on Monitor with the mouse pointer is default)<br />
   WinSetOnTop F"*{w}*"   (detto only Part of Windows)<br />
   Setontop with -1 Firefox (or NULL = setontop) and Center and Active on Monitor with the mouse pointer<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" (Nothing or 0 or or -1)<br />
   detto with moves the window on the primary monitor<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" 0 0 0 0 0 0 -3 or or -1 0 0 0 0 0 -3)<br />
   detto Windows inactive<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" 0 -1 0 0 0 0 -3 or or -1 0 0 0 0 0 -3)<br />
   NOT setontop (with -2) Firefox and moving and resizing and not activation on Monitor#1<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" -2 -2 100 200 400 400 1<br />
   detto with moves the window on the monitor with the mouse pointer<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" -2 -2 100 300 400 400 -1 (or Nothing or 0)<br />
   detto with Center (x and y = 0)<br />
   WinSetOnTop "Mozilla Firefox*" "MozillaWindowClass" -2 -2 0 0 400 400 -1 (or Nothing or 0)<br />
   detto with setontop, activation Center and no size change , moves the window to the monitor #2<br />
   WinSetOnTop "*Firefox*" "" 0 0 0 0 0 0 2 (or -1 0 0 0 0 0 2)<br />
   detto with setontop and moves the window on the monitor with the mouse pointer<br />
   WinSetOnTop "*Firefox*" "" 0 -1 0 0 0 0 0 (or Nothing or 0)<br />
   The same as<br />
   WinSetOnTop "*Firefox*"<br />
<br />
See integrated function Help too...<br />
<br />
Have fun with it!!!<br />
<br />
wfg. from Schindi aus Austria<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1389" target="_blank" title="">WinSetOnTop.qml</a> (Size: 8 KB / Downloads: 80)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Get Week of Year - (Funktion Kalenderwoche)]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7874</link>
			<pubDate>Thu, 25 Sep 2025 07:32:30 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=1594">MSCHINDI</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7874</guid>
			<description><![CDATA[If you need a Funktion for Week of the Year...<br />
<br />
(Internationale ISO 8601 Kalender-Wochen-Nummerierung)<br />
<br />
Siehe <br />
<a href="https://kalenderwoche-online.de/" target="_blank" rel="noopener" class="mycode_url">https://kalenderwoche-online.de<br />
https://www.brepols.com/Data/Downloads/ISO8601_RULE_FOR_DEFINING_WEEKNUMBERS.pdf</a><br />
<br />
The QM - built-in function: s.time( "%W" ) gives me an incorrect result for today: week 38 instead of 39 (= the same as C style parameter %U)<br />
<br />
New: Correction of the FIRST and the LAST Days in the Year (Schaltjahre / Leap years wo der 1.1. auf einen Mittwoch fällt, sind jetzt auch noch implementiert - diese haben auch 53 KW - hiezu verwenden ich die Function / I Use: "GetDaysInMonth" from TheVig and rename it to Funktion: "Schaltjahr")<br />
<br />
Bemerkung: Ist der Rückgabewert "0" so liegt der Tag noch in der letzen KW des Vorjahres - die letzte KW des Vorjahres wird in einem 2. Durchgang ermittelt...<br />
<br />
Neu: Jetzt ist auch der Funktionsaufruf mit/ohne Datumsangabe und Rückgabewert 2-stellig oder im internationalen Format möglich...<br />
<br />
If there's an even simpler solution in QM (NOT MS-EXCEL or MS-OL...), please post it... <img src="https://www.libreautomate.com/forum/images/smilies/smile.png" alt="Smile" title="Smile" class="smilie smilie_1" /><br />
<br />
Alle benötigten QM-Macros samt einem Beispiel- (Test-) Macro und ein KW-Tray Programm sind im Anhang zum Download!<br />
see also: <a href="https://www.libreautomate.com/forum/showthread.php?tid=7878" target="_blank" rel="noopener" class="mycode_url">https://www.libreautomate.com/forum/show...p?tid=7878</a><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>function'str [iY] [iM] [iD]&nbsp;&nbsp;;;WeekOfYear<br />
<br />
&nbsp;&nbsp;Die ISO 8601-Wochennummerierung folgt diesen Regeln:<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Wochenstart: Jede Woche beginnt an einem Montag und endet an einem Sonntag.<br />
&nbsp;&nbsp;&nbsp;&nbsp;Erste Woche: Die erste Woche des Jahres ist diejenige, die den ersten Donnerstag des Jahres enthält.<br />
&nbsp;&nbsp;&nbsp;&nbsp;Eine 53. Woche tritt auf, wenn der erste und der letzte Tag des Jahres ein Donnerstag ist,<br />
&nbsp;&nbsp;&nbsp;&nbsp;oder ein Schaltjahr wo der 1.Tag ein Mittwoch ist...<br />
&nbsp;&nbsp;&nbsp;&nbsp;Wenn vor der Jahreszahl ein Minuszeichen angegeben wird, wird nur die KW (=2-stelliger String) ausgegeben!<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Beispiele/Examples:<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear() or WeekOfYear(0) or WeekOfYear(-1) ;;Gets KW-String or KW-Short String from Todays Date<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( 2026 12 31 );;Gets KW or KW-String from 31.Dez.2026 = 2026-W53-4<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( 2027 01 01 );;Gets KW or KW-String from 1.Jän.2027 = Last KW from Last Year = 2026-W53-5<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( 2027 01 04 );;Gets KW or KW-String from 4.Jän.2027 = 1. Day in 1. KW = 2027-W01-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( -2027 01 04 );;Gets only KW from 4.Jän.2027 = 1. Day in 1. KW = 01<br />
 <br />
DATE dD<br />
str sY<br />
<br />
if iY &lt;= 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;sY.time( "%Y" )<br />
else<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD=F"{iD}/{iM}/{iY}"<br />
&nbsp;&nbsp;&nbsp;&nbsp;sY.time( dD "%Y" )<br />
if iY &lt; -1<br />
&nbsp;&nbsp;&nbsp;&nbsp;int iNoString=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iY=iY*-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD=F"{iD}/{iM}/{iY}"<br />
&nbsp;&nbsp;&nbsp;&nbsp;sY.time( dD "%Y" )<br />
<br />
if iY=-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iNoString=1<br />
<br />
int iGLY=0<br />
<br />
iY=val(sY)<br />
<br />
 _GLY<br />
<br />
;Jahr ermitteln<br />
;sY=2027<br />
;out F"01/01/{iY}"<br />
<br />
;out F"iGLY={iGLY}"<br />
if iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iY=iY-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;;out iY<br />
<br />
;Wochentag ermitteln (nur 1. Durchlauf)<br />
if iGLY=0<br />
&nbsp;&nbsp;&nbsp;&nbsp;str sDOW.time( dD "%w")<br />
&nbsp;&nbsp;&nbsp;&nbsp;if sDOW=0;sDOW=7<br />
&nbsp;&nbsp;&nbsp;&nbsp;;mes sDOW<br />
<br />
;Wochentag des 01.01. ermitteln<br />
DATE dD0101=F"01/01/{iY}"<br />
if iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD0101=F"31/12/{iY}"<br />
<br />
;out F"DATE:{dD0101}"<br />
<br />
str sDN0101.time( dD0101 "%w")<br />
<br />
if sDN0101="0"<br />
&nbsp;&nbsp;&nbsp;&nbsp;sDN0101="7"&nbsp;&nbsp;;;Sunday = 7. Day for Calc!<br />
;out F"sDN0101={sDN0101}"<br />
<br />
int iKorr0101=1<br />
if val(sDN0101)&gt;4<br />
&nbsp;&nbsp;&nbsp;&nbsp;iKorr0101=0<br />
<br />
;;Bugfix!<br />
if val(sDN0101)=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iKorr0101=0<br />
<br />
;out iKorr0101<br />
<br />
int iWOY<br />
<br />
iWOY=val(sY.time(dD "%W"))+iKorr0101<br />
if iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD=F"31/12/{iY}"<br />
&nbsp;&nbsp;&nbsp;&nbsp;iWOY=val(sY.time(dD "%W"))+iKorr0101<br />
<br />
;out iWOY<br />
<br />
int iYC=0<br />
if iWOY&gt;52 ;;Korr KW 53<br />
&nbsp;&nbsp;&nbsp;&nbsp;iWOY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iYC=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;if val(sDN0101)=4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iWOY=53<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iYC=0<br />
&nbsp;&nbsp;&nbsp;&nbsp;;ermittle ob Schaltjahr<br />
&nbsp;&nbsp;&nbsp;&nbsp;if Schaltjahr(02 iY)=29&nbsp;&nbsp;;;I Use Function: "GetDaysInMonth" from TheVig and rename it to Funktion: "Schaltjahr")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if val(sDN0101)=3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;mes "Schaltjahr!!!"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iWOY=53<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iYC=0<br />
<br />
;out iWOY<br />
<br />
if iWOY=0<br />
&nbsp;&nbsp;&nbsp;&nbsp;;mes "GLY=true"<br />
&nbsp;&nbsp;&nbsp;&nbsp;iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;goto _GLY<br />
<br />
;;internationales Format:<br />
<br />
str sWOY=iWOY<br />
if iWOY&lt;10<br />
&nbsp;&nbsp;&nbsp;&nbsp;sWOY=F"0{iWOY}"<br />
<br />
if iNoString=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;ret sWOY<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
;out F"{iY+iYC}-W{sWOY}-{sDOW}"<br />
<br />
ret F"{iY+iYC}-W{sWOY}-{sDOW}"<br />
<br />
end</code></div></div><br />
wfg. from Schindi aus Austria<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1375" target="_blank" title="">Test_WeekOfYear_Func.qml</a> (Size: 4 KB / Downloads: 67)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1376" target="_blank" title="">WeekOfYear.qml</a> (Size: 5 KB / Downloads: 59)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1377" target="_blank" title="">Schaltjahr.qml</a> (Size: 3 KB / Downloads: 59)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1382" target="_blank" title="">KW-Tray.zip</a> (Size: 270.85 KB / Downloads: 70)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[If you need a Funktion for Week of the Year...<br />
<br />
(Internationale ISO 8601 Kalender-Wochen-Nummerierung)<br />
<br />
Siehe <br />
<a href="https://kalenderwoche-online.de/" target="_blank" rel="noopener" class="mycode_url">https://kalenderwoche-online.de<br />
https://www.brepols.com/Data/Downloads/ISO8601_RULE_FOR_DEFINING_WEEKNUMBERS.pdf</a><br />
<br />
The QM - built-in function: s.time( "%W" ) gives me an incorrect result for today: week 38 instead of 39 (= the same as C style parameter %U)<br />
<br />
New: Correction of the FIRST and the LAST Days in the Year (Schaltjahre / Leap years wo der 1.1. auf einen Mittwoch fällt, sind jetzt auch noch implementiert - diese haben auch 53 KW - hiezu verwenden ich die Function / I Use: "GetDaysInMonth" from TheVig and rename it to Funktion: "Schaltjahr")<br />
<br />
Bemerkung: Ist der Rückgabewert "0" so liegt der Tag noch in der letzen KW des Vorjahres - die letzte KW des Vorjahres wird in einem 2. Durchgang ermittelt...<br />
<br />
Neu: Jetzt ist auch der Funktionsaufruf mit/ohne Datumsangabe und Rückgabewert 2-stellig oder im internationalen Format möglich...<br />
<br />
If there's an even simpler solution in QM (NOT MS-EXCEL or MS-OL...), please post it... <img src="https://www.libreautomate.com/forum/images/smilies/smile.png" alt="Smile" title="Smile" class="smilie smilie_1" /><br />
<br />
Alle benötigten QM-Macros samt einem Beispiel- (Test-) Macro und ein KW-Tray Programm sind im Anhang zum Download!<br />
see also: <a href="https://www.libreautomate.com/forum/showthread.php?tid=7878" target="_blank" rel="noopener" class="mycode_url">https://www.libreautomate.com/forum/show...p?tid=7878</a><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>function'str [iY] [iM] [iD]&nbsp;&nbsp;;;WeekOfYear<br />
<br />
&nbsp;&nbsp;Die ISO 8601-Wochennummerierung folgt diesen Regeln:<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Wochenstart: Jede Woche beginnt an einem Montag und endet an einem Sonntag.<br />
&nbsp;&nbsp;&nbsp;&nbsp;Erste Woche: Die erste Woche des Jahres ist diejenige, die den ersten Donnerstag des Jahres enthält.<br />
&nbsp;&nbsp;&nbsp;&nbsp;Eine 53. Woche tritt auf, wenn der erste und der letzte Tag des Jahres ein Donnerstag ist,<br />
&nbsp;&nbsp;&nbsp;&nbsp;oder ein Schaltjahr wo der 1.Tag ein Mittwoch ist...<br />
&nbsp;&nbsp;&nbsp;&nbsp;Wenn vor der Jahreszahl ein Minuszeichen angegeben wird, wird nur die KW (=2-stelliger String) ausgegeben!<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Beispiele/Examples:<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear() or WeekOfYear(0) or WeekOfYear(-1) ;;Gets KW-String or KW-Short String from Todays Date<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( 2026 12 31 );;Gets KW or KW-String from 31.Dez.2026 = 2026-W53-4<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( 2027 01 01 );;Gets KW or KW-String from 1.Jän.2027 = Last KW from Last Year = 2026-W53-5<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( 2027 01 04 );;Gets KW or KW-String from 4.Jän.2027 = 1. Day in 1. KW = 2027-W01-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;WeekOfYear( -2027 01 04 );;Gets only KW from 4.Jän.2027 = 1. Day in 1. KW = 01<br />
 <br />
DATE dD<br />
str sY<br />
<br />
if iY &lt;= 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;sY.time( "%Y" )<br />
else<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD=F"{iD}/{iM}/{iY}"<br />
&nbsp;&nbsp;&nbsp;&nbsp;sY.time( dD "%Y" )<br />
if iY &lt; -1<br />
&nbsp;&nbsp;&nbsp;&nbsp;int iNoString=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iY=iY*-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD=F"{iD}/{iM}/{iY}"<br />
&nbsp;&nbsp;&nbsp;&nbsp;sY.time( dD "%Y" )<br />
<br />
if iY=-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iNoString=1<br />
<br />
int iGLY=0<br />
<br />
iY=val(sY)<br />
<br />
 _GLY<br />
<br />
;Jahr ermitteln<br />
;sY=2027<br />
;out F"01/01/{iY}"<br />
<br />
;out F"iGLY={iGLY}"<br />
if iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iY=iY-1<br />
&nbsp;&nbsp;&nbsp;&nbsp;;out iY<br />
<br />
;Wochentag ermitteln (nur 1. Durchlauf)<br />
if iGLY=0<br />
&nbsp;&nbsp;&nbsp;&nbsp;str sDOW.time( dD "%w")<br />
&nbsp;&nbsp;&nbsp;&nbsp;if sDOW=0;sDOW=7<br />
&nbsp;&nbsp;&nbsp;&nbsp;;mes sDOW<br />
<br />
;Wochentag des 01.01. ermitteln<br />
DATE dD0101=F"01/01/{iY}"<br />
if iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD0101=F"31/12/{iY}"<br />
<br />
;out F"DATE:{dD0101}"<br />
<br />
str sDN0101.time( dD0101 "%w")<br />
<br />
if sDN0101="0"<br />
&nbsp;&nbsp;&nbsp;&nbsp;sDN0101="7"&nbsp;&nbsp;;;Sunday = 7. Day for Calc!<br />
;out F"sDN0101={sDN0101}"<br />
<br />
int iKorr0101=1<br />
if val(sDN0101)&gt;4<br />
&nbsp;&nbsp;&nbsp;&nbsp;iKorr0101=0<br />
<br />
;;Bugfix!<br />
if val(sDN0101)=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iKorr0101=0<br />
<br />
;out iKorr0101<br />
<br />
int iWOY<br />
<br />
iWOY=val(sY.time(dD "%W"))+iKorr0101<br />
if iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;dD=F"31/12/{iY}"<br />
&nbsp;&nbsp;&nbsp;&nbsp;iWOY=val(sY.time(dD "%W"))+iKorr0101<br />
<br />
;out iWOY<br />
<br />
int iYC=0<br />
if iWOY&gt;52 ;;Korr KW 53<br />
&nbsp;&nbsp;&nbsp;&nbsp;iWOY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;iYC=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;if val(sDN0101)=4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iWOY=53<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iYC=0<br />
&nbsp;&nbsp;&nbsp;&nbsp;;ermittle ob Schaltjahr<br />
&nbsp;&nbsp;&nbsp;&nbsp;if Schaltjahr(02 iY)=29&nbsp;&nbsp;;;I Use Function: "GetDaysInMonth" from TheVig and rename it to Funktion: "Schaltjahr")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if val(sDN0101)=3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;mes "Schaltjahr!!!"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iWOY=53<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iYC=0<br />
<br />
;out iWOY<br />
<br />
if iWOY=0<br />
&nbsp;&nbsp;&nbsp;&nbsp;;mes "GLY=true"<br />
&nbsp;&nbsp;&nbsp;&nbsp;iGLY=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;goto _GLY<br />
<br />
;;internationales Format:<br />
<br />
str sWOY=iWOY<br />
if iWOY&lt;10<br />
&nbsp;&nbsp;&nbsp;&nbsp;sWOY=F"0{iWOY}"<br />
<br />
if iNoString=1<br />
&nbsp;&nbsp;&nbsp;&nbsp;ret sWOY<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
;out F"{iY+iYC}-W{sWOY}-{sDOW}"<br />
<br />
ret F"{iY+iYC}-W{sWOY}-{sDOW}"<br />
<br />
end</code></div></div><br />
wfg. from Schindi aus Austria<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1375" target="_blank" title="">Test_WeekOfYear_Func.qml</a> (Size: 4 KB / Downloads: 67)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1376" target="_blank" title="">WeekOfYear.qml</a> (Size: 5 KB / Downloads: 59)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1377" target="_blank" title="">Schaltjahr.qml</a> (Size: 3 KB / Downloads: 59)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1382" target="_blank" title="">KW-Tray.zip</a> (Size: 270.85 KB / Downloads: 70)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Parse and create JSON with Chilkat ActiveX]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7832</link>
			<pubDate>Tue, 10 Jun 2025 07:29:50 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7832</guid>
			<description><![CDATA[<span style="font-weight: bold;" class="mycode_b">Setup</span><br />
<br />
Download the 32-bit zip file from <a href="https://www.chilkatsoft.com/downloads_ActiveX.asp" target="_blank" rel="noopener" class="mycode_url">https://www.chilkatsoft.com/downloads_ActiveX.asp</a><br />
Unzip the dll to the QM folder. Don't need other files.<br />
<br />
Run this macro if need a manifest file for registration-free COM activation using <span style="font-weight: bold;" class="mycode_b">__ComActivator</span>.<br />
Macro <span style="font-weight: bold;" class="mycode_b">Chilkat create manifest</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Creates manifest file for __ComActivator ca.Activate("&#36;qm&#36;&#92;ChilkatAx-win32.X.manifest")</span><br />
<br />
<span class='fu'>__ComActivator_CreateManifest</span> <span class='s'>"&#36;qm&#36;&#92;ChilkatAx-win32.dll"</span></code></div></div><br />
<span style="font-weight: bold;" class="mycode_b">Examples</span><br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">Parse JSON</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Uses Chilkat ActiveX.</span><br />
<span class='c'>;Docs: https://www.chilkatsoft.com/refdoc/xChilkatJsonObjectRef.html</span><br />
<span class='c'>;Download: https://www.chilkatsoft.com/downloads_ActiveX.asp</span><br />
<span class='c'>;JSONPath online evaluator and docs: https://jsonpath.com/</span><br />
<br />
<span class='c'>;__ComActivator ca.Activate("&#36;qm&#36;&#92;ChilkatAx-win32.X.manifest") ;;enable this if want to use the library without COM registration, eg in exe. Note: QM anyway auto-registers when compiling.</span><br />
<span class='fq'>typelib</span> <span class='lib'>Chilkat</span> <span class='s'>"&#36;qm&#36;&#92;ChilkatAx-win32.dll"</span><br />
<br />
<span class='fq'>out</span><br />
<br />
<span class='t'>str</span> json<span class='o'>=</span><br />
<span class='s'>;{</span><br />
<span class='s'>;"one":"ONE",</span><br />
<span class='s'>;"two":2,</span><br />
<span class='s'>;"obj": {</span><br />
<span class='s'>;;"three":"THREE",</span><br />
<span class='s'>;;"four":"FOUR",</span><br />
<span class='s'>;;"bool":true</span><br />
<span class='s'>;},</span><br />
<span class='s'>;"arr":["A", "B", {"six":"SIX","seven":"SEVEN"}]</span><br />
<span class='s'>;}</span><br />
<br />
<span class='t'>ChilkatJsonObject</span> j.<span class='fq'>_create</span><br />
j.<span class='fd'>Load</span><span class='p'>(</span>json<span class='p'>)</span><br />
<br />
<span class='fq'>out</span> j.<span class='fd'>StringAt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>IntAt</span><span class='p'>(</span><span class='n'>1</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>IntOf</span><span class='p'>(</span><span class='s'>"two"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>".obj.four"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>BoolOf</span><span class='p'>(</span><span class='s'>".obj.bool"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>FindObjectWithMember</span><span class='p'>(</span><span class='s'>"three"</span><span class='p'>)</span>.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>"four"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>FindObjectWithMember</span><span class='p'>(</span><span class='s'>"six"</span><span class='p'>)</span>.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>"seven"</span><span class='p'>)</span><br />
<br />
<span class='c'>;arrays:</span><br />
<span class='fq'>out</span> j.<span class='fd'>ArrayOf</span><span class='p'>(</span><span class='s'>"arr"</span><span class='p'>)</span>.<span class='fd'>StringAt</span><span class='p'>(</span><span class='n'>1</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<span class='c'>;out j.StringOf(".arr[1]") ;;why fails?</span><br />
<span class='fq'>out</span> j.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>".arr[1:2]"</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<span class='fq'>out</span> j.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>".arr[2:3].six"</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<span class='fq'>out</span> j.<span class='fd'>ArrayOf</span><span class='p'>(</span><span class='s'>"arr"</span><span class='p'>)</span>.<span class='fd'>ObjectAt</span><span class='p'>(</span><span class='n'>2</span><span class='p'>)</span>.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>"seven"</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<br />
<span class='c'>;if need a variable:</span><br />
<span class='c'>;IChilkatJsonArray a=j.ArrayOf("arr"); out a.StringAt(1)</span><br />
<span class='c'>;IChilkatJsonObject o=j.ArrayOf("arr").ObjectAt(2); out o.StringOf("six")</span><br />
<br />
<span class='c'>;the functions don't throw exceptions but set last error:</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>j.<span class='fd'>LastMethodSuccess</span><span class='p'>)</span> <span class='fq'>out</span> j.<span class='fd'>LastErrorText</span></code></div></div><br />
Macro <span style="font-weight: bold;" class="mycode_b">Create JSON</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Uses Chilkat ActiveX.</span><br />
<span class='c'>;Docs: https://www.chilkatsoft.com/refdoc/xChilkatJsonObjectRef.html</span><br />
<span class='c'>;Download: https://www.chilkatsoft.com/downloads_ActiveX.asp</span><br />
<br />
<span class='c'>;__ComActivator ca.Activate("&#36;qm&#36;&#92;ChilkatAx-win32.X.manifest") ;;enable this if want to use the library without COM registration, eg in exe. Note: QM anyway auto-registers when compiling.</span><br />
<span class='fq'>typelib</span> <span class='lib'>Chilkat</span> <span class='s'>"&#36;qm&#36;&#92;ChilkatAx-win32.dll"</span><br />
<br />
<span class='fq'>out</span><br />
<br />
<span class='t'>ChilkatJsonObject</span> j.<span class='fq'>_create</span><br />
j.<span class='fd'>AppendString</span><span class='p'>(</span><span class='s'>"one"</span> <span class='s'>"ONE"</span><span class='p'>)</span><br />
j.<span class='fd'>AppendInt</span><span class='p'>(</span><span class='s'>"two"</span> <span class='n'>2</span><span class='p'>)</span><br />
<span class='t'>IChilkatJsonObject</span> o<span class='o'>=</span>j.<span class='fd'>AppendObject</span><span class='p'>(</span><span class='s'>"obj"</span><span class='p'>)</span><br />
o.<span class='fd'>AppendString</span><span class='p'>(</span><span class='s'>"three"</span> <span class='s'>"THREE"</span><span class='p'>)</span><br />
o.<span class='fd'>AppendBool</span><span class='p'>(</span><span class='s'>"four"</span> <span class='n'>1</span><span class='p'>)</span><br />
<span class='t'>IChilkatJsonArray</span> a<span class='o'>=</span>j.<span class='fd'>AppendArray</span><span class='p'>(</span><span class='s'>"arr"</span><span class='p'>)</span><br />
a.<span class='fd'>AddStringAt</span><span class='p'>(</span><span class='o'>-</span><span class='n'>1</span> <span class='s'>"A"</span><span class='p'>)</span><br />
a.<span class='fd'>AddStringAt</span><span class='p'>(</span><span class='o'>-</span><span class='n'>1</span> <span class='s'>"B"</span><span class='p'>)</span><br />
a.<span class='fd'>AddObjectAt</span><span class='p'>(</span><span class='o'>-</span><span class='n'>1</span><span class='p'>)</span><br />
a.<span class='fd'>ObjectAt</span><span class='p'>(</span>a.<span class='fd'>size</span><span class='o'>-</span><span class='n'>1</span><span class='p'>)</span>.<span class='fd'>AppendString</span><span class='p'>(</span><span class='s'>"C"</span> <span class='s'>"CC"</span><span class='p'>)</span><br />
a.<span class='fd'>ObjectAt</span><span class='p'>(</span>a.<span class='fd'>size</span><span class='o'>-</span><span class='n'>1</span><span class='p'>)</span>.<span class='fd'>AppendBool</span><span class='p'>(</span><span class='s'>"D"</span> <span class='n'>1</span><span class='p'>)</span><br />
<br />
j.<span class='fd'>EmitCompact</span><span class='o'>=</span><span class='n'>0</span><br />
<span class='t'>str</span> json<span class='o'>=</span>j.<span class='fd'>Emit</span><span class='p'>()</span><br />
<span class='fq'>out</span> json</code></div></div>]]></description>
			<content:encoded><![CDATA[<span style="font-weight: bold;" class="mycode_b">Setup</span><br />
<br />
Download the 32-bit zip file from <a href="https://www.chilkatsoft.com/downloads_ActiveX.asp" target="_blank" rel="noopener" class="mycode_url">https://www.chilkatsoft.com/downloads_ActiveX.asp</a><br />
Unzip the dll to the QM folder. Don't need other files.<br />
<br />
Run this macro if need a manifest file for registration-free COM activation using <span style="font-weight: bold;" class="mycode_b">__ComActivator</span>.<br />
Macro <span style="font-weight: bold;" class="mycode_b">Chilkat create manifest</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Creates manifest file for __ComActivator ca.Activate("&#36;qm&#36;&#92;ChilkatAx-win32.X.manifest")</span><br />
<br />
<span class='fu'>__ComActivator_CreateManifest</span> <span class='s'>"&#36;qm&#36;&#92;ChilkatAx-win32.dll"</span></code></div></div><br />
<span style="font-weight: bold;" class="mycode_b">Examples</span><br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">Parse JSON</span> <span/><br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Uses Chilkat ActiveX.</span><br />
<span class='c'>;Docs: https://www.chilkatsoft.com/refdoc/xChilkatJsonObjectRef.html</span><br />
<span class='c'>;Download: https://www.chilkatsoft.com/downloads_ActiveX.asp</span><br />
<span class='c'>;JSONPath online evaluator and docs: https://jsonpath.com/</span><br />
<br />
<span class='c'>;__ComActivator ca.Activate("&#36;qm&#36;&#92;ChilkatAx-win32.X.manifest") ;;enable this if want to use the library without COM registration, eg in exe. Note: QM anyway auto-registers when compiling.</span><br />
<span class='fq'>typelib</span> <span class='lib'>Chilkat</span> <span class='s'>"&#36;qm&#36;&#92;ChilkatAx-win32.dll"</span><br />
<br />
<span class='fq'>out</span><br />
<br />
<span class='t'>str</span> json<span class='o'>=</span><br />
<span class='s'>;{</span><br />
<span class='s'>;"one":"ONE",</span><br />
<span class='s'>;"two":2,</span><br />
<span class='s'>;"obj": {</span><br />
<span class='s'>;;"three":"THREE",</span><br />
<span class='s'>;;"four":"FOUR",</span><br />
<span class='s'>;;"bool":true</span><br />
<span class='s'>;},</span><br />
<span class='s'>;"arr":["A", "B", {"six":"SIX","seven":"SEVEN"}]</span><br />
<span class='s'>;}</span><br />
<br />
<span class='t'>ChilkatJsonObject</span> j.<span class='fq'>_create</span><br />
j.<span class='fd'>Load</span><span class='p'>(</span>json<span class='p'>)</span><br />
<br />
<span class='fq'>out</span> j.<span class='fd'>StringAt</span><span class='p'>(</span><span class='n'>0</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>IntAt</span><span class='p'>(</span><span class='n'>1</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>IntOf</span><span class='p'>(</span><span class='s'>"two"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>".obj.four"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>BoolOf</span><span class='p'>(</span><span class='s'>".obj.bool"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>FindObjectWithMember</span><span class='p'>(</span><span class='s'>"three"</span><span class='p'>)</span>.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>"four"</span><span class='p'>)</span><br />
<span class='fq'>out</span> j.<span class='fd'>FindObjectWithMember</span><span class='p'>(</span><span class='s'>"six"</span><span class='p'>)</span>.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>"seven"</span><span class='p'>)</span><br />
<br />
<span class='c'>;arrays:</span><br />
<span class='fq'>out</span> j.<span class='fd'>ArrayOf</span><span class='p'>(</span><span class='s'>"arr"</span><span class='p'>)</span>.<span class='fd'>StringAt</span><span class='p'>(</span><span class='n'>1</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<span class='c'>;out j.StringOf(".arr[1]") ;;why fails?</span><br />
<span class='fq'>out</span> j.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>".arr[1:2]"</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<span class='fq'>out</span> j.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>".arr[2:3].six"</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<span class='fq'>out</span> j.<span class='fd'>ArrayOf</span><span class='p'>(</span><span class='s'>"arr"</span><span class='p'>)</span>.<span class='fd'>ObjectAt</span><span class='p'>(</span><span class='n'>2</span><span class='p'>)</span>.<span class='fd'>StringOf</span><span class='p'>(</span><span class='s'>"seven"</span><span class='p'>)</span> <span class='c2'>;;OK</span><br />
<br />
<span class='c'>;if need a variable:</span><br />
<span class='c'>;IChilkatJsonArray a=j.ArrayOf("arr"); out a.StringAt(1)</span><br />
<span class='c'>;IChilkatJsonObject o=j.ArrayOf("arr").ObjectAt(2); out o.StringOf("six")</span><br />
<br />
<span class='c'>;the functions don't throw exceptions but set last error:</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>j.<span class='fd'>LastMethodSuccess</span><span class='p'>)</span> <span class='fq'>out</span> j.<span class='fd'>LastErrorText</span></code></div></div><br />
Macro <span style="font-weight: bold;" class="mycode_b">Create JSON</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Uses Chilkat ActiveX.</span><br />
<span class='c'>;Docs: https://www.chilkatsoft.com/refdoc/xChilkatJsonObjectRef.html</span><br />
<span class='c'>;Download: https://www.chilkatsoft.com/downloads_ActiveX.asp</span><br />
<br />
<span class='c'>;__ComActivator ca.Activate("&#36;qm&#36;&#92;ChilkatAx-win32.X.manifest") ;;enable this if want to use the library without COM registration, eg in exe. Note: QM anyway auto-registers when compiling.</span><br />
<span class='fq'>typelib</span> <span class='lib'>Chilkat</span> <span class='s'>"&#36;qm&#36;&#92;ChilkatAx-win32.dll"</span><br />
<br />
<span class='fq'>out</span><br />
<br />
<span class='t'>ChilkatJsonObject</span> j.<span class='fq'>_create</span><br />
j.<span class='fd'>AppendString</span><span class='p'>(</span><span class='s'>"one"</span> <span class='s'>"ONE"</span><span class='p'>)</span><br />
j.<span class='fd'>AppendInt</span><span class='p'>(</span><span class='s'>"two"</span> <span class='n'>2</span><span class='p'>)</span><br />
<span class='t'>IChilkatJsonObject</span> o<span class='o'>=</span>j.<span class='fd'>AppendObject</span><span class='p'>(</span><span class='s'>"obj"</span><span class='p'>)</span><br />
o.<span class='fd'>AppendString</span><span class='p'>(</span><span class='s'>"three"</span> <span class='s'>"THREE"</span><span class='p'>)</span><br />
o.<span class='fd'>AppendBool</span><span class='p'>(</span><span class='s'>"four"</span> <span class='n'>1</span><span class='p'>)</span><br />
<span class='t'>IChilkatJsonArray</span> a<span class='o'>=</span>j.<span class='fd'>AppendArray</span><span class='p'>(</span><span class='s'>"arr"</span><span class='p'>)</span><br />
a.<span class='fd'>AddStringAt</span><span class='p'>(</span><span class='o'>-</span><span class='n'>1</span> <span class='s'>"A"</span><span class='p'>)</span><br />
a.<span class='fd'>AddStringAt</span><span class='p'>(</span><span class='o'>-</span><span class='n'>1</span> <span class='s'>"B"</span><span class='p'>)</span><br />
a.<span class='fd'>AddObjectAt</span><span class='p'>(</span><span class='o'>-</span><span class='n'>1</span><span class='p'>)</span><br />
a.<span class='fd'>ObjectAt</span><span class='p'>(</span>a.<span class='fd'>size</span><span class='o'>-</span><span class='n'>1</span><span class='p'>)</span>.<span class='fd'>AppendString</span><span class='p'>(</span><span class='s'>"C"</span> <span class='s'>"CC"</span><span class='p'>)</span><br />
a.<span class='fd'>ObjectAt</span><span class='p'>(</span>a.<span class='fd'>size</span><span class='o'>-</span><span class='n'>1</span><span class='p'>)</span>.<span class='fd'>AppendBool</span><span class='p'>(</span><span class='s'>"D"</span> <span class='n'>1</span><span class='p'>)</span><br />
<br />
j.<span class='fd'>EmitCompact</span><span class='o'>=</span><span class='n'>0</span><br />
<span class='t'>str</span> json<span class='o'>=</span>j.<span class='fd'>Emit</span><span class='p'>()</span><br />
<span class='fq'>out</span> json</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Restoring an environment variable]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7781</link>
			<pubDate>Fri, 13 Dec 2024 07:20:41 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7781</guid>
			<description><![CDATA[Macro <span style="font-weight: bold;" class="mycode_b">TempEnvVar help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Auto-restores an environment variable. Or auto-deletes if did not exist.</span><br />
<br />
<span class='c'>;Example</span><br />
<br />
<span class='t'>TempEnvVar</span> x.<span class='fu'>Var</span><span class='p'>(</span><span class='s'>"TEST"</span><span class='p'>)</span> <span class='c2'>;;need just this single line</span><br />
<br />
<span class='fu'>GetEnvVar</span><span class='p'>(</span><span class='s'>"TEST"</span> _s<span class='p'>);</span> <span class='fq'>out</span> <span class='o'>F</span><span class='s'>"old: {</span>_s<span class='s'>}"</span><br />
<span class='fu'>SetEnvVar</span><span class='p'>(</span><span class='s'>"TEST"</span> <span class='s'>"new value"</span><span class='p'>)</span><br />
<span class='fu'>GetEnvVar</span><span class='p'>(</span><span class='s'>"TEST"</span> _s<span class='p'>);</span> <span class='fq'>out</span> <span class='o'>F</span><span class='s'>"new: {</span>_s<span class='s'>}"</span><br />
<br />
<br />
<span class='c'>;The TempEnvVar destructor restores or deletes the variable. It runs when the macro or function ends, even on exception.</span></code></div></div><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1367" target="_blank" title="">TempEnvVar.qml</a> (Size: 3 KB / Downloads: 173)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Macro <span style="font-weight: bold;" class="mycode_b">TempEnvVar help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Auto-restores an environment variable. Or auto-deletes if did not exist.</span><br />
<br />
<span class='c'>;Example</span><br />
<br />
<span class='t'>TempEnvVar</span> x.<span class='fu'>Var</span><span class='p'>(</span><span class='s'>"TEST"</span><span class='p'>)</span> <span class='c2'>;;need just this single line</span><br />
<br />
<span class='fu'>GetEnvVar</span><span class='p'>(</span><span class='s'>"TEST"</span> _s<span class='p'>);</span> <span class='fq'>out</span> <span class='o'>F</span><span class='s'>"old: {</span>_s<span class='s'>}"</span><br />
<span class='fu'>SetEnvVar</span><span class='p'>(</span><span class='s'>"TEST"</span> <span class='s'>"new value"</span><span class='p'>)</span><br />
<span class='fu'>GetEnvVar</span><span class='p'>(</span><span class='s'>"TEST"</span> _s<span class='p'>);</span> <span class='fq'>out</span> <span class='o'>F</span><span class='s'>"new: {</span>_s<span class='s'>}"</span><br />
<br />
<br />
<span class='c'>;The TempEnvVar destructor restores or deletes the variable. It runs when the macro or function ends, even on exception.</span></code></div></div><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1367" target="_blank" title="">TempEnvVar.qml</a> (Size: 3 KB / Downloads: 173)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Send email without mailbee]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=7172</link>
			<pubDate>Mon, 01 Nov 2021 13:52:26 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=7172</guid>
			<description><![CDATA[Sends email. Uses C# and .NET instead of mailbee.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">SendMailCs</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>account <span class='o'>&#36;</span>to <span class='o'>&#36;</span>subject <span class='o'>&#36;</span>text [flags] [<span class='o'>&#36;</span>headers] [<span class='o'>&#36;</span>attachments] <span class='c2'>;;flags: 1 HTML</span><br />
<br />
<span class='c'>;Sends email message.</span><br />
<br />
<span class='c'>;account - SMTP settings. See example.</span><br />
<span class='c'>;to - email.</span><br />
<span class='c'>;subject - subject.</span><br />
<span class='c'>;text - text.</span><br />
<span class='c'>;headers - XML containing additional headers. See example.</span><br />
<span class='c'>;attachments - XML containing attachments. See example.</span><br />
<br />
<span class='c'>;REMARKS</span><br />
<span class='c'>;Text encodings not tested.</span><br />
<br />
<span class='c'>;EXAMPLES</span><br />
<span class='c'>;str account=</span><br />
<span class='c'>;;&lt;account</span><br />
<span class='c'>;;host='smtp.example.com'</span><br />
<span class='c'>;;user='me@example.com'</span><br />
<span class='c'>;;password='PASSWORD'</span><br />
<span class='c'>;;port='587'</span><br />
<span class='c'>;;ssl='true'</span><br />
<span class='c'>;;timeout='30'</span><br />
<span class='c'>;;email='sender-email-optional-if-user-is-email@example.com'</span><br />
<span class='c'>;;displayName='optional sender name'</span><br />
<span class='c'>;;/&gt;</span><br />
<span class='c'>;SendMailCs account "friend@example.com" "Test" "Hi"</span><br />
<span class='c'>;</span><br />
<span class='c'>;str headers=</span><br />
<span class='c'>;;&lt;headers&gt;</span><br />
<span class='c'>;;&lt;h name='Organization'&gt;kkkkkkkk&lt;/h&gt;</span><br />
<span class='c'>;;&lt;h name='X-Custom'&gt;mmmmmmmm&lt;/h&gt;</span><br />
<span class='c'>;;&lt;/headers&gt;</span><br />
<span class='c'>;str attachments=</span><br />
<span class='c'>;;&lt;attachments&gt;</span><br />
<span class='c'>;;&lt;a&gt;c:&#92;test&#92;image.png&lt;/a&gt;</span><br />
<span class='c'>;;&lt;a&gt;c:&#92;test&#92;program.exe&lt;/a&gt;</span><br />
<span class='c'>;;&lt;/attachments&gt;</span><br />
<span class='c'>;SendMailCs account "friend@example.com" "Test2" "Hi, &lt;b&gt;HTML&lt;/b&gt;" 1 headers attachments</span><br />
<br />
<br />
<span class='c'>;CsScript bug(?): strings cannot be null</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>headers<span class='p'>)</span> headers<span class='o'>=</span><span class='s'>""</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>attachments<span class='p'>)</span> attachments<span class='o'>=</span><span class='s'>""</span><br />
<br />
<span class='t'>CsScript</span> x.<span class='fu'>SetOptions</span><span class='p'>(</span><span class='s'>"references=System.XML"</span><span class='p'>)</span><br />
x.<span class='fu'>AddCode</span><span class='p'>(</span><span class='s'>""</span><span class='p'>)</span><br />
x.<span class='fu'>Call</span><span class='p'>(</span><span class='s'>"Email.Send"</span> account to subject text flags<span class='o'>&amp;</span><span class='n'>1</span> headers attachments<span class='p'>)</span><br />
<br />
<br />
<span class='dir'>#ret</span><br />
<span class='c'>//C# code</span><br />
using System<span class='p'>;</span><br />
using System.Net<span class='p'>;</span><br />
using System.Net.Mail<span class='p'>;</span><br />
using System.Xml.Linq<span class='p'>;</span><br />
<br />
public <span class='fq'>class</span> Email {<br />
<span class='i'>,</span>static public void Send<span class='p'>(</span><span class='lib'>string</span> account<span class='p'>,</span> <span class='lib'>string</span> email<span class='p'>,</span> <span class='lib'>string</span> subject<span class='p'>,</span> <span class='lib'>string</span> body<span class='p'>,</span> bool isHtml<span class='p'>,</span> <span class='lib'>string</span> headers<span class='p'>,</span> <span class='lib'>string</span> attachments<span class='p'>)</span> {<br />
<span class='i'>,,</span><span class='lib'>string</span> host<span class='o'>=</span>null<span class='p'>,</span> user<span class='o'>=</span>null<span class='p'>,</span> password<span class='o'>=</span>null<span class='p'>,</span> fromEmail<span class='o'>=</span>null<span class='p'>,</span> fromName<span class='o'>=</span>null<span class='p'>;</span><br />
<span class='i'>,,</span><span class='t'>int</span> port<span class='o'>=</span><span class='n'>0</span><span class='p'>,</span> timeout<span class='o'>=</span><span class='n'>60</span><span class='p'>;</span><br />
<span class='i'>,,</span>bool ssl<span class='o'>=</span>false<span class='p'>;</span><br />
<span class='i'>,,</span>var x<span class='o'>=</span>XElement.Parse<span class='p'>(</span>account<span class='p'>);</span><br />
<span class='i'>,,</span><span class='fq'>foreach</span><span class='p'>(</span>var k in x.Attributes<span class='p'>())</span> {<br />
<span class='i'>,,,</span>switch<span class='p'>(</span>k.Name.LocalName<span class='p'>)</span> {<br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"host"</span><span class='p'>:</span> host<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"user"</span><span class='p'>:</span> user<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"password"</span><span class='p'>:</span> password<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"email"</span><span class='p'>:</span> fromEmail<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"displayName"</span><span class='p'>:</span> fromName<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"port"</span><span class='p'>:</span> port<span class='o'>=</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"timeout"</span><span class='p'>:</span> timeout<span class='o'>=</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"ssl"</span><span class='p'>:</span> ssl<span class='o'>=</span><span class='p'>(</span>bool<span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span>}<br />
<span class='i'>,,</span>}<br />
<span class='i'>,,</span><br />
<span class='i'>,,</span>var fromAddress <span class='o'>=</span> new <span class='fu'>MailAddress</span><span class='p'>(</span>fromEmail <span class='o'>!=</span> null ? fromEmail <span class='p'>:</span> user<span class='p'>,</span> fromName<span class='p'>);</span><br />
<span class='i'>,,</span>var toAddress <span class='o'>=</span> new <span class='fu'>MailAddress</span><span class='p'>(</span>email<span class='p'>);</span><br />
<br />
<span class='i'>,,</span>using<span class='p'>(</span>var smtp <span class='o'>=</span> new SmtpClient {<br />
<span class='i'>,,,</span>Host <span class='o'>=</span> host<span class='p'>,</span><br />
<span class='i'>,,,</span>Port <span class='o'>=</span> port<span class='p'>,</span><br />
<span class='i'>,,,</span>EnableSsl <span class='o'>=</span> ssl<span class='p'>,</span><br />
<span class='i'>,,,</span>DeliveryMethod <span class='o'>=</span> SmtpDeliveryMethod.Network<span class='p'>,</span><br />
<span class='i'>,,,</span>UseDefaultCredentials <span class='o'>=</span> false<span class='p'>,</span><br />
<span class='i'>,,,</span>Credentials <span class='o'>=</span> new NetworkCredential<span class='p'>(</span>user<span class='p'>,</span> password<span class='p'>),</span><br />
<span class='i'>,,,</span>Timeout <span class='o'>=</span> timeout<span class='o'>*</span><span class='n'>1000</span><span class='p'>,</span><br />
<span class='i'>,,</span>}<span class='p'>)</span><br />
<span class='i'>,,</span>using <span class='p'>(</span>var m <span class='o'>=</span> new <span class='fu'>MailMessage</span><span class='p'>(</span>fromAddress<span class='p'>,</span> toAddress<span class='p'>)</span> {<br />
<span class='i'>,,,</span>Subject <span class='o'>=</span> subject<span class='p'>,</span><br />
<span class='i'>,,,</span>Body <span class='o'>=</span> body<span class='p'>,</span><br />
<span class='i'>,,,</span>IsBodyHtml <span class='o'>=</span> isHtml<br />
<span class='i'>,,</span>}<span class='p'>)</span> {<br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='lib'>string.</span>IsNullOrEmpty<span class='p'>(</span>headers<span class='p'>))</span> {<br />
<span class='i'>,,,,</span>x<span class='o'>=</span>XElement.Parse<span class='p'>(</span>headers<span class='p'>);</span><br />
<span class='i'>,,,,</span><span class='fq'>foreach</span><span class='p'>(</span>var k in x.Elements<span class='p'>())</span> m.Headers.Add<span class='p'>(</span>k.Attribute<span class='p'>(</span><span class='s'>"name"</span><span class='p'>)</span>.Value<span class='p'>,</span> k.Value<span class='p'>);</span><br />
<span class='i'>,,,</span>}<br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='lib'>string.</span>IsNullOrEmpty<span class='p'>(</span>attachments<span class='p'>))</span> {<br />
<span class='i'>,,,,</span>x<span class='o'>=</span>XElement.Parse<span class='p'>(</span>attachments<span class='p'>);</span><br />
<span class='i'>,,,,</span><span class='fq'>foreach</span><span class='p'>(</span>var k in x.Elements<span class='p'>())</span>  {<br />
<span class='i'>,,,,,</span>var mta<span class='o'>=</span>k.Attribute<span class='p'>(</span><span class='s'>"mediaType"</span><span class='p'>);</span><br />
<span class='i'>,,,,,</span>m.Attachments.Add<span class='p'>(</span>new Attachment<span class='p'>(</span>k.Value<span class='p'>,</span> mta<span class='o'>!=</span>null ? mta.Value <span class='p'>:</span> null<span class='p'>));</span><br />
<span class='i'>,,,,</span>}<br />
<span class='i'>,,,</span>}<br />
<span class='i'>,,,</span>smtp.Send<span class='p'>(</span>m<span class='p'>);</span><br />
<span class='i'>,,</span>}<br />
<span class='i'>,</span>}<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Sends email. Uses C# and .NET instead of mailbee.<br />
<br />
Function <span style="font-weight: bold;" class="mycode_b">SendMailCs</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>account <span class='o'>&#36;</span>to <span class='o'>&#36;</span>subject <span class='o'>&#36;</span>text [flags] [<span class='o'>&#36;</span>headers] [<span class='o'>&#36;</span>attachments] <span class='c2'>;;flags: 1 HTML</span><br />
<br />
<span class='c'>;Sends email message.</span><br />
<br />
<span class='c'>;account - SMTP settings. See example.</span><br />
<span class='c'>;to - email.</span><br />
<span class='c'>;subject - subject.</span><br />
<span class='c'>;text - text.</span><br />
<span class='c'>;headers - XML containing additional headers. See example.</span><br />
<span class='c'>;attachments - XML containing attachments. See example.</span><br />
<br />
<span class='c'>;REMARKS</span><br />
<span class='c'>;Text encodings not tested.</span><br />
<br />
<span class='c'>;EXAMPLES</span><br />
<span class='c'>;str account=</span><br />
<span class='c'>;;&lt;account</span><br />
<span class='c'>;;host='smtp.example.com'</span><br />
<span class='c'>;;user='me@example.com'</span><br />
<span class='c'>;;password='PASSWORD'</span><br />
<span class='c'>;;port='587'</span><br />
<span class='c'>;;ssl='true'</span><br />
<span class='c'>;;timeout='30'</span><br />
<span class='c'>;;email='sender-email-optional-if-user-is-email@example.com'</span><br />
<span class='c'>;;displayName='optional sender name'</span><br />
<span class='c'>;;/&gt;</span><br />
<span class='c'>;SendMailCs account "friend@example.com" "Test" "Hi"</span><br />
<span class='c'>;</span><br />
<span class='c'>;str headers=</span><br />
<span class='c'>;;&lt;headers&gt;</span><br />
<span class='c'>;;&lt;h name='Organization'&gt;kkkkkkkk&lt;/h&gt;</span><br />
<span class='c'>;;&lt;h name='X-Custom'&gt;mmmmmmmm&lt;/h&gt;</span><br />
<span class='c'>;;&lt;/headers&gt;</span><br />
<span class='c'>;str attachments=</span><br />
<span class='c'>;;&lt;attachments&gt;</span><br />
<span class='c'>;;&lt;a&gt;c:&#92;test&#92;image.png&lt;/a&gt;</span><br />
<span class='c'>;;&lt;a&gt;c:&#92;test&#92;program.exe&lt;/a&gt;</span><br />
<span class='c'>;;&lt;/attachments&gt;</span><br />
<span class='c'>;SendMailCs account "friend@example.com" "Test2" "Hi, &lt;b&gt;HTML&lt;/b&gt;" 1 headers attachments</span><br />
<br />
<br />
<span class='c'>;CsScript bug(?): strings cannot be null</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>headers<span class='p'>)</span> headers<span class='o'>=</span><span class='s'>""</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span>attachments<span class='p'>)</span> attachments<span class='o'>=</span><span class='s'>""</span><br />
<br />
<span class='t'>CsScript</span> x.<span class='fu'>SetOptions</span><span class='p'>(</span><span class='s'>"references=System.XML"</span><span class='p'>)</span><br />
x.<span class='fu'>AddCode</span><span class='p'>(</span><span class='s'>""</span><span class='p'>)</span><br />
x.<span class='fu'>Call</span><span class='p'>(</span><span class='s'>"Email.Send"</span> account to subject text flags<span class='o'>&amp;</span><span class='n'>1</span> headers attachments<span class='p'>)</span><br />
<br />
<br />
<span class='dir'>#ret</span><br />
<span class='c'>//C# code</span><br />
using System<span class='p'>;</span><br />
using System.Net<span class='p'>;</span><br />
using System.Net.Mail<span class='p'>;</span><br />
using System.Xml.Linq<span class='p'>;</span><br />
<br />
public <span class='fq'>class</span> Email {<br />
<span class='i'>,</span>static public void Send<span class='p'>(</span><span class='lib'>string</span> account<span class='p'>,</span> <span class='lib'>string</span> email<span class='p'>,</span> <span class='lib'>string</span> subject<span class='p'>,</span> <span class='lib'>string</span> body<span class='p'>,</span> bool isHtml<span class='p'>,</span> <span class='lib'>string</span> headers<span class='p'>,</span> <span class='lib'>string</span> attachments<span class='p'>)</span> {<br />
<span class='i'>,,</span><span class='lib'>string</span> host<span class='o'>=</span>null<span class='p'>,</span> user<span class='o'>=</span>null<span class='p'>,</span> password<span class='o'>=</span>null<span class='p'>,</span> fromEmail<span class='o'>=</span>null<span class='p'>,</span> fromName<span class='o'>=</span>null<span class='p'>;</span><br />
<span class='i'>,,</span><span class='t'>int</span> port<span class='o'>=</span><span class='n'>0</span><span class='p'>,</span> timeout<span class='o'>=</span><span class='n'>60</span><span class='p'>;</span><br />
<span class='i'>,,</span>bool ssl<span class='o'>=</span>false<span class='p'>;</span><br />
<span class='i'>,,</span>var x<span class='o'>=</span>XElement.Parse<span class='p'>(</span>account<span class='p'>);</span><br />
<span class='i'>,,</span><span class='fq'>foreach</span><span class='p'>(</span>var k in x.Attributes<span class='p'>())</span> {<br />
<span class='i'>,,,</span>switch<span class='p'>(</span>k.Name.LocalName<span class='p'>)</span> {<br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"host"</span><span class='p'>:</span> host<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"user"</span><span class='p'>:</span> user<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"password"</span><span class='p'>:</span> password<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"email"</span><span class='p'>:</span> fromEmail<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"displayName"</span><span class='p'>:</span> fromName<span class='o'>=</span><span class='p'>(</span><span class='lib'>string</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"port"</span><span class='p'>:</span> port<span class='o'>=</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"timeout"</span><span class='p'>:</span> timeout<span class='o'>=</span><span class='p'>(</span><span class='t'>int</span><span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span><span class='fq'>case</span> <span class='s'>"ssl"</span><span class='p'>:</span> ssl<span class='o'>=</span><span class='p'>(</span>bool<span class='p'>)</span>k<span class='p'>;</span> <span class='fq'>break</span><span class='p'>;</span><br />
<span class='i'>,,,</span>}<br />
<span class='i'>,,</span>}<br />
<span class='i'>,,</span><br />
<span class='i'>,,</span>var fromAddress <span class='o'>=</span> new <span class='fu'>MailAddress</span><span class='p'>(</span>fromEmail <span class='o'>!=</span> null ? fromEmail <span class='p'>:</span> user<span class='p'>,</span> fromName<span class='p'>);</span><br />
<span class='i'>,,</span>var toAddress <span class='o'>=</span> new <span class='fu'>MailAddress</span><span class='p'>(</span>email<span class='p'>);</span><br />
<br />
<span class='i'>,,</span>using<span class='p'>(</span>var smtp <span class='o'>=</span> new SmtpClient {<br />
<span class='i'>,,,</span>Host <span class='o'>=</span> host<span class='p'>,</span><br />
<span class='i'>,,,</span>Port <span class='o'>=</span> port<span class='p'>,</span><br />
<span class='i'>,,,</span>EnableSsl <span class='o'>=</span> ssl<span class='p'>,</span><br />
<span class='i'>,,,</span>DeliveryMethod <span class='o'>=</span> SmtpDeliveryMethod.Network<span class='p'>,</span><br />
<span class='i'>,,,</span>UseDefaultCredentials <span class='o'>=</span> false<span class='p'>,</span><br />
<span class='i'>,,,</span>Credentials <span class='o'>=</span> new NetworkCredential<span class='p'>(</span>user<span class='p'>,</span> password<span class='p'>),</span><br />
<span class='i'>,,,</span>Timeout <span class='o'>=</span> timeout<span class='o'>*</span><span class='n'>1000</span><span class='p'>,</span><br />
<span class='i'>,,</span>}<span class='p'>)</span><br />
<span class='i'>,,</span>using <span class='p'>(</span>var m <span class='o'>=</span> new <span class='fu'>MailMessage</span><span class='p'>(</span>fromAddress<span class='p'>,</span> toAddress<span class='p'>)</span> {<br />
<span class='i'>,,,</span>Subject <span class='o'>=</span> subject<span class='p'>,</span><br />
<span class='i'>,,,</span>Body <span class='o'>=</span> body<span class='p'>,</span><br />
<span class='i'>,,,</span>IsBodyHtml <span class='o'>=</span> isHtml<br />
<span class='i'>,,</span>}<span class='p'>)</span> {<br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='lib'>string.</span>IsNullOrEmpty<span class='p'>(</span>headers<span class='p'>))</span> {<br />
<span class='i'>,,,,</span>x<span class='o'>=</span>XElement.Parse<span class='p'>(</span>headers<span class='p'>);</span><br />
<span class='i'>,,,,</span><span class='fq'>foreach</span><span class='p'>(</span>var k in x.Elements<span class='p'>())</span> m.Headers.Add<span class='p'>(</span>k.Attribute<span class='p'>(</span><span class='s'>"name"</span><span class='p'>)</span>.Value<span class='p'>,</span> k.Value<span class='p'>);</span><br />
<span class='i'>,,,</span>}<br />
<span class='i'>,,,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='lib'>string.</span>IsNullOrEmpty<span class='p'>(</span>attachments<span class='p'>))</span> {<br />
<span class='i'>,,,,</span>x<span class='o'>=</span>XElement.Parse<span class='p'>(</span>attachments<span class='p'>);</span><br />
<span class='i'>,,,,</span><span class='fq'>foreach</span><span class='p'>(</span>var k in x.Elements<span class='p'>())</span>  {<br />
<span class='i'>,,,,,</span>var mta<span class='o'>=</span>k.Attribute<span class='p'>(</span><span class='s'>"mediaType"</span><span class='p'>);</span><br />
<span class='i'>,,,,,</span>m.Attachments.Add<span class='p'>(</span>new Attachment<span class='p'>(</span>k.Value<span class='p'>,</span> mta<span class='o'>!=</span>null ? mta.Value <span class='p'>:</span> null<span class='p'>));</span><br />
<span class='i'>,,,,</span>}<br />
<span class='i'>,,,</span>}<br />
<span class='i'>,,,</span>smtp.Send<span class='p'>(</span>m<span class='p'>);</span><br />
<span class='i'>,,</span>}<br />
<span class='i'>,</span>}<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Web browser control - disable IE7 emulation]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=6437</link>
			<pubDate>Mon, 14 May 2018 03:48:05 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=6437</guid>
			<description><![CDATA[Function <span style="font-weight: bold;" class="mycode_b">WebBrowserControlDisableIE7Emulation</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> [flags] <span class='c2'>;;flags: 1 for all users</span><br />
<br />
<span class='c'>;Ensures that web browser controls of this program (qm.exe or qmmacro.exe or your QM-created exe) can use features of current Internet Explorer version (CSS3, HTML5 etc).</span><br />
<br />
<span class='c'>;REMARKS</span><br />
<span class='c'>;By default, web browser controls work in compatibility mode with Internet Explorer 7. IE 8/9/10/11 features are unavailable.</span><br />
<span class='c'>;This function sets this registry value, if it is missing or different:</span><br />
<span class='c'>;;;SOFTWARE&#92;Microsoft&#92;Internet Explorer&#92;Main&#92;FeatureControl&#92;FEATURE_BROWSER_EMULATION:&lt;ThisProgram.exe&gt;=&lt;CurrentInternetExplorerVersion&gt;</span><br />
<span class='c'>;By default sets its only for current user, in HKEY_CURRENT_USER. If flag 1, sets for all users, in HKEY_LOCAL_MACHINE; then error if this process is not running as administrator.</span><br />
<span class='c'>;You can call this function before ShowDialog if the dialog contains an ActiveX control SHDocVw.WebBrowser. Or call it once.</span><br />
<br />
<br />
<span class='fq'>if</span><span class='p'>(</span>_iever<span class='o'>&lt;</span><span class='n'>8</span><span class='p'>)</span> <span class='fq'>ret</span><br />
<span class='t'>str</span> e.<span class='fq'>getfilename</span><span class='p'>(</span><span class='fu'>ExeFullPath</span> <span class='n'>1</span><span class='p'>)</span><br />
<span class='c'>;out e</span><br />
<span class='t'>int</span> t v<span class='o'>=</span>_iever<span class='o'>&gt;&gt;</span><span class='n'>8</span><span class='o'>*</span><span class='n'>1000</span><br />
<span class='c'>;out v</span><br />
<span class='t'>int</span> h<span class='o'>=</span><span class='fq'>iif</span><span class='p'>(</span>flags<span class='o'>&amp;</span><span class='n'>1</span> <span class='d'>HKEY_LOCAL_MACHINE</span> <span class='d'>HKEY_CURRENT_USER</span><span class='p'>)</span><br />
<span class='t'>lpstr</span> k<span class='o'>=</span><span class='s'>"SOFTWARE&#92;Microsoft&#92;Internet Explorer&#92;Main&#92;FeatureControl&#92;FEATURE_BROWSER_EMULATION"</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='fq'>rget</span><span class='p'>(</span>t e k h<span class='p'>)</span> <span class='fq'>and</span> t<span class='o'>=</span>v<span class='p'>)</span> <span class='fq'>ret</span><br />
<span class='c'>;out t</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='fq'>rset</span><span class='p'>(</span>v e k h<span class='p'>))</span> <span class='fq'>end</span> <span class='d'>ERR_ADMIN</span></code></div></div>]]></description>
			<content:encoded><![CDATA[Function <span style="font-weight: bold;" class="mycode_b">WebBrowserControlDisableIE7Emulation</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> [flags] <span class='c2'>;;flags: 1 for all users</span><br />
<br />
<span class='c'>;Ensures that web browser controls of this program (qm.exe or qmmacro.exe or your QM-created exe) can use features of current Internet Explorer version (CSS3, HTML5 etc).</span><br />
<br />
<span class='c'>;REMARKS</span><br />
<span class='c'>;By default, web browser controls work in compatibility mode with Internet Explorer 7. IE 8/9/10/11 features are unavailable.</span><br />
<span class='c'>;This function sets this registry value, if it is missing or different:</span><br />
<span class='c'>;;;SOFTWARE&#92;Microsoft&#92;Internet Explorer&#92;Main&#92;FeatureControl&#92;FEATURE_BROWSER_EMULATION:&lt;ThisProgram.exe&gt;=&lt;CurrentInternetExplorerVersion&gt;</span><br />
<span class='c'>;By default sets its only for current user, in HKEY_CURRENT_USER. If flag 1, sets for all users, in HKEY_LOCAL_MACHINE; then error if this process is not running as administrator.</span><br />
<span class='c'>;You can call this function before ShowDialog if the dialog contains an ActiveX control SHDocVw.WebBrowser. Or call it once.</span><br />
<br />
<br />
<span class='fq'>if</span><span class='p'>(</span>_iever<span class='o'>&lt;</span><span class='n'>8</span><span class='p'>)</span> <span class='fq'>ret</span><br />
<span class='t'>str</span> e.<span class='fq'>getfilename</span><span class='p'>(</span><span class='fu'>ExeFullPath</span> <span class='n'>1</span><span class='p'>)</span><br />
<span class='c'>;out e</span><br />
<span class='t'>int</span> t v<span class='o'>=</span>_iever<span class='o'>&gt;&gt;</span><span class='n'>8</span><span class='o'>*</span><span class='n'>1000</span><br />
<span class='c'>;out v</span><br />
<span class='t'>int</span> h<span class='o'>=</span><span class='fq'>iif</span><span class='p'>(</span>flags<span class='o'>&amp;</span><span class='n'>1</span> <span class='d'>HKEY_LOCAL_MACHINE</span> <span class='d'>HKEY_CURRENT_USER</span><span class='p'>)</span><br />
<span class='t'>lpstr</span> k<span class='o'>=</span><span class='s'>"SOFTWARE&#92;Microsoft&#92;Internet Explorer&#92;Main&#92;FeatureControl&#92;FEATURE_BROWSER_EMULATION"</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='fq'>rget</span><span class='p'>(</span>t e k h<span class='p'>)</span> <span class='fq'>and</span> t<span class='o'>=</span>v<span class='p'>)</span> <span class='fq'>ret</span><br />
<span class='c'>;out t</span><br />
<span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='fq'>rset</span><span class='p'>(</span>v e k h<span class='p'>))</span> <span class='fq'>end</span> <span class='d'>ERR_ADMIN</span></code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Auto-enable accessible objects in Chrome]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=6247</link>
			<pubDate>Tue, 18 Jul 2017 07:45:07 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=6247</guid>
			<description><![CDATA[The Chrome web browser supports accessible objects in web pages, but this is disabled by default. QM tries to auto-enable it on demand, but with some Chrome versions it fails (always or in some cases).<br />
<br />
You can explicitly enable Chrome accessible objects: run chrome.exe with command line --force-renderer-accessibility. Before it make sure there are no hidden chrome.exe processes.<br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>run</span> <span class='s'>"chrome.exe"</span> <span class='s'>"--force-renderer-accessibility"</span></code></div></div><br />
The alternative way (code deleted) no longer works. Use the above way.]]></description>
			<content:encoded><![CDATA[The Chrome web browser supports accessible objects in web pages, but this is disabled by default. QM tries to auto-enable it on demand, but with some Chrome versions it fails (always or in some cases).<br />
<br />
You can explicitly enable Chrome accessible objects: run chrome.exe with command line --force-renderer-accessibility. Before it make sure there are no hidden chrome.exe processes.<br />
 <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='fq'>run</span> <span class='s'>"chrome.exe"</span> <span class='s'>"--force-renderer-accessibility"</span></code></div></div><br />
The alternative way (code deleted) no longer works. Use the above way.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Pastebin]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5999</link>
			<pubDate>Sat, 15 Oct 2016 09:11:16 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5999</guid>
			<description><![CDATA[<a href="http://pastebin.com" target="_blank" rel="noopener" class="mycode_url">http://pastebin.com</a><br />
<a href="http://pastebin.com/api" target="_blank" rel="noopener" class="mycode_url">http://pastebin.com/api</a><br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">Pastebin help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Wraps pastebin API.</span><br />
<span class='c'>;&lt;link&gt;http://pastebin.com/api&lt;/link&gt;</span><br />
<br />
<span class='c'>;The functions throw error if failed, for example if an argument is invalid.</span><br />
<br />
<span class='c'>;EXAMPLES</span><br />
<br />
<span class='t'>str</span> devKey<span class='o'>=</span><span class='s'>"xxxxxxxxxxxxxxxxxxxxxxxxxxxx"</span><br />
<span class='t'>str</span> user<span class='o'>=</span><span class='s'>"xxxxxxxx"</span><br />
<span class='t'>str</span> password<span class='o'>=</span><span class='s'>"xxxxxxxx"</span><br />
<span class='t'>str</span> text<span class='o'>=</span><br />
<span class='s'>;test</span><br />
<span class='s'>;Pastebin class</span><br />
<span class='t'>str</span> response<br />
<br />
<span class='dir'>#compile</span> <span class='s'>"__Pastebin"</span><br />
<span class='t'>Pastebin</span> x.<span class='fu'>Init</span><span class='p'>(</span>devKey<span class='p'>)</span><br />
<span class='fq'>sel</span> <span class='fu'>ListDialog</span><span class='p'>(</span><span class='s'>"Paste as guest[]Paste as user[]List user's pastes[]Get a paste[]Delete a paste"</span> <span class='s'>"Run example"</span> <span class='s'>"Pastebin"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>1</span> <span class='c2'>;;paste as guest</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>Paste</span><span class='p'>(</span><span class='s'>"text pasted as guest"</span> <span class='s'>"example"</span> <span class='n'>1</span> <span class='s'>"10M"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><span class='fq'>run</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>2</span> <span class='c2'>;;paste as user</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>Paste</span><span class='p'>(</span><span class='s'>"text pasted as user"</span> <span class='s'>"example"</span> <span class='n'>2</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><span class='fq'>run</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>3</span> <span class='c2'>;;list</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>List</span><span class='p'>()</span><br />
<span class='i'>,</span><span class='fq'>out</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>4</span> <span class='c2'>;;get</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>Get</span><span class='p'>(</span><span class='s'>"45VaC3eG"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>5</span> <span class='c2'>;;delete</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Delete</span><span class='p'>(</span><span class='s'>"45VaC3eG"</span><span class='p'>)</span></code></div></div><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=598" target="_blank" title="">Pastebin.qml</a> (Size: 8 KB / Downloads: 793)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[<a href="http://pastebin.com" target="_blank" rel="noopener" class="mycode_url">http://pastebin.com</a><br />
<a href="http://pastebin.com/api" target="_blank" rel="noopener" class="mycode_url">http://pastebin.com/api</a><br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">Pastebin help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Wraps pastebin API.</span><br />
<span class='c'>;&lt;link&gt;http://pastebin.com/api&lt;/link&gt;</span><br />
<br />
<span class='c'>;The functions throw error if failed, for example if an argument is invalid.</span><br />
<br />
<span class='c'>;EXAMPLES</span><br />
<br />
<span class='t'>str</span> devKey<span class='o'>=</span><span class='s'>"xxxxxxxxxxxxxxxxxxxxxxxxxxxx"</span><br />
<span class='t'>str</span> user<span class='o'>=</span><span class='s'>"xxxxxxxx"</span><br />
<span class='t'>str</span> password<span class='o'>=</span><span class='s'>"xxxxxxxx"</span><br />
<span class='t'>str</span> text<span class='o'>=</span><br />
<span class='s'>;test</span><br />
<span class='s'>;Pastebin class</span><br />
<span class='t'>str</span> response<br />
<br />
<span class='dir'>#compile</span> <span class='s'>"__Pastebin"</span><br />
<span class='t'>Pastebin</span> x.<span class='fu'>Init</span><span class='p'>(</span>devKey<span class='p'>)</span><br />
<span class='fq'>sel</span> <span class='fu'>ListDialog</span><span class='p'>(</span><span class='s'>"Paste as guest[]Paste as user[]List user's pastes[]Get a paste[]Delete a paste"</span> <span class='s'>"Run example"</span> <span class='s'>"Pastebin"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>1</span> <span class='c2'>;;paste as guest</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>Paste</span><span class='p'>(</span><span class='s'>"text pasted as guest"</span> <span class='s'>"example"</span> <span class='n'>1</span> <span class='s'>"10M"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><span class='fq'>run</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>2</span> <span class='c2'>;;paste as user</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>Paste</span><span class='p'>(</span><span class='s'>"text pasted as user"</span> <span class='s'>"example"</span> <span class='n'>2</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><span class='fq'>run</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>3</span> <span class='c2'>;;list</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>List</span><span class='p'>()</span><br />
<span class='i'>,</span><span class='fq'>out</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>4</span> <span class='c2'>;;get</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>response<span class='o'>=</span>x.<span class='fu'>Get</span><span class='p'>(</span><span class='s'>"45VaC3eG"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>out</span> response<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>5</span> <span class='c2'>;;delete</span><br />
<span class='i'>,</span>x.<span class='fu'>Login</span><span class='p'>(</span>user password<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Delete</span><span class='p'>(</span><span class='s'>"45VaC3eG"</span><span class='p'>)</span></code></div></div><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=598" target="_blank" title="">Pastebin.qml</a> (Size: 8 KB / Downloads: 793)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Set end-thread hotkey]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5929</link>
			<pubDate>Fri, 29 Jul 2016 05:08:24 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5929</guid>
			<description><![CDATA[Function <span style="font-weight: bold;" class="mycode_b">SetEndThreadHotkey</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;/</span><br />
<br />
<span class='fq'>function</span> <span class='o'>&#36;</span>hotkey<br />
<br />
<span class='c'>;Sets a hotkey to end current thread (running macro or function).</span><br />
<br />
<span class='c'>;hotkey - a single key without modifiers (Ctrl etc), specified as QM key code like with &lt;help&gt;key&lt;/help&gt; and QM keyboard triggers.</span><br />
<br />
<span class='c'>;EXAMPLE</span><br />
<span class='c'>;SetEndThreadHotkey "F8"</span><br />
<span class='c'>;;macro</span><br />
<span class='c'>;rep</span><br />
<span class='i'>,</span><span class='c'>;out 1</span><br />
<span class='i'>,</span><span class='c'>;wait 1</span><br />
<br />
<br />
<span class='t'>int</span> mod vk<span class='p'>;</span> <span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='fu'>TO_HotkeyFromQmKeys</span><span class='p'>(</span>hotkey mod vk<span class='p'>))</span> <span class='fq'>end</span> <span class='s'>"invalid hotkey string"</span><br />
<span class='fq'>if</span><span class='p'>(</span>mod<span class='p'>)</span> <span class='fq'>end</span> <span class='s'>"modifier keys not supported"</span><br />
<br />
<span class='t'>QMTHREAD</span> qt<span class='p'>;</span> <span class='fd'>GetQmThreadInfo</span><span class='p'>(</span><span class='n'>0</span> qt<span class='p'>)</span><br />
<span class='fq'>mac</span> <span class='s'>"sub.Thread"</span> <span class='s'>""</span> qt.threadhandle vk<br />
<br />
<br />
<span class='dir'>#sub</span> Thread<br />
<span class='fq'>function</span> ht vk<br />
<br />
<span class='t'>int</span><span class='o'>-</span> __ht82657<span class='p'>(</span>ht<span class='p'>)</span> __vk82657<span class='p'>(</span>vk<span class='p'>)</span><br />
<br />
<span class='t'>int</span> hh<span class='o'>=</span><span class='fd'>SetWindowsHookEx</span><span class='p'>(</span><span class='d'>WH_KEYBOARD_LL</span> <span class='o'>&amp;</span><span class='fu'>sub.Hook_WH_KEYBOARD_LL</span> _hinst <span class='n'>0</span><span class='p'>)</span><br />
<span class='fq'>opt</span> waitmsg <span class='n'>1</span><br />
<span class='fq'>wait</span> <span class='n'>0</span> H ht<br />
<span class='fd'>UnhookWindowsHookEx</span> hh<br />
<br />
<br />
<span class='dir'>#sub</span> Hook_WH_KEYBOARD_LL<br />
<span class='fq'>function</span><span class='o'>#</span> nCode message <span class='t'>KBDLLHOOKSTRUCT</span><span class='o'>&amp;</span>k<br />
<span class='fq'>if</span><span class='p'>(</span>nCode<span class='o'>&lt;</span><span class='n'>0</span><span class='p'>)</span> <span class='fq'>goto</span> gNext<br />
<span class='fq'>if</span><span class='p'>(</span>k.flags<span class='o'>&amp;</span><span class='p'>(</span><span class='d'>LLKHF_UP</span><span class='o'>|</span><span class='d'>LLKHF_INJECTED</span><span class='p'>))</span> <span class='fq'>goto</span> gNext<br />
<br />
<span class='t'>int</span><span class='o'>-</span> __ht82657 __vk82657<br />
<span class='fq'>if</span> k.vkCode<span class='o'>=</span>__vk82657<br />
<span class='i'>,</span><span class='fu'>EndThread</span> <span class='s'>""</span> __ht82657<br />
<span class='i'>,</span><span class='fq'>ret</span> <span class='n'>1</span><br />
<br />
<span class='c'>;gNext</span><br />
<span class='fq'>ret</span> <span class='fd'>CallNextHookEx</span><span class='p'>(</span><span class='n'>0</span> nCode message <span class='o'>&amp;</span>k<span class='p'>)</span></code></div></div><br />
example<br />
Macro <span style="font-weight: bold;" class="mycode_b">Macro2718</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;add this line before the macro. Change the hotkey.</span><br />
<span class='fu'>SetEndThreadHotkey</span> <span class='s'>"F12"</span><br />
<br />
<span class='c'>;your macro (example)</span><br />
<span class='fq'>rep</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='n'>1</span><br />
<span class='i'>,</span><span class='fq'>wait</span> <span class='n'>1</span></code></div></div><br />
This can be useful where the common hotkey (Pause) cannot be used:<br />
To end a non-macro thread (function etc).<br />
When the macro has property "run simultaneously".<br />
When you want to use a separate end-thread hotkey for some macros.<br />
This also can be used to end .exe macros, but probably it's better to set hotkey in the "Make exe" dialog.]]></description>
			<content:encoded><![CDATA[Function <span style="font-weight: bold;" class="mycode_b">SetEndThreadHotkey</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;/</span><br />
<br />
<span class='fq'>function</span> <span class='o'>&#36;</span>hotkey<br />
<br />
<span class='c'>;Sets a hotkey to end current thread (running macro or function).</span><br />
<br />
<span class='c'>;hotkey - a single key without modifiers (Ctrl etc), specified as QM key code like with &lt;help&gt;key&lt;/help&gt; and QM keyboard triggers.</span><br />
<br />
<span class='c'>;EXAMPLE</span><br />
<span class='c'>;SetEndThreadHotkey "F8"</span><br />
<span class='c'>;;macro</span><br />
<span class='c'>;rep</span><br />
<span class='i'>,</span><span class='c'>;out 1</span><br />
<span class='i'>,</span><span class='c'>;wait 1</span><br />
<br />
<br />
<span class='t'>int</span> mod vk<span class='p'>;</span> <span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='fu'>TO_HotkeyFromQmKeys</span><span class='p'>(</span>hotkey mod vk<span class='p'>))</span> <span class='fq'>end</span> <span class='s'>"invalid hotkey string"</span><br />
<span class='fq'>if</span><span class='p'>(</span>mod<span class='p'>)</span> <span class='fq'>end</span> <span class='s'>"modifier keys not supported"</span><br />
<br />
<span class='t'>QMTHREAD</span> qt<span class='p'>;</span> <span class='fd'>GetQmThreadInfo</span><span class='p'>(</span><span class='n'>0</span> qt<span class='p'>)</span><br />
<span class='fq'>mac</span> <span class='s'>"sub.Thread"</span> <span class='s'>""</span> qt.threadhandle vk<br />
<br />
<br />
<span class='dir'>#sub</span> Thread<br />
<span class='fq'>function</span> ht vk<br />
<br />
<span class='t'>int</span><span class='o'>-</span> __ht82657<span class='p'>(</span>ht<span class='p'>)</span> __vk82657<span class='p'>(</span>vk<span class='p'>)</span><br />
<br />
<span class='t'>int</span> hh<span class='o'>=</span><span class='fd'>SetWindowsHookEx</span><span class='p'>(</span><span class='d'>WH_KEYBOARD_LL</span> <span class='o'>&amp;</span><span class='fu'>sub.Hook_WH_KEYBOARD_LL</span> _hinst <span class='n'>0</span><span class='p'>)</span><br />
<span class='fq'>opt</span> waitmsg <span class='n'>1</span><br />
<span class='fq'>wait</span> <span class='n'>0</span> H ht<br />
<span class='fd'>UnhookWindowsHookEx</span> hh<br />
<br />
<br />
<span class='dir'>#sub</span> Hook_WH_KEYBOARD_LL<br />
<span class='fq'>function</span><span class='o'>#</span> nCode message <span class='t'>KBDLLHOOKSTRUCT</span><span class='o'>&amp;</span>k<br />
<span class='fq'>if</span><span class='p'>(</span>nCode<span class='o'>&lt;</span><span class='n'>0</span><span class='p'>)</span> <span class='fq'>goto</span> gNext<br />
<span class='fq'>if</span><span class='p'>(</span>k.flags<span class='o'>&amp;</span><span class='p'>(</span><span class='d'>LLKHF_UP</span><span class='o'>|</span><span class='d'>LLKHF_INJECTED</span><span class='p'>))</span> <span class='fq'>goto</span> gNext<br />
<br />
<span class='t'>int</span><span class='o'>-</span> __ht82657 __vk82657<br />
<span class='fq'>if</span> k.vkCode<span class='o'>=</span>__vk82657<br />
<span class='i'>,</span><span class='fu'>EndThread</span> <span class='s'>""</span> __ht82657<br />
<span class='i'>,</span><span class='fq'>ret</span> <span class='n'>1</span><br />
<br />
<span class='c'>;gNext</span><br />
<span class='fq'>ret</span> <span class='fd'>CallNextHookEx</span><span class='p'>(</span><span class='n'>0</span> nCode message <span class='o'>&amp;</span>k<span class='p'>)</span></code></div></div><br />
example<br />
Macro <span style="font-weight: bold;" class="mycode_b">Macro2718</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;add this line before the macro. Change the hotkey.</span><br />
<span class='fu'>SetEndThreadHotkey</span> <span class='s'>"F12"</span><br />
<br />
<span class='c'>;your macro (example)</span><br />
<span class='fq'>rep</span><br />
<span class='i'>,</span><span class='fq'>out</span> <span class='n'>1</span><br />
<span class='i'>,</span><span class='fq'>wait</span> <span class='n'>1</span></code></div></div><br />
This can be useful where the common hotkey (Pause) cannot be used:<br />
To end a non-macro thread (function etc).<br />
When the macro has property "run simultaneously".<br />
When you want to use a separate end-thread hotkey for some macros.<br />
This also can be used to end .exe macros, but probably it's better to set hotkey in the "Make exe" dialog.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Execute Python code in QM]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5919</link>
			<pubDate>Sat, 02 Jul 2016 14:02:17 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5919</guid>
			<description><![CDATA[These functions can be used to execute Python code in QM.<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Python setup</span><br />
<br />
1. Download Python 32-bit (not 64-bit) from <a href="https://www.python.org/downloads/windows/" target="_blank" rel="noopener" class="mycode_url">https://www.python.org/downloads/windows/</a><br />
    Note: may not work with Python 3.12 and later. Works with 3.11.<br />
2. Uninstall other versions of 32-bit Python.<br />
3. Run the downloaded Python installer as administrator.<br />
4. Check "Add python.exe to PATH".<br />
5. Install.<br />
6. Run cmd as administrator. Run it directly from explorer (eg Start menu), else it may inherit old environment variables.<br />
7. In cmd run: where python<br />
    It should print one or more paths. One of them must be of the new installed 32-bit Python. Copy it without "\python.exe" to the clipboard.<br />
8. In cmd change current directory to the copied. Example:<br />
    cd C:\Users\me\AppData\Local\Programs\Python\Python312-32<br />
9. In cmd run: python -m pip install --upgrade pywin32<br />
10. In cmd run one of the following. The first installs just what need for QM, the second something more.<br />
    python Lib\site-packages\win32comext\axscript\client\pyscript.py<br />
    python Scripts/pywin32_postinstall.py -install<br />
11. Exit QM (not just close window). Run QM again. Now QM Python functions should work.<br />
<br />
--<br />
The SETUP instructions in the downloaded macro are now obsolete.<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=592" target="_blank" title="">Python.qml</a> (Size: 10 KB / Downloads: 1407)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[These functions can be used to execute Python code in QM.<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Python setup</span><br />
<br />
1. Download Python 32-bit (not 64-bit) from <a href="https://www.python.org/downloads/windows/" target="_blank" rel="noopener" class="mycode_url">https://www.python.org/downloads/windows/</a><br />
    Note: may not work with Python 3.12 and later. Works with 3.11.<br />
2. Uninstall other versions of 32-bit Python.<br />
3. Run the downloaded Python installer as administrator.<br />
4. Check "Add python.exe to PATH".<br />
5. Install.<br />
6. Run cmd as administrator. Run it directly from explorer (eg Start menu), else it may inherit old environment variables.<br />
7. In cmd run: where python<br />
    It should print one or more paths. One of them must be of the new installed 32-bit Python. Copy it without "\python.exe" to the clipboard.<br />
8. In cmd change current directory to the copied. Example:<br />
    cd C:\Users\me\AppData\Local\Programs\Python\Python312-32<br />
9. In cmd run: python -m pip install --upgrade pywin32<br />
10. In cmd run one of the following. The first installs just what need for QM, the second something more.<br />
    python Lib\site-packages\win32comext\axscript\client\pyscript.py<br />
    python Scripts/pywin32_postinstall.py -install<br />
11. Exit QM (not just close window). Run QM again. Now QM Python functions should work.<br />
<br />
--<br />
The SETUP instructions in the downloaded macro are now obsolete.<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=592" target="_blank" title="">Python.qml</a> (Size: 10 KB / Downloads: 1407)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Windows API declarations for C#]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5909</link>
			<pubDate>Mon, 20 Jun 2016 07:24:15 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5909</guid>
			<description><![CDATA[<a href="http://www.quickmacros.com/com/Api.zip" target="_blank" rel="noopener" class="mycode_url">Download</a><br />
<br />
This is for C# programmers, not for QM. In QM can be used only in C# scripts.<br />
<br />
Contains 48000 declarations of struct, enum, delegate, extern functions, interfaces, coclasses, Guid, const.<br />
<br />
Converted commonly used Windows 10 SDK header files. The list is below.<br />
<br />
Tools used to convert C to C#:<br />
<a href="http://www.quickmacros.com" target="_blank" rel="noopener" class="mycode_url">Quick Macros</a> - scripting.<br />
<a href="http://clang.llvm.org/" target="_blank" rel="noopener" class="mycode_url">Clang</a> - preprocessing.<br />
Dumpbin from SDK - extracting dll names and GUID.<br />
My C-to-C# converter project.<br />
<br />
More declarations may be added in the future. Usually for me it is easy to do with these tools. Your suggestions are welcome.<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">SDK headers</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>//#define __cplusplus 201103L //clang defines this</span><br />
<span class='o'>#</span>define _MSC_VER <span class='n'>1900</span> <span class='o'>//</span>VS2015<br />
<span class='o'>#</span>define _MSC_FULL_VER <span class='n'>190023026</span><br />
<span class='o'>#</span>define _MSC_EXTENSIONS <span class='n'>1</span><br />
<br />
<span class='o'>#</span>define _UNICODE <span class='n'>1</span><br />
<span class='o'>#</span>define UNICODE <span class='n'>1</span><br />
<span class='o'>#</span>define _WCHAR_T_DEFINED <span class='n'>1</span><br />
<span class='o'>#</span>define _MT <span class='n'>1</span><br />
<span class='o'>#</span>define _DLL <span class='n'>1</span><br />
<span class='o'>#</span>define _WIN32 <span class='n'>1</span> <span class='o'>//</span>defined <span class='fq'>for</span> <span class='n'>32</span> <span class='fq'>and</span> <span class='n'>64</span><br />
<br />
<span class='dir'>#ifdef</span> USE64BIT<br />
<span class='o'>#</span>define _WIN64 <span class='n'>1</span><br />
<span class='o'>#</span>define _M_AMD64 <span class='n'>100</span><br />
<span class='o'>#</span>define _M_X64 <span class='n'>100</span><br />
<span class='dir'>#else</span><br />
<span class='o'>#</span>define _M_IX86 <span class='n'>600</span><br />
<span class='dir'>#endif</span><br />
<span class='o'>#</span>define _INTEGRAL_MAX_BITS <span class='n'>64</span> <span class='o'>//</span>need <span class='fq'>if</span> <span class='n'>32</span><br />
<br />
<span class='o'>#</span>define <span class='d'>WINVER</span> <span class='n'>0x0A00</span> <span class='o'>//</span>Win10<br />
<span class='o'>#</span>define _WIN32_WINNT <span class='n'>0x0A00</span><br />
<span class='o'>#</span>define _WIN32_IE <span class='n'>0x0B00</span> <span class='o'>//</span>IE11<br />
<br />
<span class='c'>//add __int128 struct, because C# does not have a matching type</span><br />
struct __int128 { float a<span class='p'>,</span> b<span class='p'>,</span> c<span class='p'>,</span> d<span class='p'>;</span> }<span class='p'>;</span><br />
struct __int128d { float a<span class='p'>,</span> b<span class='p'>,</span> c<span class='p'>,</span> d<span class='p'>;</span> }<span class='p'>;</span><br />
struct __int128i { float a<span class='p'>,</span> b<span class='p'>,</span> c<span class='p'>,</span> d<span class='p'>;</span> }<span class='p'>;</span><br />
<br />
<span class='c'>//prevent adding XML interfaces, but need some for parameters</span><br />
<span class='o'>#</span>define __msxml_h__<br />
<span class='o'>#</span>define __msxml2_h__<br />
<span class='o'>#</span>define __msxml6_h__<br />
typedef IntPtr IXMLElement<span class='p'>;</span><br />
typedef IntPtr IXMLDOMDocument<span class='p'>;</span><br />
<br />
<span class='c'>//add some that are in headers that we remove</span><br />
<span class='o'>#</span>define size_t LPARAM<br />
<span class='o'>#</span>define intptr_t LPARAM<br />
<span class='o'>#</span>define uintptr_t LPARAM<br />
<span class='o'>#</span>define time_t LPARAM<br />
typedef void<span class='o'>*</span> va_list<span class='p'>;</span><br />
typedef struct _iobuf { char <span class='o'>*</span>_ptr<span class='p'>;</span> <span class='t'>int</span> _cnt<span class='p'>;</span> char <span class='o'>*</span>_base<span class='p'>;</span> <span class='t'>int</span> _flag<span class='p'>;</span> <span class='t'>int</span> _file<span class='p'>;</span> <span class='t'>int</span> _charbuf<span class='p'>;</span> <span class='t'>int</span> _bufsiz<span class='p'>;</span> char <span class='o'>*</span>_tmpfname<span class='p'>;</span> } FILE<span class='p'>;</span><br />
<br />
<span class='o'>#</span>define WIN32_LEAN_AND_MEAN <span class='o'>//</span>don<span class='p'>'</span>t include come rarely used headers in windows.h<br />
<span class='o'>#</span>define USE_COM_CONTEXT_DEF <span class='o'>//</span>IContext etc<br />
<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>windows.h<span class='o'>&gt;</span><br />
<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>regstr.h<span class='o'>&gt;</span> <span class='o'>//</span>registry strings<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ole2.h<span class='o'>&gt;</span> <span class='o'>//</span>OLE. Includes objbase.h<span class='p'>,</span> oleauto.h<span class='p'>,</span> urlmon.h<span class='p'>,</span> ...<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>commctrl.h<span class='o'>&gt;</span> <span class='o'>//</span>common controls<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shlobj.h<span class='o'>&gt;</span> <span class='o'>//</span>shell<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shellapi.h<span class='o'>&gt;</span> <span class='o'>//</span>shell<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shlwapi.h<span class='o'>&gt;</span> <span class='o'>//</span>misc <span class='lib'>string</span> functions etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>olectl.h<span class='o'>&gt;</span> <span class='o'>//</span>some OLE API<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>oleacc.h<span class='o'>&gt;</span> <span class='o'>//</span>MSAA accessible objects<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>UIAutomation.h<span class='o'>&gt;</span> <span class='o'>//</span>UI Automation<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>mmsystem.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>multimedia</span> etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>tlhelp32.h<span class='o'>&gt;</span> <span class='o'>//</span>process info etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>psapi.h<span class='o'>&gt;</span> <span class='o'>//</span>process info etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>wtsapi32.h<span class='o'>&gt;</span> <span class='o'>//</span>user sessions etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winperf.h<span class='o'>&gt;</span> <span class='o'>//</span>something used with PDH<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>pdh.h<span class='o'>&gt;</span> <span class='o'>//</span>performance counters <span class='o'>//</span>TODO<span class='p'>:</span> test System.Diagnostics.PerformanceCounter<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>uxtheme.h<span class='o'>&gt;</span> <span class='o'>//</span>visual styles<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>vsstyle.h<span class='o'>&gt;</span> <span class='o'>//</span>visual styles<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dwmapi.h<span class='o'>&gt;</span> <span class='o'>//</span>DWM<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>htmlhelp.h<span class='o'>&gt;</span> <span class='o'>//</span>HTML help<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winioctl.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>file</span> IO low<span class='o'>-</span>level<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>aclapi.h<span class='o'>&gt;</span> <span class='o'>//</span>security <span class='o'>//</span>TODO<span class='p'>:</span> test System.Security.AccessControl etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>sddl.h<span class='o'>&gt;</span> <span class='o'>//</span>security strings<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>taskschd.h<span class='o'>&gt;</span> <span class='o'>//</span>Task Scheduler<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ShellScalingAPI.h<span class='o'>&gt;</span> <span class='o'>//</span>high DPI<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>appmodel.h<span class='o'>&gt;</span> <span class='o'>//</span>Windows Store apps<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winternl.h<span class='o'>&gt;</span> <span class='o'>//</span>Windows semi<span class='o'>-</span>internal API<span class='p'>,</span> eg NtX<span class='p'>,</span> RtlX<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>iepmapi.h<span class='o'>&gt;</span> <span class='o'>//</span>IE protected mode<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>userenv.h<span class='o'>&gt;</span> <span class='o'>//</span>user profiles<span class='p'>,</span> CreateEnvironmentBlock<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>netlistmgr.h<span class='o'>&gt;</span> <span class='o'>//</span>network <span class='fu'>list</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winnetwk.h<span class='o'>&gt;</span> <span class='o'>//</span>networking<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>cderr.h<span class='o'>&gt;</span> <span class='o'>//</span>commdlg errors<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>commdlg.h<span class='o'>&gt;</span> <span class='o'>//</span>common dialogs <span class='o'>//</span>TODO<span class='p'>:</span> test System.Windows.Forms.OpenFileDialog<span class='p'>,</span> .FontDialog etc.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dde.h<span class='o'>&gt;</span> <span class='o'>//</span>DDE<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ddeml.h<span class='o'>&gt;</span> <span class='o'>//</span>DDE<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>wininet.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>internet.</span> We can instead use System.Net.Http namespace <span class='fq'>and</span> System.Net.FtpWebRequest classes<span class='p'>,</span> <span class='fq'>but</span> maybe this still can be useful.<br />
<span class='o'>#</span>define _WINSOCK_DEPRECATED_NO_WARNINGS<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winsock2.h<span class='o'>&gt;</span> <span class='o'>//</span>sockets <span class='p'>(</span>TCP etc<span class='p'>)</span> <span class='o'>//</span>TODO<span class='p'>:</span> test System.Net.Sockets<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>nspapi.h<span class='o'>&gt;</span> <span class='o'>//</span>MS extensions <span class='fq'>for</span> sockets<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>richedit.h<span class='o'>&gt;</span> <span class='o'>//</span>rich edit <span class='lib'>control</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>usp10.h<span class='o'>&gt;</span> <span class='o'>//</span>text drawing low<span class='o'>-</span>level<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dbt.h<span class='o'>&gt;</span> <span class='o'>//</span>const<span class='o'>/</span>struct <span class='fq'>for</span> <span class='d'>WM_DEVICECHANGE</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ktmw32.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>file</span> transaction<br />
<span class='o'>#</span>define _MSI_NO_CRYPTO<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>msi.h<span class='o'>&gt;</span> <span class='o'>//</span>installer. MsiGetShortcutTarget<span class='p'>,</span> MsiGetComponentPath.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>commoncontrols.h<span class='o'>&gt;</span> <span class='o'>//</span>IImageList<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>powrprof.h<span class='o'>&gt;</span> <span class='o'>//</span>power profiles<span class='p'>,</span> SetSuspendState<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>lm.h<span class='o'>&gt;</span> <span class='o'>//</span>LAN management<span class='p'>,</span> <span class='fd'>NetServerEnum</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Wlanapi.h<span class='o'>&gt;</span> <span class='o'>//</span>WiFi<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>adhoc.h<span class='o'>&gt;</span> <span class='o'>//</span>WiFi<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>mscoree.h<span class='o'>&gt;</span> <span class='o'>//</span>unmanaged .NET API<br />
<br />
<span class='c'>//core audio API</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Audioclient.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Audiopolicy.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Mmdeviceapi.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Devicetopology.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Endpointvolume.h<span class='o'>&gt;</span><br />
<br />
<span class='dir'>#if</span> <span class='n'>0</span><br />
<span class='c'>//these are little tested and probably not useful</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>iphlpapi.h<span class='o'>&gt;</span> <span class='o'>//</span>IP helper<span class='p'>,</span> eg <span class='fu'>list</span> network adapters. Use System.Net.NetworkInformation namespace.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>icmpapi.h<span class='o'>&gt;</span> <span class='o'>//</span>ICMP<span class='p'>,</span> eg to implement a <span class='fu'>Ping</span><span class='p'>()</span>. Use System.Net.NetworkInformation namespace.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>GL<span class='o'>/</span>gl.h<span class='o'>&gt;</span> <span class='o'>//</span>openGL<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>GL<span class='o'>/</span>glu.h<span class='o'>&gt;</span> <span class='o'>//</span>openGL util<br />
<br />
<span class='c'>//these are never tested but seem interesting</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>RestartManager.h<span class='o'>&gt;</span> <span class='o'>//</span>restart manager<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Pla.h<span class='o'>&gt;</span> <span class='o'>//</span>performance logs <span class='fq'>and</span> alerts<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Esent.h<span class='o'>&gt;</span> <span class='o'>//</span>extensible storage engine<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Clfsw32.h<span class='o'>&gt;</span> <span class='o'>//</span>common <span class='fd'>log</span> <span class='lib'>file</span> system. .NET has something similar in System.Diagnostics.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Clfsmgmtw32.h<span class='o'>&gt;</span> <span class='o'>//</span>common <span class='fd'>log</span> <span class='lib'>file</span> management. .NET has something similar in System.Diagnostics.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>WinEvt.h<span class='o'>&gt;</span> <span class='o'>//</span>event <span class='fd'>log</span>. .NET has something similar in System.Diagnostics.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Winsxs.h<span class='o'>&gt;</span> <span class='o'>//</span>several interfaces <span class='fq'>for</span> side<span class='o'>-</span>by<span class='o'>-</span>side assembly management<br />
<br />
<span class='c'>//these probably should not be added</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shldisp.h<span class='o'>&gt;</span> <span class='o'>//</span>shell <span class='t'>IDispatch</span> interfaces<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>scrnsave.h<span class='o'>&gt;</span> <span class='o'>//</span>screen saver<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dbghelp.h<span class='o'>&gt;</span> <span class='o'>//</span>debug help library<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>imagehlp.h<span class='o'>&gt;</span> <span class='o'>//</span>many the same as dbghelp.h. Includes wintrust.h <span class='o'>-&gt;</span> wincrypt.h which is not welcome.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>setupapi.h<span class='o'>&gt;</span> <span class='o'>//</span>obsolete<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>mapi.h<span class='o'>&gt;</span> <span class='o'>//</span>only <span class='fq'>for</span> MS Outlook. Can instead use Outlook COM.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>snmp.h<span class='o'>&gt;</span> <span class='o'>//</span>can instead download a SNMP .NET library<br />
<span class='o'>#</span>include Sspi.h <span class='o'>//</span>authentication. Includes Security.h. Use .NET classes.<br />
<span class='c'>//these would be included if no WIN32_LEAN_AND_MEAN</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winefs.h<span class='o'>&gt;</span> <span class='o'>//</span>encrypted <span class='lib'>file</span> system. .NET can encrypt<span class='o'>/</span>decrypt a <span class='lib'>file</span><span class='p'>,</span> <span class='fq'>but</span> maybe this also can be useful.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winspool.h<span class='o'>&gt;</span> <span class='o'>//</span>printer API. Big. Use System.Drawing.Printing namespace. See also System.Printing namespace.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>wincrypt.h<span class='o'>&gt;</span> <span class='o'>//</span>cryptography. Large. Use System.Security.Cryptography namespace.<br />
<span class='dir'>#endif</span></code></div></div><br />
How to use the downloaded file containing Windows API declarations:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>// Don't add this file to your project. Copy-paste only declarations that you need.</span><br />
<span class='c'>// Not all declarations can be compiled without editing.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;For example, cannot declare some struct pointer (use IntPtr instead, or in struct replace non-blittable types with IntPtr etc), cannot use undefined struct pointer/ref/out (use IntPtr instead).</span><br />
<span class='c'>// Not all declarations are correct, usually because declarations in Windows SDK files from which they have been automatically converted lack some info.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;For example, some function parameters that should be 'out' or '[Out]' or '[In]' or array now are just 'ref', because SDK declarations didn't have proper in/out annotations. Also for this reason some parameters that should be 'string' now are 'StringBuilder'.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;You may want to create overloads where parameters can be of more than one type.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;You may want to add 'SetLastError=true' to DllImport attribute parameters.</span><br />
<span class='c'>// Some declarations contain pointers and therefore can be used only in 'unsafe' context, in some cases with 'fixed'. Or you can replace pointers to IntPtr.</span><br />
<span class='c'>// These declarations are for Windows 10. Some Windows API are different or missing on other Windows versions.</span><br />
<span class='c'>// In some cases need to use different declarations in 32-bit and 64-bit process. This file contains everything that is not different, + 64-bit versions, + 32-bit versions with name suffix ""__32"".</span></code></div></div><br />
Also known as P/invoke, pinvoke, platform invoke signatures, call unmanaged dll exported methods, Win32 API, COM interop.]]></description>
			<content:encoded><![CDATA[<a href="http://www.quickmacros.com/com/Api.zip" target="_blank" rel="noopener" class="mycode_url">Download</a><br />
<br />
This is for C# programmers, not for QM. In QM can be used only in C# scripts.<br />
<br />
Contains 48000 declarations of struct, enum, delegate, extern functions, interfaces, coclasses, Guid, const.<br />
<br />
Converted commonly used Windows 10 SDK header files. The list is below.<br />
<br />
Tools used to convert C to C#:<br />
<a href="http://www.quickmacros.com" target="_blank" rel="noopener" class="mycode_url">Quick Macros</a> - scripting.<br />
<a href="http://clang.llvm.org/" target="_blank" rel="noopener" class="mycode_url">Clang</a> - preprocessing.<br />
Dumpbin from SDK - extracting dll names and GUID.<br />
My C-to-C# converter project.<br />
<br />
More declarations may be added in the future. Usually for me it is easy to do with these tools. Your suggestions are welcome.<br />
<br />
Macro <span style="font-weight: bold;" class="mycode_b">SDK headers</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>//#define __cplusplus 201103L //clang defines this</span><br />
<span class='o'>#</span>define _MSC_VER <span class='n'>1900</span> <span class='o'>//</span>VS2015<br />
<span class='o'>#</span>define _MSC_FULL_VER <span class='n'>190023026</span><br />
<span class='o'>#</span>define _MSC_EXTENSIONS <span class='n'>1</span><br />
<br />
<span class='o'>#</span>define _UNICODE <span class='n'>1</span><br />
<span class='o'>#</span>define UNICODE <span class='n'>1</span><br />
<span class='o'>#</span>define _WCHAR_T_DEFINED <span class='n'>1</span><br />
<span class='o'>#</span>define _MT <span class='n'>1</span><br />
<span class='o'>#</span>define _DLL <span class='n'>1</span><br />
<span class='o'>#</span>define _WIN32 <span class='n'>1</span> <span class='o'>//</span>defined <span class='fq'>for</span> <span class='n'>32</span> <span class='fq'>and</span> <span class='n'>64</span><br />
<br />
<span class='dir'>#ifdef</span> USE64BIT<br />
<span class='o'>#</span>define _WIN64 <span class='n'>1</span><br />
<span class='o'>#</span>define _M_AMD64 <span class='n'>100</span><br />
<span class='o'>#</span>define _M_X64 <span class='n'>100</span><br />
<span class='dir'>#else</span><br />
<span class='o'>#</span>define _M_IX86 <span class='n'>600</span><br />
<span class='dir'>#endif</span><br />
<span class='o'>#</span>define _INTEGRAL_MAX_BITS <span class='n'>64</span> <span class='o'>//</span>need <span class='fq'>if</span> <span class='n'>32</span><br />
<br />
<span class='o'>#</span>define <span class='d'>WINVER</span> <span class='n'>0x0A00</span> <span class='o'>//</span>Win10<br />
<span class='o'>#</span>define _WIN32_WINNT <span class='n'>0x0A00</span><br />
<span class='o'>#</span>define _WIN32_IE <span class='n'>0x0B00</span> <span class='o'>//</span>IE11<br />
<br />
<span class='c'>//add __int128 struct, because C# does not have a matching type</span><br />
struct __int128 { float a<span class='p'>,</span> b<span class='p'>,</span> c<span class='p'>,</span> d<span class='p'>;</span> }<span class='p'>;</span><br />
struct __int128d { float a<span class='p'>,</span> b<span class='p'>,</span> c<span class='p'>,</span> d<span class='p'>;</span> }<span class='p'>;</span><br />
struct __int128i { float a<span class='p'>,</span> b<span class='p'>,</span> c<span class='p'>,</span> d<span class='p'>;</span> }<span class='p'>;</span><br />
<br />
<span class='c'>//prevent adding XML interfaces, but need some for parameters</span><br />
<span class='o'>#</span>define __msxml_h__<br />
<span class='o'>#</span>define __msxml2_h__<br />
<span class='o'>#</span>define __msxml6_h__<br />
typedef IntPtr IXMLElement<span class='p'>;</span><br />
typedef IntPtr IXMLDOMDocument<span class='p'>;</span><br />
<br />
<span class='c'>//add some that are in headers that we remove</span><br />
<span class='o'>#</span>define size_t LPARAM<br />
<span class='o'>#</span>define intptr_t LPARAM<br />
<span class='o'>#</span>define uintptr_t LPARAM<br />
<span class='o'>#</span>define time_t LPARAM<br />
typedef void<span class='o'>*</span> va_list<span class='p'>;</span><br />
typedef struct _iobuf { char <span class='o'>*</span>_ptr<span class='p'>;</span> <span class='t'>int</span> _cnt<span class='p'>;</span> char <span class='o'>*</span>_base<span class='p'>;</span> <span class='t'>int</span> _flag<span class='p'>;</span> <span class='t'>int</span> _file<span class='p'>;</span> <span class='t'>int</span> _charbuf<span class='p'>;</span> <span class='t'>int</span> _bufsiz<span class='p'>;</span> char <span class='o'>*</span>_tmpfname<span class='p'>;</span> } FILE<span class='p'>;</span><br />
<br />
<span class='o'>#</span>define WIN32_LEAN_AND_MEAN <span class='o'>//</span>don<span class='p'>'</span>t include come rarely used headers in windows.h<br />
<span class='o'>#</span>define USE_COM_CONTEXT_DEF <span class='o'>//</span>IContext etc<br />
<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>windows.h<span class='o'>&gt;</span><br />
<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>regstr.h<span class='o'>&gt;</span> <span class='o'>//</span>registry strings<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ole2.h<span class='o'>&gt;</span> <span class='o'>//</span>OLE. Includes objbase.h<span class='p'>,</span> oleauto.h<span class='p'>,</span> urlmon.h<span class='p'>,</span> ...<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>commctrl.h<span class='o'>&gt;</span> <span class='o'>//</span>common controls<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shlobj.h<span class='o'>&gt;</span> <span class='o'>//</span>shell<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shellapi.h<span class='o'>&gt;</span> <span class='o'>//</span>shell<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shlwapi.h<span class='o'>&gt;</span> <span class='o'>//</span>misc <span class='lib'>string</span> functions etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>olectl.h<span class='o'>&gt;</span> <span class='o'>//</span>some OLE API<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>oleacc.h<span class='o'>&gt;</span> <span class='o'>//</span>MSAA accessible objects<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>UIAutomation.h<span class='o'>&gt;</span> <span class='o'>//</span>UI Automation<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>mmsystem.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>multimedia</span> etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>tlhelp32.h<span class='o'>&gt;</span> <span class='o'>//</span>process info etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>psapi.h<span class='o'>&gt;</span> <span class='o'>//</span>process info etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>wtsapi32.h<span class='o'>&gt;</span> <span class='o'>//</span>user sessions etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winperf.h<span class='o'>&gt;</span> <span class='o'>//</span>something used with PDH<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>pdh.h<span class='o'>&gt;</span> <span class='o'>//</span>performance counters <span class='o'>//</span>TODO<span class='p'>:</span> test System.Diagnostics.PerformanceCounter<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>uxtheme.h<span class='o'>&gt;</span> <span class='o'>//</span>visual styles<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>vsstyle.h<span class='o'>&gt;</span> <span class='o'>//</span>visual styles<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dwmapi.h<span class='o'>&gt;</span> <span class='o'>//</span>DWM<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>htmlhelp.h<span class='o'>&gt;</span> <span class='o'>//</span>HTML help<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winioctl.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>file</span> IO low<span class='o'>-</span>level<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>aclapi.h<span class='o'>&gt;</span> <span class='o'>//</span>security <span class='o'>//</span>TODO<span class='p'>:</span> test System.Security.AccessControl etc<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>sddl.h<span class='o'>&gt;</span> <span class='o'>//</span>security strings<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>taskschd.h<span class='o'>&gt;</span> <span class='o'>//</span>Task Scheduler<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ShellScalingAPI.h<span class='o'>&gt;</span> <span class='o'>//</span>high DPI<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>appmodel.h<span class='o'>&gt;</span> <span class='o'>//</span>Windows Store apps<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winternl.h<span class='o'>&gt;</span> <span class='o'>//</span>Windows semi<span class='o'>-</span>internal API<span class='p'>,</span> eg NtX<span class='p'>,</span> RtlX<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>iepmapi.h<span class='o'>&gt;</span> <span class='o'>//</span>IE protected mode<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>userenv.h<span class='o'>&gt;</span> <span class='o'>//</span>user profiles<span class='p'>,</span> CreateEnvironmentBlock<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>netlistmgr.h<span class='o'>&gt;</span> <span class='o'>//</span>network <span class='fu'>list</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winnetwk.h<span class='o'>&gt;</span> <span class='o'>//</span>networking<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>cderr.h<span class='o'>&gt;</span> <span class='o'>//</span>commdlg errors<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>commdlg.h<span class='o'>&gt;</span> <span class='o'>//</span>common dialogs <span class='o'>//</span>TODO<span class='p'>:</span> test System.Windows.Forms.OpenFileDialog<span class='p'>,</span> .FontDialog etc.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dde.h<span class='o'>&gt;</span> <span class='o'>//</span>DDE<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ddeml.h<span class='o'>&gt;</span> <span class='o'>//</span>DDE<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>wininet.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>internet.</span> We can instead use System.Net.Http namespace <span class='fq'>and</span> System.Net.FtpWebRequest classes<span class='p'>,</span> <span class='fq'>but</span> maybe this still can be useful.<br />
<span class='o'>#</span>define _WINSOCK_DEPRECATED_NO_WARNINGS<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winsock2.h<span class='o'>&gt;</span> <span class='o'>//</span>sockets <span class='p'>(</span>TCP etc<span class='p'>)</span> <span class='o'>//</span>TODO<span class='p'>:</span> test System.Net.Sockets<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>nspapi.h<span class='o'>&gt;</span> <span class='o'>//</span>MS extensions <span class='fq'>for</span> sockets<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>richedit.h<span class='o'>&gt;</span> <span class='o'>//</span>rich edit <span class='lib'>control</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>usp10.h<span class='o'>&gt;</span> <span class='o'>//</span>text drawing low<span class='o'>-</span>level<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dbt.h<span class='o'>&gt;</span> <span class='o'>//</span>const<span class='o'>/</span>struct <span class='fq'>for</span> <span class='d'>WM_DEVICECHANGE</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>ktmw32.h<span class='o'>&gt;</span> <span class='o'>//</span><span class='lib'>file</span> transaction<br />
<span class='o'>#</span>define _MSI_NO_CRYPTO<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>msi.h<span class='o'>&gt;</span> <span class='o'>//</span>installer. MsiGetShortcutTarget<span class='p'>,</span> MsiGetComponentPath.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>commoncontrols.h<span class='o'>&gt;</span> <span class='o'>//</span>IImageList<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>powrprof.h<span class='o'>&gt;</span> <span class='o'>//</span>power profiles<span class='p'>,</span> SetSuspendState<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>lm.h<span class='o'>&gt;</span> <span class='o'>//</span>LAN management<span class='p'>,</span> <span class='fd'>NetServerEnum</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Wlanapi.h<span class='o'>&gt;</span> <span class='o'>//</span>WiFi<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>adhoc.h<span class='o'>&gt;</span> <span class='o'>//</span>WiFi<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>mscoree.h<span class='o'>&gt;</span> <span class='o'>//</span>unmanaged .NET API<br />
<br />
<span class='c'>//core audio API</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Audioclient.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Audiopolicy.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Mmdeviceapi.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Devicetopology.h<span class='o'>&gt;</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Endpointvolume.h<span class='o'>&gt;</span><br />
<br />
<span class='dir'>#if</span> <span class='n'>0</span><br />
<span class='c'>//these are little tested and probably not useful</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>iphlpapi.h<span class='o'>&gt;</span> <span class='o'>//</span>IP helper<span class='p'>,</span> eg <span class='fu'>list</span> network adapters. Use System.Net.NetworkInformation namespace.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>icmpapi.h<span class='o'>&gt;</span> <span class='o'>//</span>ICMP<span class='p'>,</span> eg to implement a <span class='fu'>Ping</span><span class='p'>()</span>. Use System.Net.NetworkInformation namespace.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>GL<span class='o'>/</span>gl.h<span class='o'>&gt;</span> <span class='o'>//</span>openGL<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>GL<span class='o'>/</span>glu.h<span class='o'>&gt;</span> <span class='o'>//</span>openGL util<br />
<br />
<span class='c'>//these are never tested but seem interesting</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>RestartManager.h<span class='o'>&gt;</span> <span class='o'>//</span>restart manager<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Pla.h<span class='o'>&gt;</span> <span class='o'>//</span>performance logs <span class='fq'>and</span> alerts<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Esent.h<span class='o'>&gt;</span> <span class='o'>//</span>extensible storage engine<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Clfsw32.h<span class='o'>&gt;</span> <span class='o'>//</span>common <span class='fd'>log</span> <span class='lib'>file</span> system. .NET has something similar in System.Diagnostics.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Clfsmgmtw32.h<span class='o'>&gt;</span> <span class='o'>//</span>common <span class='fd'>log</span> <span class='lib'>file</span> management. .NET has something similar in System.Diagnostics.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>WinEvt.h<span class='o'>&gt;</span> <span class='o'>//</span>event <span class='fd'>log</span>. .NET has something similar in System.Diagnostics.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>Winsxs.h<span class='o'>&gt;</span> <span class='o'>//</span>several interfaces <span class='fq'>for</span> side<span class='o'>-</span>by<span class='o'>-</span>side assembly management<br />
<br />
<span class='c'>//these probably should not be added</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>shldisp.h<span class='o'>&gt;</span> <span class='o'>//</span>shell <span class='t'>IDispatch</span> interfaces<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>scrnsave.h<span class='o'>&gt;</span> <span class='o'>//</span>screen saver<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>dbghelp.h<span class='o'>&gt;</span> <span class='o'>//</span>debug help library<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>imagehlp.h<span class='o'>&gt;</span> <span class='o'>//</span>many the same as dbghelp.h. Includes wintrust.h <span class='o'>-&gt;</span> wincrypt.h which is not welcome.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>setupapi.h<span class='o'>&gt;</span> <span class='o'>//</span>obsolete<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>mapi.h<span class='o'>&gt;</span> <span class='o'>//</span>only <span class='fq'>for</span> MS Outlook. Can instead use Outlook COM.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>snmp.h<span class='o'>&gt;</span> <span class='o'>//</span>can instead download a SNMP .NET library<br />
<span class='o'>#</span>include Sspi.h <span class='o'>//</span>authentication. Includes Security.h. Use .NET classes.<br />
<span class='c'>//these would be included if no WIN32_LEAN_AND_MEAN</span><br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winefs.h<span class='o'>&gt;</span> <span class='o'>//</span>encrypted <span class='lib'>file</span> system. .NET can encrypt<span class='o'>/</span>decrypt a <span class='lib'>file</span><span class='p'>,</span> <span class='fq'>but</span> maybe this also can be useful.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>winspool.h<span class='o'>&gt;</span> <span class='o'>//</span>printer API. Big. Use System.Drawing.Printing namespace. See also System.Printing namespace.<br />
<span class='o'>#</span>include <span class='o'>&lt;</span>wincrypt.h<span class='o'>&gt;</span> <span class='o'>//</span>cryptography. Large. Use System.Security.Cryptography namespace.<br />
<span class='dir'>#endif</span></code></div></div><br />
How to use the downloaded file containing Windows API declarations:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>// Don't add this file to your project. Copy-paste only declarations that you need.</span><br />
<span class='c'>// Not all declarations can be compiled without editing.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;For example, cannot declare some struct pointer (use IntPtr instead, or in struct replace non-blittable types with IntPtr etc), cannot use undefined struct pointer/ref/out (use IntPtr instead).</span><br />
<span class='c'>// Not all declarations are correct, usually because declarations in Windows SDK files from which they have been automatically converted lack some info.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;For example, some function parameters that should be 'out' or '[Out]' or '[In]' or array now are just 'ref', because SDK declarations didn't have proper in/out annotations. Also for this reason some parameters that should be 'string' now are 'StringBuilder'.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;You may want to create overloads where parameters can be of more than one type.</span><br />
<span class='c'>//&nbsp;&nbsp;&nbsp;&nbsp;You may want to add 'SetLastError=true' to DllImport attribute parameters.</span><br />
<span class='c'>// Some declarations contain pointers and therefore can be used only in 'unsafe' context, in some cases with 'fixed'. Or you can replace pointers to IntPtr.</span><br />
<span class='c'>// These declarations are for Windows 10. Some Windows API are different or missing on other Windows versions.</span><br />
<span class='c'>// In some cases need to use different declarations in 32-bit and 64-bit process. This file contains everything that is not different, + 64-bit versions, + 32-bit versions with name suffix ""__32"".</span></code></div></div><br />
Also known as P/invoke, pinvoke, platform invoke signatures, call unmanaged dll exported methods, Win32 API, COM interop.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[open web page with POST variables]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5322</link>
			<pubDate>Mon, 29 Dec 2014 16:26:17 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=262">hirschor</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5322</guid>
			<description><![CDATA[I am trying to open a web page with POST instead of GET in order to post some variables to it, but I can't get the code to work.  The page opens, but it does not receive the POST variables.<br />
<br />
VARIANT flags=0<br />
VARIANT target="_blank"<br />
VARIANT* postdata<br />
VARIANT headers = "Content-Type: application/x-www-form-urlencoded"<br />
SAFEARRAY* psa<br />
str data="a=hello"<br />
<br />
<br />
psa = SafeArrayCreateVector(VT_UI1,0,len(data))<br />
SafeArrayAccessData(psa, &amp;data)<br />
SafeArrayUnaccessData(psa) ;; not sure if this is needed<br />
<br />
postdata = psa<br />
<br />
SHDocVw.IWebBrowser2 b=web("")<br />
b.Navigate("http://siuhradweb/test.php" &amp;flags &amp;target postdata &amp;headers)]]></description>
			<content:encoded><![CDATA[I am trying to open a web page with POST instead of GET in order to post some variables to it, but I can't get the code to work.  The page opens, but it does not receive the POST variables.<br />
<br />
VARIANT flags=0<br />
VARIANT target="_blank"<br />
VARIANT* postdata<br />
VARIANT headers = "Content-Type: application/x-www-form-urlencoded"<br />
SAFEARRAY* psa<br />
str data="a=hello"<br />
<br />
<br />
psa = SafeArrayCreateVector(VT_UI1,0,len(data))<br />
SafeArrayAccessData(psa, &amp;data)<br />
SafeArrayUnaccessData(psa) ;; not sure if this is needed<br />
<br />
postdata = psa<br />
<br />
SHDocVw.IWebBrowser2 b=web("")<br />
b.Navigate("http://siuhradweb/test.php" &amp;flags &amp;target postdata &amp;headers)]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[COeMessages help]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5299</link>
			<pubDate>Mon, 24 Nov 2014 11:44:43 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=335">ssimop</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5299</guid>
			<description><![CDATA[Referring to : <a href="http://www.quickmacros.com/forum/showthread.php?tid=2938" target="_blank" rel="noopener" class="mycode_url">Getting and managing Outlook Express messages and folders</a><br />
<br />
I am wondering about the way these routines may be modified in order to handle messages of an OE identity, other than Main Identity. <br />
<br />
I understand the information here is relevant :<br />
<a href="http://stackoverflow.com/questions/20059996/selecting-outlook-express-identity-using-code" target="_blank" rel="noopener" class="mycode_url">http://stackoverflow.com/questions/2005 ... using-code</a><br />
<br />
Any advice is welcome. Many thanks in advance.]]></description>
			<content:encoded><![CDATA[Referring to : <a href="http://www.quickmacros.com/forum/showthread.php?tid=2938" target="_blank" rel="noopener" class="mycode_url">Getting and managing Outlook Express messages and folders</a><br />
<br />
I am wondering about the way these routines may be modified in order to handle messages of an OE identity, other than Main Identity. <br />
<br />
I understand the information here is relevant :<br />
<a href="http://stackoverflow.com/questions/20059996/selecting-outlook-express-identity-using-code" target="_blank" rel="noopener" class="mycode_url">http://stackoverflow.com/questions/2005 ... using-code</a><br />
<br />
Any advice is welcome. Many thanks in advance.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Selenium web recorder and QM]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5209</link>
			<pubDate>Mon, 15 Sep 2014 09:09:08 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5209</guid>
			<description><![CDATA[2014-11-24. Updated to work with Selenium IDE 2.8.0. Tested WebDriver 2.44, now works with Firefox.<br />
<br />
This class allows to automate Internet Explorer, Firefox and Chrome using Selenium WebDriver.<br />
 Selenium is a web recorder and API for web page automation, eg for automated testing. Free, open-source.<br />
 Selenium downloads: <a href="http://docs.seleniumhq.org/download/" target="_blank" rel="noopener" class="mycode_url">http://docs.seleniumhq.org/download/</a><br />
 Selenium scripts can be recorded/edited with the Selenium IDE or created manually in QM.<br />
 To export current script (Test Case) from Selenium IDE to QM, use the small toolbar with QM icon that QM adds to the IDE.<br />
 In QM macros the scripts can be executed in 2 ways:<br />
   1. Call ISelenium interface functions directly. The QM Selenium toolbar button creates such code if in Selenium IDE menu Options -&gt; Clipboard Format is selected C# Remote Control.<br />
   2. Call a user-defined C# function that uses functions of IWebDriver and other Selenium classes/interfaces available in C#. The QM Selenium toolbar button creates such code if in Selenium IDE menu Options -&gt; Clipboard Format is selected C# WebDriver.<br />
 You can find the Selenium API reference in the Selenium website or in the help file downloaded with C# language bindings.<br />
<br />
 Selenium setup:<br />
 Create folder for Selenium files. It should be QM folder's subfolder Selenium (&#36;qm&#36;\Selenium); if not, will need to specify it with SetOptions().<br />
 Selenium consists of multiple components without a common installer. Download what you need.<br />
 From Selenium website you need:<br />
	 Selenium IDE. Need it only to record web actions, don't need to run Selenium scripts.<br />
	 Selenium WebDriver bindings for C#. Create folder C# in the Selenium folder (&#36;qm&#36;\Selenium\C#) and add there all files from downloaded folder net35 (WinXP/7) or net40 (Win8/10).<br />
	 If you'll use IE, download Internet Explorer Driver Server. Add IEDriverServer.exe to the Selenium folder.<br />
	 If you'll use Chrome, download Chrome browser driver. Add chromedriver.exe to the Selenium folder.<br />
 Also you need:<br />
	 Windows XP SP2 or later.<br />
	 .NET framework 3.5 or 4.x. Windows 7 and 8 have it. If your Windows is older and the .NET framework is not installed, download .NET 3.5 from Microsoft.<br />
	 Firefox. Only for Selenium IDE, because it is a Firefox plugin.<br />
 Also you may need:<br />
	 NUnit. Only if you'll use Assert.IsTrue etc in C#. Don't need for ISelenium functions. Install NUnit eg in Program Files, and copy nunit.framework.dll to the Selenium folder.<br />
<br />
 Selenium problems:<br />
 There are no ways to automate an existing browser instance.<br />
   You can reuse only the browser instance started by StartChrome() etc without flag 1 in same QM process.<br />
   Also it means that if QM is running as admin, browser processes also run as admin. It is not good for security.<br />
 Manually closing a Selenium-started browser does not close its driver process and does not delete temporary files (eg a Firefox profile may be 30 MB).<br />
   The correct way to close browser - call Quit in the macro. Or use flag 1 with StartChrome() etc, then Quit is called automatically.<br />
   Without flag 1, StartChrome() etc correctly closes the browser that was previously started by the same function (StartChrome() etc) without flag 1 in same QM process.<br />
   Another correct way - use flag 2 with StartChrome() etc. It shows a driver console window if the browser is Chrome or IE. Let the user close the console after closing its controlled browser.<br />
 If using IE, may need to change Protected Mode in IE Options -&gt; Security. Must be the same in all zones.<br />
 The IE driver process may crash when an ISelenium function does not find an element.<br />
 Selenium-started IE does not respond to user clicks.<br />
 On one of my computers did not work correctly with IE if Java is not installed. You can download Java 32-bit from Oracle. Look in Control Panel, maybe you already have it.<br />
 Does not support high DPI. Clicks in wrong place. Tested only with IE.<br />
 Does not give the browser window handle. If you need it, use win() after StartChrome() etc.<br />
 WebDriver 2.42 did not work with Firefox 32 and later. Version 2.44 works.<br />
<br />
Examples<br />
Macro <span style="font-weight: bold;" class="mycode_b">WebDriver help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Example with ISelenium functions called from QM macro</span><br />
<span class='r'>#region Selenium, recorded 2014.09.13 08:21</span><br />
<span class='dir'>#compile</span> <span class='s'>"__WebDriver"</span><br />
<span class='t'>WebDriver</span> x.<span class='fu'>Init</span><span class='p'>(</span><span class='s'>""</span><span class='p'>)</span><br />
<span class='t'>str</span> baseURL<span class='o'>=</span><span class='s'>"http://www.quickmacros.com"</span><br />
<span class='t'>ISelenium</span> selenium<span class='o'>=</span>x.<span class='fu'>StartChrome</span><span class='p'>(</span>baseURL<span class='p'>)</span> <span class='c2'>;;StartChrome, StartFirefox or StartIE</span><br />
<br />
selenium.<span class='fd'>Open</span><span class='p'>(</span><span class='s'>"/index.html"</span><span class='p'>)</span><br />
selenium.<span class='fd'>Click</span><span class='p'>(</span><span class='s'>"id=m_forum"</span><span class='p'>);</span> selenium.<span class='fd'>WaitForPageToLoad</span><span class='p'>(</span><span class='s'>"30000"</span><span class='p'>)</span><br />
selenium.<span class='fd'>Click</span><span class='p'>(</span><span class='s'>"link=QM Extensions"</span><span class='p'>);</span> selenium.<span class='fd'>WaitForPageToLoad</span><span class='p'>(</span><span class='s'>"30000"</span><span class='p'>)</span><br />
<br />
<span class='fq'>if</span><span class='p'>(</span><span class='fq'>mes</span><span class='p'>(</span><span class='s'>"Close browser?"</span> <span class='s'>""</span> <span class='s'>"YN?2"</span><span class='p'>)</span><span class='o'>=</span><span class='n'>'Y'</span><span class='p'>)</span> x.<span class='fu'>Quit</span><br />
<span class='r'>#endregion</span></code></div></div>Macro <span style="font-weight: bold;" class="mycode_b">WebDriver help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Example with IWebDriver functions called from C# code</span><br />
<span class='r'>#region Selenium, recorded 2014.09.13 08:21</span><br />
<span class='dir'>#compile</span> <span class='s'>"__WebDriver"</span><br />
<span class='t'>WebDriver</span> x2.<span class='fu'>Init</span><span class='p'>(</span><span class='d'>__FUNCTION__</span><span class='p'>)</span><br />
<span class='t'>str</span> baseURL2<span class='o'>=</span><span class='s'>"http://www.quickmacros.com"</span><br />
x2.<span class='fu'>StartChrome</span><span class='p'>(</span>baseURL2<span class='p'>)</span> <span class='c2'>;;StartChrome, StartFirefox or StartIE</span><br />
<br />
x2.x.Run<br />
<br />
<span class='fq'>if</span><span class='p'>(</span><span class='fq'>mes</span><span class='p'>(</span><span class='s'>"Close browser?"</span> <span class='s'>""</span> <span class='s'>"YN?2"</span><span class='p'>)</span><span class='o'>=</span><span class='n'>'Y'</span><span class='p'>)</span> x2.<span class='fu'>Quit</span><br />
<span class='r'>#endregion</span><br />
<br />
<br />
<span class='dir'>#ret</span><br />
public void Run<span class='p'>()</span>{<br />
driver.Navigate<span class='p'>()</span>.GoToUrl<span class='p'>(</span>baseURL <span class='o'>+</span> <span class='s'>"/index.html"</span><span class='p'>);</span><br />
driver.FindElement<span class='p'>(</span>By.Id<span class='p'>(</span><span class='s'>"m_forum"</span><span class='p'>))</span>.Click<span class='p'>();</span><br />
driver.FindElement<span class='p'>(</span>By.LinkText<span class='p'>(</span><span class='s'>"QM Extensions"</span><span class='p'>))</span>.Click<span class='p'>();</span><br />
}</code></div></div><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=494" target="_blank" title="">Selenium.qml</a> (Size: 36 KB / Downloads: 1453)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[2014-11-24. Updated to work with Selenium IDE 2.8.0. Tested WebDriver 2.44, now works with Firefox.<br />
<br />
This class allows to automate Internet Explorer, Firefox and Chrome using Selenium WebDriver.<br />
 Selenium is a web recorder and API for web page automation, eg for automated testing. Free, open-source.<br />
 Selenium downloads: <a href="http://docs.seleniumhq.org/download/" target="_blank" rel="noopener" class="mycode_url">http://docs.seleniumhq.org/download/</a><br />
 Selenium scripts can be recorded/edited with the Selenium IDE or created manually in QM.<br />
 To export current script (Test Case) from Selenium IDE to QM, use the small toolbar with QM icon that QM adds to the IDE.<br />
 In QM macros the scripts can be executed in 2 ways:<br />
   1. Call ISelenium interface functions directly. The QM Selenium toolbar button creates such code if in Selenium IDE menu Options -&gt; Clipboard Format is selected C# Remote Control.<br />
   2. Call a user-defined C# function that uses functions of IWebDriver and other Selenium classes/interfaces available in C#. The QM Selenium toolbar button creates such code if in Selenium IDE menu Options -&gt; Clipboard Format is selected C# WebDriver.<br />
 You can find the Selenium API reference in the Selenium website or in the help file downloaded with C# language bindings.<br />
<br />
 Selenium setup:<br />
 Create folder for Selenium files. It should be QM folder's subfolder Selenium (&#36;qm&#36;\Selenium); if not, will need to specify it with SetOptions().<br />
 Selenium consists of multiple components without a common installer. Download what you need.<br />
 From Selenium website you need:<br />
	 Selenium IDE. Need it only to record web actions, don't need to run Selenium scripts.<br />
	 Selenium WebDriver bindings for C#. Create folder C# in the Selenium folder (&#36;qm&#36;\Selenium\C#) and add there all files from downloaded folder net35 (WinXP/7) or net40 (Win8/10).<br />
	 If you'll use IE, download Internet Explorer Driver Server. Add IEDriverServer.exe to the Selenium folder.<br />
	 If you'll use Chrome, download Chrome browser driver. Add chromedriver.exe to the Selenium folder.<br />
 Also you need:<br />
	 Windows XP SP2 or later.<br />
	 .NET framework 3.5 or 4.x. Windows 7 and 8 have it. If your Windows is older and the .NET framework is not installed, download .NET 3.5 from Microsoft.<br />
	 Firefox. Only for Selenium IDE, because it is a Firefox plugin.<br />
 Also you may need:<br />
	 NUnit. Only if you'll use Assert.IsTrue etc in C#. Don't need for ISelenium functions. Install NUnit eg in Program Files, and copy nunit.framework.dll to the Selenium folder.<br />
<br />
 Selenium problems:<br />
 There are no ways to automate an existing browser instance.<br />
   You can reuse only the browser instance started by StartChrome() etc without flag 1 in same QM process.<br />
   Also it means that if QM is running as admin, browser processes also run as admin. It is not good for security.<br />
 Manually closing a Selenium-started browser does not close its driver process and does not delete temporary files (eg a Firefox profile may be 30 MB).<br />
   The correct way to close browser - call Quit in the macro. Or use flag 1 with StartChrome() etc, then Quit is called automatically.<br />
   Without flag 1, StartChrome() etc correctly closes the browser that was previously started by the same function (StartChrome() etc) without flag 1 in same QM process.<br />
   Another correct way - use flag 2 with StartChrome() etc. It shows a driver console window if the browser is Chrome or IE. Let the user close the console after closing its controlled browser.<br />
 If using IE, may need to change Protected Mode in IE Options -&gt; Security. Must be the same in all zones.<br />
 The IE driver process may crash when an ISelenium function does not find an element.<br />
 Selenium-started IE does not respond to user clicks.<br />
 On one of my computers did not work correctly with IE if Java is not installed. You can download Java 32-bit from Oracle. Look in Control Panel, maybe you already have it.<br />
 Does not support high DPI. Clicks in wrong place. Tested only with IE.<br />
 Does not give the browser window handle. If you need it, use win() after StartChrome() etc.<br />
 WebDriver 2.42 did not work with Firefox 32 and later. Version 2.44 works.<br />
<br />
Examples<br />
Macro <span style="font-weight: bold;" class="mycode_b">WebDriver help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Example with ISelenium functions called from QM macro</span><br />
<span class='r'>#region Selenium, recorded 2014.09.13 08:21</span><br />
<span class='dir'>#compile</span> <span class='s'>"__WebDriver"</span><br />
<span class='t'>WebDriver</span> x.<span class='fu'>Init</span><span class='p'>(</span><span class='s'>""</span><span class='p'>)</span><br />
<span class='t'>str</span> baseURL<span class='o'>=</span><span class='s'>"http://www.quickmacros.com"</span><br />
<span class='t'>ISelenium</span> selenium<span class='o'>=</span>x.<span class='fu'>StartChrome</span><span class='p'>(</span>baseURL<span class='p'>)</span> <span class='c2'>;;StartChrome, StartFirefox or StartIE</span><br />
<br />
selenium.<span class='fd'>Open</span><span class='p'>(</span><span class='s'>"/index.html"</span><span class='p'>)</span><br />
selenium.<span class='fd'>Click</span><span class='p'>(</span><span class='s'>"id=m_forum"</span><span class='p'>);</span> selenium.<span class='fd'>WaitForPageToLoad</span><span class='p'>(</span><span class='s'>"30000"</span><span class='p'>)</span><br />
selenium.<span class='fd'>Click</span><span class='p'>(</span><span class='s'>"link=QM Extensions"</span><span class='p'>);</span> selenium.<span class='fd'>WaitForPageToLoad</span><span class='p'>(</span><span class='s'>"30000"</span><span class='p'>)</span><br />
<br />
<span class='fq'>if</span><span class='p'>(</span><span class='fq'>mes</span><span class='p'>(</span><span class='s'>"Close browser?"</span> <span class='s'>""</span> <span class='s'>"YN?2"</span><span class='p'>)</span><span class='o'>=</span><span class='n'>'Y'</span><span class='p'>)</span> x.<span class='fu'>Quit</span><br />
<span class='r'>#endregion</span></code></div></div>Macro <span style="font-weight: bold;" class="mycode_b">WebDriver help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;Example with IWebDriver functions called from C# code</span><br />
<span class='r'>#region Selenium, recorded 2014.09.13 08:21</span><br />
<span class='dir'>#compile</span> <span class='s'>"__WebDriver"</span><br />
<span class='t'>WebDriver</span> x2.<span class='fu'>Init</span><span class='p'>(</span><span class='d'>__FUNCTION__</span><span class='p'>)</span><br />
<span class='t'>str</span> baseURL2<span class='o'>=</span><span class='s'>"http://www.quickmacros.com"</span><br />
x2.<span class='fu'>StartChrome</span><span class='p'>(</span>baseURL2<span class='p'>)</span> <span class='c2'>;;StartChrome, StartFirefox or StartIE</span><br />
<br />
x2.x.Run<br />
<br />
<span class='fq'>if</span><span class='p'>(</span><span class='fq'>mes</span><span class='p'>(</span><span class='s'>"Close browser?"</span> <span class='s'>""</span> <span class='s'>"YN?2"</span><span class='p'>)</span><span class='o'>=</span><span class='n'>'Y'</span><span class='p'>)</span> x2.<span class='fu'>Quit</span><br />
<span class='r'>#endregion</span><br />
<br />
<br />
<span class='dir'>#ret</span><br />
public void Run<span class='p'>()</span>{<br />
driver.Navigate<span class='p'>()</span>.GoToUrl<span class='p'>(</span>baseURL <span class='o'>+</span> <span class='s'>"/index.html"</span><span class='p'>);</span><br />
driver.FindElement<span class='p'>(</span>By.Id<span class='p'>(</span><span class='s'>"m_forum"</span><span class='p'>))</span>.Click<span class='p'>();</span><br />
driver.FindElement<span class='p'>(</span>By.LinkText<span class='p'>(</span><span class='s'>"QM Extensions"</span><span class='p'>))</span>.Click<span class='p'>();</span><br />
}</code></div></div><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=494" target="_blank" title="">Selenium.qml</a> (Size: 36 KB / Downloads: 1453)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Image manipulation with FreeImage graphics library]]></title>
			<link>https://www.libreautomate.com/forum/showthread.php?tid=5046</link>
			<pubDate>Wed, 19 Mar 2014 05:27:15 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://www.libreautomate.com/forum/member.php?action=profile&uid=2">Gintaras</a>]]></dc:creator>
			<guid isPermaLink="false">https://www.libreautomate.com/forum/showthread.php?tid=5046</guid>
			<description><![CDATA[Macro <span style="font-weight: bold;" class="mycode_b">FiBitmap help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;FreeImage API declarations, and class FiBitmap.</span><br />
<br />
<span class='c'>;FreeImage is a graphics library, &lt;link&gt;http://freeimage.sourceforge.net/download.html&lt;/link&gt;</span><br />
<span class='c'>;Download FreeImage DLL and Documentation. Don't need source. Put FreeImage.dll in QM folder.</span><br />
<span class='c'>;FreeImage is good for converting image file formats and basic image manipulation with good quality - resize, etc. Unlike many other graphics libraries like ImageMagick, you need just single dll file (~3MB), don't need to install. Easy to use, well documented.</span><br />
<span class='c'>;Other alternatives that can be easily used in QM: GDI+ (a Windows component), GflAx (a COM component, seems abandoned). Search forum.</span><br />
<br />
<span class='c'>;Class FiBitmap stores and manages FIBITMAP*. Auto-deletes when destroying the variable.</span><br />
<span class='c'>;The class wraps just basic FreeImage API functions - load, save, etc.</span><br />
<span class='c'>;All FreeImage API functions etc can be accessed through FIMG, like FIMG.FreeImage_GetWidth(x) or FIMG.FIF_BMP.</span><br />
<span class='c'>;A FiBitmap variable can be used with FreeImage API functions as FIBITMAP*.</span><br />
<br />
<span class='c'>;EXAMPLES</span><br />
<br />
<span class='dir'>#compile</span> <span class='s'>"__FreeImage"</span> <span class='c2'>;;declares FIMG and FiBitmap. You can put this line in your init2 function, or in macros where used.</span><br />
<span class='fu'>FI_ShowMoreErrorInfo</span> <span class='c2'>;;optional</span><br />
<span class='t'>FiBitmap</span> x<br />
<br />
<span class='t'>str</span> test<span class='o'>=</span><br />
<span class='s'>;1 convert file format bmp to png</span><br />
<span class='s'>;2 capture image from screen and save as png file</span><br />
<span class='s'>;3 load png file and store the bitmap in clipboard</span><br />
<span class='s'>;4 load png file and draw in a window</span><br />
<span class='s'>;5 resize to 50%</span><br />
<span class='s'>;6 load/save from/to memory</span><br />
<span class='s'>;7 load from resources (QM 2.4.1+)</span><br />
<span class='fq'>sel</span> <span class='fu'>ShowMenu</span><span class='p'>(</span>test<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>1</span> <span class='c2'>;;convert file format bmp to png</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-conv.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>2</span> <span class='c2'>;;capture image from screen and save as png file</span><br />
<span class='i'>,</span><span class='t'>__GdiHandle</span> hb<br />
<span class='i'>,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='fu'>CaptureImageOrColor</span><span class='p'>(</span>hb <span class='n'>0</span><span class='p'>))</span> <span class='fq'>ret</span><br />
<span class='i'>,</span>x.<span class='fu'>FromHBITMAP</span><span class='p'>(</span>hb<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-capt.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>3</span> <span class='c2'>;;load png file and store the bitmap in clipboard</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-conv.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;__GdiHandle hb2=x.ToHBITMAP ;;no, don't need to delete bitmap stored in clipboard</span><br />
<span class='i'>,</span><span class='t'>int</span> hb2<span class='o'>=</span>x.<span class='fu'>ToHBITMAP</span><br />
<span class='i'>,</span><span class='fd'>OpenClipboard</span> <span class='n'>0</span><span class='p'>;</span> <span class='fd'>EmptyClipboard</span><br />
<span class='i'>,</span><span class='fd'>SetClipboardData</span> <span class='d'>CF_BITMAP</span> hb2<br />
<span class='i'>,</span><span class='fd'>CloseClipboard</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>4</span> <span class='c2'>;;load png file and draw in a window</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-conv.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='t'>int</span> hwnd<span class='o'>=</span><span class='n'>0</span> <span class='c2'>;;screen. Normally you would draw in a window/dialog procedure on WM_PAINT, and use BeginPoint/EndPaint instead of GetDC/ReleaseDC.</span><br />
<span class='i'>,</span><span class='t'>RECT</span> r<span class='p'>;</span> <span class='fd'>SetRect</span> <span class='o'>&amp;</span>r <span class='n'>0</span> <span class='n'>0</span> <span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetWidth</span><span class='p'>(</span>x<span class='p'>)</span> <span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetHeight</span><span class='p'>(</span>x<span class='p'>)</span><br />
<span class='i'>,</span><span class='t'>int</span> hdc<span class='o'>=</span><span class='fd'>GetDC</span><span class='p'>(</span>hwnd<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Draw</span><span class='p'>(</span>hdc r<span class='p'>)</span><br />
<span class='i'>,</span><span class='fd'>ReleaseDC</span> hwnd hdc<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>5</span> <span class='c2'>;;resize to 50%</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='t'>int</span> newWidth<span class='o'>=</span><span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetWidth</span><span class='p'>(</span>x<span class='p'>)</span><span class='o'>/</span><span class='n'>2</span><br />
<span class='i'>,</span><span class='t'>int</span> newHeight<span class='o'>=</span><span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetHeight</span><span class='p'>(</span>x<span class='p'>)</span><span class='o'>/</span><span class='n'>2</span><br />
<span class='i'>,</span><span class='t'>FiBitmap</span> x2.<span class='fu'>Attach</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='fd'>FreeImage_Rescale</span><span class='p'>(</span>x newWidth newHeight <span class='lib'>FIMG.</span><span class='d'>FILTER_BSPLINE</span><span class='p'>))</span><br />
<span class='i'>,</span>x2.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"&#36;my qm&#36;&#92;test-siz.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>6</span> <span class='c2'>;;load/save from/to memory</span><br />
<span class='i'>,</span><span class='t'>str</span> s1 s2<br />
<span class='i'>,</span>s1.<span class='fq'>getfile</span><span class='p'>(</span><span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>LoadMem</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> s1<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>SaveMem</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_JPEG</span> s2<span class='p'>)</span><br />
<span class='i'>,</span>s2.<span class='fq'>setfile</span><span class='p'>(</span><span class='s'>"&#36;my qm&#36;&#92;test-mem.jpg"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='dir'>#if</span> <span class='d'>QMVER</span><span class='o'>&gt;=</span><span class='n'>0x02040100</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>7</span> <span class='c2'>;;load from resources</span><br />
<span class='i'>,</span>s1.<span class='fq'>getfile</span><span class='p'>(</span><span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;_qmfile.ResourceAdd(+-1 "test FiBitmap.bmp" s1 s1.len) ;;add a bitmap resource for testing</span><br />
<span class='i'>,</span><span class='c'>;x.Load(FIMG.FIF_BMP "resource:test FiBitmap.bmp")</span><br />
<span class='i'>,</span>s1.<span class='fq'>encrypt</span><span class='p'>(</span><span class='n'>32</span><span class='p'>);</span> _qmfile.<span class='fd'>ResourceAdd</span><span class='p'>(</span><span class='o'>+-</span><span class='n'>1</span> <span class='s'>"image:test FiBitmap"</span> s1 s1.len<span class='p'>)</span> <span class='c2'>;;add a compressed .bitmap resource for testing</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"image:test FiBitmap"</span><span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-res.png"</span><span class='p'>)</span><br />
<span class='dir'>#endif</span><br />
<span class='i'>,</span></code></div></div><br />
Download FreeImage DLL from<br />
<a href="http://freeimage.sourceforge.net/download.html" target="_blank" rel="noopener" class="mycode_url">http://freeimage.sourceforge.net/download.html</a><br />
Extract FreeImage.dll to QM folder. In the zip file it is probably in folder Dist\x32.<br />
Also download and import the attached QM file.<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=399" target="_blank" title="">FreeImage.qml</a> (Size: 45 KB / Downloads: 1235)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Macro <span style="font-weight: bold;" class="mycode_b">FiBitmap help</span> <span/><br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code><span class='c'>;FreeImage API declarations, and class FiBitmap.</span><br />
<br />
<span class='c'>;FreeImage is a graphics library, &lt;link&gt;http://freeimage.sourceforge.net/download.html&lt;/link&gt;</span><br />
<span class='c'>;Download FreeImage DLL and Documentation. Don't need source. Put FreeImage.dll in QM folder.</span><br />
<span class='c'>;FreeImage is good for converting image file formats and basic image manipulation with good quality - resize, etc. Unlike many other graphics libraries like ImageMagick, you need just single dll file (~3MB), don't need to install. Easy to use, well documented.</span><br />
<span class='c'>;Other alternatives that can be easily used in QM: GDI+ (a Windows component), GflAx (a COM component, seems abandoned). Search forum.</span><br />
<br />
<span class='c'>;Class FiBitmap stores and manages FIBITMAP*. Auto-deletes when destroying the variable.</span><br />
<span class='c'>;The class wraps just basic FreeImage API functions - load, save, etc.</span><br />
<span class='c'>;All FreeImage API functions etc can be accessed through FIMG, like FIMG.FreeImage_GetWidth(x) or FIMG.FIF_BMP.</span><br />
<span class='c'>;A FiBitmap variable can be used with FreeImage API functions as FIBITMAP*.</span><br />
<br />
<span class='c'>;EXAMPLES</span><br />
<br />
<span class='dir'>#compile</span> <span class='s'>"__FreeImage"</span> <span class='c2'>;;declares FIMG and FiBitmap. You can put this line in your init2 function, or in macros where used.</span><br />
<span class='fu'>FI_ShowMoreErrorInfo</span> <span class='c2'>;;optional</span><br />
<span class='t'>FiBitmap</span> x<br />
<br />
<span class='t'>str</span> test<span class='o'>=</span><br />
<span class='s'>;1 convert file format bmp to png</span><br />
<span class='s'>;2 capture image from screen and save as png file</span><br />
<span class='s'>;3 load png file and store the bitmap in clipboard</span><br />
<span class='s'>;4 load png file and draw in a window</span><br />
<span class='s'>;5 resize to 50%</span><br />
<span class='s'>;6 load/save from/to memory</span><br />
<span class='s'>;7 load from resources (QM 2.4.1+)</span><br />
<span class='fq'>sel</span> <span class='fu'>ShowMenu</span><span class='p'>(</span>test<span class='p'>)</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>1</span> <span class='c2'>;;convert file format bmp to png</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-conv.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>2</span> <span class='c2'>;;capture image from screen and save as png file</span><br />
<span class='i'>,</span><span class='t'>__GdiHandle</span> hb<br />
<span class='i'>,</span><span class='fq'>if</span><span class='p'>(</span><span class='o'>!</span><span class='fu'>CaptureImageOrColor</span><span class='p'>(</span>hb <span class='n'>0</span><span class='p'>))</span> <span class='fq'>ret</span><br />
<span class='i'>,</span>x.<span class='fu'>FromHBITMAP</span><span class='p'>(</span>hb<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-capt.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>3</span> <span class='c2'>;;load png file and store the bitmap in clipboard</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-conv.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;__GdiHandle hb2=x.ToHBITMAP ;;no, don't need to delete bitmap stored in clipboard</span><br />
<span class='i'>,</span><span class='t'>int</span> hb2<span class='o'>=</span>x.<span class='fu'>ToHBITMAP</span><br />
<span class='i'>,</span><span class='fd'>OpenClipboard</span> <span class='n'>0</span><span class='p'>;</span> <span class='fd'>EmptyClipboard</span><br />
<span class='i'>,</span><span class='fd'>SetClipboardData</span> <span class='d'>CF_BITMAP</span> hb2<br />
<span class='i'>,</span><span class='fd'>CloseClipboard</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>4</span> <span class='c2'>;;load png file and draw in a window</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-conv.png"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='t'>int</span> hwnd<span class='o'>=</span><span class='n'>0</span> <span class='c2'>;;screen. Normally you would draw in a window/dialog procedure on WM_PAINT, and use BeginPoint/EndPaint instead of GetDC/ReleaseDC.</span><br />
<span class='i'>,</span><span class='t'>RECT</span> r<span class='p'>;</span> <span class='fd'>SetRect</span> <span class='o'>&amp;</span>r <span class='n'>0</span> <span class='n'>0</span> <span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetWidth</span><span class='p'>(</span>x<span class='p'>)</span> <span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetHeight</span><span class='p'>(</span>x<span class='p'>)</span><br />
<span class='i'>,</span><span class='t'>int</span> hdc<span class='o'>=</span><span class='fd'>GetDC</span><span class='p'>(</span>hwnd<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Draw</span><span class='p'>(</span>hdc r<span class='p'>)</span><br />
<span class='i'>,</span><span class='fd'>ReleaseDC</span> hwnd hdc<br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>5</span> <span class='c2'>;;resize to 50%</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='t'>int</span> newWidth<span class='o'>=</span><span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetWidth</span><span class='p'>(</span>x<span class='p'>)</span><span class='o'>/</span><span class='n'>2</span><br />
<span class='i'>,</span><span class='t'>int</span> newHeight<span class='o'>=</span><span class='lib'>FIMG.</span><span class='fd'>FreeImage_GetHeight</span><span class='p'>(</span>x<span class='p'>)</span><span class='o'>/</span><span class='n'>2</span><br />
<span class='i'>,</span><span class='t'>FiBitmap</span> x2.<span class='fu'>Attach</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='fd'>FreeImage_Rescale</span><span class='p'>(</span>x newWidth newHeight <span class='lib'>FIMG.</span><span class='d'>FILTER_BSPLINE</span><span class='p'>))</span><br />
<span class='i'>,</span>x2.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"&#36;my qm&#36;&#92;test-siz.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>6</span> <span class='c2'>;;load/save from/to memory</span><br />
<span class='i'>,</span><span class='t'>str</span> s1 s2<br />
<span class='i'>,</span>s1.<span class='fq'>getfile</span><span class='p'>(</span><span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>LoadMem</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> s1<span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>SaveMem</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_JPEG</span> s2<span class='p'>)</span><br />
<span class='i'>,</span>s2.<span class='fq'>setfile</span><span class='p'>(</span><span class='s'>"&#36;my qm&#36;&#92;test-mem.jpg"</span><span class='p'>)</span><br />
<span class='i'>,</span><br />
<span class='dir'>#if</span> <span class='d'>QMVER</span><span class='o'>&gt;=</span><span class='n'>0x02040100</span><br />
<span class='i'>,</span><span class='fq'>case</span> <span class='n'>7</span> <span class='c2'>;;load from resources</span><br />
<span class='i'>,</span>s1.<span class='fq'>getfile</span><span class='p'>(</span><span class='s'>"&#36;my qm&#36;&#92;test.bmp"</span><span class='p'>)</span><br />
<span class='i'>,</span><span class='c'>;_qmfile.ResourceAdd(+-1 "test FiBitmap.bmp" s1 s1.len) ;;add a bitmap resource for testing</span><br />
<span class='i'>,</span><span class='c'>;x.Load(FIMG.FIF_BMP "resource:test FiBitmap.bmp")</span><br />
<span class='i'>,</span>s1.<span class='fq'>encrypt</span><span class='p'>(</span><span class='n'>32</span><span class='p'>);</span> _qmfile.<span class='fd'>ResourceAdd</span><span class='p'>(</span><span class='o'>+-</span><span class='n'>1</span> <span class='s'>"image:test FiBitmap"</span> s1 s1.len<span class='p'>)</span> <span class='c2'>;;add a compressed .bitmap resource for testing</span><br />
<span class='i'>,</span>x.<span class='fu'>Load</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_BMP</span> <span class='s'>"image:test FiBitmap"</span><span class='p'>)</span><br />
<span class='i'>,</span>x.<span class='fu'>Save</span><span class='p'>(</span><span class='lib'>FIMG.</span><span class='d'>FIF_PNG</span> <span class='s'>"&#36;my qm&#36;&#92;test-res.png"</span><span class='p'>)</span><br />
<span class='dir'>#endif</span><br />
<span class='i'>,</span></code></div></div><br />
Download FreeImage DLL from<br />
<a href="http://freeimage.sourceforge.net/download.html" target="_blank" rel="noopener" class="mycode_url">http://freeimage.sourceforge.net/download.html</a><br />
Extract FreeImage.dll to QM folder. In the zip file it is probably in folder Dist\x32.<br />
Also download and import the attached QM file.<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://www.libreautomate.com/forum/images/qm/qml.png" title="Quick Macros file" border="0" alt=".qml" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=399" target="_blank" title="">FreeImage.qml</a> (Size: 45 KB / Downloads: 1235)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
	</channel>
</rss>