├── .github
└── workflows
│ └── build.yml
├── LICENSE
├── LaunchAppContainer.au3
├── LaunchAppContainer.ini
├── LearningMode.au3
├── README.md
├── SetAppContainerACL.au3
├── app.ico
├── bin
├── AppContainerSid.exe
├── LaunchAppContainer.exe
└── SetACL.exe
├── checked.ico
├── data
└── capslist.txt
├── includes
├── AutOnExit.au3
├── ExtMsgBox.au3
├── GUIComboBoxColor.au3
├── GUIComboBoxFont.au3
├── GUIDarkMode_v0.02mod.au3
├── GUIListViewEx.au3
├── GUIRegisterMsg20.au3
├── GuiCtrls_HiDpi.au3
├── ModernMenuRaw.au3
├── StringSize.au3
└── _GUICtrlListView_SaveCSV.au3
└── unchecked.ico
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build Binaries
2 | run-name: Build version ${{ inputs.version }}
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | version:
7 | description: The version of the library
8 | required: true
9 | default: 0.1.0
10 | type: string
11 | release:
12 | description: Create a release
13 | required: true
14 | default: false
15 | type: boolean
16 | permissions:
17 | contents: write
18 | actions: write
19 | checks: write
20 | jobs:
21 | build:
22 | runs-on: windows-latest
23 | steps:
24 | - uses: actions/checkout@v4
25 | - name: Cache tools
26 | uses: actions/cache@v4
27 | id: cache
28 | with:
29 | path: |
30 | autoit-v3-setup.exe
31 | SciTE4AutoIt3.exe
32 | C:\Program Files (x86)\AutoIt3\SciTE\Au3Stripper
33 | key: v3
34 | - name: Download tools
35 | if: steps.cache.outputs.cache-hit != 'true'
36 | run: |
37 | curl -sSfL https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe -o autoit-v3-setup.exe `
38 | -sSfL https://www.autoitscript.com/cgi-bin/getfile.pl?../autoit3/scite/download/SciTE4AutoIt3.exe -o SciTE4AutoIt3.exe `
39 | -sSfLO https://www.autoitscript.com/autoit3/scite/download/Au3Stripper.zip
40 | Expand-Archive Au3Stripper.zip "${env:ProgramFiles(x86)}\AutoIt3\SciTE\Au3Stripper"
41 | - name: Install tools
42 | run: |
43 | Start-Process autoit-v3-setup.exe -ArgumentList /S -NoNewWindow -Wait
44 | Start-Process SciTE4AutoIt3.exe -ArgumentList /S -NoNewWindow -Wait
45 | - name: Compile
46 | run: |
47 | Start-Process "${env:ProgramFiles(x86)}\AutoIt3\AutoIt3.exe" "`"${env:ProgramFiles(x86)}\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3`" /NoStatus /prod /in LaunchAppContainer.au3" -NoNewWindow -Wait
48 | Start-Process "${env:ProgramFiles(x86)}\AutoIt3\AutoIt3.exe" "`"${env:ProgramFiles(x86)}\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3`" /NoStatus /prod /in LearningMode.au3" -NoNewWindow -Wait
49 | Start-Process "${env:ProgramFiles(x86)}\AutoIt3\AutoIt3.exe" "`"${env:ProgramFiles(x86)}\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3`" /NoStatus /prod /in SetAppContainerACL.au3" -NoNewWindow -Wait
50 | - uses: actions/upload-artifact@v4
51 | with:
52 | name: executable-files
53 | path: |
54 | LaunchAppContainer*.exe
55 | LearningMode*.exe
56 | SetAppContainerACL*.exe
57 | if-no-files-found: error
58 | - name: Zip package
59 | run: 7z a win32-appcontainer-tools.zip LaunchAppContainer*.exe LearningMode*.exe SetAppContainerACL*.exe
60 | 7z a win32-appcontainer-tools.zip bin\
61 | 7z a win32-appcontainer-tools.zip data\
62 | 7z a win32-appcontainer-tools.zip LaunchAppContainer.ini
63 | - name: Rename archive with tag
64 | shell: pwsh
65 | run: |
66 | Copy-Item win32-appcontainer-tools.zip -Destination win32-appcontainer-tools-${{ inputs.version }}.zip
67 | - name: Create release
68 | uses: softprops/action-gh-release@v2
69 | if: ${{ inputs.release }}
70 | with:
71 | draft: true
72 | name: win32-appcontainer-tools ${{ inputs.version }}
73 | tag_name: ${{ inputs.version }}
74 | files: |
75 | win32-appcontainer-tools-${{ inputs.version }}.zip
76 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/LaunchAppContainer.ini:
--------------------------------------------------------------------------------
1 | [LaunchAppContainer]
2 | Name=AppContainer.Testing
3 |
--------------------------------------------------------------------------------
/LearningMode.au3:
--------------------------------------------------------------------------------
1 | ; *** Start added Standard Include files by AutoIt3Wrapper ***
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | ; *** End added Standard Include files by AutoIt3Wrapper ***
12 | #RequireAdmin
13 | #NoTrayIcon
14 |
15 | #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
16 | #AutoIt3Wrapper_Icon=app.ico
17 | #AutoIt3Wrapper_UseX64=y
18 | #AutoIt3Wrapper_Res_Description=Permissive Learning Mode
19 | #AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator
20 | #AutoIt3Wrapper_Res_Fileversion=1.1.1
21 | #AutoIt3Wrapper_Res_ProductVersion=1.1.1
22 | #AutoIt3Wrapper_Res_ProductName=PermissiveLearningMode
23 | #AutoIt3Wrapper_Outfile_x64=LearningMode.exe
24 | #AutoIt3Wrapper_Res_LegalCopyright=@ 2025 WildByDesign
25 | #AutoIt3Wrapper_Res_Language=1033
26 | #AutoIt3Wrapper_Res_HiDpi=P
27 | #AutoIt3Wrapper_Res_Icon_Add=app.ico
28 | #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
29 |
30 | #Region ; *** Dynamically added Include files ***
31 | #include ; added:01/24/25 06:43:50
32 | #include ; added:01/24/25 06:43:50
33 | #include ; added:01/24/25 06:43:50
34 | #include ; added:01/24/25 06:43:50
35 | #include ; added:01/24/25 06:43:50
36 | #include ; added:01/24/25 06:43:50
37 | #include ; added:01/24/25 06:43:50
38 | #include ; added:01/24/25 06:43:50
39 | #include ; added:01/24/25 06:43:50
40 | #include ; added:01/24/25 06:43:50
41 | #include ; added:01/24/25 06:43:50
42 | #include ; added:01/24/25 06:43:50
43 | #include ; added:01/24/25 06:43:50
44 | #include ; added:01/24/25 06:43:50
45 | #include ; added:01/24/25 06:43:50
46 | #include ; added:01/24/25 06:43:50
47 | #include ; added:01/24/25 06:43:50
48 | #include ; added:01/24/25 06:43:50
49 | #include ; added:01/24/25 06:43:50
50 | #include ; added:01/24/25 06:43:50
51 | #include ; added:01/24/25 06:43:50
52 | #EndRegion ; *** Dynamically added Include files ***
53 |
54 | #include "includes\ExtMsgBox.au3"
55 | #include "includes\GUIDarkMode_v0.02mod.au3"
56 | #include "includes\GUIListViewEx.au3"
57 |
58 | #include "includes\ModernMenuRaw.au3"
59 | #include "includes\_GUICtrlListView_SaveCSV.au3"
60 |
61 |
62 | If @Compiled = 0 Then
63 | ; System aware DPI awareness
64 | ;DllCall("User32.dll", "bool", "SetProcessDPIAware")
65 | ; Per-monitor V2 DPI awareness
66 | DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -4)
67 | EndIf
68 |
69 |
70 | Global $tracepath = '"' & @LocalAppDataDir & '\Temp\AppContainerTrace.etl' & '"'
71 | Global $xmlpath = '"' & @LocalAppDataDir & '\Temp\AppContainerTrace.xml' & '"'
72 | Global $xmlpath2 = @LocalAppDataDir & '\Temp\AppContainerTrace.xml'
73 | Global $aArray1, $aTemp, $aRetArray, $PermissiveCount, $aUniques
74 | Global $cListView, $hListView, $aContent
75 | Global $oComError = ObjEvent('AutoIt.Error', ErrorHandler)
76 |
77 | Global Const $SBS_SIZEBOX = 0x08, $SBS_SIZEGRIP = 0x10
78 |
79 |
80 | If _Singleton("LearningMode", 1) = 0 Then
81 | $sMsg = " An instance of AppContainer Learning Mode is already running. " & @CRLF
82 | MsgBox($MB_SYSTEMMODAL, "AppContainer Learning Mode", $sMsg)
83 | Exit
84 | EndIf
85 |
86 |
87 | $idLightBk = _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_BTNFACE))
88 |
89 | isDarkMode()
90 | Func isDarkMode()
91 | Global $isDarkMode = _WinAPI_ShouldAppsUseDarkMode()
92 | Endfunc
93 |
94 |
95 | If $isDarkMode = True Then
96 | Global $g_iBkColor = 0x2c2c2c, $g_iTextColor = 0xffffff
97 | Else
98 | Global $g_iBkColor = $idLightBk, $g_iTextColor = 0x000000
99 | EndIf
100 |
101 | Global $g_hSizebox, $g_hOldProc, $g_hStatus, $g_iHeight, $g_aText, $g_aRatioW, $g_hDots
102 |
103 |
104 | If $isDarkMode = True Then
105 | _ExtMsgBoxSet(Default)
106 | ;_ExtMsgBoxSet(1, 5, -1, -1, -1, "Consolas", 800, 800)
107 | _ExtMsgBoxSet(1, 4, 0x202020, 0xe0e0e0, 9, -1, 1200)
108 | Else
109 | _ExtMsgBoxSet(Default)
110 | ;_ExtMsgBoxSet(1, 5, -1, -1, -1, "Consolas", 800, 800)
111 | _ExtMsgBoxSet(1, 4, -1, -1, 9, -1, 1200)
112 | EndIf
113 |
114 | Global $ifPS7Exists = FileExists(@ProgramFilesDir & '\PowerShell\7\pwsh.exe')
115 | ;If $ifPS7Exists Then
116 | ; Global $o_powershell = @ProgramFilesDir & '\PowerShell\7\pwsh.exe -NoProfile -Command'
117 | ;Else
118 | Global $o_powershell = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Command"
119 | ;EndIf
120 |
121 | If $isDarkMode = True Then
122 | Global $iDllGDI = DllOpen("gdi32.dll")
123 | Global $iDllUSER32 = DllOpen("user32.dll")
124 |
125 | ;Three column colours
126 | Global $aCol[11][2] = [[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff],[0xffffff, 0xffffff]]
127 |
128 | ;Convert RBG to BGR for SetText/BkColor()
129 | For $i = 0 To UBound($aCol)-1
130 | $aCol[$i][0] = _BGR2RGB($aCol[$i][0])
131 | $aCol[$i][1] = _BGR2RGB($aCol[$i][1])
132 | Next
133 | EndIf
134 |
135 |
136 | _GDIPlus_Startup()
137 |
138 | Global $iW = @DesktopWidth - 400, $iH = @DesktopHeight / 2
139 | $hGUI = GUICreate("Permissive Learning Mode", $iW, $iH, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX)
140 |
141 | GUISetIcon(@ScriptFullPath, 201)
142 |
143 | $aWinSize = WinGetClientSize($hGUI)
144 |
145 | ;-----------------
146 | ; Create a sizebox window (Scrollbar class) BEFORE creating the StatusBar control
147 | $g_hSizebox = _WinAPI_CreateWindowEx(0, "Scrollbar", "", $WS_CHILD + $WS_VISIBLE + $SBS_SIZEBOX, _
148 | 0, 0, 0, 0, $hGUI) ; $SBS_SIZEBOX or $SBS_SIZEGRIP
149 |
150 | ; Subclass the sizebox (by changing the window procedure associated with the Scrollbar class)
151 | Local $hProc = DllCallbackRegister('ScrollbarProc', 'lresult', 'hwnd;uint;wparam;lparam')
152 | $g_hOldProc = _WinAPI_SetWindowLong($g_hSizebox, $GWL_WNDPROC, DllCallbackGetPtr($hProc))
153 |
154 | Local $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZENWSE)
155 | _WinAPI_SetClassLongEx($g_hSizebox, -12, $hCursor) ; $GCL_HCURSOR = -12
156 |
157 | ;$g_hBrush = _WinAPI_CreateSolidBrush($g_iBkColor)
158 |
159 | ;-----------------
160 | $g_hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $WS_CLIPSIBLINGS) ; ClipSiblings style +++
161 | Local $aParts[1] = [-1]
162 | If $aParts[Ubound($aParts) - 1] = -1 Then $aParts[Ubound($aParts) - 1] = $iW ; client width size
163 | _MyGUICtrlStatusBar_SetParts($g_hStatus, $aParts)
164 |
165 | Dim $g_aText[Ubound($aParts)] = [" Go to Trace Actions to start a Permissive Learning Mode trace."]
166 | Dim $g_aRatioW[Ubound($aParts)]
167 | For $i = 0 To UBound($g_aText) - 1
168 | _GUICtrlStatusBar_SetText($g_hStatus, "", $i, $SBT_OWNERDRAW + $SBT_NOBORDERS)
169 | ; _GUICtrlStatusBar_SetText($g_hStatus, "", $i, $SBT_OWNERDRAW + $SBT_NOBORDERS) ; interesting ?
170 | $g_aRatioW[$i] = $aParts[$i] / $iW
171 | Next
172 |
173 |
174 | ; get status bar height for GUI and listview height
175 | $StatusBarCtrlID = _WinAPI_GetDlgCtrlID($g_hStatus)
176 | $aPos = ControlGetPos($hGUI, "", $StatusBarCtrlID)
177 | $StatusBarCtrlIDV = $aPos[1]
178 | $StatusBarCtrlIDHeight = $aPos[3]
179 |
180 |
181 | $aGUI_Pos = WinGetPos($hGUI)
182 | $aGUI_ClientSize = WinGetClientSize($hGUI)
183 | $iCaptionHeight = $aGUI_Pos[3] - $aGUI_ClientSize[1]
184 |
185 |
186 | If $isDarkMode = True Then
187 | _SetMenuBkColor(0x2c2c2c)
188 | _SetMenuTextColor(0xffffff)
189 | _SetMenuSelectTextColor(0xffffff)
190 | _SetMenuSelectBkColor(0x404040)
191 | _SetMenuSelectRectColor(0x404040)
192 | _SetMenuIconBkColor(0x2c2c2c)
193 | _SetMenuIconBkGrdColor(0x2c2c2c)
194 | Else
195 | _SetMenuBkColor($idLightBk)
196 | _SetMenuTextColor(0x000000)
197 | _SetMenuSelectTextColor(0x000000)
198 | _SetMenuSelectBkColor(0xf5cba7)
199 | _SetMenuSelectRectColor(0xf5cba7)
200 | _SetMenuIconBkColor($idLightBk)
201 | _SetMenuIconBkGrdColor($idLightBk)
202 | EndIf
203 |
204 |
205 | Local $iFileMenu5 = _GUICtrlCreateODTopMenu( "&File", $hGUI )
206 | Local $iFileMenu4 = _GUICtrlCreateODTopMenu( "&Trace Actions", $hGUI )
207 |
208 |
209 | If $isDarkMode = True Then
210 | $menuStartTrace = GUICtrlCreateMenuItem( "Start Trace", $iFileMenu4)
211 | $menuStopTrace = GUICtrlCreateMenuItem( "Stop Trace", $iFileMenu4)
212 |
213 | $menuExportCSV = GUICtrlCreateMenuItem( "Export as CSV", $iFileMenu5)
214 | $menuFileExit = GUICtrlCreateMenuItem( "Exit", $iFileMenu5)
215 | Else
216 | $menuStartTrace = _GUICtrlCreateODMenuItem( "Start Trace", $iFileMenu4)
217 | $menuStopTrace = _GUICtrlCreateODMenuItem( "Stop Trace", $iFileMenu4)
218 |
219 | $menuExportCSV = _GUICtrlCreateODMenuItem( "Export as CSV", $iFileMenu5)
220 | $menuFileExit = _GUICtrlCreateODMenuItem( "Exit", $iFileMenu5)
221 | EndIf
222 |
223 |
224 | Local Const $sCascadiaPath = @WindowsDir & "\fonts\CascadiaCode.ttf"
225 | Local $iCascadiaExists = FileExists($sCascadiaPath)
226 |
227 | If $iCascadiaExists Then
228 | GUISetFont(10, $FW_THIN, -1, "Cascadia Mono")
229 | Else
230 | GUISetFont(10, $FW_NORMAL, -1, "Consolas")
231 | EndIf
232 |
233 |
234 | $aGUI_ClientSizeLV = WinGetClientSize($hGUI)
235 |
236 |
237 | Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER), $cListView
238 | $cListView = GUICtrlCreateListView("Time Created|Process|Type|Object|Requested Access", 0, 0, $aWinSize[0], $aGUI_ClientSizeLV[1] - $StatusBarCtrlIDHeight)
239 | GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
240 | $hListView = GUICtrlGetHandle($cListView)
241 |
242 | $aPos = ControlGetPos($hGUI, "", $cListView)
243 | ;MsgBox($MB_SYSTEMMODAL, "", "Position: " & $aPos[0] & ", " & $aPos[1] & @CRLF & "Size: " & $aPos[2] & ", " & $aPos[3])
244 | $cListViewPosV = $aPos[1]
245 | $cListViewPosH = $aPos[0] + $aPos[2]
246 | $cListViewLength = $aPos[2]
247 | $cListViewHeight = $aPos[3]
248 |
249 | _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
250 |
251 | _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
252 | _GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
253 | _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER)
254 | _GUICtrlListView_SetColumnWidth($hListView, 3, @DesktopWidth / 2)
255 | _GUICtrlListView_SetColumnWidth($hListView, 4, $LVSCW_AUTOSIZE_USEHEADER)
256 |
257 | HeaderFix()
258 |
259 | Func HeaderFix()
260 | If $isDarkMode = True Then
261 | ;get handle to child SysHeader32 control of ListView
262 | Global $hHeader = HWnd(GUICtrlSendMsg($cListView, $LVM_GETHEADER, 0, 0))
263 | ;Turn off theme for header
264 | DllCall("uxtheme.dll", "int", "SetWindowTheme", "hwnd", $hHeader, "wstr", "", "wstr", "")
265 | ;subclass ListView to get at NM_CUSTOMDRAW notification sent to ListView
266 | Global $wProcNew = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
267 | Global $wProcOld = _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))
268 |
269 | ;Optional: Flat Header - remove header 3D button effect
270 | Global $iStyle = _WinAPI_GetWindowLong($hHeader, $GWL_STYLE)
271 | _WinAPI_SetWindowLong($hHeader, $GWL_STYLE, BitOR($iStyle, $HDS_FLAT))
272 | EndIf
273 | Endfunc
274 |
275 |
276 | ; apply theme color after listview
277 |
278 | ApplyThemeColor()
279 | Func ApplyThemeColor()
280 |
281 | If $isDarkMode = True Then
282 | GuiDarkmodeApply($hGUI)
283 | Else
284 | Local $bEnableDarkTheme = False
285 | GuiLightmodeApply($hGUI)
286 | EndIf
287 |
288 | Endfunc
289 |
290 |
291 | ; to allow the setting of StatusBar BkColor at least under Windows 10
292 | _WinAPI_SetWindowTheme($g_hStatus, "", "")
293 |
294 | ; Set status bar background color
295 | _GUICtrlStatusBar_SetBkColor($g_hStatus, $g_iBkColor)
296 |
297 | ;$g_iHeight = _GUICtrlStatusBar_GetHeight($g_hStatus) + 3 ; change the constant (+3) if necessary
298 | $g_iHeight = $StatusBarCtrlIDHeight
299 | $g_hDots = CreateDots($g_iHeight, $g_iHeight, 0xFF000000 + $g_iBkColor, 0xFF000000 + $g_iTextColor)
300 |
301 | GUIRegisterMsg($WM_SIZE, "WM_SIZE")
302 | GUIRegisterMsg($WM_MOVE, "WM_MOVE")
303 | GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM")
304 |
305 |
306 | GUICtrlSetState($menuStopTrace, $GUI_DISABLE)
307 | GUICtrlSetState($menuExportCSV, $GUI_DISABLE)
308 |
309 |
310 | GUISetState()
311 |
312 |
313 | Func _LVWndProc($hWnd, $iMsg, $wParam, $lParam)
314 | #forceref $hWnd, $iMsg, $wParam
315 | If $iMsg = $WM_NOTIFY Then
316 | Local $tNMHDR, $hWndFrom, $iCode, $iItem, $hDC
317 | $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
318 | $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
319 | $iCode = DllStructGetData($tNMHDR, "Code")
320 | ;Local $IDFrom = DllStructGetData($tNMHDR, "IDFrom")
321 |
322 | Switch $hWndFrom
323 | Case $hHeader
324 | Switch $iCode
325 | Case $NM_CUSTOMDRAW
326 | Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
327 | Switch DllStructGetData($tCustDraw, "dwDrawStage")
328 | Case $CDDS_PREPAINT
329 | Return $CDRF_NOTIFYITEMDRAW
330 | Case $CDDS_ITEMPREPAINT
331 | $hDC = DllStructGetData($tCustDraw, "hDC")
332 | $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
333 | DllCall($iDllGDI, "int", "SetTextColor", "handle", $hDC, "dword", $aCol[$iItem][0])
334 | DllCall($iDllGDI, "int", "SetBkColor", "handle", $hDC, "dword", $aCol[$iItem][1])
335 | Return $CDRF_NEWFONT
336 | Return $CDRF_SKIPDEFAULT
337 | EndSwitch
338 | EndSwitch
339 | EndSwitch
340 | EndIf
341 | ;pass the unhandled messages to default WindowProc
342 | Local $aResult = DllCall($iDllUSER32, "lresult", "CallWindowProcW", "ptr", $wProcOld, _
343 | "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam)
344 | If @error Then Return -1
345 | Return $aResult[0]
346 | EndFunc ;==>_LVWndProc
347 |
348 | Func _BGR2RGB($iColor)
349 | ;Author: Wraithdu
350 | Return BitOR(BitShift(BitAND($iColor, 0x0000FF), -16), BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0xFF0000), 16))
351 | EndFunc ;==>_BGR2RGB
352 |
353 |
354 | Func StartTrace()
355 | ;Local $o_CmdString1 = " $name = 'AppContainerTrace'; New-NetEventSession -Name $name -LocalFilePath $env:LOCALAPPDATA+'\Temp\AppContainerTrace.etl' | Out-Null; Add-NetEventProvider -SessionName $name -Name 'Microsoft-Windows-Kernel-General' -MatchAllKeyword 0x20 | Out-Null; Start-NetEventSession -Name $name"
356 |
357 | Local $tracepath = @LocalAppDataDir & "\Temp\AppContainerTrace.etl"
358 | Local $o_Cmd1 = " $name = 'AppContainerTrace';"
359 | Local $o_Cmd2 = " New-NetEventSession -Name $name -LocalFilePath " & $tracepath & " | Out-Null;"
360 | Local $o_Cmd3 = " Add-NetEventProvider -SessionName $name -Name 'Microsoft-Windows-Kernel-General' -MatchAllKeyword 0x20 | Out-Null; Start-NetEventSession -Name $name"
361 |
362 | Local $o_Pid = Run($o_powershell & $o_Cmd1 & $o_Cmd2 & $o_Cmd3 , "", @SW_Hide)
363 | ;ProcessWaitClose($o_Pid)
364 | ;$out = StdoutRead($o_Pid)
365 | ;CreatePolicyTable($out)
366 | EndFunc
367 |
368 |
369 | Func StopTrace()
370 | ;Local $o_CmdString1 = " $name = 'AppContainerTrace'; New-NetEventSession -Name $name -LocalFilePath $env:LOCALAPPDATA+'\Temp\AppContainerTrace.etl' | Out-Null; Add-NetEventProvider -SessionName $name -Name 'Microsoft-Windows-Kernel-General' -MatchAllKeyword 0x20 | Out-Null; Start-NetEventSession -Name $name"
371 |
372 | ;Local $tracepath = @LocalAppDataDir & "\Temp\AppContainerTrace.etl"
373 | Local $o_Cmd1 = " $name = 'AppContainerTrace';"
374 | Local $o_Cmd2 = " Stop-NetEventSession -Name $name;"
375 | Local $o_Cmd3 = " Remove-NetEventSession -Name $name"
376 |
377 | Local $o_Pid = Run($o_powershell & $o_Cmd1 & $o_Cmd2 & $o_Cmd3 , "", @SW_Hide)
378 | ProcessWaitClose($o_Pid)
379 | ;$out = StdoutRead($o_Pid)
380 | ;CreatePolicyTable($out)
381 | ParseTrace()
382 | EndFunc
383 |
384 |
385 | Func ParseTrace()
386 | ; tracerpt.exe access_trace2.etl -of XML -o etw.xml -y -lr
387 | Local $iPID = Run('tracerpt.exe ' & $tracepath & ' -of XML -o ' & $xmlpath & ' -y -lr', @SystemDir, @SW_HIDE)
388 | ProcessWaitClose($iPID)
389 | ParseXMLData()
390 | EndFunc
391 |
392 |
393 | Func ParseXMLData()
394 |
395 | Local $oXML = ObjCreate("Microsoft.XMLDOM")
396 | $oXML.async = False
397 | $oXML.load($xmlpath2)
398 | If $oXML.parseError.errorCode Then Exit MsgBox($MB_SYSTEMMODAL, "You have an error", $oXML.parseError.reason)
399 |
400 | Local $oNodes = $oXML.SelectNodes("//ComplexData")
401 | $oNodes.removeAll()
402 |
403 | $oNodes = $oXML.SelectNodes("//Event")
404 | For $oNode In $oNodes
405 | $oData = $oNode.selectSingleNode("EventData")
406 | If Not IsObj($oData) Then
407 | $oXML.documentElement.removeChild($oNode)
408 | EndIf
409 |
410 | Next
411 |
412 | $oNodes = $oXML.SelectNodes("//Event")
413 | For $oNode In $oNodes
414 | $oData = $oNode.selectSingleNode("ExtendedTracingInfo")
415 | If IsObj($oData) Then
416 | $oXML.documentElement.removeChild($oNode)
417 | EndIf
418 |
419 | Next
420 |
421 | $oXML.save($xmlpath2)
422 |
423 | CountPermissive()
424 | EndFunc
425 |
426 |
427 | Func ErrorHandler($oError)
428 | EndFunc
429 |
430 |
431 | Func CountPermissive()
432 |
433 | Local $hFileOpen = FileOpen($xmlpath2, $FO_READ)
434 | Local $ReadFile = FileRead($hFileOpen)
435 | StringReplace($ReadFile, 'Permissive', 'Permissive')
436 | Global $PermissiveCount = @extended
437 | ;MsgBox($MB_SYSTEMMODAL, "Permissive Count", $PermissiveCount)
438 | FileClose($hFileOpen)
439 | If $PermissiveCount = 0 Then
440 | Return
441 | Else
442 | CreateArrayFromXML()
443 | EndIf
444 | EndFunc
445 |
446 |
447 |
448 | Func CreateArrayFromXML()
449 | Local $hFileOpen = FileOpen($xmlpath2, $FO_READ)
450 | Local $sFileRead = FileRead($hFileOpen)
451 | ;$aArray1 = _StringBetween($sFileRead, '', '')
452 | ;_ArrayTranspose($aArray1)
453 | ;_ArrayDisplay($aArray1, "Mode")
454 | ;_ArrayTranspose($aArray1, Default)
455 | ;_ArrayDisplay($aArray1, "Mode")
456 | $aArray1 = _StringBetween($sFileRead, '')
457 | _ArrayTranspose($aArray1)
458 | $aArray2 = _StringBetween($sFileRead, '', '')
459 | _ArrayTranspose($aArray2)
460 | ;_ArrayDisplay($aArray1, "SystemTime")
461 | $aArray3 = _StringBetween($sFileRead, '', '')
462 | _ArrayTranspose($aArray3)
463 | ;_ArrayDisplay($aArray3, "ProcessName")
464 | $aArray4 = _StringBetween($sFileRead, '', '')
465 | _ArrayTranspose($aArray4)
466 | ;_ArrayDisplay($aArray4, "ObjectType")
467 | $aArray5 = _StringBetween($sFileRead, '', '')
468 | _ArrayTranspose($aArray5)
469 | ;_ArrayDisplay($aArray5, "ObjectName")
470 | $aArray6 = _StringBetween($sFileRead, '', '')
471 | _ArrayTranspose($aArray6)
472 | ;_ArrayDisplay($aArray6, "AccessMask")
473 |
474 | _ArrayAdd($aArray1, $aArray2)
475 | _ArrayAdd($aArray1, $aArray3)
476 | ;_ArrayTranspose($aArray1, Default)
477 | ;_ArrayDisplay($aArray1, "Mode")
478 |
479 | _ArrayAdd($aArray1, $aArray4)
480 | _ArrayAdd($aArray1, $aArray5)
481 | _ArrayAdd($aArray1, $aArray6)
482 | _ArrayTranspose($aArray1, Default)
483 | ;_ArrayDisplay($aArray1, "Mode")
484 |
485 | FileClose($hFileOpen)
486 | RemoveNonPermissive()
487 | EndFunc
488 |
489 |
490 | Func RemoveNonPermissive()
491 |
492 | For $i = UBound($aArray1) - 1 To 0 Step -1
493 | If $aArray1[$i][1] <> 'Permissive' Then _ArrayDelete($aArray1, $i)
494 | Next
495 | _ArrayColDelete($aArray1, 1)
496 | ;_ArrayDisplay($aArray1, "Non-Permissive Removed")
497 | ComparePermissiveCount()
498 |
499 | EndFunc
500 |
501 |
502 | Func ComparePermissiveCount()
503 |
504 | $ArrayRowCount = UBound ($aArray1, $UBOUND_ROWS)
505 | If $ArrayRowCount <> $PermissiveCount Then
506 | MsgBox($MB_SYSTEMMODAL, "Permissive Count", 'There is a mismatch between Permissive Count and Array Row Count.')
507 | EndIf
508 |
509 | RemoveBlankEntries()
510 | EndFunc
511 |
512 | ; Remove Object entries that have no values
513 | Func RemoveBlankEntries()
514 | For $i = UBound($aArray1) - 1 To 0 Step -1
515 | If $aArray1[$i][3] = '' Or $aArray1[$i][1] = '' Then _ArrayDelete($aArray1, $i)
516 | Next
517 |
518 | ParseLearningData()
519 |
520 | EndFunc
521 |
522 |
523 | Func ParseLearningData()
524 |
525 | For $i = 0 To UBound($aArray1) - 1
526 |
527 | ; Fix TimeStamp
528 | $DateTime = StringLeft($aArray1[$i][0], 19)
529 | $aArray1[$i][0] = $DateTime
530 | $aArray1[$i][0] = StringReplace($aArray1[$i][0], "T", " ")
531 |
532 | $test = $aArray1[$i][2]
533 | ;Global $dosname = _DosPathNameToPathName($aArray1[$i][0])
534 | Global $dosname = $aArray1[$i][1]
535 | Global $dosname2 = $aArray1[$i][3]
536 | Global $drivename = _DosPathNameToPathName($dosname)
537 | Global $drivename2 = _DosPathNameToPathName($dosname2)
538 | $aArray1[$i][1] = StringReplace($aArray1[$i][1], $aArray1[$i][1], $drivename)
539 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], $aArray1[$i][3], $drivename2)
540 |
541 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], '\??\', '')
542 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], '\REGISTRY\MACHINE', 'HKEY_LOCAL_MACHINE')
543 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], 'HKEY_LOCAL_MACHINE\Software', 'HKEY_LOCAL_MACHINE\SOFTWARE', 0, $STR_CASESENSE)
544 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], 'HKEY_LOCAL_MACHINE\System', 'HKEY_LOCAL_MACHINE\SYSTEM', 0, $STR_CASESENSE)
545 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], '\REGISTRY\USER', 'HKEY_USERS')
546 |
547 | If $test = 'ALPC Port' Then
548 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x1', 'Connect')
549 |
550 | ElseIf $test = 'Directory' Then
551 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x4', 'CreateObject')
552 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x1', 'Query')
553 |
554 | ElseIf $test = 'File' Then
555 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x113008A', 'WriteData, ReadEa, ReadAttributes, Delete, ReadControl, Synchronize, AccessSystemSecurity')
556 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x17019F', 'ReadData, WriteData, AppendData, ReadEa, WriteEa, ReadAttributes, WriteAttributes, Delete, ReadControl, WriteDac, Synchronize')
557 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x120196', 'WriteData, AppendData, WriteEa, ReadAttributes, WriteAttributes, ReadControl, Synchronize')
558 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100001', 'ReadData, Synchronize')
559 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x13019F', 'ReadData, WriteData, AppendData, ReadEa, WriteEa, ReadAttributes, WriteAttributes, Delete, ReadControl, Synchronize')
560 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100180', 'ReadAttributes, WriteAttributes, Synchronize')
561 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x110080', 'ReadAttributes, Delete, Synchronize')
562 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100002', 'WriteData, Synchronize')
563 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100000', 'Synchronize')
564 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100020', 'Execute, Synchronize')
565 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100084', 'AppendData, ReadAttributes, Synchronize')
566 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100081', 'ReadData, ReadAttributes, Synchronize')
567 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100080', 'ReadAttributes, Synchronize')
568 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x1F019F', 'ReadData, WriteData, AppendData, ReadEa, WriteEa, ReadAttributes, WriteAttributes, Delete, ReadControl, WriteDac, WriteOwner, Synchronize')
569 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x13008A', 'WriteData, ReadEa, ReadAttributes, Delete, ReadControl, Synchronize')
570 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x120116', 'WriteData, AppendData, WriteEa, WriteAttributes, ReadControl, Synchronize')
571 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x120089', 'ReadData, ReadEa, ReadAttributes, ReadControl, Synchronize')
572 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x12019b', 'ReadData, WriteData, ReadEa, WriteEa, ReadAttributes, WriteAttributes, ReadControl, Synchronize')
573 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x12019f', 'ReadData, WriteData, AppendData, ReadEa, WriteEa, ReadAttributes, WriteAttributes, ReadControl, Synchronize')
574 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x10001', 'ReadData, Delete')
575 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x20080', 'ReadAttributes, ReadControl')
576 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x20000', 'ReadControl')
577 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x60080', 'ReadAttributes, ReadControl, WriteDac')
578 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x10080', 'ReadAttributes, Delete')
579 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x80', 'ReadAttributes')
580 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x40', 'DeleteChild')
581 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x4', 'AppendData')
582 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x2', 'WriteData')
583 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x1', 'ReadData')
584 |
585 | ElseIf $test = 'Key' Then
586 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x2000000', 'MaximumAllowed')
587 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x2020019', 'QueryValue, EnumerateSubKeys, Notify, ReadControl, MaximumAllowed')
588 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x20019', 'QueryValue, EnumerateSubKeys, Notify, ReadControl')
589 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x20006', 'SetValue, CreateSubKey, ReadControl')
590 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x2001f', 'QueryValue, SetValue, CreateSubKey, EnumerateSubKeys, Notify, ReadControl')
591 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x3001f', 'QueryValue, SetValue, CreateSubKey, EnumerateSubKeys, Notify, Delete, ReadControl')
592 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0xf003f', 'QueryValue, SetValue, CreateSubKey, EnumerateSubKeys, Notify, CreateLink, Delete, ReadControl, WriteDac, WriteOwner')
593 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x8', 'EnumerateSubKeys')
594 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x4', 'CreateSubKey')
595 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x11', 'QueryValue, Notify')
596 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x10', 'Notify')
597 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x1', 'QueryValue')
598 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x2', 'SetValue')
599 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x3', 'QueryValue, SetValue')
600 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x9', 'QueryValue, EnumerateSubKeys')
601 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], "windows nt", "Windows NT", 0, $STR_CASESENSE)
602 | $aArray1[$i][3] = StringReplace($aArray1[$i][3], "\\", "\")
603 |
604 | ElseIf $test = 'Mutant' Then
605 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100000', 'Synchronize')
606 |
607 | ElseIf $test = 'Desktop' Then
608 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x8', 'HookControl')
609 |
610 | ElseIf $test = 'SymbolicLink' Then
611 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x1', 'Query')
612 |
613 | ElseIf $test = 'Event' Then
614 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x100000', 'Synchronize')
615 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x1', 'QueryState')
616 |
617 | ;ElseIf $test = 'RPC Interface' Then
618 | ; $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x4', '')
619 |
620 | ElseIf $test = 'Section' Then
621 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x4', 'MapRead')
622 | $aArray1[$i][4] = StringReplace($aArray1[$i][4], '0x6', 'MapWrite, MapRead')
623 |
624 | EndIf
625 |
626 | Next
627 |
628 | ; Remove duplicates
629 | Global $aUniques = _ArrayUnique2D_Ex($aArray1, "1,2,3,4", True)
630 |
631 |
632 | _GUICtrlListView_AddArray($hListView,$aUniques)
633 |
634 | ; Read ListView content into an array
635 | $aContent = _GUIListViewEx_ReadToArray($cListView)
636 |
637 | ; Initiate ListView
638 | $iLV_Index = _GUIListViewEx_Init($cListView, $aContent, 0, Default, False, 1)
639 |
640 | ; Register required messages
641 | _GUIListViewEx_MsgRegister()
642 |
643 | _GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE)
644 | _GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE)
645 | _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE)
646 | _GUICtrlListView_SetColumnWidth($hListView, 3, @DesktopWidth / 2)
647 | _GUICtrlListView_SetColumnWidth($hListView, 4, $LVSCW_AUTOSIZE_USEHEADER)
648 |
649 | EndFunc
650 |
651 |
652 | ; Remove duplicates
653 | ; Global $aUniques = _ArrayUnique2D_Ex($aArray1, "1,2,3,4", True)
654 | ; _ArrayDisplay($aUniques, "Output array")
655 | ;
656 | ; CREDIT: Gianni
657 | ; LINK: https://www.autoitscript.com/forum/topic/169361-_arrayunique-on-multiple-columns/#findComment-1237749
658 | Func _ArrayUnique2D_Ex(ByRef $aSource, $sColumns = "*", $iReturnAllCols = True)
659 | ; check wanted columns
660 | If $sColumns = "*" Then
661 | Local $aColumns[UBound($aSource, 2)]
662 | For $i = 0 To UBound($aColumns) - 1
663 | $aColumns[$i] = $i
664 | Next
665 | Else
666 | Local $aColumns = StringSplit($sColumns, ",", 2) ; NO count in element 0
667 | EndIf
668 |
669 | ; chain fields to check
670 | Local $aChainFileds[UBound($aSource, 1)][2]
671 | For $iRow = 0 To UBound($aSource, 1) - 1
672 | $aChainFileds[$iRow][1] = 0
673 | For $iField = 0 To UBound($aColumns) - 1
674 | $aChainFileds[$iRow][0] &= $aSource[$iRow][$aColumns[$iField]]
675 | Next
676 | Next
677 | ; uniqe from chain
678 | $aTemp = _ArrayUnique($aChainFileds, 0, 0, 0, 1) ; remove duplicate records (if any)
679 | If $iReturnAllCols Then
680 | Local $aUniques[UBound($aTemp)][UBound($aSource, 2)] ; Return all columns
681 | Else
682 | Local $aUniques[UBound($aTemp)][UBound($aColumns)] ; Return only checked columns
683 | EndIf
684 | $aUniques[0][0] = 0 ; pointer to next free row to fill
685 | If UBound($aChainFileds) <> $aTemp[0] Then ; there are some duplicate
686 | Local $aDuplicates[UBound($aChainFileds, 1) - $aTemp[0] + 1][UBound($aSource, 2)] ; will hold only duplicate
687 | $aDuplicates[0][0] = 0 ; pointer to next free row to fill
688 |
689 | For $iRow = 0 To UBound($aChainFileds, 1) - 1
690 | If Not $aChainFileds[$iRow][1] Then ; this record still not checked
691 | $aTemp = _ArrayFindAll($aChainFileds, $aChainFileds[$iRow][0]) ; find duplicates (if any)
692 | For $i = 0 To UBound($aTemp) - 1
693 | $aChainFileds[$aTemp[$i]][1] = UBound($aTemp) ; mark this record as a duplicate
694 | Next
695 | $aUniques[0][0] += 1
696 | If $iReturnAllCols Then
697 | For $iField = 0 To UBound($aSource, 2) - 1
698 | $aUniques[$aUniques[0][0]][$iField] = $aSource[$aTemp[0]][$iField]
699 | Next
700 | Else
701 | For $iField = 0 To UBound($aColumns) - 1
702 | $aUniques[$aUniques[0][0]][$iField] = $aSource[$aTemp[0]][$aColumns[$iField]]
703 | Next
704 | EndIf
705 | If UBound($aTemp) > 1 Then ; there are duplicates of this record
706 | For $i = 1 To UBound($aTemp) - 1
707 | $aDuplicates[0][0] += 1
708 | For $iField = 0 To UBound($aSource, 2) - 1
709 | $aDuplicates[$aDuplicates[0][0]][$iField] = $aSource[$aTemp[$i]][$iField]
710 | Next
711 | Next
712 | EndIf
713 | EndIf
714 | Next
715 | ; _ArrayDisplay($aUniques, "Those are unique elements")
716 | ; _ArrayDisplay($aDuplicates, "These are duplicates discarded")
717 | Else
718 | ; there are not duplicates in source array
719 | ; return passed array unchanged
720 | Return $aSource
721 | EndIf
722 | _ArrayDelete($aUniques, 0) ; remove the count row
723 | Return $aUniques
724 |
725 | EndFunc ;==>_ArrayUnique2D_Ex
726 |
727 |
728 | Func _DosPathNameToPathName($sPath)
729 |
730 | Local $sName, $aDrive = DriveGetDrive('ALL')
731 |
732 | If Not IsArray($aDrive) Then
733 | Return SetError(1, 0, $sPath)
734 | EndIf
735 |
736 | For $i = 1 To $aDrive[0]
737 | $sName = _WinAPI_QueryDosDevice($aDrive[$i])
738 | If StringInStr($sPath, $sName) = 1 Then
739 | Return StringReplace($sPath, $sName, StringUpper($aDrive[$i]), 1)
740 | EndIf
741 | Next
742 | Return SetError(2, 0, $sPath)
743 | EndFunc
744 |
745 |
746 | Func ExportToCSV()
747 | Local Const $sMessage = "Choose a filename."
748 | Local $sFileSaveDialog = FileSaveDialog($sMessage, @DesktopDir, "Comma-separated values (*.csv)", $FD_PATHMUSTEXIST + $FD_PROMPTOVERWRITE, "AppContainerLearning")
749 |
750 | If @error Then
751 | ;MsgBox($MB_SYSTEMMODAL, "", "No file was saved.")
752 | Else
753 | Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSEBASIC, -1))
754 |
755 | Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSEBASIC)
756 |
757 | If $iExtension Then
758 | If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".csv") Then $sFileSaveDialog &= ".csv"
759 | Else
760 | $sFileSaveDialog &= ".csv"
761 | EndIf
762 |
763 | _GUICtrlListView_SaveCSV($cListView, $sFileSaveDialog)
764 | EndIf
765 | EndFunc
766 |
767 |
768 | ;==============================================
769 | Func ScrollbarProc($hWnd, $iMsg, $wParam, $lParam) ; Andreik
770 |
771 | If $hWnd = $g_hSizebox And $iMsg = $WM_PAINT Then
772 | Local $tPAINTSTRUCT
773 | Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
774 | Local $iWidth = DllStructGetData($tPAINTSTRUCT, 'rPaint', 3) - DllStructGetData($tPAINTSTRUCT, 'rPaint', 1)
775 | Local $iHeight = DllStructGetData($tPAINTSTRUCT, 'rPaint', 4) - DllStructGetData($tPAINTSTRUCT, 'rPaint', 2)
776 | Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC)
777 | _GDIPlus_GraphicsDrawImageRect($hGraphics, $g_hDots, 0, 0, $iWidth, $iHeight)
778 | _GDIPlus_GraphicsDispose($hGraphics)
779 | _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
780 | Return 0
781 | EndIf
782 | Return _WinAPI_CallWindowProc($g_hOldProc, $hWnd, $iMsg, $wParam, $lParam)
783 | EndFunc ;==>ScrollbarProc
784 |
785 | ;==============================================
786 | Func CreateDots($iWidth, $iHeight, $iBackgroundColor, $iDotsColor) ; Andreik
787 |
788 | Local $iDotSize = Int($iHeight / 10)
789 | Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
790 | Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
791 | Local $hBrush = _GDIPlus_BrushCreateSolid($iDotsColor)
792 | _GDIPlus_GraphicsClear($hGraphics, $iBackgroundColor)
793 | Local $a[6][2] = [[2,6], [2,4], [2,2], [4,4], [4,2], [6,2]]
794 | For $i = 0 To UBound($a) - 1
795 | _GDIPlus_GraphicsFillRect($hGraphics, $iWidth - $iDotSize * $a[$i][0], $iHeight - $iDotSize * $a[$i][1], $iDotSize, $iDotSize, $hBrush)
796 | Next
797 | _GDIPlus_BrushDispose($hBrush)
798 | _GDIPlus_GraphicsDispose($hGraphics)
799 | Return $hBitmap
800 | EndFunc ;==>CreateDots
801 |
802 | ;==============================================
803 | Func _MyGUICtrlStatusBar_SetParts($hWnd, $aPartEdge) ; Pixelsearch
804 |
805 | If Not IsArray($aPartEdge) Then Return False
806 | Local $iParts = UBound($aPartEdge)
807 | Local $tParts = DllStructCreate("int[" & $iParts & "]")
808 | For $i = 0 To $iParts - 1
809 | DllStructSetData($tParts, 1, $aPartEdge[$i], $i + 1)
810 | Next
811 | DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $SB_SETPARTS, "wparam", $iParts, "struct*", $tParts)
812 | _GUICtrlStatusBar_Resize($hWnd)
813 | Return True
814 | EndFunc ;==>_MyGUICtrlStatusBar_SetParts
815 |
816 | ;==============================================
817 | Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ; Pixelsearch
818 | #forceref $iMsg, $wParam, $lParam
819 |
820 | If $hWnd = $hGUI Then
821 | Local Static $bIsSizeBoxShown = True
822 | Local $aSize = WinGetClientSize($hGUI)
823 | Local $aGetParts = _GUICtrlStatusBar_GetParts($g_hStatus)
824 | Local $aParts[$aGetParts[0]]
825 | For $i = 0 To $aGetParts[0] - 1
826 | $aParts[$i] = Int($aSize[0] * $g_aRatioW[$i])
827 | Next
828 | If BitAND(WinGetState($hGUI), $WIN_STATE_MAXIMIZED) Then
829 | _GUICtrlStatusBar_SetParts($g_hStatus, $aParts) ; set parts until GUI right border
830 | _WinAPI_ShowWindow($g_hSizebox, @SW_HIDE)
831 | $bIsSizeBoxShown = False
832 | Else
833 | _MyGUICtrlStatusBar_SetParts($g_hStatus, $aParts) ; set parts as user scripted them
834 | WinMove($g_hSizebox, "", $aSize[0] - $g_iHeight, $aSize[1] - $g_iHeight, $g_iHeight, $g_iHeight)
835 | If Not $bIsSizeBoxShown Then
836 | _WinAPI_ShowWindow($g_hSizebox, @SW_SHOW)
837 | $bIsSizeBoxShown = True
838 | EndIf
839 | EndIf
840 | EndIf
841 | Return $GUI_RUNDEFMSG
842 | EndFunc ;==>WM_SIZE
843 |
844 | ;==============================================
845 | Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
846 | #forceref $iMsg, $wParam, $lParam
847 |
848 | If $hWnd = $hGUI Then
849 | _WinAPI_RedrawWindow($g_hSizebox)
850 | EndIf
851 | Return $GUI_RUNDEFMSG
852 | EndFunc ;==>WM_MOVE
853 |
854 | ;==============================================
855 | Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam) ; Kafu
856 | #forceref $hWnd, $iMsg, $wParam
857 |
858 | Local Static $tagDRAWITEM = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;hwnd hwndItem;handle hDC;long rcItem[4];ulong_ptr itemData"
859 | Local $tDRAWITEM = DllStructCreate($tagDRAWITEM, $lParam)
860 | If $tDRAWITEM.hwndItem = $g_hStatus Then
861 |
862 | Local $itemID = $tDRAWITEM.itemID ; status bar part number (0, 1, ...)
863 | Local $hDC = $tDRAWITEM.hDC
864 | Local $tRect = DllStructCreate("long left;long top;long right;long bottom", DllStructGetPtr($tDRAWITEM, "rcItem"))
865 | ;_WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $g_hBrush) ; backgound color
866 | _WinAPI_SetTextColor($hDC, $g_iTextColor) ; text color
867 | _WinAPI_SetBkMode($hDC, $TRANSPARENT)
868 | DllStructSetData($tRect, "top", $tRect.top + 1)
869 | DllStructSetData($tRect, "left", $tRect.left + 1)
870 | _WinAPI_DrawText($hDC, $g_aText[$itemID], $tRect, $DT_LEFT)
871 |
872 | Return $GUI_RUNDEFMSG
873 | Else
874 | _WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam)
875 | EndIf
876 | EndFunc ;==>WM_DRAWITEM
877 |
878 |
879 | While 1
880 | $MSG = GUIGetMsg()
881 | Select
882 | Case $MSG = $GUI_EVENT_CLOSE
883 | _GDIPlus_BitmapDispose($g_hDots)
884 | _GUICtrlStatusBar_Destroy($g_hStatus)
885 | _WinAPI_DestroyCursor($hCursor)
886 | ;_WinAPI_DeleteObject($g_hBrush)
887 | _WinAPI_SetWindowLong($g_hSizebox, $GWL_WNDPROC, $g_hOldProc)
888 | DllCallbackFree($hProc)
889 | _GDIPlus_Shutdown()
890 | GUIDelete($hGUI)
891 | Exit
892 | Case $MSG = $menuFileExit
893 | _GDIPlus_BitmapDispose($g_hDots)
894 | _GUICtrlStatusBar_Destroy($g_hStatus)
895 | _WinAPI_DestroyCursor($hCursor)
896 | ;_WinAPI_DeleteObject($g_hBrush)
897 | _WinAPI_SetWindowLong($g_hSizebox, $GWL_WNDPROC, $g_hOldProc)
898 | DllCallbackFree($hProc)
899 | _GDIPlus_Shutdown()
900 | GUIDelete($hGUI)
901 | Exit
902 | Case $MSG = $menuExportCSV
903 | ExportToCSV()
904 | Case $MSG = $menuStartTrace
905 | _GUICtrlListView_DeleteAllItems($cListView)
906 | GUICtrlSetState($menuStopTrace, $GUI_ENABLE)
907 | GUICtrlSetState($menuStartTrace, $GUI_DISABLE)
908 | GUICtrlSetState($menuExportCSV, $GUI_DISABLE)
909 | $g_aText[0] = " AppContainer Learning Mode has started. Data will appear after clicking Stop Learning."
910 | ; redraw status bar to update values
911 | _WinAPI_RedrawWindow($g_hStatus)
912 | StartTrace()
913 | Case $MSG = $menuStopTrace
914 | GUICtrlSetState($menuStartTrace, $GUI_ENABLE)
915 | GUICtrlSetState($menuStopTrace, $GUI_DISABLE)
916 | $g_aText[0] = " Parsing Learning Data... (time to parse depends on size of dataset)"
917 | ; redraw status bar to update values
918 | _WinAPI_RedrawWindow($g_hStatus)
919 | StopTrace()
920 | $g_aText[0] = " "
921 | ; redraw status bar to update values
922 | _WinAPI_RedrawWindow($g_hStatus)
923 | GUICtrlSetState($menuExportCSV, $GUI_ENABLE)
924 | EndSelect
925 |
926 | WEnd
927 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tools
2 |
3 | `LaunchAppContainer.exe` - launching win32 apps in AppContainer sandboxes with various options
4 |
5 | `LearningMode.exe` - provides ETW tracing for Permissive Learning Mode
6 |
7 | `SetAppContainerACL.exe` - allows settings ACL permissions for specific AppContainer sandboxes
8 |
9 |
10 | All programs have a dark mode or light mode depending on the system theme settings.
11 |
12 | # Screenshots
13 |
14 | 
15 |
16 | 
17 |
18 | 
19 |
20 |
21 | # Acknowledgements
22 |
23 | [SetACL](https://helgeklein.com/setacl/) - Thanks to @helgeklein for giving permission to distribute the SetACL command line tool with my AppContainer tools.
24 |
25 | [AppContainerSid](https://github.com/forderud/RunInSandbox/tree/master/AppContainerSid) - Thanks to @forderud for giving permission to include AppContainerSid.
26 |
27 | [LaunchAppContainer](https://github.com/microsoft/SandboxSecurityTools/tree/main/LaunchAppContainer) - Thanks to @microsoft for providing this tool.
28 |
29 | [LowBox Token Permissive Learning Mode](https://www.tiraniddo.dev/2021/09/lowbox-token-permissive-learning-mode.html) - Thanks to @tyranid for the inspiration for the Learning Mode tool.
30 |
--------------------------------------------------------------------------------
/app.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/win32-appcontainer-tools/bff820bc882cb86cc54b553628c362a5a20a8f98/app.ico
--------------------------------------------------------------------------------
/bin/AppContainerSid.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/win32-appcontainer-tools/bff820bc882cb86cc54b553628c362a5a20a8f98/bin/AppContainerSid.exe
--------------------------------------------------------------------------------
/bin/LaunchAppContainer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/win32-appcontainer-tools/bff820bc882cb86cc54b553628c362a5a20a8f98/bin/LaunchAppContainer.exe
--------------------------------------------------------------------------------
/bin/SetACL.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/win32-appcontainer-tools/bff820bc882cb86cc54b553628c362a5a20a8f98/bin/SetACL.exe
--------------------------------------------------------------------------------
/checked.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/win32-appcontainer-tools/bff820bc882cb86cc54b553628c362a5a20a8f98/checked.ico
--------------------------------------------------------------------------------
/data/capslist.txt:
--------------------------------------------------------------------------------
1 | accessoryManager
2 | activateAsUser
3 | activity
4 | activityData
5 | activitySystem
6 | allAppMods
7 | allJoyn
8 | allowElevation
9 | appBroadcast
10 | appBroadcastServices
11 | appBroadcastSettings
12 | appCaptureServices
13 | appCaptureSettings
14 | appDiagnostics
15 | applicationDefaults
16 | applicationDefaultsUserChoice
17 | applicationViewActivation
18 | appLicensing
19 | appManagementSystem
20 | appointments
21 | appointmentsSystem
22 | audioDeviceConfiguration
23 | automatedAppLaunch
24 | backgroundMediaPlayback
25 | backgroundMediaRecording
26 | backgroundSpatialPerception
27 | backgroundVoIP
28 | biometricSystem
29 | blockedChatMessages
30 | bluetooth
31 | bluetooth.genericAttributeProfile
32 | bluetooth.rfcomm
33 | bluetoothAdapter
34 | bluetoothDeviceSettings
35 | bluetoothDiagnostics
36 | bluetoothSync
37 | bootstrapNetworkConnection
38 | broadFileSystemAccess
39 | browserAppList
40 | browserCredentials
41 | cameraProcessingExtension
42 | capabilityAccessConsentDeviceSettings
43 | cellularData
44 | cellularDeviceControl
45 | cellularDeviceIdentity
46 | cellularMessaging
47 | chat
48 | chatSystem
49 | childWebContent
50 | chromeInstallFiles
51 | cloudExperienceHost
52 | cloudStore
53 | codeGeneration
54 | componentUiInWebContent
55 | comPort
56 | confirmAppClose
57 | constrainedImpersonation
58 | contacts
59 | contactsSystem
60 | contentDeliveryManagerSettings
61 | contentRestrictions
62 | coreShell
63 | cortanaPermissions
64 | cortanaSettings
65 | cortanaSpeechAccessory
66 | cortanaSurface
67 | curatedTileCollections
68 | customInstallActions
69 | dateAndTimeDeviceSettings
70 | dependencyTarget
71 | delegatedTokenRequests
72 | developerSettings
73 | developmentModeNetwork
74 | deviceEncryptionManagement
75 | deviceIdentityManagement
76 | deviceLockManagement
77 | deviceManagementAdministrator
78 | deviceManagementDeclaredConfiguration
79 | deviceManagementDeviceLockPolicies
80 | deviceManagementDmAccount
81 | deviceManagementEmailAccount
82 | deviceManagementFoundation
83 | deviceManagementRegistration
84 | deviceManagementWapSecurityPolicies
85 | devicePortalProvider
86 | deviceProvisioningAdministrator
87 | deviceUnlock
88 | diagnostics
89 | displayDeviceSettings
90 | documentsLibrary
91 | downloadsFolder
92 | dualSimTiles
93 | email
94 | emailSystem
95 | enterpriseAuthentication
96 | enterpriseCloudSSO
97 | enterpriseDataPolicy
98 | enterpriseDeviceLockdown
99 | eraApplication
100 | exclusiveResource
101 | expandedResources
102 | extendedBackgroundTaskTime
103 | extendedExecutionBackgroundAudio
104 | extendedExecutionCritical
105 | extendedExecutionUnconstrained
106 | featureStagingInfo
107 | feedbackLogCollection
108 | firstSignInSettings
109 | flashPlayerSupport
110 | fullFileSystemAccess
111 | gameBarServices
112 | gameConfigStoreManagement
113 | gameList
114 | gameMonitor
115 | gamingContainerResources
116 | gazeInput
117 | globalMediaControl
118 | graphicsCapture
119 | graphicsCaptureProgrammatic
120 | graphicsCaptureWithoutBorder
121 | hardwareManagerMocks
122 | hevcPlayback
123 | hfxSystem
124 | hidTelephony
125 | holographicCompositor
126 | holographicCompositorSystem
127 | humanInterfaceDevice
128 | humanPresence
129 | imeSystem
130 | indexedContent
131 | inProcessMediaExtension
132 | inputForegroundObservation
133 | inputInjection
134 | inputInjectionBrokered
135 | inputObservation
136 | inputOverride
137 | inputSettings
138 | inputSuppression
139 | internetClient
140 | internetClientServer
141 | interopServices
142 | keyboardDeviceSettings
143 | kinectAudio
144 | kinectExpressions
145 | kinectFace
146 | kinectGamechat
147 | kinectRequired
148 | kinectVideo
149 | kinectVision
150 | languageAndRegionDeviceSettings
151 | languageSettings
152 | learningModeLogging
153 | liveIdService
154 | localExperienceCumulativeInternal
155 | localExperienceInternal
156 | localSystemServices
157 | location
158 | locationHistory
159 | locationSystem
160 | lockScreenCreatives
161 | lowLevel
162 | lowLevelDevices
163 | lpacAppExperience
164 | lpacClipboard
165 | lpacCom
166 | lpacCryptoServices
167 | lpacDeviceAccess
168 | lpacEdgeWdagComms
169 | lpacEnterprisePolicyChangeNotifications
170 | lpacIdentityServices
171 | lpacIME
172 | lpacInstrumentation
173 | lpacMedia
174 | lpacMediaFoundationCdmData
175 | lpacPackageManagerOperation
176 | lpacPayments
177 | lpacPnPNotifications
178 | lpacPrinting
179 | lpacServicesManagement
180 | lpacSessionManagement
181 | lpacWebPlatform
182 | mediaFoundationCdmFiles
183 | microphone
184 | microsoftEdgeRemoteDebugging
185 | mixedRealityEnvironmentInternal
186 | mmsTransportSystem
187 | modifiableApp
188 | msaExtension
189 | multiplaneOverlay
190 | muma
191 | musicLibrary
192 | networkConnectionManagerProvisioning
193 | networkDataPlanProvisioning
194 | networkDataUsageManagement
195 | networkDeviceAdminSettings
196 | networkDeviceSettings
197 | networkDiagnostics
198 | networkingVpnProvider
199 | nfcSystem
200 | notificationsDeviceSettings
201 | objects3D
202 | oemDeployment
203 | oemPublicDirectory
204 | offlineMapsManagement
205 | oneProcessVoIP
206 | optical
207 | pacJsWorker
208 | packageContents
209 | packageManagement
210 | packagePolicySystem
211 | packageQuery
212 | packageWriteRedirectionCompatibilityShim
213 | packagedServices
214 | perceptionMonitoring
215 | perceptionSensorsExperimental
216 | perceptionSystem
217 | personalizationDeviceSettings
218 | phoneCall
219 | phoneCallHistory
220 | phoneCallHistoryPublic
221 | phoneCallHistorySystem
222 | phoneCallSystem
223 | phoneLineTransportManagement
224 | picturesLibrary
225 | pointOfService
226 | polarisService
227 | policyManager
228 | powerDeviceSettings
229 | preemptiveCamera
230 | previewHfx
231 | previewInkWorkspace
232 | previewPenWorkspace
233 | previewStore
234 | previewUiComposition
235 | privateNetworkClientServer
236 | projectionDeviceSettings
237 | protectedApp
238 | proximity
239 | radios
240 | recordedCallsFolder
241 | regionSettings
242 | registryRead
243 | relatedPackages
244 | remoteAutomationHost
245 | remoteFileAccess
246 | remotePassportAuthentication
247 | remoteSystem
248 | removableStorage
249 | resetPhone
250 | runFullTrust
251 | screenDuplication
252 | searchSettings
253 | secondaryAuthenticationFactor
254 | secureAssessment
255 | sensors.custom
256 | serialCommunication
257 | sessionImpersonation
258 | settingSyncConfiguration
259 | sharedMachineKeysCapability
260 | sharedUserCertificates
261 | shellDisplayManagement
262 | shellExperience
263 | shellExperienceComposer
264 | slapiQueryLicenseValue
265 | smbios
266 | sms
267 | smsSend
268 | smsSystem
269 | smsTransportSystem
270 | spatialPerception
271 | startScreenManagement
272 | storeAppInstall
273 | storeAppInstallation
274 | storeConfiguration
275 | storeLicenseManagement
276 | storeOptionalPackageInstallManagement
277 | systemAllocWindowID
278 | systemDialog
279 | systemDialogEmergency
280 | systemManagement
281 | systemRegistrar
282 | targetedContent
283 | targetedContentSubscription
284 | teamEditionDeviceCredential
285 | teamEditionExperience
286 | teamEditionView
287 | telemetryData
288 | terminalPowerManagement
289 | thumbnailCache
290 | timezone
291 | uiAccess
292 | uiAutomationCrossMachineHostingSystem
293 | uiAutomationSystem
294 | unvirtualizedResources
295 | unzipFile
296 | updateAndSecurityDeviceSettings
297 | usb
298 | userAccountInformation
299 | userDataAccountSetup
300 | userDataAccountsProvider
301 | userDataSystem
302 | userDataTasks
303 | userDataTasksSystem
304 | userManagementSystem
305 | userNotificationListener
306 | userOnboardingState
307 | userPrincipalName
308 | userSigninSupport
309 | userSystemId
310 | userWebAccounts
311 | videosLibrary
312 | visualElementsSystem
313 | visualVoiceMail
314 | vmWorkerProcess
315 | voipCall
316 | walletSystem
317 | webcam
318 | webPlatformMediaExtension
319 | wiFiControl
320 | wifiData
321 | wiFiDirect
322 | windowInfo
323 | windowManagement
324 | windowManagementSystem
325 | windowsHelloCredentialAccess
326 | windowsPerformanceCounters
327 | xboxAccessoryManagement
328 | xboxBroadcaster
329 | xboxGameSpeechWindow
330 | xboxLiveAuthenticationProvider
331 | xboxSystemApplicationClipQuery
332 | xboxTrackingStream
--------------------------------------------------------------------------------
/includes/AutOnExit.au3:
--------------------------------------------------------------------------------
1 | #cs ----------------------------------------------------------------------------
2 | AutoIt Version: 3.3.16.1
3 | Author: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com)
4 | Remarks: Used to perform on exit garbage cleanup
5 | #ce ----------------------------------------------------------------------------
6 |
7 | #include-once
8 |
9 | ; Use this add new garbage cleanups funcs
10 | ; [n][0] = function to call/cleanup
11 | ; [n][1-8] = argument (could be hwnd or some other val, only allows 8 arguments
12 | Global $AUTONEXIT_MAXPARAMS = 8
13 | Global $AUTONEXIT_ARGS[1][$AUTONEXIT_MAXPARAMS + 1] = [[Null,Null,Null,Null,Null,Null,Null,Null,Null]]
14 | Global $AUTONEXIT_ARGSCOUNT = -1
15 |
16 | OnAutoItExitRegister(__AutOnExit_Cleanup);
17 |
18 | ; #CURRENT# =====================================================================================================================
19 | ; _AutOnExit_AddFunc
20 | ; ===============================================================================================================================
21 |
22 | ; #FUNCTION# ====================================================================================================================
23 | ; Name ..........: _AutOnExit_AddFunc
24 | ; Description ...: Add a single or multiple exit functions with up to 8 parameters each
25 | ; Syntax ........: _AutOnExit_AddFunc($vFunc[, $vParam1 = "@APPEXITPARAM@"[, $vParam2 = "@APPEXITPARAM@"[, $vParam3 = "@APPEXITPARAM@"[,
26 | ; $vParam4 = "@APPEXITPARAM@"[, $vParam5 = "@APPEXITPARAM@"[, $vParam6 = "@APPEXITPARAM@"[, $vParam7 = "@APPEXITPARAM@"[,
27 | ; $vParam8 = "@APPEXITPARAM@"]]]]]]]])
28 | ; Parameters ....: $vFunc - a variant value.
29 | ; $vParam1-$vParam8 - optional parameters
30 | ; Author ........: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com)
31 | ; Modified ......:
32 | ; ===============================================================================================================================
33 | Func _AutOnExit_AddFunc($vFunc, _
34 | $vParam1 = "@APPEXITPARAM@", $vParam2 = "@APPEXITPARAM@", _
35 | $vParam3 = "@APPEXITPARAM@", $vParam4 = "@APPEXITPARAM@", _
36 | $vParam5 = "@APPEXITPARAM@", $vParam6 = "@APPEXITPARAM@", _
37 | $vParam7 = "@APPEXITPARAM@", $vParam8 = "@APPEXITPARAM@")
38 |
39 | If IsString($vFunc) Then $vFunc = Execute($vFunc)
40 |
41 | Local $aParams[$AUTONEXIT_MAXPARAMS + 2] = [$vParam1, $vParam2, $vParam3, _
42 | $vParam4, $vParam5, $vParam6, $vParam7, $vParam8]
43 |
44 | $AUTONEXIT_ARGSCOUNT += 1
45 | ReDim $AUTONEXIT_ARGS[$AUTONEXIT_ARGSCOUNT + 1][$AUTONEXIT_MAXPARAMS + 1]
46 | ; fill arguments
47 | For $i = 1 To $AUTONEXIT_MAXPARAMS
48 | $AUTONEXIT_ARGS[$AUTONEXIT_ARGSCOUNT][$i] = "@APPEXITPARAM@"
49 | Next
50 |
51 | ; first param is function
52 | $AUTONEXIT_ARGS[$AUTONEXIT_ARGSCOUNT][0] = $vFunc
53 |
54 | ; now for rest of parameters/arguments
55 | For $i = 1 To @NumParams - 1
56 | $AUTONEXIT_ARGS[$AUTONEXIT_ARGSCOUNT][$i] = $aParams[$i]
57 | Next
58 |
59 | EndFunc
60 |
61 | Func __AutOnExit_Cleanup()
62 |
63 | Local $vCall, $iArgs = 0
64 |
65 | If IsDeclared("$AUTONEXIT_ARGSCOUNT") Then
66 | For $i = 0 To $AUTONEXIT_ARGSCOUNT
67 |
68 | ; get filled argument counts
69 | $iArgs = 0
70 | For $n = 1 To UBound($AUTONEXIT_ARGS, 2) - 1
71 | If $AUTONEXIT_ARGS[$i][$n] = "@APPEXITPARAM@" Then ExitLoop
72 | $iArgs += 1
73 | Next
74 |
75 | $vCall = $AUTONEXIT_ARGS[$i][0]
76 | Switch $iArgs
77 | Case 0
78 | $vCall()
79 | Case 1
80 | $vCall($AUTONEXIT_ARGS[$i][1])
81 | Case 2
82 | $vCall($AUTONEXIT_ARGS[$i][1], _
83 | $AUTONEXIT_ARGS[$i][2])
84 | Case 3
85 | $vCall($AUTONEXIT_ARGS[$i][1], _
86 | $AUTONEXIT_ARGS[$i][2], _
87 | $AUTONEXIT_ARGS[$i][3])
88 | Case 4
89 | $vCall($AUTONEXIT_ARGS[$i][1], _
90 | $AUTONEXIT_ARGS[$i][2], _
91 | $AUTONEXIT_ARGS[$i][3], _
92 | $AUTONEXIT_ARGS[$i][4])
93 | Case 5
94 | $vCall($AUTONEXIT_ARGS[$i][1], _
95 | $AUTONEXIT_ARGS[$i][2], _
96 | $AUTONEXIT_ARGS[$i][3], _
97 | $AUTONEXIT_ARGS[$i][4], _
98 | $AUTONEXIT_ARGS[$i][5])
99 | Case 6
100 | $vCall($AUTONEXIT_ARGS[$i][1], _
101 | $AUTONEXIT_ARGS[$i][2], _
102 | $AUTONEXIT_ARGS[$i][3], _
103 | $AUTONEXIT_ARGS[$i][4], _
104 | $AUTONEXIT_ARGS[$i][5], _
105 | $AUTONEXIT_ARGS[$i][6])
106 | Case 7
107 | $vCall($AUTONEXIT_ARGS[$i][1], _
108 | $AUTONEXIT_ARGS[$i][2], _
109 | $AUTONEXIT_ARGS[$i][3], _
110 | $AUTONEXIT_ARGS[$i][4], _
111 | $AUTONEXIT_ARGS[$i][5], _
112 | $AUTONEXIT_ARGS[$i][6], _
113 | $AUTONEXIT_ARGS[$i][7])
114 | Case 8
115 | $vCall($AUTONEXIT_ARGS[$i][1], _
116 | $AUTONEXIT_ARGS[$i][2], _
117 | $AUTONEXIT_ARGS[$i][3], _
118 | $AUTONEXIT_ARGS[$i][4], _
119 | $AUTONEXIT_ARGS[$i][5], _
120 | $AUTONEXIT_ARGS[$i][6], _
121 | $AUTONEXIT_ARGS[$i][7], _
122 | $AUTONEXIT_ARGS[$i][8])
123 | EndSwitch
124 | Next
125 | EndIf
126 | EndFunc
--------------------------------------------------------------------------------
/includes/ExtMsgBox.au3:
--------------------------------------------------------------------------------
1 | #include-once
2 |
3 | ; #INDEX# ============================================================================================================
4 | ; Title .........: ExtMsgBox
5 | ; AutoIt Version : v3.2.12.1 or higher
6 | ; Language ......: English
7 | ; Description ...: Generates user defined message boxes centred on a GUI, on screen or at defined coordinates
8 | ; Remarks .......:
9 | ; Note ..........:
10 | ; Author(s) .....: Melba23, based on some original code by photonbuddy & YellowLab, and KaFu (default font code)
11 | ; ====================================================================================================================
12 |
13 | ;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7
14 |
15 | ; #INCLUDES# =========================================================================================================
16 | #include "StringSize.au3"
17 | #include
18 | #include
19 | #include
20 |
21 | ; #GLOBAL CONSTANTS# =================================================================================================
22 | Global Const $EMB_ICONSTOP = 16 ; Stop-sign icon
23 | Global Const $EMB_ICONQUERY = 32 ; Question-mark icon
24 | Global Const $EMB_ICONEXCLAM = 48 ; Exclamation-point icon
25 | Global Const $EMB_ICONINFO = 64 ; Icon consisting of an 'i' in a circle
26 |
27 | ; #GLOBAL VARIABLES# =================================================================================================
28 |
29 | Global $g_aEMB_Settings[15]
30 | ; [0] = Style [6] = Max Width [12] = Title bar reduction
31 | ; [1] = Justification [7] = Absolute Width [13] = Focused button character
32 | ; [2] = Back Colour [8] = Default Back Colour [14] = Default titlebar icon
33 | ; [3] = Text Colour [9] = Default Text Colour
34 | ; [4] = Font Size [10] = Default Font Size
35 | ; [5] = Font Name [11] = Default Font Name
36 | ;
37 |
38 | ; Default settings
39 | ; Font
40 | Global $g_aEMB_TempArray = __EMB_GetDefaultFont()
41 | $g_aEMB_Settings[10] = $g_aEMB_TempArray[0]
42 | $g_aEMB_Settings[11] = $g_aEMB_TempArray[1]
43 | ; Colours
44 | $g_aEMB_TempArray = DllCall("User32.dll", "int", "GetSysColor", "int", 15) ; $COLOR_3DFACE
45 | $g_aEMB_Settings[8] = BitAND(BitShift(String(Binary($g_aEMB_TempArray[0])), 8), 0xFFFFFF)
46 | $g_aEMB_TempArray = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT
47 | $g_aEMB_Settings[9] = BitAND(BitShift(String(Binary($g_aEMB_TempArray[0])), 8), 0xFFFFFF)
48 | ; Title bar width reduction by icon and [X] button in various themes
49 | $g_aEMB_TempArray = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 11) ; Title bar icon width
50 | $g_aEMB_Settings[12] = $g_aEMB_TempArray[0]
51 | $g_aEMB_TempArray = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 30) ; Title bar button width
52 | $g_aEMB_Settings[12] += ( ($g_aEMB_TempArray[0] < 30) ? ($g_aEMB_TempArray[0] * 3) : ($g_aEMB_TempArray[0]) ) ; Compensate for small buttons in some themes
53 | $g_aEMB_TempArray = 0
54 | $g_aEMB_TempArray = DllCall("dwmapi.dll", "uint", "DwmIsCompositionEnabled", "int*", $g_aEMB_TempArray) ; Check for Aero enabled
55 | If Not @error And $g_aEMB_TempArray[1] = True Then
56 | $g_aEMB_TempArray = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 7) ; GUI button frame width
57 | $g_aEMB_Settings[12] += ($g_aEMB_TempArray[0] * 4) ; Add frames to compensate for incorrect Aero return
58 | EndIf
59 | $g_aEMB_TempArray = 0
60 |
61 | ; Set default values
62 | $g_aEMB_Settings[0] = 0
63 | $g_aEMB_Settings[1] = 0
64 | $g_aEMB_Settings[2] = $g_aEMB_Settings[8]
65 | $g_aEMB_Settings[3] = $g_aEMB_Settings[9]
66 | $g_aEMB_Settings[4] = $g_aEMB_Settings[10]
67 | $g_aEMB_Settings[5] = $g_aEMB_Settings[11]
68 | $g_aEMB_Settings[6] = 370
69 | $g_aEMB_Settings[7] = 500
70 | $g_aEMB_Settings[13] = "~"
71 | $g_aEMB_Settings[14] = ""
72 |
73 | ; #CURRENT# ==========================================================================================================
74 | ; _ExtMsgBoxSet: Sets the GUI style, justification, colours, font and max width for subsequent _ExtMsgBox function calls
75 | ; _ExtMsgBox: Generates user defined message boxes centred on a GUI, on screen or at defined coordinates
76 | ; ====================================================================================================================
77 |
78 | ; #INTERNAL_USE_ONLY#=================================================================================================
79 | ; __EMB_GetDefaultFont: Determines Windows default MsgBox font size and name
80 | ; ====================================================================================================================
81 |
82 | ; #FUNCTION# =========================================================================================================
83 | ; Name...........: _ExtMsgBoxSet
84 | ; Description ...: Sets the GUI style, justification, colours, font and max width for subsequent _ExtMsgBox function calls
85 | ; Syntax.........: _ExtMsgBoxSet($iStyle, $iJust, [$iBkCol, [$iCol, [$sFont_Size, [$iFont_Name, [$iWidth, [$iWidth_Abs, [$sFocus_Char, [$sTitlebar_Icon]]]]]]]])
86 | ; Parameters ....: $iStyle -> 0 (Default) - Taskbar Button, TOPMOST, button in user font, no tab expansion,
87 | ; no checkbox, titlebar icon, active closure [X] and SysMenu close
88 | ; Combine following to change:
89 | ; 1 = No Taskbar Button
90 | ; 2 = TOPMOST Style not set
91 | ; 4 = Buttons use default font
92 | ; 8 = Expand Tabs to ensure adequate sizing of GUI
93 | ; 16 = "Do not display again" checkbox
94 | ; 32 = Show no icon on title bar
95 | ; 64 = Disable EMB closure [X] and SysMenu Close
96 | ; $iJust -> 0 = Left justified (Default), 1 = Centred , 2 = Right justified
97 | ; + 4 = Centred single button. Note: multiple buttons are always centred
98 | ; ($SS_LEFT, $SS_CENTER, $SS_RIGHT can also be used - must #include )
99 | ; $iBkCol -> The colour for the message box background. Default = system colour
100 | ; $iCol -> The colour for the message box text. Default = system colour
101 | ; $iFont_Size -> The font size in points to use for the message box. Default = system font size
102 | ; $sFont_Name -> The font to use for the message box. Default = system font
103 | ; $iWidth -> Normal max width for EMB. Default/min = 370 pixels - max = @DesktopWidth - 20
104 | ; $iWidth_Abs -> Absolute max width for EMB. Default/min = 370 pixels - max = @DesktopWidth - 20
105 | ; EMB will expand to this value to accommodate long unbroken character strings
106 | ; Forced to $iWidth value if less
107 | ; $sFocus_Char -> Character to define focused button. Default = "~"
108 | ; $sTitlebar_Icon -> Icon to use on ExtMsgBox titlebar - default is standard AutoIt icon
109 | ; When set to name of an ico or exe file, the main icon within will be displayed
110 | ; If another icon from the file is required, add a trailing "|" followed by the icon index
111 | ; Requirement(s).: v3.2.12.1 or higher
112 | ; Return values .: Success - Returns 1
113 | ; Failure - Returns 0 and sets @error to 1 with @extended set to incorrect parameter index number
114 | ; Remarks .......; - Setting any parameter to -1 leaves the current value unchanged
115 | ; Setting the $iStyle parameter to 'Default' resets ALL parameters to default values <<<<<<<<<<<<<<<<<<<<<<<
116 | ; Setting any other parameter to "Default" only resets that parameter
117 | ; - Setting a titlebar icon overrides any "show no icon" numeric setting
118 | ; Author ........: Melba23
119 | ; Example........; Yes
120 | ;=====================================================================================================================
121 | Func _ExtMsgBoxSet($iStyle = -1, $iJust = -1, $iBkCol = -1, $iCol = -1, $iFont_Size = -1, $sFont_Name = -1, $iWidth = -1, $iWidth_Abs = -1, $sFocus_Char = "~", $sTitlebar_Icon = "")
122 |
123 | ; Set global EMB variables to required values
124 | Switch $iStyle
125 | Case Default
126 | $g_aEMB_Settings[0] = 0
127 | $g_aEMB_Settings[1] = 0
128 | $g_aEMB_Settings[2] = $g_aEMB_Settings[8]
129 | $g_aEMB_Settings[3] = $g_aEMB_Settings[9]
130 | $g_aEMB_Settings[5] = $g_aEMB_Settings[11]
131 | $g_aEMB_Settings[4] = $g_aEMB_Settings[10]
132 | $g_aEMB_Settings[6] = 370
133 | $g_aEMB_Settings[7] = 370
134 | $g_aEMB_Settings[13] = "~"
135 | $g_aEMB_Settings[14] = ""
136 | Return
137 | Case -1
138 | ; Do nothing
139 | Case 0 To 127
140 | $g_aEMB_Settings[0] = Int($iStyle)
141 | Case Else
142 | Return SetError(1, 1, 0)
143 | EndSwitch
144 |
145 | Switch $iJust
146 | Case Default
147 | $g_aEMB_Settings[1] = 0
148 | Case -1
149 | ; Do nothing
150 | Case 0, 1, 2, 4, 5, 6
151 | $g_aEMB_Settings[1] = $iJust
152 | Case Else
153 | Return SetError(1, 2, 0)
154 | EndSwitch
155 |
156 | Switch $iBkCol
157 | Case Default
158 | $g_aEMB_Settings[2] = $g_aEMB_Settings[8]
159 | Case -1
160 | ; Do nothing
161 | Case 0 To 0xFFFFFF
162 | $g_aEMB_Settings[2] = Int($iBkCol)
163 | Case Else
164 | Return SetError(1, 3, 0)
165 | EndSwitch
166 |
167 | Switch $iCol
168 | Case Default
169 | $g_aEMB_Settings[3] = $g_aEMB_Settings[9]
170 | Case -1
171 | ; Do nothing
172 | Case 0 To 0xFFFFFF
173 | $g_aEMB_Settings[3] = Int($iCol)
174 | Case Else
175 | Return SetError(1, 4, 0)
176 | EndSwitch
177 |
178 | Switch $iFont_Size
179 | Case Default
180 | $g_aEMB_Settings[4] = $g_aEMB_Settings[10]
181 | Case -1
182 | ; Do nothing
183 | Case 8 To 72
184 | $g_aEMB_Settings[4] = Int($iFont_Size)
185 | Case Else
186 | Return SetError(1, 5, 0)
187 | EndSwitch
188 |
189 | Switch $sFont_Name
190 | Case Default
191 | $g_aEMB_Settings[5] = $g_aEMB_Settings[11]
192 | Case -1
193 | ; Do nothing
194 | Case Else
195 | If IsString($sFont_Name) Then
196 | $g_aEMB_Settings[5] = $sFont_Name
197 | Else
198 | Return SetError(1, 6, 0)
199 | EndIf
200 | EndSwitch
201 |
202 | Switch $iWidth
203 | Case Default
204 | $g_aEMB_Settings[6] = 370
205 | Case -1
206 | ; Do nothing
207 | Case 370 To @DesktopWidth - 20
208 | $g_aEMB_Settings[6] = Int($iWidth)
209 | Case Else
210 | Return SetError(1, 7, 0)
211 | EndSwitch
212 |
213 | Switch $iWidth_Abs
214 | Case Default
215 | $g_aEMB_Settings[7] = 370
216 | Case -1
217 | ; Do nothing
218 | Case 370 To @DesktopWidth - 20
219 | $g_aEMB_Settings[7] = Int($iWidth_Abs)
220 | Case Else
221 | Return SetError(1, 8, 0)
222 | EndSwitch
223 |
224 | ; Check absolute width is at least max width
225 | If $g_aEMB_Settings[7] < $g_aEMB_Settings[6] Then
226 | $g_aEMB_Settings[7] = $g_aEMB_Settings[6]
227 | EndIf
228 |
229 | Switch $sFocus_Char
230 | Case Default
231 | $g_aEMB_Settings[13] = "~"
232 | Case -1
233 | ; Do nothing
234 | Case Else
235 | If IsString($sFocus_Char) Then
236 | $g_aEMB_Settings[13] = StringLeft($sFocus_Char, 1)
237 | Else
238 | $g_aEMB_Settings[13] = "~"
239 | EndIf
240 | EndSwitch
241 |
242 | Switch $sTitlebar_Icon
243 | Case Default
244 | $g_aEMB_Settings[14] = ""
245 | Case -1
246 | ; Do nothing
247 | Case Else
248 | If IsString($sTitlebar_Icon) Then
249 | $g_aEMB_Settings[14] = $sTitlebar_Icon
250 | Else
251 | $g_aEMB_Settings[14] = ""
252 | EndIf
253 | EndSwitch
254 |
255 | Return 1
256 |
257 | EndFunc ;==>_ExtMsgBoxSet
258 |
259 | ; #FUNCTION# =========================================================================================================
260 | ; Name...........: _ExtMsgBox
261 | ; Description ...: Generates user defined message boxes centred on a GUI, the desktop, or at defined coordinates
262 | ; Syntax.........: _ExtMsgBox ($vIcon, $vButton, $sTitle, $sText, [$vTimeout, [$hWin, [$iVPos, [$bMain = True]]]])
263 | ; Parameters ....: $vIcon -> Sets the required icon in the GUI display and optionally in the titlebar of the ExtMsgBox
264 | ; GUI display icon:
265 | ; Numeric value:
266 | ; 0 - No icon
267 | ; 8 - UAC
268 | ; 16 - Stop )
269 | ; 32 - Query ) or equivalent $MB/$EMB_ICON constant
270 | ; 48 - Exclamation )
271 | ; 64 - Information )
272 | ; 128 - Countdown digits if $iTimeOut set
273 | ; Any other numeric value returns Error 1
274 | ; String value:
275 | ; If set to the name of an ico or exe file, the main icon within will be displayed
276 | ; If another icon from the file is required, add a trailing "|" followed by the icon index
277 | ; If set to the name of an image file, that image will be displayed
278 | ; Titlebar icon:
279 | ; Use a semicolon delimiter followed by the name/index of the required exe/ico file
280 | ; Default (no delimiter or name) = use global icon setting from _ExtMsgBoxSet
281 | ; $vButton -> Button text separated with "|" character. " " = no buttons.
282 | ; Putting a user-defined character (default = "~") before the text indicates button to be focused
283 | ; Two focused buttons returns Error 2. A single button is always focused
284 | ; Use of standard Windows keyboard shortcut by adding "&" before the button text is still available
285 | ; Note UDF focused button character must be placed first, e.g. "~&Yes|&No"
286 | ; Can also use $MB_ button numeric constants to define buttons: 0 = "OK", 1 = "~OK|Cancel",
287 | ; 2 = "~Abort|Retry|Ignore", 3 = "~Yes|No|Cancel", 4 = "~Yes|No", 5 = "~Retry|Cancel",
288 | ; 6 = "~Cancel|Try Again|Continue". Other values return Error 3
289 | ; Default max width of 370 gives 1-4 buttons @ width 80, 5 @ width 60, 6 @ width 50
290 | ; Min button width set at 50, so unless default widths changed 7 buttons will return Error 4
291 | ; $sTitle -> The title of the message box.
292 | ; Procrustean truncation if too long to fit
293 | ; $sText -> The text to be displayed. Long lines will wrap. The box depth is adjusted to fit.
294 | ; If unbroken character strings in $sText too long for set max width,
295 | ; EMB expands to set absolute width. Error 6 if still not able to fit
296 | ; $vTimeout -> Single integer sets timeout delay in secs before EMB closes. 0 = no timeout (Default).
297 | ; If no buttons and no timeout set, timeout automatically set to 5
298 | ; Colon-delimited string sets EMB timeout delay and initial button(s) disabled delay ("EMB:Button")
299 | ; Default = button(s) not disabled
300 | ; $hWin -> Handle of the GUI in which EMB is centred
301 | ; If GUI hidden or no handle passed - EMB centred in desktop (Default)
302 | ; If not valid window handle, interpreted as horizontal coordinate for EMB location
303 | ; $iVPos -> Vertical coordinate for EMB location
304 | ; Only valid if $hWin parameter interpreted as horizontal coordinate (Default = 0)
305 | ; $bMain -> True (default) = Adjust dialog position to ensure dialog positioned on main screen
306 | ; False = Dialog positioned at user-defined coords, which can be on other screens
307 | ; Requirement(s).: v3.2.12.1 or higher
308 | ; Return values .: Success: Returns 1-based index of the button pressed, counting from the LEFT.
309 | ; Returns 0 if closed by a "CloseGUI" event (i.e. click [X] or press Escape)
310 | ; Returns 9 if timed out
311 | ; If "Not again" checkbox is present and checked, return value is negated
312 | ; Failure: Returns -1 and sets @error as follows:
313 | ; 1 - Icon parameter error
314 | ; 2 - Multiple default button error
315 | ; 3 - Button constant error
316 | ; 4 - Too many buttons to fit in max available EMB width
317 | ; 5 - Button text too long for max available button width
318 | ; 6 - StringSize error
319 | ; 7 - GUI creation error
320 | ; Remarks .......; - If $bMain set EMB adjusted to appear on main screen closest to required position.
321 | ; - Setting a titlebar icon overrides any _ExtMsgBoxSet global setting - either "no-icon" or a specific file.
322 | ; - When buttons disabled, closure "X" still functions. Use $iStyle parameter of _ExtMsgBoxSet to prevent this.
323 | ; Author ........: Melba23, based on some original code by photonbuddy & YellowLab
324 | ; Example........; Yes
325 | ;=====================================================================================================================
326 | Func _ExtMsgBox($vIcon, $vButton, $sTitle, $sText, $vTimeOut = 0, $hWin = "", $iVPos = 0, $bMain = True)
327 |
328 | ; Set default sizes for message box
329 | Local $iMsg_Width_Max = $g_aEMB_Settings[6], $iMsg_Width_Min = 150, $iMsg_Width_Abs = $g_aEMB_Settings[7]
330 | Local $iMsg_Height_Min = 100, $iButton_Width_Def = 80, $iButton_Width_Min = 50, $iTimeOut = 0, $iTimeIn = 0
331 |
332 | ; Declare local variables
333 | Local $iParent_Win = 0, $fCountdown = False, $cCheckbox, $aLabel_Size, $aRet, $iRet_Value, $iHpos
334 | Local $sButton_Text, $iButton_Width, $iButton_Xpos
335 |
336 | ; Check for icon(s)
337 | Local $vTitlebar_Icon
338 | Local $iTitlebar_Icon_Style = 0
339 | Local $sTitlebar_DLL = ""
340 | Local $iIcon_Style = 0
341 | Local $iIcon_Reduction = 42
342 | Local $sDLL = "user32.dll"
343 | Local $sImg = ""
344 | Local $aSplit
345 |
346 | ; Validate timeout value
347 | $iTimeOut = Int($vTimeOut)
348 | ; If negative then increase timer font size if required
349 | If $iTimeOut < 0 Then
350 | $iTimeOut = Abs($iTimeOut)
351 | $iIcon_Reduction = 74
352 | EndIf
353 | ; Check for button disabling
354 | If StringInStr($vTimeOut, ":") Then
355 | $iTimeIn = Abs(Int(StringSplit($vTimeOut, ":")[2]))
356 | EndIf
357 | ; Set automatic timeout if no buttons and no timeout set
358 | If $vButton == " " And $iTimeOut = 0 Then
359 | $iTimeOut = 5
360 | EndIf
361 |
362 | ; Check icon parameter for titlebar icon data
363 | If StringInStr($vIcon, ";") Then
364 | ; Extract GUI icon data
365 | $aSplit = StringSplit($vIcon, ";")
366 | ; Keep display icon data
367 | $vIcon = $aSplit[1]
368 | ; Get required titlebar icon data
369 | $sTitlebar_DLL = $aSplit[2]
370 | ; Parse data
371 | If StringInStr($vTitlebar_Icon, "|") Then
372 | $iTitlebar_Icon_Style = StringRegExpReplace($sTitlebar_DLL, "(.*)\|", "")
373 | $sTitlebar_DLL = StringRegExpReplace($sTitlebar_DLL, "\|.*$", "")
374 | EndIf
375 | Else
376 | ; Use global setting if available
377 | $sTitlebar_DLL = $g_aEMB_Settings[14]
378 | EndIf
379 |
380 | ; Cancel numeric countdown if no timeout
381 | If $iTimeOut = 0 And $vIcon = 128 Then
382 | $vIcon = 0
383 | EndIf
384 |
385 | ; Get required display icon data
386 | If StringIsDigit($vIcon) Then
387 | Switch $vIcon
388 | Case 0
389 | $iIcon_Reduction = 0
390 | Case 8
391 | $sDLL = "imageres.dll"
392 | $iIcon_Style = 78
393 | Case 16 ; Stop
394 | $iIcon_Style = -4
395 | Case 32 ; Query
396 | $iIcon_Style = -3
397 | Case 48 ; Exclam
398 | $iIcon_Style = -2
399 | Case 64 ; Info
400 | $iIcon_Style = -5
401 | Case 128 ; Countdown
402 | If $iTimeOut > 0 Then
403 | $fCountdown = True
404 | EndIf
405 | Case Else
406 | Return SetError(1, 0, -1)
407 | EndSwitch
408 | Else
409 | If StringInStr($vIcon, "|") Then
410 | $iIcon_Style = StringRegExpReplace($vIcon, "(.*)\|", "")
411 | $vIcon = StringRegExpReplace($vIcon, "\|.*$", "")
412 | EndIf
413 | ; Parse data
414 | Switch StringLower(StringRight($vIcon, 3))
415 | Case "exe", "ico"
416 | $sDLL = $vIcon
417 | Case "bmp", "jpg", "gif", "png"
418 | $sImg = $vIcon
419 | EndSwitch
420 | EndIf
421 |
422 | ; Check if two buttons are seeking focus
423 | Local $sFocus_Char = $g_aEMB_Settings[13]
424 | StringReplace($vButton, $sFocus_Char, "")
425 | If @extended > 1 Then
426 | Return SetError(2, 0, -1)
427 | EndIf
428 |
429 | ; Check if using constants or text
430 | If IsNumber($vButton) Then
431 | Switch $vButton
432 | Case 0
433 | $vButton = "OK"
434 | Case 1
435 | $vButton = $sFocus_Char & "OK|Cancel"
436 | Case 2
437 | $vButton = $sFocus_Char & "Abort|Retry|Ignore"
438 | Case 3
439 | $vButton = $sFocus_Char & "Yes|No|Cancel"
440 | Case 4
441 | $vButton = $sFocus_Char & "Yes|No"
442 | Case 5
443 | $vButton = $sFocus_Char & "Retry|Cancel"
444 | Case 6
445 | $vButton = $sFocus_Char & "Cancel|Try Again|Continue"
446 | Case Else
447 | Return SetError(3, 0, -1)
448 | EndSwitch
449 | EndIf
450 |
451 | ; Set default values
452 | Local $aButton_Text[1] = [0]
453 | Local $iButton_Width_Req = 0
454 | ; Get required button size
455 | If $vButton <> " " Then
456 | ; Split button text into individual strings
457 | $aButton_Text = StringSplit($vButton, "|")
458 |
459 | ; Get absolute available width for each button
460 | Local $iButton_Width_Abs = Floor((($iMsg_Width_Max - 10) / $aButton_Text[0]) - 10)
461 | ; Error if below min button size
462 | If $iButton_Width_Abs < $iButton_Width_Min Then
463 | Return SetError(4, 0, -1)
464 | EndIf
465 | ; Determine required size of buttons to fit text
466 | Local $iButton_Width_Text = 0
467 | ; Loop through button text
468 | For $i = 1 To $aButton_Text[0]
469 | ; Remove a possible leading focus character
470 | $sButton_Text = StringRegExpReplace($aButton_Text[$i], "^" & $sFocus_Char & "?(.*)$", "$1")
471 | ; Check on font to use
472 | If BitAND($g_aEMB_Settings[0], 4) Then
473 | $aRet = _StringSize($sButton_Text, $g_aEMB_Settings[10], Default, Default, $g_aEMB_Settings[11])
474 | Else
475 | $aRet = _StringSize($sButton_Text, $g_aEMB_Settings[4], Default, Default, $g_aEMB_Settings[5])
476 | EndIf
477 | If IsArray($aRet) And $aRet[2] + 10 > $iButton_Width_Text Then
478 | ; Find max button width required for text
479 | $iButton_Width_Text = $aRet[2] + 10
480 | EndIf
481 | Next
482 | ; Error if text would make required button width > absolute available
483 | If $iButton_Width_Text > $iButton_Width_Abs Then
484 | Return SetError(5, 0, -1)
485 | EndIf
486 | ; Determine button size to use - assume default
487 | $iButton_Width = $iButton_Width_Def
488 | ; If text requires wider then default
489 | If $iButton_Width_Text > $iButton_Width_Def Then
490 | ; Increase - cannot be > absolute
491 | $iButton_Width = $iButton_Width_Text
492 | EndIf
493 | ; If absolute < default
494 | If $iButton_Width_Abs < $iButton_Width_Def Then
495 | ; If text > min (text must be < abs)
496 | If $iButton_Width_Text > $iButton_Width_Min Then
497 | ; Set text width
498 | $iButton_Width = $iButton_Width_Text
499 | Else
500 | ; Set min width
501 | $iButton_Width = $iButton_Width_Min
502 | EndIf
503 | EndIf
504 | ; Determine GUI width required for all buttons at this width
505 | $iButton_Width_Req = (($iButton_Width + 10) * $aButton_Text[0]) + 10
506 | EndIf
507 |
508 | ; Set tab expansion flag if required
509 | Local $iExpTab = Default
510 | If BitAND($g_aEMB_Settings[0], 8) Then
511 | $iExpTab = 1
512 | EndIf
513 |
514 | ; Get message label size
515 | While 1
516 | Local $aLabel_Pos = _StringSize($sText, $g_aEMB_Settings[4], Default, $iExpTab, $g_aEMB_Settings[5], $iMsg_Width_Max - 20 - $iIcon_Reduction)
517 | If @error Then
518 | If $iMsg_Width_Max >= $iMsg_Width_Abs Then
519 | Return SetError(6, 0, -1)
520 | Else
521 | $iMsg_Width_Max += 10
522 | EndIf
523 | Else
524 | ExitLoop
525 | EndIf
526 | WEnd
527 | ; Reset text to wrapped version
528 | $sText = $aLabel_Pos[0]
529 | ; Set label size
530 | Local $iLabel_Width = $aLabel_Pos[2]
531 | Local $iLabel_Height = $aLabel_Pos[3]
532 |
533 | ; Set GUI size
534 | Local $iMsg_Width = $iLabel_Width + 20 + $iIcon_Reduction
535 | ; Increase width to fit buttons if needed
536 | If $iButton_Width_Req > $iMsg_Width Then $iMsg_Width = $iButton_Width_Req
537 | If $iMsg_Width < $iMsg_Width_Min Then
538 | $iMsg_Width = $iMsg_Width_Min
539 | $iLabel_Width = $iMsg_Width_Min - 20
540 | EndIf
541 |
542 | ; Check if title sets width
543 | Local $iDialog_Width = $iMsg_Width
544 | ; Size title
545 | Local $aTitleSize = _StringSize($sTitle, $g_aEMB_Settings[10], Default, Default, $g_aEMB_Settings[11])
546 |
547 | ; Check if title wider than text
548 | If $aTitleSize[2] > ($iMsg_Width - 70) Then ; Assume icon reduction of 50 regardless of icon setting
549 | ; Adjust dialog width up to absolute dialog width value
550 | $iDialog_Width = ( ($aTitleSize[2] < ($g_aEMB_Settings[7] - $g_aEMB_Settings[12])) ? ($aTitleSize[2] + $g_aEMB_Settings[12]) : ($g_aEMB_Settings[7]) )
551 | EndIf
552 |
553 | Local $iMsg_Height = $iLabel_Height + 35
554 | ; Increase height if buttons present
555 | If $vButton <> " " Then
556 | $iMsg_Height += 30
557 | EndIf
558 | ; Increase height if checkbox required
559 | If BitAND($g_aEMB_Settings[0], 16) Then
560 | $iMsg_Height += 40
561 | EndIf
562 | If $iMsg_Height < $iMsg_Height_Min Then $iMsg_Height = $iMsg_Height_Min
563 |
564 | ; If only single line, lower label to to centre text on icon
565 | Local $iLabel_Vert = 20
566 | If StringInStr($sText, @CRLF) = 0 Then $iLabel_Vert = 27
567 |
568 | ; Check for taskbar button style required
569 | If Mod($g_aEMB_Settings[0], 2) = 1 Then ; Hide taskbar button so create as child
570 | If IsHWnd($hWin) Then
571 | $iParent_Win = $hWin ; Make child of that window
572 | Else
573 | $iParent_Win = WinGetHandle(AutoItWinGetTitle()) ; Make child of AutoIt window
574 | EndIf
575 | EndIf
576 |
577 | ; Determine EMB location
578 | If $hWin = "" Then
579 | ; No handle or position passed so centre on screen
580 | $iHpos = (@DesktopWidth - $iDialog_Width) / 2
581 | $iVPos = (@DesktopHeight - $iMsg_Height) / 2
582 | Else
583 | If IsHWnd($hWin) Then
584 | ; Get parent GUI pos if visible
585 | If BitAND(WinGetState($hWin), 2) Then
586 | ; Set EMB to centre on parent
587 | Local $aPos = WinGetPos($hWin)
588 | $iHpos = ($aPos[2] - $iDialog_Width) / 2 + $aPos[0] - 3
589 | $iVPos = ($aPos[3] - $iMsg_Height) / 2 + $aPos[1] - 20
590 | Else
591 | ; Set EMB to centre om screen
592 | $iHpos = (@DesktopWidth - $iDialog_Width) / 2
593 | $iVPos = (@DesktopHeight - $iMsg_Height) / 2
594 | EndIf
595 | Else
596 | ; Assume parameter is horizontal coord
597 | $iHpos = $hWin ; $iVpos already set
598 | EndIf
599 | EndIf
600 |
601 | ; If dialog is to appear on main display
602 | If $bMain Then
603 | ; Dialog is visible horizontally
604 | If $iHpos < 10 Then $iHpos = 10
605 | If $iHpos + $iDialog_Width > @DesktopWidth - 20 Then $iHpos = @DesktopWidth - 20 - $iDialog_Width
606 | ; Then vertically
607 | If $iVPos < 10 Then $iVPos = 10
608 | If $iVPos + $iMsg_Height > @DesktopHeight - 60 Then $iVPos = @DesktopHeight - 60 - $iMsg_Height
609 | EndIf
610 |
611 | ; Remove TOPMOST extended style if required
612 | Local $iExtStyle = 0x00000008 ; $WS_TOPMOST
613 | If BitAND($g_aEMB_Settings[0], 2) Then $iExtStyle = -1
614 |
615 | ; Create GUI with $WS_POPUPWINDOW, $WS_CAPTION style and required extended style
616 | Local $hMsgGUI = GUICreate($sTitle, $iDialog_Width, $iMsg_Height, $iHpos, $iVPos, BitOR(0x80880000, 0x00C00000), $iExtStyle, $iParent_Win)
617 | If @error Then
618 | Return SetError(7, 0, -1)
619 | EndIf
620 |
621 | ; Check if custom or no titlebar icon required
622 | Select
623 | ; Specific icon set
624 | Case $sTitlebar_DLL <> ""
625 | GUISetIcon($sTitlebar_DLL, $iTitlebar_Icon_Style)
626 | ; No icon - actually uses transparent icon from AutoIt executable
627 | Case BitAND($g_aEMB_Settings[0], 32)
628 | If @Compiled Then
629 | GUISetIcon(@ScriptName, -2, $hMsgGUI)
630 | Else
631 | GUISetIcon(@AutoItExe, -2, $hMsgGUI)
632 | EndIf
633 | ; In all other cases use standard Autoit icon
634 | EndSelect
635 |
636 | If $g_aEMB_Settings[2] <> Default Then GUISetBkColor($g_aEMB_Settings[2])
637 |
638 | ; Check if user closure permitted
639 | If BitAND($g_aEMB_Settings[0], 64) Then
640 | $aRet = DllCall("User32.dll", "hwnd", "GetSystemMenu", "hwnd", $hMsgGUI, "int", 0)
641 | Local $hSysMenu = $aRet[0]
642 | DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", 0xF060, "int", 0) ; $SC_CLOSE
643 | DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $hMsgGUI)
644 | EndIf
645 |
646 | ; Set centring parameter
647 | Local $iLabel_Style = 0 ; $SS_LEFT
648 | If BitAND($g_aEMB_Settings[1], 1) = 1 Then
649 | $iLabel_Style = 1 ; $SS_CENTER
650 | ElseIf BitAND($g_aEMB_Settings[1], 2) = 2 Then
651 | $iLabel_Style = 2 ; $SS_RIGHT
652 | EndIf
653 |
654 | ; Create label
655 | GUICtrlCreateLabel($sText, 10 + $iIcon_Reduction, $iLabel_Vert, $iLabel_Width, $iLabel_Height, $iLabel_Style)
656 | GUICtrlSetFont(-1, $g_aEMB_Settings[4], Default, Default, $g_aEMB_Settings[5])
657 | If $g_aEMB_Settings[3] <> Default Then GUICtrlSetColor(-1, $g_aEMB_Settings[3])
658 |
659 | ; Create checkbox if required
660 | If BitAND($g_aEMB_Settings[0], 16) Then
661 | Local $sAgain = " Do not show again"
662 | Local $iY = $iLabel_Vert + $iLabel_Height + 10
663 | ; Create checkbox
664 | $cCheckbox = GUICtrlCreateCheckbox("", 10 + $iIcon_Reduction, $iY, 20, 20)
665 | ; Write text in separate checkbox label
666 | Local $cCheckLabel = GUICtrlCreateLabel($sAgain, 20, 20, 20, 20)
667 | GUICtrlSetColor($cCheckLabel, $g_aEMB_Settings[3])
668 | GUICtrlSetBkColor($cCheckLabel, $g_aEMB_Settings[2])
669 | ; Set font if required and size checkbox label text
670 | If BitAND($g_aEMB_Settings[0], 4) Then
671 | $aLabel_Size = _StringSize($sAgain)
672 | Else
673 | $aLabel_Size = _StringSize($sAgain, $g_aEMB_Settings[4], 400, 0, $g_aEMB_Settings[5])
674 | GUICtrlSetFont($cCheckLabel, $g_aEMB_Settings[4], 400, 0, $g_aEMB_Settings[5])
675 | EndIf
676 | ; Move and resize checkbox label to fit
677 | $iY = ($iY + 10) - ($aLabel_Size[3] - 4) / 2
678 | ControlMove($hMsgGUI, "", $cCheckLabel, 30 + $iIcon_Reduction, $iY, $iMsg_Width - (30 + $iIcon_Reduction), $aLabel_Size[3])
679 | EndIf
680 |
681 | ; Create icon, image or countdown timer
682 | If $fCountdown = True Then
683 | Local $cCountdown_Label = GUICtrlCreateLabel(StringFormat("%2s", $iTimeOut), 10, 20, $iIcon_Reduction - 10, $iIcon_Reduction - 10)
684 | GUICtrlSetFont(-1, ($iIcon_Reduction > 42) ? (36) : (18), Default, Default, $g_aEMB_Settings[5])
685 | GUICtrlSetColor(-1, $g_aEMB_Settings[3])
686 | Else
687 | If $iIcon_Reduction Then
688 | Switch StringLower(StringRight($sImg, 3))
689 | Case "bmp", "jpg", "gif"
690 | GUICtrlCreatePic($sImg, 10, 20, 32, 32)
691 | Case "png"
692 | __EMB_ShowPNG($sImg)
693 | Case Else
694 | GUICtrlCreateIcon($sDLL, $iIcon_Style, 10, 20)
695 | EndSwitch
696 | EndIf
697 | EndIf
698 |
699 | ; Create buttons
700 | Local $aButtonCID[$aButton_Text[0] + 1] = [9999] ; Placeholder prevent problems if no buttons
701 | If $vButton <> " " Then
702 |
703 | ; Calculate button horizontal start
704 | If $aButton_Text[0] = 1 Then
705 | If BitAND($g_aEMB_Settings[1], 4) = 4 Then
706 | ; Single centred button
707 | $iButton_Xpos = ($iMsg_Width - $iButton_Width) / 2
708 | Else
709 | ; Single offset button
710 | $iButton_Xpos = $iMsg_Width - $iButton_Width - 10
711 | EndIf
712 | Else
713 | ; Multiple centred buttons
714 | $iButton_Xpos = ($iMsg_Width - ($iButton_Width_Req - 20)) / 2
715 | EndIf
716 |
717 | ; Set default button style
718 | Local $iDef_Button_Style = 0
719 | ; Work through button list
720 | For $i = 0 To $aButton_Text[0] - 1
721 | Local $iButton_Text = $aButton_Text[$i + 1]
722 | ; Set default button
723 | If $aButton_Text[0] = 1 Then ; Only 1 button
724 | $iDef_Button_Style = 0x0001
725 | ElseIf StringLeft($iButton_Text, 1) = $sFocus_Char Then ; Look for focus character
726 | $iDef_Button_Style = 0x0001
727 | $aButton_Text[$i + 1] = StringTrimLeft($iButton_Text, 1)
728 | EndIf
729 | ; Draw button
730 | $aButtonCID[$i + 1] = GUICtrlCreateButton($aButton_Text[$i + 1], $iButton_Xpos + ($i * ($iButton_Width + 10)), $iMsg_Height - 35, $iButton_Width, 25, $iDef_Button_Style)
731 | ; Set focus if default
732 | If $iDef_Button_Style Then
733 | GUICtrlSetState($aButtonCID[$i + 1], 256) ; $GUI_FOCUS
734 | EndIf
735 | ; Set font if required
736 | If Not BitAND($g_aEMB_Settings[0], 4) Then GUICtrlSetFont(-1, $g_aEMB_Settings[4], 400, 0, $g_aEMB_Settings[5])
737 | ; Reset default style parameter
738 | $iDef_Button_Style = 0
739 | ; Disable if required
740 | If $iTimeIn Then
741 | GUICtrlSetState($aButtonCID[$i + 1], 128) ; $GUI_DISABLE
742 | EndIf
743 | Next
744 | EndIf
745 |
746 | ; Show GUI
747 | GUISetState(@SW_SHOW, $hMsgGUI)
748 |
749 | ; Begin timeout counter
750 | Local $iTimeout_Begin = TimerInit()
751 | Local $iCounter = 0
752 |
753 | ; Declare GUIGetMsg return array here and not in loop
754 | Local $aMsg
755 |
756 | ; Set MessageLoop mode
757 | Local $iOrgMode = Opt('GUIOnEventMode', 0)
758 |
759 | While 1
760 | $aMsg = GUIGetMsg(1)
761 |
762 | If $aMsg[1] = $hMsgGUI Then
763 | Select
764 | Case $aMsg[0] = -3 ; $GUI_EVENT_CLOSE
765 | $iRet_Value = 0
766 | ExitLoop
767 | Case Else
768 | ; Check for other buttons
769 | For $i = 1 To UBound($aButtonCID) - 1
770 | If $aMsg[0] = $aButtonCID[$i] Then
771 | $iRet_Value = $i
772 | ; No point in looking further
773 | ExitLoop 2
774 | EndIf
775 | Next
776 | EndSelect
777 | EndIf
778 |
779 | ; Timeout if required
780 | If TimerDiff($iTimeout_Begin) / 1000 >= $iTimeOut And $iTimeOut > 0 Then
781 | $iRet_Value = 9
782 | ExitLoop
783 | EndIf
784 |
785 | ; Check for button TimeIn
786 | If $iTimeIn > 0 And TimerDiff($iTimeout_Begin) / 1000 >= $iTimeIn Then
787 | For $i = 1 To $aButton_Text[0]
788 | GUICtrlSetState($aButtonCID[$i], 64) ; $GUI_ENABLE
789 | Next
790 | $iTimeIn = 0
791 | EndIf
792 |
793 | ; Show countdown if required
794 | If $fCountdown = True Then
795 | Local $iTimeRun = Int(TimerDiff($iTimeout_Begin) / 1000)
796 | If $iTimeRun <> $iCounter Then
797 | $iCounter = $iTimeRun
798 | GUICtrlSetData($cCountdown_Label, StringFormat("%2s", $iTimeOut - $iCounter))
799 | EndIf
800 | EndIf
801 |
802 | WEnd
803 |
804 | ; Reset original mode
805 | Opt('GUIOnEventMode', $iOrgMode)
806 |
807 | If GUICtrlRead($cCheckbox) = 1 Then
808 | ; Negate the return value
809 | $iRet_Value *= -1
810 | EndIf
811 |
812 | GUIDelete($hMsgGUI)
813 |
814 | Return $iRet_Value
815 |
816 | EndFunc ;==>_ExtMsgBox
817 |
818 | ; #INTERNAL_USE_ONLY#============================================================================================================
819 | ; Name...........: _EMB_GetDefaultFont
820 | ; Description ...: Determines Windows default MsgBox font size and name
821 | ; Syntax.........: _EMB_GetDefaultFont()
822 | ; Return values .: Success - Array holding determined font data
823 | ; : Failure - Array holding default values
824 | ; Array elements - [0] = Size, [1] = Weight, [2] = Style, [3] = Name, [4] = Quality
825 | ; Author ........: KaFu
826 | ; Remarks .......: Used internally by ExtMsgBox UDF
827 | ; ===============================================================================================================================
828 | Func __EMB_GetDefaultFont()
829 |
830 | ; Fill array with standard default data
831 | Local $aDefFontData[2] = [9, "Tahoma"]
832 |
833 | ; Get AutoIt GUI handle
834 | Local $hWnd = WinGetHandle(AutoItWinGetTitle())
835 | ; Open Theme DLL
836 | Local $hThemeDLL = DllOpen("uxtheme.dll")
837 | ; Get default theme handle
838 | Local $hTheme = DllCall($hThemeDLL, 'ptr', 'OpenThemeData', 'hwnd', $hWnd, 'wstr', "Static")
839 | If @error Then Return $aDefFontData
840 | $hTheme = $hTheme[0]
841 | ; Create LOGFONT structure
842 | Local $tFont = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;wchar[32]")
843 | Local $pFont = DllStructGetPtr($tFont)
844 | ; Get MsgBox font from theme
845 | DllCall($hThemeDLL, 'long', 'GetThemeSysFont', 'HANDLE', $hTheme, 'int', 805, 'ptr', $pFont) ; TMT_MSGBOXFONT
846 | If @error Then Return $aDefFontData
847 | ; Get default DC
848 | Local $hDC = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd)
849 | If @error Then Return $aDefFontData
850 | $hDC = $hDC[0]
851 | ; Get font vertical size
852 | Local $iPixel_Y = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; LOGPIXELSY
853 | If Not @error Then
854 | $iPixel_Y = $iPixel_Y[0]
855 | $aDefFontData[0] = Int(2 * (.25 - DllStructGetData($tFont, 1) * 72 / $iPixel_Y)) / 2
856 | EndIf
857 | ; Close DC
858 | DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC)
859 | ; Extract font data from LOGFONT structure
860 | $aDefFontData[1] = DllStructGetData($tFont, 14)
861 |
862 | Return $aDefFontData
863 |
864 | EndFunc ;==>__EMB_GetDefaultFont
865 |
866 | ; #INTERNAL_USE_ONLY#=================================================================================================
867 | ; Name...........: __EMB_ShowPNG
868 | ; Description ...: Set PNG as image
869 | ; Author ........: UEZ
870 | ; Modified.......: Melba23, guinness
871 | ; Remarks .......:
872 | ; ====================================================================================================================
873 | Func __EMB_ShowPNG($sImg)
874 |
875 | _GDIPlus_Startup()
876 | Local $hPic = GUICtrlCreatePic("", 10, 20, 32, 32)
877 | Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sImg)
878 | Local $hBitmap_Resized = _GDIPlus_BitmapCreateFromScan0(32, 32)
879 | Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized)
880 | _GDIPlus_GraphicsSetInterpolationMode($hBMP_Ctxt, 7)
881 | _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, 32, 32)
882 | Local $hHBitmap = __EMB_BitmapCreateDIB($hBitmap_Resized)
883 | _WinAPI_DeleteObject(GUICtrlSendMsg($hPic, 0x0172, 0, $hHBitmap)) ; $STM_SETIMAGE
884 | _GDIPlus_BitmapDispose($hBitmap)
885 | _GDIPlus_BitmapDispose($hBitmap_Resized)
886 | _GDIPlus_GraphicsDispose($hBMP_Ctxt)
887 | _WinAPI_DeleteObject($hHBitmap)
888 | _GDIPlus_Shutdown()
889 |
890 | EndFunc ;==>__EMB_ShowPNG
891 |
892 | ; #INTERNAL_USE_ONLY#=================================================================================================
893 | ; Name...........: __EMB_BitmapCreateDIB
894 | ; Description ...: Create bitmap
895 | ; Author ........: UEZ
896 | ; Modified.......:
897 | ; Remarks .......:
898 | ; ====================================================================================================================
899 | Func __EMB_BitmapCreateDIB($hBitmap)
900 |
901 | Local $hRet = 0
902 |
903 | Local $aRet1 = DllCall($__g_hGDIPDll, "uint", "GdipGetImageDimension", "ptr", $hBitmap, "float*", 0, "float*", 0)
904 | If (@error) Or ($aRet1[0]) Then Return 0
905 | Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet1[2], $aRet1[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
906 | Local $pBits = DllStructGetData($tData, "Scan0")
907 | If Not $pBits Then Return 0
908 | Local $tBIHDR = DllStructCreate("dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword")
909 | DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR))
910 | DllStructSetData($tBIHDR, 2, $aRet1[2])
911 | DllStructSetData($tBIHDR, 3, $aRet1[3])
912 | DllStructSetData($tBIHDR, 4, 1)
913 | DllStructSetData($tBIHDR, 5, 32)
914 | DllStructSetData($tBIHDR, 6, 0)
915 | Local $aRet2 = DllCall("gdi32.dll", "ptr", "CreateDIBSection", "hwnd", 0, "ptr", DllStructGetPtr($tBIHDR), "uint", 0, "ptr*", 0, "ptr", 0, "dword", 0)
916 | If (Not @error) And ($aRet2[0]) Then
917 | DllCall("gdi32.dll", "dword", "SetBitmapBits", "ptr", $aRet2[0], "dword", $aRet1[2] * $aRet1[3] * 4, "ptr", DllStructGetData($tData, "Scan0"))
918 | $hRet = $aRet2[0]
919 | EndIf
920 | _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
921 | Return $hRet
922 | EndFunc ;==>__EMB_BitmapCreateDIB
923 |
--------------------------------------------------------------------------------
/includes/GUIComboBoxColor.au3:
--------------------------------------------------------------------------------
1 | ;~ #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
2 | ; #INDEX# =======================================================================================================================
3 | ; Title .........: GUIComboBoxFont
4 | ; AutoIt Version : 3.3.16.1
5 | ; Version .......: 0.0.2
6 | ; ===============================================================================================================================
7 | #include-once
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include "AutOnExit.au3"
15 | #include "GUIRegisterMsg20.au3"
16 |
17 | Global Enum _
18 | $CBOX_CTRL_COLORHWND, _
19 | $CBOX_CTRL_COLOREDITHWND, _
20 | $CBOX_CTRL_COLORLBHWND, _
21 | $CBOX_CTRL_COLORLBHWNDHBRUSH, _
22 | $CBOX_CTRL_COLOREDITHWNDHBRUSH, _
23 | $CBOX_CTRL_COLORLBTXTCOLOR, _
24 | $CBOX_CTRL_COLORLBBKCOLOR, _
25 | $CBOX_CTRL_COLOREDITTXTCOLOR, _
26 | $CBOX_CTRL_COLOREDITBKCOLOR, _
27 | $CBOX_CTRL_COLORENDENUM
28 |
29 | Global $CBOX_CTRL_COLORMAXDIM = 5
30 | Global $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORMAXDIM][$CBOX_CTRL_COLORENDENUM]
31 | Global $CBOX_CTRL_COLORENUM = 0
32 |
33 | ; #FUNCTION# ====================================================================================================================
34 | ; Name ..........: _GUICtrlComboBoxEx_SetColor
35 | ; Description ...: Set the background color/colour to the combobox
36 | ; Syntax ........: _GUICtrlComboBoxEx_SetColor($hWnd[, $iLBBkGrColor = Default[, $iLBTextColor = Default[,
37 | ; $iEditBkGrColor = Default[, $iEditTextColor = Default]]]])
38 | ; Parameters ....: $hWnd - The handle to the combobox control
39 | ; $iLBBkGrColor - Background color to the drop down listbox, default is system window color
40 | ; $iLBTextColor - Foreground/Font color to the drop down text, default is system window text color
41 | ; $iEditBkGrColor - Background color to the edit box (by the button), default is listbox back ground color
42 | ; $iEditTextColor - Foreground/Font color to the edit box (by the button), default is listbox text color
43 | ; Return values .: Success - Array:
44 | ; [0] = Hwnd to control/combobox
45 | ; [1] = Edit hwnd to control/combobox
46 | ; [2] = Listbox hwnd to control/combobox
47 | ; Failure - @error: 1 = Could not get combo info
48 | ; Author ........: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com)
49 | ; Modified ......:
50 | ; Links .........: GUIRegisterMsg20 subclassing by LarsJ
51 | ; https://www.autoitscript.com/forum/topic/195151-guiregistermsg20-subclassing-made-easy
52 | ; ComboBox Set DROPDOWNLIST Colors/size UDF by argumentum (has more options than just background coloring)
53 | ; with a different approach
54 | ; https://www.autoitscript.com/forum/topic/191035-combobox-set-dropdownlist-colorssize-udf/
55 | ; ===============================================================================================================================
56 | Func _GUICtrlComboBoxEx_SetColor($hWnd, $iLBBkGrColor = Default, $iLBTextColor = Default, $iEditBkGrColor = Default, $iEditTextColor = Default)
57 |
58 | If Not IsHWnd($hWnd) Then
59 | $hWnd = IsInt($hWnd) ? GUICtrlGetHandle($hWnd) : HWnd($hWnd)
60 | $hWnd = IsInt($hWnd) ? GUICtrlGetHandle($hWnd) : HWnd($hWnd)
61 | EndIf
62 |
63 | $iLBBkGrColor = ($iLBBkGrColor = Default Or $iLBBkGrColor == -1) ? _
64 | _WinAPI_GetSysColor($COLOR_WINDOW) : __GUICtrlComboBoxEx_ColorShiftBits($iLBBkGrColor)
65 | $iLBTextColor = ($iLBTextColor = Default Or $iLBTextColor == -1) ? _
66 | _WinAPI_GetSysColor($COLOR_WINDOWTEXT) : __GUICtrlComboBoxEx_ColorShiftBits($iLBTextColor)
67 | $iEditBkGrColor = ($iEditBkGrColor = Default Or $iEditBkGrColor == -1) ? _
68 | $iLBBkGrColor : __GUICtrlComboBoxEx_ColorShiftBits($iEditBkGrColor)
69 | $iEditTextColor = ($iEditTextColor = Default Or $iEditTextColor == -1) ? _
70 | $iLBTextColor : __GUICtrlComboBoxEx_ColorShiftBits($iEditTextColor)
71 |
72 |
73 | Local $tInfo
74 | If Not _GUICtrlComboBox_GetComboBoxInfo($hWnd, $tInfo) Then
75 | Return SetError(1, 0, 0)
76 | EndIf
77 |
78 | Local $hEdit = HWnd(DllStructGetData($tInfo, "hEdit"))
79 | Local $hLBox = HWnd(DllStructGetData($tInfo, "hList"))
80 | Local $hLBBrush = _WinAPI_CreateSolidBrush($iLBBkGrColor)
81 | Local $hEditBrush = _WinAPI_CreateSolidBrush($iEditBkGrColor)
82 |
83 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLORHWND] = $hWnd
84 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLOREDITHWND] = $hEdit
85 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLORLBHWND] = $hLBox
86 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLORLBHWNDHBRUSH] = $hLBBrush
87 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLOREDITHWNDHBRUSH] = $hEditBrush
88 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLORLBTXTCOLOR] = $iLBTextColor
89 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLORLBBKCOLOR] = $iLBBkGrColor
90 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLOREDITTXTCOLOR] = $iEditTextColor
91 | $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLOREDITBKCOLOR] = $iEditBkGrColor
92 |
93 | ; clean up func when script exits
94 | _AutOnExit_AddFunc(_WinAPI_DeleteObject, $hLBBrush)
95 | _AutOnExit_AddFunc(_WinAPI_DeleteObject, $hEditBrush)
96 |
97 | $CBOX_CTRL_COLORENUM += 1
98 | If Mod($CBOX_CTRL_COLORENUM, $CBOX_CTRL_COLORMAXDIM) = 0 Then
99 | ReDim $CBOX_CTRL_COLORARRAY[$CBOX_CTRL_COLORMAXDIM + $CBOX_CTRL_COLORENUM][$CBOX_CTRL_COLORENDENUM]
100 | EndIf
101 |
102 | GUIRegisterMsg20($hWnd, $WM_CTLCOLORLISTBOX, __GUICtrlComboBoxEx_SubClass_CtrlColor)
103 | GUIRegisterMsg20($hWnd, $WM_CTLCOLOREDIT, __GUICtrlComboBoxEx_SubClass_CtrlColor)
104 |
105 | _SendMessage($hWnd, $WM_CTLCOLORLISTBOX, _WinAPI_GetDC($hLBox), $hLBox)
106 | _SendMessage($hWnd, $WM_CTLCOLOREDIT, _WinAPI_GetDC($hEdit), $hEdit)
107 |
108 | Local $aRet[3] = [$hWnd,$hEdit,$hLBox]
109 | Return SetExtended(1, $aRet)
110 | EndFunc
111 |
112 | ; #INTERNAL_USE_ONLY# ===========================================================================================================
113 | ; Name ..........: __GUICtrlComboBoxEx_SubClass_CtrlColor
114 | ; Description ...: Internal function used to paint the combobox, cannot (should not) be called
115 | ; ===============================================================================================================================
116 | Func __GUICtrlComboBoxEx_SubClass_CtrlColor($hWnd, $iMsg, $wParam, $lParam)
117 | #forceref $hWnd, $iMsg, $wParam, $lParam
118 |
119 | Local $iIndex = $CBOX_CTRL_COLORENUM
120 | Local $aCombo = $CBOX_CTRL_COLORARRAY
121 |
122 | Switch ($iMsg)
123 | Case $WM_CTLCOLORLISTBOX
124 | For $i = 0 To $iIndex - 1
125 | If ($aCombo[$i][$CBOX_CTRL_COLORLBHWND] == HWnd($lParam)) Then
126 | _WinAPI_SetTextColor($wParam, $aCombo[$i][$CBOX_CTRL_COLORLBTXTCOLOR])
127 | _WinAPI_SetBkColor($wParam, $aCombo[$i][$CBOX_CTRL_COLORLBBKCOLOR])
128 | Return $aCombo[$i][$CBOX_CTRL_COLORLBHWNDHBRUSH]
129 | EndIf
130 | Next
131 | Case $WM_CTLCOLOREDIT
132 | For $i = 0 To $iIndex - 1
133 | If ($aCombo[$i][$CBOX_CTRL_COLOREDITHWND] == HWnd($lParam)) Then
134 | _WinAPI_SetTextColor($wParam, $aCombo[$i][$CBOX_CTRL_COLOREDITTXTCOLOR])
135 | _WinAPI_SetBkColor($wParam, $aCombo[$i][$CBOX_CTRL_COLOREDITBKCOLOR])
136 | Return $aCombo[$i][$CBOX_CTRL_COLOREDITHWNDHBRUSH]
137 | EndIf
138 | Next
139 | EndSwitch
140 |
141 | Return $GUI_RUNDEFMSG
142 | EndFunc
143 |
144 | ; #INTERNAL_USE_ONLY# ===========================================================================================================
145 | ; Name ..........: __GUICtrlComboBoxEx_ColorShiftBits
146 | ; Description ...: Internal function used swap the color bits
147 | ; ===============================================================================================================================
148 | Func __GUICtrlComboBoxEx_ColorShiftBits($iColor)
149 | Return BitOR(BitAND($iColor, 0x00FF00), _
150 | BitShift(BitAND($iColor, 0x0000FF), -16), _
151 | BitShift(BitAND($iColor, 0xFF0000), 16))
152 | EndFunc
--------------------------------------------------------------------------------
/includes/GUIComboBoxFont.au3:
--------------------------------------------------------------------------------
1 | ;~ #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
2 | ; #INDEX# =======================================================================================================================
3 | ; Title .........: GUIComboBoxFont
4 | ; AutoIt Version : 3.3.16.1
5 | ; Version .......: 0.0.1
6 | ; ===============================================================================================================================
7 | #include-once
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include "AutOnExit.au3"
17 |
18 | ; #CURRENT# =====================================================================================================================
19 | ; _GUICtrlComboBoxEx_SetFont
20 | ; _GUICtrlComboBoxEx_SetControlFont
21 | ; _GUICtrlComboBoxEx_SetEditFont
22 | ; _GUICtrlComboBoxEx_SetLBFont
23 | ; ===============================================================================================================================
24 |
25 | ; #FUNCTION# ====================================================================================================================
26 | ; Name ..........: _GUICtrlComboBoxEx_SetFont
27 | ; Description ...: Set font data for all 3 hwnds (control/edit/listbox)
28 | ; Syntax ........: _GUICtrlComboBoxEx_SetFont($hWnd[, $iSize = Default[, $iWeight = Default[, $iAttribute = Default[,
29 | ; $sFont = Default[, $iQuality = Default[, $iCharSet = Default[, $iOutputPrec = Default[, $iClipPrec = Default[,
30 | ; $iPitch = Default]]]]]]]]])
31 | ; Parameters ....: $hWnd - The combobox's hwnd (or ctrlid if using standard functions (not really tested)
32 | ; The below values can all be found in either GUICtrlSetFont or _WinAPI_CreateFont
33 | ; $iSize - Size/Height of font. Default is 8.5.
34 | ; $iWeight - The weight of the font in the range 0 through 1000. Default is $FW_DONTCARE.
35 | ; $iAttribute - Font attributes, which can be a combination. Default is D$GUI_FONTNORMAL.
36 | ; $sFont - Name of the font to use. (OS default GUI font is used if the font is "" or is not found)
37 | ; $iQuality - Font quality to select. Default is $DEFAULT_QUALITY.
38 | ; $iCharSet - Specifies the character set. Default is $DEFAULT_CHARSET.
39 | ; $iOutputPrec - Specifies the output precision. Default is $OUT_DEFAULT_PRECIS.
40 | ; $iClipPrec - Specifies the clipping precision. Default is $CLIP_DEFAULT_PRECIS.
41 | ; $iPitch - Specifies the pitch and family of the font. Default is $FF_DONTCARE.
42 | ; Return values .: Success - Font Array [0] = ComboBox font handle
43 | ; [1] = Edit font handle
44 | ; [2] = ListBox font handle
45 | ; Author ........: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com)
46 | ; Modified ......:
47 | ; ===============================================================================================================================
48 | Func _GUICtrlComboBoxEx_SetFont($hWnd, $iSize = Default, $iWeight = Default, $iAttribute = Default, $sFont = Default, _
49 | $iQuality = Default, $iCharSet = Default, $iOutputPrec = Default, $iClipPrec = Default, $iPitch = Default)
50 |
51 | If Not IsHWnd($hWnd) Then $hWnd = IsInt($hWnd) ? GUICtrlGetHandle($hWnd) : HWnd($hWnd)
52 |
53 | Local $tInfo
54 | If Not _GUICtrlComboBox_GetComboBoxInfo($hWnd, $tInfo) Then
55 | Return SetError(1, 0, 0)
56 | EndIf
57 |
58 | Local $hEdit = HWnd(DllStructGetData($tInfo, "hEdit"))
59 | Local $hLBox = HWnd(DllStructGetData($tInfo, "hList"))
60 |
61 | Local $aFont[3]
62 | $aFont[0] = __GUICtrlComboBoxEx_SetFontDefault($hWnd, $iSize, $iWeight, $iAttribute, $sFont, $iQuality, $iCharSet, $iOutputPrec, $iClipPrec, $iPitch)
63 | $aFont[1] = __GUICtrlComboBoxEx_SetFontDefault($hEdit, $iSize, $iWeight, $iAttribute, $sFont, $iQuality, $iCharSet, $iOutputPrec, $iClipPrec, $iPitch)
64 | $aFont[2] = __GUICtrlComboBoxEx_SetFontDefault($hLBox, $iSize, $iWeight, $iAttribute, $sFont, $iQuality, $iCharSet, $iOutputPrec, $iClipPrec, $iPitch)
65 |
66 | Return $aFont
67 | EndFunc
68 |
69 | ; #FUNCTION# ====================================================================================================================
70 | ; Name ..........: _GUICtrlComboBoxEx_SetControlFont
71 | ; Description ...:
72 | ; Syntax ........: _GUICtrlComboBoxEx_SetControlFont($hWnd[, $iSize = Default[, $iWeight = Default[, $iAttribute = Default[,
73 | ; $sFont = Default[, $iQuality = Default[, $iCharSet = Default[, $iOutputPrec = Default[, $iClipPrec = Default[,
74 | ; $iPitch = Default]]]]]]]]])
75 | ; Parameters ....: $hWnd - The combobox's hwnd (or ctrlid if using standard functions (not really tested)
76 | ; The below values can all be found in either GUICtrlSetFont or _WinAPI_CreateFont
77 | ; $iSize - Size/Height of font. Default is 8.5.
78 | ; $iWeight - The weight of the font in the range 0 through 1000. Default is $FW_DONTCARE.
79 | ; $iAttribute - Font attributes, which can be a combination. Default is D$GUI_FONTNORMAL.
80 | ; $sFont - Name of the font to use. (OS default GUI font is used if the font is "" or is not found)
81 | ; $iQuality - Font quality to select. Default is $DEFAULT_QUALITY.
82 | ; $iCharSet - Specifies the character set. Default is $DEFAULT_CHARSET.
83 | ; $iOutputPrec - Specifies the output precision. Default is $OUT_DEFAULT_PRECIS.
84 | ; $iClipPrec - Specifies the clipping precision. Default is $CLIP_DEFAULT_PRECIS.
85 | ; $iPitch - Specifies the pitch and family of the font. Default is $FF_DONTCARE.
86 | ; Return values .: Success - ComboBox font handle
87 | ; Author ........: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com)
88 | ; Modified ......:
89 | ; ===============================================================================================================================
90 | Func _GUICtrlComboBoxEx_SetControlFont($hWnd, $iSize = Default, $iWeight = Default, $iAttribute = Default, $sFont = Default, _
91 | $iQuality = Default, $iCharSet = Default, $iOutputPrec = Default, $iClipPrec = Default, $iPitch = Default)
92 |
93 | If Not IsHWnd($hWnd) Then $hWnd = IsInt($hWnd) ? GUICtrlGetHandle($hWnd) : HWnd($hWnd)
94 |
95 | Local $sHWNDType = _WinAPI_GetClassName($hWnd)
96 |
97 | If $sHWNDType <> "ComboBox" Then
98 | Return SetError(1, 0, $sHWNDType)
99 | EndIf
100 |
101 | Return __GUICtrlComboBoxEx_SetFontDefault($hWnd, $iSize, $iWeight, $iAttribute, $sFont, $iQuality, $iCharSet, $iOutputPrec, $iClipPrec, $iPitch)
102 | EndFunc
103 |
104 | ; #FUNCTION# ====================================================================================================================
105 | ; Name ..........: _GUICtrlComboBoxEx_SetEditFont
106 | ; Description ...:
107 | ; Syntax ........: _GUICtrlComboBoxEx_SetEditFont($hWnd[, $iSize = Default[, $iWeight = Default[, $iAttribute = Default[,
108 | ; $sFont = Default[, $iQuality = Default[, $iCharSet = Default[, $iOutputPrec = Default[, $iClipPrec = Default[,
109 | ; $iPitch = Default]]]]]]]]])
110 | ; Parameters ....: $hWnd - The combobox's hwnd (or ctrlid if using standard functions (not really tested)
111 | ; The below values can all be found in either GUICtrlSetFont or _WinAPI_CreateFont
112 | ; $iSize - Size/Height of font. Default is 8.5.
113 | ; $iWeight - The weight of the font in the range 0 through 1000. Default is $FW_DONTCARE.
114 | ; $iAttribute - Font attributes, which can be a combination. Default is D$GUI_FONTNORMAL.
115 | ; $sFont - Name of the font to use. (OS default GUI font is used if the font is "" or is not found)
116 | ; $iQuality - Font quality to select. Default is $DEFAULT_QUALITY.
117 | ; $iCharSet - Specifies the character set. Default is $DEFAULT_CHARSET.
118 | ; $iOutputPrec - Specifies the output precision. Default is $OUT_DEFAULT_PRECIS.
119 | ; $iClipPrec - Specifies the clipping precision. Default is $CLIP_DEFAULT_PRECIS.
120 | ; $iPitch - Specifies the pitch and family of the font. Default is $FF_DONTCARE.
121 | ; Return values .: Success - Combobox Edit font handle
122 | ; Author ........: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com)
123 | ; Modified ......:
124 | ; ===============================================================================================================================
125 | Func _GUICtrlComboBoxEx_SetEditFont($hWnd, $iSize = Default, $iWeight = Default, $iAttribute = Default, $sFont = Default, _
126 | $iQuality = Default, $iCharSet = Default, $iOutputPrec = Default, $iClipPrec = Default, $iPitch = Default)
127 |
128 | If Not IsHWnd($hWnd) Then $hWnd = IsInt($hWnd) ? GUICtrlGetHandle($hWnd) : HWnd($hWnd)
129 |
130 | Local $sHWNDType = _WinAPI_GetClassName($hWnd)
131 |
132 | If $sHWNDType <> "Edit" Then
133 | Return SetError(1, 0, $sHWNDType)
134 | EndIf
135 |
136 | Return __GUICtrlComboBoxEx_SetFontDefault($hWnd, $iSize, $iWeight, $iAttribute, $sFont, $iQuality, $iCharSet, $iOutputPrec, $iClipPrec, $iPitch)
137 | EndFunc
138 |
139 | ; #FUNCTION# ====================================================================================================================
140 | ; Name ..........: _GUICtrlComboBoxEx_SetLBFont
141 | ; Description ...:
142 | ; Syntax ........: _GUICtrlComboBoxEx_SetLBFont($hWnd[, $iSize = Default[, $iWeight = Default[, $iAttribute = Default[,
143 | ; $sFont = Default[, $iQuality = Default[, $iCharSet = Default[, $iOutputPrec = Default[, $iClipPrec = Default[,
144 | ; $iPitch = Default]]]]]]]]])
145 | ; Parameters ....: $hWnd - The combobox's hwnd (or ctrlid if using standard functions (not really tested)
146 | ; The below values can all be found in either GUICtrlSetFont or _WinAPI_CreateFont
147 | ; $iSize - Size/Height of font. Default is 8.5.
148 | ; $iWeight - The weight of the font in the range 0 through 1000. Default is $FW_DONTCARE.
149 | ; $iAttribute - Font attributes, which can be a combination. Default is D$GUI_FONTNORMAL.
150 | ; $sFont - Name of the font to use. (OS default GUI font is used if the font is "" or is not found)
151 | ; $iQuality - Font quality to select. Default is $DEFAULT_QUALITY.
152 | ; $iCharSet - Specifies the character set. Default is $DEFAULT_CHARSET.
153 | ; $iOutputPrec - Specifies the output precision. Default is $OUT_DEFAULT_PRECIS.
154 | ; $iClipPrec - Specifies the clipping precision. Default is $CLIP_DEFAULT_PRECIS.
155 | ; $iPitch - Specifies the pitch and family of the font. Default is $FF_DONTCARE.
156 | ; Return values .: Success - ComboBox Listbox font handle
157 | ; Author ........: SmOke_N (Ron Nielsen.. Ron.SMACKThatApp@GMail.com)
158 | ; Modified ......:
159 | ; ===============================================================================================================================
160 | Func _GUICtrlComboBoxEx_SetLBFont($hWnd, $iSize = Default, $iWeight = Default, $iAttribute = Default, $sFont = Default, _
161 | $iQuality = Default, $iCharSet = Default, $iOutputPrec = Default, $iClipPrec = Default, $iPitch = Default)
162 |
163 | If Not IsHWnd($hWnd) Then $hWnd = IsInt($hWnd) ? GUICtrlGetHandle($hWnd) : HWnd($hWnd)
164 |
165 | Local $sHWNDType = _WinAPI_GetClassName($hWnd)
166 |
167 | If $sHWNDType <> "ComboLBox" Then
168 | Return SetError(1, 0, $sHWNDType)
169 | EndIf
170 |
171 | Return __GUICtrlComboBoxEx_SetFontDefault($hWnd, $iSize, $iWeight, $iAttribute, $sFont, $iQuality, $iCharSet, $iOutputPrec, $iClipPrec, $iPitch)
172 |
173 | EndFunc
174 |
175 | ; #INTERNAL_USE_ONLY# ===========================================================================================================
176 | ; Name ..........: __GUICtrlComboBoxEx_SubClass_CtrlColor
177 | ; Description ...: Internal function used to paint the combobox, cannot (should not) be called
178 | ; Remarks .......: This really is the bread and butter function, it's actually a stand-alone that should
179 | ; be able to work on most standard or non-standard gui funcs, I just found it easier to implement
180 | ; this way with the combobox because the 3 different hwnds
181 | ; ===============================================================================================================================
182 | Func __GUICtrlComboBoxEx_SetFontDefault($hWnd, $iSize = Default, $iWeight = Default, $iAttribute = Default, $sFont = Default, _
183 | $iQuality = Default, $iCharSet = Default, $iOutputPrec = Default, $iClipPrec = Default, $iPitch = Default)
184 |
185 | If Not IsHWnd($hWnd) Then $hWnd = IsInt($hWnd) ? GUICtrlGetHandle($hWnd) : HWnd($hWnd)
186 |
187 | $iSize = ($iSize = Default Or $iSize == -1) ? 8.5 : $iSize
188 | $iWeight = ($iWeight = Default Or $iWeight == -1) ? $FW_DONTCARE : $iWeight
189 | $iAttribute = ($iAttribute = Default Or $iWeight == -1) ? $GUI_FONTNORMAL : $iAttribute
190 | $sFont = ($sFont = Default Or $sFont == -1) ? $DEFAULT_GUI_FONT : $sFont
191 | $iQuality = ($iQuality = Default Or $iQuality == -1) ? $DEFAULT_QUALITY : $iQuality
192 | $iCharSet = ($iCharSet = Default Or $iCharSet == -1) ? $DEFAULT_CHARSET : $iCharSet
193 | $iOutputPrec = ($iOutputPrec = Default Or $iOutputPrec == -1) ? $OUT_DEFAULT_PRECIS : $iOutputPrec
194 | $iClipPrec = ($iClipPrec = Default Or $iClipPrec == -1) ? $CLIP_DEFAULT_PRECIS : $iClipPrec
195 | $iPitch = ($iPitch = Default Or $iPitch == -1) ? $FF_DONTCARE : $iPitch
196 |
197 | Local $bItalic = (BitAND($iAttribute, $GUI_FONTITALIC) <> 0)
198 | Local $bUnderlined = (BitAND($iAttribute, $GUI_FONTUNDER) <> 0)
199 | Local $bStrike = (BitAND($iAttribute, $GUI_FONTSTRIKE) <> 0)
200 |
201 | Local $hDC = _WinAPI_GetDC($hWnd)
202 | Local $iGDC = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY)
203 | $iSize = -1 * _WinAPI_MulDiv($iSize, $iGDC, 72)
204 | _WinAPI_ReleaseDC($hWnd, $hDC)
205 |
206 | Local $hFont = _WinAPI_CreateFont($iSize, 0, 0, 0, $iWeight, $bItalic, $bUnderlined, $bStrike, $iCharSet, _
207 | $iOutputPrec, $iClipPrec, $iQuality, $iPitch, $sFont)
208 |
209 | _WinAPI_SetFont($hWnd, $hFont, True)
210 |
211 | _AutOnExit_AddFunc(_WinAPI_DeleteObject, $hFont)
212 |
213 | Return $hFont
214 | EndFunc
--------------------------------------------------------------------------------
/includes/GUIRegisterMsg20.au3:
--------------------------------------------------------------------------------
1 |
2 | ; GUIRegisterMsg20 - Subclassing Made Easy
3 |
4 | #include-once
5 |
6 | Global $aGUIRegisterMsg20[51][5]
7 |
8 | ; Register a message handler function for a window or control message
9 | ; GUIRegisterMsg20( $vWinOrCtrl, _ ; Window handle or control ID/handle
10 | ; $WM_MESSAGE, _ ; Window message or control message
11 | ; $hFunction ) ; User supplied message handler func
12 | ;
13 | ; $vWinOrCtrl GUI handle as returned by GUICreate, controlID as returned by GUICtrlCreate functions
14 | ; or control handle as returned by _GUICtrl_Create UDF functions or GUICtrlGetHandle.
15 | ;
16 | ; $WM_MESSAGE A Windows message code as listed in Appendix section in help file. Or a control message code
17 | ; eg. a LVM_MESSAGE or TVM_MESSAGE as listed in ListViewConstants.au3 or TreeViewConstants.au3.
18 | ; This parameter is only checked to be within the valid range of Windows and control messages:
19 | ; 0x0000 - 0x7FFF.
20 | ;
21 | ; $hFunction The user supplied function (not the name but the FUNCTION) to call when the message appears.
22 | ; The function is defined in exactly the same way as the function for the official GUIRegisterMsg:
23 | ; Takes four input parameters ($hWnd, $iMsg, $wParam, $lParam) and returns $GUI_RUNDEFMSG to conti-
24 | ; nue with default message handling, or a specific value if the message is handled by the function.
25 | ;
26 | ; Error code in @error Return value
27 | ; 1 => Invalid window handle or control ID/handle Success => 1
28 | ; 2 => Invalid Window or control message Failure => 0
29 | ; 3 => Invalid function handle
30 | ; 4 => Too many subclasses
31 | ;
32 | Func GUIRegisterMsg20( $vWinOrCtrl, $WM_MESSAGE, $hFunction )
33 | ; Check $vWinOrCtrl
34 | Local $hWndHandle = $vWinOrCtrl
35 | If Not IsHWnd( $hWndHandle ) Then $hWndHandle = GUICtrlGetHandle( $hWndHandle )
36 | If Not IsHWnd( $hWndHandle ) Then Return SetError( 1, 0, 0 )
37 |
38 | ; Check $WM_MESSAGE
39 | If Not ( $WM_MESSAGE >= 0 And $WM_MESSAGE <= 32767 ) Then Return SetError( 2, 0, 0 )
40 |
41 | ; Check $hFunction
42 | If Not IsFunc( $hFunction ) Then Return SetError( 3, 0, 0 )
43 |
44 | ; Check existing subclass
45 | If $aGUIRegisterMsg20[0][0] Then
46 | For $i = 1 To $aGUIRegisterMsg20[0][1]
47 | If Not $aGUIRegisterMsg20[$i][0] Then ContinueLoop
48 | If ( $aGUIRegisterMsg20[$i][1] = $vWinOrCtrl Or $aGUIRegisterMsg20[$i][2] = $vWinOrCtrl ) And _
49 | $aGUIRegisterMsg20[$i][3] = $WM_MESSAGE And $aGUIRegisterMsg20[$i][4] = $hFunction Then Return 1 ; Existing subclass, return without error
50 | Next
51 | EndIf
52 |
53 | ; Too many subclasses?
54 | If $aGUIRegisterMsg20[0][0] = $aGUIRegisterMsg20[0][1] Then Return SetError( 4, 0, 0 )
55 |
56 | ; Register new subclass
57 | For $i = 1 To $aGUIRegisterMsg20[0][1]
58 | If Not $aGUIRegisterMsg20[$i][0] Then ExitLoop
59 | Next
60 | $aGUIRegisterMsg20[0][0] += 1
61 | $aGUIRegisterMsg20[$i][0] = $i
62 | $aGUIRegisterMsg20[$i][1] = $vWinOrCtrl
63 | $aGUIRegisterMsg20[$i][2] = $hWndHandle
64 | $aGUIRegisterMsg20[$i][3] = $WM_MESSAGE
65 | $aGUIRegisterMsg20[$i][4] = $hFunction
66 | If Not $aGUIRegisterMsg20[0][2] Then $aGUIRegisterMsg20[0][2] = DllCallbackGetPtr( DllCallbackRegister( "GUIRegisterMsg20_Handler", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) )
67 | DllCall( "comctl32.dll", "bool", "SetWindowSubclass", "hwnd", $hWndHandle, "ptr", $aGUIRegisterMsg20[0][2], "uint_ptr", $i, "dword_ptr", 0 ) ; $iSubclassId = $i, $pData = 0
68 |
69 | Return 1
70 | EndFunc
71 |
72 | ; Unregister a message handler function for a window or control message
73 | ; GUIUnRegisterMsg20( $vWinOrCtrl, _ ; Window handle or control ID/handle
74 | ; $WM_MESSAGE, _ ; Window message or control message
75 | ; $hFunction ) ; User supplied message handler func
76 | ;
77 | ; Error code in @error Return value
78 | ; 1 => Invalid window handle or control ID/handle Success => 1
79 | ; 2 => Invalid Window or control message Failure => 0
80 | ; 3 => Invalid function handle
81 | ; 5 => Subclass not found
82 | ;
83 | Func GUIUnRegisterMsg20( $vWinOrCtrl, $WM_MESSAGE, $hFunction )
84 | ; Check $vWinOrCtrl
85 | Local $hWndHandle = $vWinOrCtrl
86 | If Not IsHWnd( $hWndHandle ) Then $hWndHandle = GUICtrlGetHandle( $hWndHandle )
87 | If Not IsHWnd( $hWndHandle ) Then Return SetError( 1, 0, 0 )
88 |
89 | ; Check $WM_MESSAGE
90 | If Not ( $WM_MESSAGE >= 0 And $WM_MESSAGE <= 32767 ) Then Return SetError( 2, 0, 0 )
91 |
92 | ; Check $hFunction
93 | If Not IsFunc( $hFunction ) Then Return SetError( 3, 0, 0 )
94 |
95 | ; Find existing subclass
96 | If Not $aGUIRegisterMsg20[0][0] Then Return 1
97 | For $i = 1 To $aGUIRegisterMsg20[0][1]
98 | If Not $aGUIRegisterMsg20[$i][0] Then ContinueLoop
99 | If ( $aGUIRegisterMsg20[$i][1] = $vWinOrCtrl Or $aGUIRegisterMsg20[$i][2] = $vWinOrCtrl ) And _
100 | $aGUIRegisterMsg20[$i][3] = $WM_MESSAGE And $aGUIRegisterMsg20[$i][4] = $hFunction Then ExitLoop
101 | Next
102 | If $i = $aGUIRegisterMsg20[0][1] + 1 Then Return SetError( 5, 0, 0 )
103 |
104 | ; Remove subclass
105 | $aGUIRegisterMsg20[0][0] -= 1
106 | $aGUIRegisterMsg20[$i][0] = 0
107 | DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $vWinOrCtrl, "ptr", $aGUIRegisterMsg20[0][2], "uint_ptr", $i ) ; $iSubclassId = $i
108 |
109 | Return 1
110 | EndFunc
111 |
112 |
113 | ; ##############################################################################
114 | ; # #
115 | ; # --- Internal global array and internal functions --- #
116 | ; # #
117 | ; ##############################################################################
118 |
119 | ; Global $aGUIRegisterMsg20[51][5] ; Internal global array
120 |
121 | ; Column information for row 0
122 | ; --------------------------------------------------------------------
123 | $aGUIRegisterMsg20[0][0] = 0 ; Number of registered subclasses
124 | $aGUIRegisterMsg20[0][1] = 50 ; Max. number of registered subclasses
125 | ; $aGUIRegisterMsg20[0][2] ; Subclass callback function
126 |
127 | ; Room for 50 registered subclasses in rows 1 - 50
128 |
129 | ; Column information for other rows
130 | ; ------------------------------------------------------
131 | ; 0 Row index Index in $aGUIRegisterMsg20 array
132 | ; 1 $vWinOrCtrl Window handle or control ID/handle
133 | ; 2 $hWndHandle Control ID converted into a HWND
134 | ; 3 $WM_MESSAGE Window message or control message
135 | ; 4 $hFunction User supplied message handler func
136 |
137 | ; Remove all subclasses on exit
138 | OnAutoItExitRegister( "GUIRegisterMsg20_Exit" )
139 |
140 | Func GUIRegisterMsg20_Handler( $hWnd, $iMsg, $wParam, $lParam, $idx, $pData )
141 | If $iMsg <> $aGUIRegisterMsg20[$idx][3] Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0]
142 | Local $vRetVal = $aGUIRegisterMsg20[$idx][4]( $hWnd, $iMsg, $wParam, $lParam ) ; Execute user supplied message handler function
143 | If $vRetVal == "GUI_RUNDEFMSG" Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0]
144 | Return $vRetVal
145 | #forceref $pData
146 | EndFunc
147 |
148 | ; Remove subclasses on exit
149 | Func GUIRegisterMsg20_Exit()
150 | If Not $aGUIRegisterMsg20[0][0] Then Return
151 | For $i = 1 To $aGUIRegisterMsg20[0][1]
152 | If Not $aGUIRegisterMsg20[$i][0] Then ContinueLoop
153 | DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $aGUIRegisterMsg20[$i][2], "ptr", $aGUIRegisterMsg20[0][2], "uint_ptr", $i ) ; $iSubclassId = $i
154 | Next
155 | EndFunc
156 |
--------------------------------------------------------------------------------
/includes/GuiCtrls_HiDpi.au3:
--------------------------------------------------------------------------------
1 | #include-once ; GuiCtrls_HiDpi.au3 ; v 0.2023.7.29(a) ; https://www.autoitscript.com/forum/topic/210613-guictrls_hidpi-udf-in-progress/
2 |
3 | Global $___gn__HiDpi_ratio = 1
4 | Global $___gi__HiDpi_DPI = 96
5 |
6 | Func _HiDpi_GUICreate($sTitle = "", $iWidth = Default, $iHeight = Default, $iLeft = -1, $iTop = -1, $iStyle = -1, $iExStyle = -1, $hParent = 0)
7 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
8 | Local $hRet = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, $iStyle, $iExStyle, $hParent) ; Create a GUI window.
9 | Return SetError(@error, @extended, $hRet)
10 | EndFunc ;==>_HiDpi_GUICreate
11 |
12 | #Region GUICtrlCreate__
13 |
14 | Func _HiDpi_SplashTextOn($sTitle, $sText, $iWidth = 500, $iHeight = 400, $iLeft = Default, $iTop = Default, $iOpt = Default, $sFontname = Default, $iFontSz = 12, $iFfontWt = 400)
15 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
16 | Local $iRet = SplashTextOn($sTitle, $sText, $iWidth, $iHeight, $iLeft, $iTop, $iOpt, $sFontname, $iFontSz, $iFfontWt)
17 | Return SetError(@error, @extended, $iRet)
18 | EndFunc
19 |
20 | Func _HiDpi_GUICtrlCreateAvi($sFilename, $iSubfileId, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
21 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
22 | Local $iRet = GUICtrlCreateAvi($sFilename, $iSubfileId, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates an AVI video control for the GUI.
23 | Return SetError(@error, @extended, $iRet)
24 | EndFunc ;==>_HiDpi_GUICtrlCreateAvi
25 |
26 | Func _HiDpi_GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
27 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
28 | Local $iRet = GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Button control for the GUI.
29 | Return SetError(@error, @extended, $iRet)
30 | EndFunc ;==>_HiDpi_GUICtrlCreateButton
31 |
32 | Func _HiDpi_GUICtrlCreateCheckbox($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
33 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
34 | Local $iRet = GUICtrlCreateCheckbox($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Checkbox control for the GUI.
35 | Return SetError(@error, @extended, $iRet)
36 | EndFunc ;==>_HiDpi_GUICtrlCreateCheckbox
37 |
38 | Func _HiDpi_GUICtrlCreateCombo($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
39 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
40 | Local $iRet = GUICtrlCreateCombo($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a ComboBox control for the GUI.
41 | Return SetError(@error, @extended, $iRet)
42 | EndFunc ;==>_HiDpi_GUICtrlCreateCombo
43 |
44 | Func _HiDpi_GUICtrlCreateDate($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
45 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
46 | Local $iRet = GUICtrlCreateDate($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a date control for the GUI.
47 | Return SetError(@error, @extended, $iRet)
48 | EndFunc ;==>_HiDpi_GUICtrlCreateDate
49 |
50 | Func _HiDpi_GUICtrlCreateEdit($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
51 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
52 | Local $iRet = GUICtrlCreateEdit($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates an Edit control for the GUI.
53 | Return SetError(@error, @extended, $iRet)
54 | EndFunc ;==>_HiDpi_GUICtrlCreateEdit
55 |
56 | Func _HiDpi_GUICtrlCreateGraphic($iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1)
57 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
58 | Local $iRet = GUICtrlCreateGraphic($iLeft, $iTop, $iWidth, $iHeight, $iStyle) ; Creates a Graphic control for the GUI.
59 | Return SetError(@error, @extended, $iRet)
60 | EndFunc ;==>_HiDpi_GUICtrlCreateGraphic
61 |
62 | Func _HiDpi_GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
63 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
64 | Local $iRet = GUICtrlCreateGroup($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Group control for the GUI.
65 | Return SetError(@error, @extended, $iRet)
66 | EndFunc ;==>_HiDpi_GUICtrlCreateGroup
67 |
68 | Func _HiDpi_GUICtrlCreateIcon($sFilename, $vIconName, $iLeft, $iTop, $iWidth = 32, $iHeight = 32, $iStyle = -1, $iExStyle = -1)
69 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
70 | Local $iRet = GUICtrlCreateIcon($sFilename, $vIconName, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates an Icon control for the GUI.
71 | Return SetError(@error, @extended, $iRet)
72 | EndFunc ;==>_HiDpi_GUICtrlCreateIcon
73 |
74 | Func _HiDpi_GUICtrlCreateInput($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
75 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
76 | Local $iRet = GUICtrlCreateInput($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates an Input control for the GUI.
77 | Return SetError(@error, @extended, $iRet)
78 | EndFunc ;==>_HiDpi_GUICtrlCreateInput
79 |
80 | Func _HiDpi_GUICtrlCreateLabel($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
81 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
82 | Local $iRet = GUICtrlCreateLabel($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a static Label control for the GUI.
83 | Return SetError(@error, @extended, $iRet)
84 | EndFunc ;==>_HiDpi_GUICtrlCreateLabel
85 |
86 | Func _HiDpi_GUICtrlCreateList($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
87 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
88 | Local $iRet = GUICtrlCreateList($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a List control for the GUI.
89 | Return SetError(@error, @extended, $iRet)
90 | EndFunc ;==>_HiDpi_GUICtrlCreateList
91 |
92 | Func _HiDpi_GUICtrlCreateListView($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
93 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
94 | Local $iRet = GUICtrlCreateListView($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a ListView control for the GUI.
95 | Return SetError(@error, @extended, $iRet)
96 | EndFunc ;==>_HiDpi_GUICtrlCreateListView
97 |
98 | Func _HiDpi_GUICtrlCreateMonthCal($sText, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
99 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
100 | Local $iRet = GUICtrlCreateMonthCal($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a month calendar control for the GUI.
101 | Return SetError(@error, @extended, $iRet)
102 | EndFunc ;==>_HiDpi_GUICtrlCreateMonthCal
103 |
104 | Func _HiDpi_GUICtrlCreateObj($ObjectVar, $iLeft, $iTop, $iWidth = Default, $iHeight = Default)
105 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
106 | Local $iRet = GUICtrlCreateObj($ObjectVar, $iLeft, $iTop, $iWidth, $iHeight) ; Creates an ActiveX control in the GUI.
107 | Return SetError(@error, @extended, $iRet)
108 | EndFunc ;==>_HiDpi_GUICtrlCreateObj
109 |
110 | Func _HiDpi_GUICtrlCreatePic($sFilename, $iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
111 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
112 | Local $iRet = GUICtrlCreatePic($sFilename, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Picture control for the GUI.
113 | Return SetError(@error, @extended, $iRet)
114 | EndFunc ;==>_HiDpi_GUICtrlCreatePic
115 |
116 | Func _HiDpi_GUICtrlCreateProgress($iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
117 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
118 | Local $iRet = GUICtrlCreateProgress($iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Progress control for the GUI.
119 | Return SetError(@error, @extended, $iRet)
120 | EndFunc ;==>_HiDpi_GUICtrlCreateProgress
121 |
122 | Func _HiDpi_GUICtrlCreateRadio($sText, $iLeft, $iTop = Default, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
123 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
124 | Local $iRet = GUICtrlCreateRadio($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Radio button control for the GUI.
125 | Return SetError(@error, @extended, $iRet)
126 | EndFunc ;==>_HiDpi_GUICtrlCreateRadio
127 |
128 | Func _HiDpi_GUICtrlCreateSlider($iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
129 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
130 | Local $iRet = GUICtrlCreateSlider($iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Slider control for the GUI.
131 | Return SetError(@error, @extended, $iRet)
132 | EndFunc ;==>_HiDpi_GUICtrlCreateSlider
133 |
134 | Func _HiDpi_GUICtrlCreateTab($iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
135 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
136 | Local $iRet = GUICtrlCreateTab($iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a Tab control for the GUI.
137 | Return SetError(@error, @extended, $iRet)
138 | EndFunc ;==>_HiDpi_GUICtrlCreateTab
139 |
140 | Func _HiDpi_GUICtrlCreateTreeView($iLeft, $iTop, $iWidth = Default, $iHeight = Default, $iStyle = -1, $iExStyle = -1)
141 | __HiDpi_CtrlBulkNewSize($iLeft, $iTop, $iWidth, $iHeight)
142 | Local $iRet = GUICtrlCreateTreeView($iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) ; Creates a TreeView control for the GUI.
143 | Return SetError(@error, @extended, $iRet)
144 | EndFunc ;==>_HiDpi_GUICtrlCreateTreeView
145 |
146 | #EndRegion GUICtrlCreate__
147 |
148 | ;https://learn.microsoft.com/en-us/windows/win32/hidpi/dpi-awareness-context
149 | Func _HiDpi_Ctrl_LazyInit($iCONTEXT = -2) ; under the current state of developnment, -2 is the best option for this UDF.
150 | If $iCONTEXT <> Null Then
151 | If Not ($iCONTEXT < -1 And $iCONTEXT > -5) Then $iCONTEXT = -2
152 | DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", $iCONTEXT)
153 | EndIf
154 | _HiDpi_CtrlSetVarDPI( _HiDpi_GetDpiForWindow())
155 | _HiDpi_CtrlSetVarRatio(_HiDpi_CtrlSetVarDPI() / 96)
156 | EndFunc ;==>_HiDpi_Ctrl_LazyInit
157 |
158 | Func _HiDpi_CtrlSetVarDPI($iDPI = Default)
159 | If $iDPI <> Default Then $___gi__HiDpi_DPI = $iDPI
160 | Return $___gi__HiDpi_DPI
161 | EndFunc ;==>_HiDpi_CtrlSetVarDPI
162 |
163 | Func _HiDpi_CtrlSetVarRatio($nRadio = Default)
164 | If $nRadio <> Default Then $___gn__HiDpi_ratio = $nRadio
165 | Return $___gn__HiDpi_ratio
166 | EndFunc ;==>_HiDpi_CtrlSetVarRatio
167 |
168 | Func _HiDpi_CtrlAdjRatio($iSize, $iSubstractRadio = 0, Const $_iCallerError = @error, Const $_iCallerExtended = @extended) ; @error and @extended are preserved on return.
169 | If $___gn__HiDpi_ratio = 1 Then Return SetError($_iCallerError, $_iCallerExtended, $iSize)
170 | If $iSubstractRadio Then
171 | $iSize /= $___gn__HiDpi_ratio
172 | Else
173 | $iSize *= $___gn__HiDpi_ratio
174 | EndIf
175 | Return SetError($_iCallerError, $_iCallerExtended, $iSize)
176 | EndFunc ;==>_HiDpi_CtrlAdjRatio
177 |
178 | ;~ Func _HiDpi_CtrlCount_Add($vRet, $iType = 2, Const $_iCallerError = @error, Const $_iCallerExtended = @extended) ; @error and @extended are preserved on return.
179 | ;~ ; working on it. Shouln't post. oops. too late.
180 | ;~ Return SetError($_iCallerError, $_iCallerExtended, $vRet)
181 | ;~ EndFunc ;==>_HiDpi_CtrlCount_Add
182 |
183 | Func __HiDpi_CtrlNewSize(ByRef $iSize) ; internal use
184 | If $___gn__HiDpi_ratio = 1 Then Return SetError(0, 0, $iSize)
185 | $iSize *= $___gn__HiDpi_ratio
186 | Return SetError(0, 1, $iSize) ; @extended = 1 ; radio is not 1 to 1 ;
187 | EndFunc ;==>__HiDpi_CtrlNewSize
188 |
189 | Func __HiDpi_CtrlBulkNewSize(ByRef $iLeft, ByRef $iTop, ByRef $iWidth, ByRef $iHeight) ; internal use
190 | If $iLeft <> -1 And $iLeft <> Default Then __HiDpi_CtrlNewSize($iLeft)
191 | If $iTop <> -1 And $iTop <> Default Then __HiDpi_CtrlNewSize($iTop)
192 | If $iWidth <> Default Then __HiDpi_CtrlNewSize($iWidth)
193 | If $iHeight <> Default Then __HiDpi_CtrlNewSize($iHeight)
194 | EndFunc ;==>__HiDpi_CtrlBulkNewSize
195 |
196 | ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow
197 | Func _HiDpi_GetDpiForWindow($hWnd = Default)
198 | Local $iErr, $iExt, $aResult, $gui = 0
199 | If $hWnd = Default Then $gui = GUICreate("")
200 | $aResult = DllCall("user32.dll", "uint", "GetDpiForWindow", "hwnd", ($gui ? $gui : $hWnd)) ;requires Win10 v1607+ / no server support
201 | $iErr = @error ; adaptation from https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1521526
202 | $iExt = @extended ; were the original code can be found.
203 | If $gui Then GUIDelete($gui)
204 | If $iErr Or Not IsArray($aResult) Then Return SetError($iErr + Int($iErr ? 0 : 100), $iExt, 96)
205 | Return $aResult[0] ; should be retutning an array[2]
206 | EndFunc ;==>_HiDpi_GetDpiForWindow
207 |
208 | Func _HiDpi_WinGetPos($sTitle, $sText = "") ; Retrieves the position and size of a given window.
209 | Local $n, $iErr, $iExt, $aArray = WinGetPos($sTitle, $sText)
210 | $iErr = @error
211 | $iExt = @extended
212 | If $iErr Then Return SetError($iErr, $iExt, $aArray)
213 | For $n = 0 To UBound($aArray) - 1 ; since _HiDpi_GUICreate() will adjust the sizes, "unadjusting" to what would have been is needed.
214 | $aArray[$n] = _HiDpi_CtrlAdjRatio($aArray[$n], 1) ; 1 = remove DPI radio rather than add
215 | Next
216 | Return SetError($iErr, $iExt, $aArray)
217 | EndFunc ;==>_HiDpi_WinGetPos
218 |
219 | Func _HiDpi_ControlGetPos($sTitle, $sText, $sControlID) ; Retrieves the position and size of a control relative to its window.
220 | Local $n, $iErr, $iExt, $aArray = ControlGetPos($sTitle, $sText, $sControlID)
221 | $iErr = @error
222 | $iExt = @extended
223 | If $iErr Then Return SetError($iErr, $iExt, $aArray)
224 | For $n = 0 To UBound($aArray) - 1
225 | $aArray[$n] = _HiDpi_CtrlAdjRatio($aArray[$n], 1)
226 | Next
227 | Return SetError($iErr, $iExt, $aArray) ; added on 2023.7.29
228 | EndFunc ;==>_HiDpi_ControlGetPos
--------------------------------------------------------------------------------
/includes/StringSize.au3:
--------------------------------------------------------------------------------
1 | #include-once
2 |
3 | ; #INDEX# ============================================================================================================
4 | ; Title .........: _StringSize
5 | ; AutoIt Version : v3.2.12.1 or higher
6 | ; Language ......: English
7 | ; Description ...: Returns size of rectangle required to display string - maximum width can be chosen
8 | ; Remarks .......:
9 | ; Note ..........:
10 | ; Author(s) .....: Melba23 - thanks to trancexx for the default DC code
11 | ; ====================================================================================================================
12 |
13 | ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
14 |
15 | ; #CURRENT# ==========================================================================================================
16 | ; _StringSize: Returns size of rectangle required to display string - maximum width can be chosen
17 | ; ====================================================================================================================
18 |
19 | ; #INTERNAL_USE_ONLY#=================================================================================================
20 | ; _StringSize_Error_Close: Releases DC and deletes font object after error
21 | ; _StringSize_DefaultFontName: Determines Windows default font
22 | ; ====================================================================================================================
23 |
24 | ; #FUNCTION# =========================================================================================================
25 | ; Name...........: _StringSize
26 | ; Description ...: Returns size of rectangle required to display string - maximum permitted width can be chosen
27 | ; Syntax ........: _StringSize($sText[, $iSize[, $iWeight[, $iAttrib[, $sName[, $iWidth[, $hWnd]]]]]])
28 | ; Parameters ....: $sText - String to display
29 | ; $iSize - [optional] Font size in points - (default = 8.5)
30 | ; $iWeight - [optional] Font weight - (default = 400 = normal)
31 | ; $iAttrib - [optional] Font attribute (0-Normal (default), 2-Italic, 4-Underline, 8 Strike)
32 | ; + 1 if tabs are to be expanded before sizing
33 | ; $sName - [optional] Font name - (default = Tahoma)
34 | ; $iWidth - [optional] Max width for rectangle - (default = 0 => width of original string)
35 | ; $hWnd - [optional] GUI in which string will be displayed - (default 0 => normally not required)
36 | ; Requirement(s) : v3.2.12.1 or higher
37 | ; Return values .: Success - Returns 4-element array: ($iWidth set // $iWidth not set)
38 | ; |$array[0] = String reformatted with additonal @CRLF // Original string
39 | ; |$array[1] = Height of single line in selected font // idem
40 | ; |$array[2] = Width of rectangle required for reformatted // original string
41 | ; |$array[3] = Height of rectangle required for reformatted // original string
42 | ; Failure - Returns 0 and sets @error:
43 | ; |1 - Incorrect parameter type (@extended = parameter index)
44 | ; |2 - DLL call error - extended set as follows:
45 | ; |1 - GetDC failure
46 | ; |2 - SendMessage failure
47 | ; |3 - GetDeviceCaps failure
48 | ; |4 - CreateFont failure
49 | ; |5 - SelectObject failure
50 | ; |6 - GetTextExtentPoint32 failure
51 | ; |3 - Font too large for chosen max width - a word will not fit
52 | ; Author ........: Melba23 - thanks to trancexx for the default DC code
53 | ; Modified ......:
54 | ; Remarks .......: The use of the $hWnd parameter is not normally necessary - it is only required if the UDF does not
55 | ; return correct dimensions without it.
56 | ; Related .......:
57 | ; Link ..........:
58 | ; Example .......: Yes
59 | ;=====================================================================================================================
60 | Func _StringSize($sText, $iSize = 8.5, $iWeight = 400, $iAttrib = 0, $sName = "", $iMaxWidth = 0, $hWnd = 0)
61 |
62 | ; Set parameters passed as Default
63 | If $iSize = Default Then $iSize = 8.5
64 | If $iWeight = Default Then $iWeight = 400
65 | If $iAttrib = Default Then $iAttrib = 0
66 | If $sName = "" Or $sName = Default Then $sName = _StringSize_DefaultFontName()
67 |
68 | ; Check parameters are correct type
69 | If Not IsString($sText) Then Return SetError(1, 1, 0)
70 | If Not IsNumber($iSize) Then Return SetError(1, 2, 0)
71 | If Not IsInt($iWeight) Then Return SetError(1, 3, 0)
72 | If Not IsInt($iAttrib) Then Return SetError(1, 4, 0)
73 | If Not IsString($sName) Then Return SetError(1, 5, 0)
74 | If Not IsNumber($iMaxWidth) Then Return SetError(1, 6, 0)
75 | If Not IsHwnd($hWnd) And $hWnd <> 0 Then Return SetError(1, 7, 0)
76 |
77 | Local $aRet, $hDC, $hFont, $hLabel = 0, $hLabel_Handle
78 |
79 | ; Check for tab expansion flag
80 | Local $iExpTab = BitAnd($iAttrib, 1)
81 | ; Remove possible tab expansion flag from font attribute value
82 | $iAttrib = BitAnd($iAttrib, BitNot(1))
83 |
84 | ; If GUI handle was passed
85 | If IsHWnd($hWnd) Then
86 | ; Create label outside GUI borders
87 | $hLabel = GUICtrlCreateLabel("", -10, -10, 10, 10)
88 | $hLabel_Handle = GUICtrlGetHandle(-1)
89 | GUICtrlSetFont(-1, $iSize, $iWeight, $iAttrib, $sName)
90 | ; Create DC
91 | $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hLabel_Handle)
92 | If @error Or $aRet[0] = 0 Then
93 | GUICtrlDelete($hLabel)
94 | Return SetError(2, 1, 0)
95 | EndIf
96 | $hDC = $aRet[0]
97 | $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont
98 | If @error Or $aRet[0] = 0 Then
99 | GUICtrlDelete($hLabel)
100 | Return SetError(2, _StringSize_Error_Close(2, $hDC), 0)
101 | EndIf
102 | $hFont = $aRet[0]
103 | Else
104 | ; Get default DC
105 | $aRet = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd)
106 | If @error Or $aRet[0] = 0 Then Return SetError(2, 1, 0)
107 | $hDC = $aRet[0]
108 | ; Create required font
109 | $aRet = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", 90) ; $LOGPIXELSY
110 | If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(3, $hDC), 0)
111 | Local $iInfo = $aRet[0]
112 | $aRet = DllCall("gdi32.dll", "handle", "CreateFontW", "int", -$iInfo * $iSize / 72, "int", 0, "int", 0, "int", 0, _
113 | "int", $iWeight, "dword", BitAND($iAttrib, 2), "dword", BitAND($iAttrib, 4), "dword", BitAND($iAttrib, 8), "dword", 0, "dword", 0, _
114 | "dword", 0, "dword", 5, "dword", 0, "wstr", $sName)
115 | If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(4, $hDC), 0)
116 | $hFont = $aRet[0]
117 | EndIf
118 |
119 | ; Select font and store previous font
120 | $aRet = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hFont)
121 | If @error Or $aRet[0] = 0 Then Return SetError(2, _StringSize_Error_Close(5, $hDC, $hFont, $hLabel), 0)
122 | Local $hPrevFont = $aRet[0]
123 |
124 | ; Declare variables
125 | Local $avSize_Info[4], $iLine_Length, $iLine_Height = 0, $iLine_Count = 0, $iLine_Width = 0, $iWrap_Count, $iLast_Word, $sTest_Line
126 | ; Declare and fill Size structure
127 | Local $tSize = DllStructCreate("int X;int Y")
128 | DllStructSetData($tSize, "X", 0)
129 | DllStructSetData($tSize, "Y", 0)
130 |
131 | ; Ensure EoL is @CRLF and break text into lines
132 | $sText = StringRegExpReplace($sText, "((? $iLine_Width Then $iLine_Width = DllStructGetData($tSize, "X")
146 | If DllStructGetData($tSize, "Y") > $iLine_Height Then $iLine_Height = DllStructGetData($tSize, "Y")
147 | Next
148 |
149 | ; Check if $iMaxWidth has been both set and exceeded
150 | If $iMaxWidth <> 0 And $iLine_Width > $iMaxWidth Then ; Wrapping required
151 | ; For each Line
152 | For $j = 1 To $asLines[0]
153 | ; Size line unwrapped
154 | $iLine_Length = StringLen($asLines[$j])
155 | DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $asLines[$j], "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
156 | If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
157 | ; Check wrap status
158 | If DllStructGetData($tSize, "X") < $iMaxWidth - 4 Then
159 | ; No wrap needed so count line and store
160 | $iLine_Count += 1
161 | $avSize_Info[0] &= $asLines[$j] & @CRLF
162 | Else
163 | ; Wrap needed so zero counter for wrapped lines
164 | $iWrap_Count = 0
165 | ; Build line to max width
166 | While 1
167 | ; Zero line width
168 | $iLine_Width = 0
169 | ; Initialise pointer for end of word
170 | $iLast_Word = 0
171 | ; Add characters until EOL or maximum width reached
172 | For $i = 1 To StringLen($asLines[$j])
173 | ; Is this just past a word ending?
174 | If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1
175 | ; Increase line by one character
176 | $sTest_Line = StringMid($asLines[$j], 1, $i)
177 | ; Get line length
178 | $iLine_Length = StringLen($sTest_Line)
179 | DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sTest_Line, "int", $iLine_Length, "ptr", DllStructGetPtr($tSize))
180 | If @error Then Return SetError(2, _StringSize_Error_Close(6, $hDC, $hFont, $hLabel), 0)
181 | $iLine_Width = DllStructGetData($tSize, "X")
182 | ; If too long exit the loop
183 | If $iLine_Width >= $iMaxWidth - 4 Then ExitLoop
184 | Next
185 | ; End of the line of text?
186 | If $i > StringLen($asLines[$j]) Then
187 | ; Yes, so add final line to count
188 | $iWrap_Count += 1
189 | ; Store line
190 | $avSize_Info[0] &= $sTest_Line & @CRLF
191 | ExitLoop
192 | Else
193 | ; No, but add line just completed to count
194 | $iWrap_Count += 1
195 | ; Check at least 1 word completed or return error
196 | If $iLast_Word = 0 Then Return SetError(3, _StringSize_Error_Close(0, $hDC, $hFont, $hLabel), 0)
197 | ; Store line up to end of last word
198 | $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF
199 | ; Strip string to point reached
200 | $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word)
201 | ; Trim leading whitespace
202 | $asLines[$j] = StringStripWS($asLines[$j], 1)
203 | ; Repeat with remaining characters in line
204 | EndIf
205 | WEnd
206 | ; Add the number of wrapped lines to the count
207 | $iLine_Count += $iWrap_Count
208 | EndIf
209 | Next
210 | ; Reset any tab expansions
211 | If $iExpTab Then
212 | $avSize_Info[0] = StringRegExpReplace($avSize_Info[0], "\x20?XXXXXXXX", @TAB)
213 | EndIf
214 | ; Complete return array
215 | $avSize_Info[1] = $iLine_Height
216 | $avSize_Info[2] = $iMaxWidth
217 | ; Convert lines to pixels and add drop margin
218 | $avSize_Info[3] = ($iLine_Count * $iLine_Height) + 4
219 | Else ; No wrapping required
220 | ; Create return array (add drop margin to height)
221 | Local $avSize_Info[4] = [$sText, $iLine_Height, $iLine_Width, ($asLines[0] * $iLine_Height) + 4]
222 | EndIf
223 |
224 | ; Clear up
225 | DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hPrevFont)
226 | DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont)
227 | DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC)
228 | If $hLabel Then GUICtrlDelete($hLabel)
229 |
230 | Return $avSize_Info
231 |
232 | EndFunc ;==>_StringSize
233 |
234 | ; #INTERNAL_USE_ONLY#============================================================================================================
235 | ; Name...........: _StringSize_Error_Close
236 | ; Description ...: Releases DC and deleted font object if required after error
237 | ; Syntax ........: _StringSize_Error_Close ($iExtCode, $hDC, $hGUI)
238 | ; Parameters ....: $iExtCode - code to return
239 | ; $hDC, $hGUI - handles as set in _StringSize function
240 | ; Return value ..: $iExtCode as passed
241 | ; Author ........: Melba23
242 | ; Modified.......:
243 | ; Remarks .......: This function is used internally by _StringSize
244 | ; ===============================================================================================================================
245 | Func _StringSize_Error_Close($iExtCode, $hDC = 0, $hFont = 0, $hLabel = 0)
246 |
247 | If $hFont <> 0 Then DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hFont)
248 | If $hDC <> 0 Then DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "handle", $hDC)
249 | If $hLabel Then GUICtrlDelete($hLabel)
250 |
251 | Return $iExtCode
252 |
253 | EndFunc ;=>_StringSize_Error_Close
254 |
255 | ; #INTERNAL_USE_ONLY#============================================================================================================
256 | ; Name...........: _StringSize_DefaultFontName
257 | ; Description ...: Determines Windows default font
258 | ; Syntax ........: _StringSize_DefaultFontName()
259 | ; Parameters ....: None
260 | ; Return values .: Success - Returns name of system default font
261 | ; Failure - Returns "Tahoma"
262 | ; Author ........: Melba23, based on some original code by Larrydalooza
263 | ; Modified.......:
264 | ; Remarks .......: This function is used internally by _StringSize
265 | ; ===============================================================================================================================
266 | Func _StringSize_DefaultFontName()
267 |
268 | ; Get default system font data
269 | Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]")
270 | DLLStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS))
271 | DLLCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0)
272 | Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DLLStructGetPtr($tNONCLIENTMETRICS, 13))
273 | If IsString(DllStructGetData($tLOGFONT, 14)) Then
274 | Return DllStructGetData($tLOGFONT, 14)
275 | Else
276 | Return "Tahoma"
277 | EndIf
278 |
279 | EndFunc ;=>_StringSize_DefaultFontName
--------------------------------------------------------------------------------
/includes/_GUICtrlListView_SaveCSV.au3:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | ; #FUNCTION# ====================================================================================================================
5 | ; Name ..........: _GUICtrlListView_SaveCSV
6 | ; Description ...: Exports a listview to a CSV file.
7 | ; Syntax ........: _GUICtrlListView_SaveCSV($hListView, $sFilePath[, $sDelimiter = '[, $sQuote = '"']])
8 | ; Parameters ....: $hListView - Control ID/Handle to the control
9 | ; $sFilePath - Filepath to save the CSV data string to.
10 | ; $sDelimiter - [optional] CSV delimiter. Default is ,.
11 | ; $sQuote - [optional] CSV quote type. Default is ".
12 | ; Return values .: Success - True
13 | ; Failure - False and sets @error to non-zero.
14 | ; Author ........: guinness
15 | ; Remarks .......: Thanks to Prog@ndy for the idea of CSV creation. GUICtrlListView.au3 should be included.
16 | ; Example .......: Yes
17 | ; ===============================================================================================================================
18 | Func _GUICtrlListView_SaveCSV($hListView, $sFilePath, $sDelimiter = ',', $sQuote = '"')
19 | If $sDelimiter = Default Then
20 | $sDelimiter = ','
21 | EndIf
22 | If $sQuote = Default Then
23 | $sQuote = '"'
24 | EndIf
25 |
26 | Local Const $iColumnCount = _GUICtrlListView_GetColumnCount($hListView) - 1
27 | Local Const $iItemCount = _GUICtrlListView_GetItemCount($hListView) - 1
28 | Local $sReturn = ''
29 | For $i = 0 To $iItemCount
30 | For $j = 0 To $iColumnCount
31 | $sReturn &= $sQuote & StringReplace(_GUICtrlListView_GetItemText($hListView, $i, $j), $sQuote, $sQuote & $sQuote, 0, 1) & $sQuote
32 | If $j < $iColumnCount Then
33 | $sReturn &= $sDelimiter
34 | EndIf
35 | Next
36 | $sReturn &= @CRLF
37 | Next
38 |
39 | Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
40 | If $hFileOpen = -1 Then
41 | Return SetError(1, 0, False)
42 | EndIf
43 | FileWrite($hFileOpen, $sReturn)
44 | FileClose($hFileOpen)
45 | Return True
46 | EndFunc ;==>_GUICtrlListView_SaveCSV
--------------------------------------------------------------------------------
/unchecked.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WildByDesign/win32-appcontainer-tools/bff820bc882cb86cc54b553628c362a5a20a8f98/unchecked.ico
--------------------------------------------------------------------------------