├── .gitattributes
├── .gitignore
├── .gitmodules
├── Irec.py
├── Irec.spec
├── LICENSE
├── MacroPlayer
├── .gitignore
├── MacroPlayer.aps
├── MacroPlayer.cpp
├── MacroPlayer.exe.manifest
├── MacroPlayer.rc
├── MacroPlayer.sln
├── MacroPlayer.vcxproj
├── MacroPlayer.vcxproj.filters
├── MacroPlayer.vcxproj.user
├── macro.h
├── resource.h
├── winput.h
└── zconf.h
├── README.md
├── README.sb
├── irec_module
├── __init__.py
├── config.py
├── macro.py
├── util.py
└── window.py
├── requirements.txt
├── res
├── Irec.ico
├── Irec.ico LICENSE.txt
├── add.png
├── add2.png
├── delete.png
├── delete2.png
├── edit.png
├── edit2.png
├── load.png
├── play.png
├── play2.png
├── rec.png
├── rec2.png
└── save.png
└── screenshots
├── edit-dialog.gif
├── main-menu.png
└── record-dialog.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | *.pyc
3 | *.xcf
4 | runreadmelang.bat
5 | readmelang.py
6 | README.rst
7 | config.dict
8 | build
9 | dist
10 | source_images
11 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "zlib"]
2 | path = zlib
3 | url = https://github.com/madler/zlib
4 | [submodule "requirements"]
5 | path = requirements
6 | url = https://github.com/Zuzu-Typ/requirements
7 |
--------------------------------------------------------------------------------
/Irec.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | """
19 |
20 | import os, sys
21 |
22 | os.environ["PyPI_REQUIREMENTS_OUTPUT"] = "ON"
23 |
24 | os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
25 |
26 | try:
27 | from requirements import requirements
28 |
29 | except IOError:
30 | print("Failed to load requirements.", file=sys.stderr)
31 |
32 | try:
33 | import winput
34 | import PIL
35 |
36 | assert hasattr(winput, "set_DPI_aware")
37 |
38 | except:
39 | sys.exit(-1)
40 |
41 |
42 | argv_short_to_long_dict = { "h" : "help", "?" : "help" }
43 |
44 | kwargs_with_argments = ()
45 |
46 | HELP_STRING = """Input Recorder.
47 | Records and plays back macros.
48 |
49 | Currently only supports GUI mode.
50 |
51 | Usage: irec
52 | """
53 |
54 | def start_command_line_mode(*args, **kwargs):
55 | pass
56 |
57 | def start_windowed_mode():
58 | import irec_module.window
59 |
60 |
61 | def main(*args, **kwargs):
62 | if kwargs.get("help", False):
63 | print(HELP_STRING)
64 | return
65 |
66 | if kwargs or args:
67 | start_command_line_mode(*args, **kwargs)
68 |
69 | start_windowed_mode()
70 |
71 | def process_argv():
72 | argv = sys.argv
73 |
74 | kwargs = {}
75 | args = []
76 |
77 | if len(argv) > 1:
78 | last_command = None
79 |
80 | for arg in argv[1:]:
81 | if len(arg) == 2 and (arg[0] == "-" or arg[0] == "/"):
82 | command_alias = arg[1]
83 |
84 | if not command_alias in argv_short_to_long_dict:
85 | raise KeyError("Unknown command line argument {}. Try -h for a list of commands.".format(arg))
86 |
87 | if last_command:
88 | raise ValueError("Argument '{}' has no value.".format(last_command))
89 |
90 | command = argv_short_to_long_dict[command_alias]
91 |
92 | if command in kwargs_with_argments:
93 | last_command = command
94 |
95 | else:
96 | kwargs[command] = True
97 |
98 | elif len(arg) > 2 and arg.startswith("--"):
99 | command = arg[2:]
100 |
101 | if not command in argv_short_to_long_dict.values():
102 | raise KeyError("Unknown command line argument {}. Try -h for a list of commands.".format(arg))
103 |
104 | if last_command:
105 | raise ValueError("Argument '{}' has no value.".format(last_command))
106 |
107 | if command in kwargs_with_argments:
108 | last_command = command
109 |
110 | else:
111 | kwargs[command] = True
112 |
113 | else:
114 | if last_command:
115 | kwargs[last_command] = arg
116 | last_command = None
117 |
118 | else:
119 | args.append(arg)
120 |
121 | if last_command:
122 | raise ValueError("Argument '{}' has no value.".format(last_command))
123 |
124 | return (args, kwargs)
125 |
126 |
127 | if __name__ == "__main__":
128 | args, kwargs = process_argv()
129 | main(*args, **kwargs)
130 |
131 |
--------------------------------------------------------------------------------
/Irec.spec:
--------------------------------------------------------------------------------
1 | # -*- mode: python ; coding: utf-8 -*-
2 |
3 |
4 | block_cipher = None
5 |
6 |
7 | a = Analysis(['Irec.py'],
8 | pathex=[],
9 | binaries=[],
10 | datas=[],
11 | hiddenimports=[],
12 | hookspath=[],
13 | hooksconfig={},
14 | runtime_hooks=[],
15 | excludes=[],
16 | win_no_prefer_redirects=False,
17 | win_private_assemblies=False,
18 | cipher=block_cipher,
19 | noarchive=False)
20 | pyz = PYZ(a.pure, a.zipped_data,
21 | cipher=block_cipher)
22 |
23 | exe = EXE(pyz,
24 | a.scripts,
25 | a.binaries,
26 | a.zipfiles,
27 | a.datas,
28 | [],
29 | name='Irec',
30 | debug=False,
31 | bootloader_ignore_signals=False,
32 | strip=False,
33 | upx=True,
34 | upx_exclude=[],
35 | runtime_tmpdir=None,
36 | console=False,
37 | disable_windowed_traceback=False,
38 | target_arch=None,
39 | codesign_identity=None,
40 | entitlements_file=None , icon='res\\Irec.ico')
41 |
--------------------------------------------------------------------------------
/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 | .
--------------------------------------------------------------------------------
/MacroPlayer/.gitignore:
--------------------------------------------------------------------------------
1 | .vs
2 | x64
3 | Debug
4 | Release
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/MacroPlayer/MacroPlayer.aps
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.cpp:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #include
21 |
22 | #include
23 |
24 | #include
25 |
26 | #include
27 |
28 | #include "macro.h"
29 |
30 | #include "zlib.h"
31 |
32 | extern const char* LICENSE_TEXT;
33 |
34 | const char* HELP_STRING = "Usage: MacroPlayer [OPTIONS] FILE\n"
35 | "\n"
36 | "Plays back the macro found in FILE.\n"
37 | "Only single binary macros (*.mcr) are supported.\n"
38 | "\n"
39 | " Option Alias Description\n"
40 | " --help -h Print this usage guide.\n"
41 | " --repeat -r Repeat the macro an additional times.\n"
42 | " --explain -e Prints out what the macro does.\n"
43 | " --license -l Prints the GPL 3.0 license text.\n"
44 | " --accept-risk Playing back a macro might cause damage to you or\n"
45 | " your computer. Use this flag to accept the risk.\n"
46 | "\n"
47 | "MacroPlayer Copyright (C) 2022 Zuzu_Typ\n"
48 | "This software is licensed under the GPL 3.0.\n"
49 | "Use the '--license' flag to view the full license";
50 |
51 | const char* RISK_STRING = "This application is used to play back macros. Those macros may consist of any number\n"
52 | "of keyboard and mouse inputs. They could result in damage to your computer or yourself.\n"
53 | "Therefore the risk must be explicitly accepted using the '--accept-risk' flag.\n"
54 | "If you do not trust this macro, you can inspect it using the '--explain' flag.";
55 |
56 | const char* ARGPARSE_ERROR_STRING = "Invalid CLI arguments. Try '--help' for a list of options.";
57 |
58 | const char* FILE_ERROR_STRING = "The requested file couldn't be read.";
59 |
60 | const char* ZLIB_ERROR_STRING = "The requested file isn't in the correct format.";
61 |
62 | static int read_file(char const* path, char*& data, uLongf& data_length)
63 | {
64 | std::ifstream file(path, std::ios::binary | std::ios::ate);
65 |
66 | if (!file) {
67 | return -1;
68 | }
69 |
70 | data_length = static_cast(file.tellg());
71 |
72 | data = reinterpret_cast(malloc(data_length));
73 |
74 | file.seekg(0, std::ios::beg);
75 |
76 | file.read(data, data_length);
77 |
78 | return 0;
79 | }
80 |
81 | static int parse_argv(int argc, char** argv, char*& path, int& repeat, bool& explain_macro) {
82 | bool risk_accepted = false;
83 | bool show_help = false;
84 | bool show_license = false;
85 | bool error_occured = false;
86 |
87 | path = NULL;
88 |
89 | for (int i = 1; i < argc; i++) {
90 | if (strcmp(argv[i], "--accept-risk") == 0) {
91 | risk_accepted = true;
92 | }
93 | else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
94 | show_help = true;
95 | }
96 | else if (strcmp(argv[i], "--license") == 0 || strcmp(argv[i], "-l") == 0) {
97 | show_license = true;
98 | }
99 | else if (strcmp(argv[i], "--explain") == 0 || strcmp(argv[i], "-e") == 0) {
100 | explain_macro = true;
101 | }
102 | else if (strcmp(argv[i], "--repeat") == 0 || strcmp(argv[i], "-r") == 0) {
103 | try {
104 | repeat = std::stoi(argv[++i]);
105 | if (repeat < 0) {
106 | error_occured = true;
107 | }
108 | }
109 | catch (...) {
110 | error_occured = true;
111 | }
112 | }
113 | else {
114 | if (path != NULL) {
115 | error_occured = true;
116 | }
117 | else {
118 | path = argv[i];
119 | }
120 | }
121 | }
122 |
123 | if (path == NULL && !show_license) {
124 | show_help = true;
125 | }
126 |
127 | if (error_occured) {
128 | std::cout << ARGPARSE_ERROR_STRING << std::endl;
129 | }
130 | else {
131 | if (show_help) {
132 | std::cout << HELP_STRING << std::endl;
133 | }
134 | else {
135 | if (show_license) {
136 | std::cout << LICENSE_TEXT << std::endl;
137 | }
138 | else {
139 | if (!risk_accepted && !explain_macro) {
140 | std::cout << RISK_STRING << std::endl;
141 | }
142 | else {
143 | return 0;
144 | }
145 | }
146 | }
147 | }
148 | return -1;
149 | }
150 |
151 | int main(int argc, char** argv)
152 | {
153 | char* filepath;
154 | int repeat_count = 0;
155 | bool should_explain_macro = false;
156 |
157 | int error = parse_argv(argc, argv, filepath, repeat_count, should_explain_macro);
158 |
159 | if (!error) {
160 | char* data;
161 | uLongf data_length;
162 |
163 | error = read_file(filepath, data, data_length);
164 |
165 | if (error) {
166 | std::cout << FILE_ERROR_STRING << std::endl;
167 | return -1;
168 | }
169 |
170 | if (data_length < 4) {
171 | std::cout << ZLIB_ERROR_STRING << std::endl;
172 | return -1;
173 | }
174 |
175 | uLongf uncompressed_data_length = *(unsigned int*)data;
176 |
177 | data += 4;
178 |
179 | Bytef* uncompressed_data = (Bytef*)malloc(uncompressed_data_length + 1);
180 |
181 | int zlib_return_code = uncompress(uncompressed_data, &uncompressed_data_length, (const Bytef*)data, data_length);
182 |
183 | if (zlib_return_code == Z_OK) {
184 | int macro_result = 0;
185 | if (should_explain_macro) {
186 | macro_result = play_macro(uncompressed_data_length, (byte*)(uncompressed_data), PlaybackMode::EXPLAIN);
187 | }
188 | else {
189 | for (int i = 0; i <= repeat_count; i++) {
190 | macro_result = play_macro(uncompressed_data_length, (byte*)(uncompressed_data), PlaybackMode::PLAY);
191 | if (macro_result) {
192 | break;
193 | }
194 | }
195 | }
196 | switch (macro_result) {
197 | case MACRO_INVALID_FORMAT:
198 | std::cout << "Invalid macro format." << std::endl;
199 | break;
200 | case MACRO_NON_SINGLE:
201 | std::cout << "This is not a single macro." << std::endl;
202 | break;
203 | case MACRO_INCOMPATIBLE:
204 | std::cout << "The given macro was created with a different version of Irec." << std::endl;
205 | break;
206 | case MACRO_EMPTY:
207 | std::cout << "The macro doesn't contain any events." << std::endl;
208 | break;
209 | }
210 | }
211 | else {
212 | std::cout << ZLIB_ERROR_STRING << std::endl;
213 | }
214 |
215 | free(uncompressed_data);
216 | }
217 | return 0;
218 | }
219 |
220 | const char* LICENSE_TEXT = \
221 | " GNU GENERAL PUBLIC LICENSE\n"
222 | " Version 3, 29 June 2007\n"
223 | "\n"
224 | " Copyright (C) 2007 Free Software Foundation, Inc. \n"
225 | " Everyone is permitted to copy and distribute verbatim copies\n"
226 | " of this license document, but changing it is not allowed.\n"
227 | "\n"
228 | " Preamble\n"
229 | "\n"
230 | " The GNU General Public License is a free, copyleft license for\n"
231 | "software and other kinds of works.\n"
232 | "\n"
233 | " The licenses for most software and other practical works are designed\n"
234 | "to take away your freedom to share and change the works. By contrast,\n"
235 | "the GNU General Public License is intended to guarantee your freedom to\n"
236 | "share and change all versions of a program--to make sure it remains free\n"
237 | "software for all its users. We, the Free Software Foundation, use the\n"
238 | "GNU General Public License for most of our software; it applies also to\n"
239 | "any other work released this way by its authors. You can apply it to\n"
240 | "your programs, too.\n"
241 | "\n"
242 | " When we speak of free software, we are referring to freedom, not\n"
243 | "price. Our General Public Licenses are designed to make sure that you\n"
244 | "have the freedom to distribute copies of free software (and charge for\n"
245 | "them if you wish), that you receive source code or can get it if you\n"
246 | "want it, that you can change the software or use pieces of it in new\n"
247 | "free programs, and that you know you can do these things.\n"
248 | "\n"
249 | " To protect your rights, we need to prevent others from denying you\n"
250 | "these rights or asking you to surrender the rights. Therefore, you have\n"
251 | "certain responsibilities if you distribute copies of the software, or if\n"
252 | "you modify it: responsibilities to respect the freedom of others.\n"
253 | "\n"
254 | " For example, if you distribute copies of such a program, whether\n"
255 | "gratis or for a fee, you must pass on to the recipients the same\n"
256 | "freedoms that you received. You must make sure that they, too, receive\n"
257 | "or can get the source code. And you must show them these terms so they\n"
258 | "know their rights.\n"
259 | "\n"
260 | " Developers that use the GNU GPL protect your rights with two steps:\n"
261 | "(1) assert copyright on the software, and (2) offer you this License\n"
262 | "giving you legal permission to copy, distribute and/or modify it.\n"
263 | "\n"
264 | " For the developers' and authors' protection, the GPL clearly explains\n"
265 | "that there is no warranty for this free software. For both users' and\n"
266 | "authors' sake, the GPL requires that modified versions be marked as\n"
267 | "changed, so that their problems will not be attributed erroneously to\n"
268 | "authors of previous versions.\n"
269 | "\n"
270 | " Some devices are designed to deny users access to install or run\n"
271 | "modified versions of the software inside them, although the manufacturer\n"
272 | "can do so. This is fundamentally incompatible with the aim of\n"
273 | "protecting users' freedom to change the software. The systematic\n"
274 | "pattern of such abuse occurs in the area of products for individuals to\n"
275 | "use, which is precisely where it is most unacceptable. Therefore, we\n"
276 | "have designed this version of the GPL to prohibit the practice for those\n"
277 | "products. If such problems arise substantially in other domains, we\n"
278 | "stand ready to extend this provision to those domains in future versions\n"
279 | "of the GPL, as needed to protect the freedom of users.\n"
280 | "\n"
281 | " Finally, every program is threatened constantly by software patents.\n"
282 | "States should not allow patents to restrict development and use of\n"
283 | "software on general-purpose computers, but in those that do, we wish to\n"
284 | "avoid the special danger that patents applied to a free program could\n"
285 | "make it effectively proprietary. To prevent this, the GPL assures that\n"
286 | "patents cannot be used to render the program non-free.\n"
287 | "\n"
288 | " The precise terms and conditions for copying, distribution and\n"
289 | "modification follow.\n"
290 | "\n"
291 | " TERMS AND CONDITIONS\n"
292 | "\n"
293 | " 0. Definitions.\n"
294 | "\n"
295 | " \"This License\" refers to version 3 of the GNU General Public License.\n"
296 | "\n"
297 | " \"Copyright\" also means copyright-like laws that apply to other kinds of\n"
298 | "works, such as semiconductor masks.\n"
299 | "\n"
300 | " \"The Program\" refers to any copyrightable work licensed under this\n"
301 | "License. Each licensee is addressed as \"you\". \"Licensees\" and\n"
302 | "\"recipients\" may be individuals or organizations.\n"
303 | "\n"
304 | " To \"modify\" a work means to copy from or adapt all or part of the work\n"
305 | "in a fashion requiring copyright permission, other than the making of an\n"
306 | "exact copy. The resulting work is called a \"modified version\" of the\n"
307 | "earlier work or a work \"based on\" the earlier work.\n"
308 | "\n"
309 | " A \"covered work\" means either the unmodified Program or a work based\n"
310 | "on the Program.\n"
311 | "\n"
312 | " To \"propagate\" a work means to do anything with it that, without\n"
313 | "permission, would make you directly or secondarily liable for\n"
314 | "infringement under applicable copyright law, except executing it on a\n"
315 | "computer or modifying a private copy. Propagation includes copying,\n"
316 | "distribution (with or without modification), making available to the\n"
317 | "public, and in some countries other activities as well.\n"
318 | "\n"
319 | " To \"convey\" a work means any kind of propagation that enables other\n"
320 | "parties to make or receive copies. Mere interaction with a user through\n"
321 | "a computer network, with no transfer of a copy, is not conveying.\n"
322 | "\n"
323 | " An interactive user interface displays \"Appropriate Legal Notices\"\n"
324 | "to the extent that it includes a convenient and prominently visible\n"
325 | "feature that (1) displays an appropriate copyright notice, and (2)\n"
326 | "tells the user that there is no warranty for the work (except to the\n"
327 | "extent that warranties are provided), that licensees may convey the\n"
328 | "work under this License, and how to view a copy of this License. If\n"
329 | "the interface presents a list of user commands or options, such as a\n"
330 | "menu, a prominent item in the list meets this criterion.\n"
331 | "\n"
332 | " 1. Source Code.\n"
333 | "\n"
334 | " The \"source code\" for a work means the preferred form of the work\n"
335 | "for making modifications to it. \"Object code\" means any non-source\n"
336 | "form of a work.\n"
337 | "\n"
338 | " A \"Standard Interface\" means an interface that either is an official\n"
339 | "standard defined by a recognized standards body, or, in the case of\n"
340 | "interfaces specified for a particular programming language, one that\n"
341 | "is widely used among developers working in that language.\n"
342 | "\n"
343 | " The \"System Libraries\" of an executable work include anything, other\n"
344 | "than the work as a whole, that (a) is included in the normal form of\n"
345 | "packaging a Major Component, but which is not part of that Major\n"
346 | "Component, and (b) serves only to enable use of the work with that\n"
347 | "Major Component, or to implement a Standard Interface for which an\n"
348 | "implementation is available to the public in source code form. A\n"
349 | "\"Major Component\", in this context, means a major essential component\n"
350 | "(kernel, window system, and so on) of the specific operating system\n"
351 | "(if any) on which the executable work runs, or a compiler used to\n"
352 | "produce the work, or an object code interpreter used to run it.\n"
353 | "\n"
354 | " The \"Corresponding Source\" for a work in object code form means all\n"
355 | "the source code needed to generate, install, and (for an executable\n"
356 | "work) run the object code and to modify the work, including scripts to\n"
357 | "control those activities. However, it does not include the work's\n"
358 | "System Libraries, or general-purpose tools or generally available free\n"
359 | "programs which are used unmodified in performing those activities but\n"
360 | "which are not part of the work. For example, Corresponding Source\n"
361 | "includes interface definition files associated with source files for\n"
362 | "the work, and the source code for shared libraries and dynamically\n"
363 | "linked subprograms that the work is specifically designed to require,\n"
364 | "such as by intimate data communication or control flow between those\n"
365 | "subprograms and other parts of the work.\n"
366 | "\n"
367 | " The Corresponding Source need not include anything that users\n"
368 | "can regenerate automatically from other parts of the Corresponding\n"
369 | "Source.\n"
370 | "\n"
371 | " The Corresponding Source for a work in source code form is that\n"
372 | "same work.\n"
373 | "\n"
374 | " 2. Basic Permissions.\n"
375 | "\n"
376 | " All rights granted under this License are granted for the term of\n"
377 | "copyright on the Program, and are irrevocable provided the stated\n"
378 | "conditions are met. This License explicitly affirms your unlimited\n"
379 | "permission to run the unmodified Program. The output from running a\n"
380 | "covered work is covered by this License only if the output, given its\n"
381 | "content, constitutes a covered work. This License acknowledges your\n"
382 | "rights of fair use or other equivalent, as provided by copyright law.\n"
383 | "\n"
384 | " You may make, run and propagate covered works that you do not\n"
385 | "convey, without conditions so long as your license otherwise remains\n"
386 | "in force. You may convey covered works to others for the sole purpose\n"
387 | "of having them make modifications exclusively for you, or provide you\n"
388 | "with facilities for running those works, provided that you comply with\n"
389 | "the terms of this License in conveying all material for which you do\n"
390 | "not control copyright. Those thus making or running the covered works\n"
391 | "for you must do so exclusively on your behalf, under your direction\n"
392 | "and control, on terms that prohibit them from making any copies of\n"
393 | "your copyrighted material outside their relationship with you.\n"
394 | "\n"
395 | " Conveying under any other circumstances is permitted solely under\n"
396 | "the conditions stated below. Sublicensing is not allowed; section 10\n"
397 | "makes it unnecessary.\n"
398 | "\n"
399 | " 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n"
400 | "\n"
401 | " No covered work shall be deemed part of an effective technological\n"
402 | "measure under any applicable law fulfilling obligations under article\n"
403 | "11 of the WIPO copyright treaty adopted on 20 December 1996, or\n"
404 | "similar laws prohibiting or restricting circumvention of such\n"
405 | "measures.\n"
406 | "\n"
407 | " When you convey a covered work, you waive any legal power to forbid\n"
408 | "circumvention of technological measures to the extent such circumvention\n"
409 | "is effected by exercising rights under this License with respect to\n"
410 | "the covered work, and you disclaim any intention to limit operation or\n"
411 | "modification of the work as a means of enforcing, against the work's\n"
412 | "users, your or third parties' legal rights to forbid circumvention of\n"
413 | "technological measures.\n"
414 | "\n"
415 | " 4. Conveying Verbatim Copies.\n"
416 | "\n"
417 | " You may convey verbatim copies of the Program's source code as you\n"
418 | "receive it, in any medium, provided that you conspicuously and\n"
419 | "appropriately publish on each copy an appropriate copyright notice;\n"
420 | "keep intact all notices stating that this License and any\n"
421 | "non-permissive terms added in accord with section 7 apply to the code;\n"
422 | "keep intact all notices of the absence of any warranty; and give all\n"
423 | "recipients a copy of this License along with the Program.\n"
424 | "\n"
425 | " You may charge any price or no price for each copy that you convey,\n"
426 | "and you may offer support or warranty protection for a fee.\n"
427 | "\n"
428 | " 5. Conveying Modified Source Versions.\n"
429 | "\n"
430 | " You may convey a work based on the Program, or the modifications to\n"
431 | "produce it from the Program, in the form of source code under the\n"
432 | "terms of section 4, provided that you also meet all of these conditions:\n"
433 | "\n"
434 | " a) The work must carry prominent notices stating that you modified\n"
435 | " it, and giving a relevant date.\n"
436 | "\n"
437 | " b) The work must carry prominent notices stating that it is\n"
438 | " released under this License and any conditions added under section\n"
439 | " 7. This requirement modifies the requirement in section 4 to\n"
440 | " \"keep intact all notices\".\n"
441 | "\n"
442 | " c) You must license the entire work, as a whole, under this\n"
443 | " License to anyone who comes into possession of a copy. This\n"
444 | " License will therefore apply, along with any applicable section 7\n"
445 | " additional terms, to the whole of the work, and all its parts,\n"
446 | " regardless of how they are packaged. This License gives no\n"
447 | " permission to license the work in any other way, but it does not\n"
448 | " invalidate such permission if you have separately received it.\n"
449 | "\n"
450 | " d) If the work has interactive user interfaces, each must display\n"
451 | " Appropriate Legal Notices; however, if the Program has interactive\n"
452 | " interfaces that do not display Appropriate Legal Notices, your\n"
453 | " work need not make them do so.\n"
454 | "\n"
455 | " A compilation of a covered work with other separate and independent\n"
456 | "works, which are not by their nature extensions of the covered work,\n"
457 | "and which are not combined with it such as to form a larger program,\n"
458 | "in or on a volume of a storage or distribution medium, is called an\n"
459 | "\"aggregate\" if the compilation and its resulting copyright are not\n"
460 | "used to limit the access or legal rights of the compilation's users\n"
461 | "beyond what the individual works permit. Inclusion of a covered work\n"
462 | "in an aggregate does not cause this License to apply to the other\n"
463 | "parts of the aggregate.\n"
464 | "\n"
465 | " 6. Conveying Non-Source Forms.\n"
466 | "\n"
467 | " You may convey a covered work in object code form under the terms\n"
468 | "of sections 4 and 5, provided that you also convey the\n"
469 | "machine-readable Corresponding Source under the terms of this License,\n"
470 | "in one of these ways:\n"
471 | "\n"
472 | " a) Convey the object code in, or embodied in, a physical product\n"
473 | " (including a physical distribution medium), accompanied by the\n"
474 | " Corresponding Source fixed on a durable physical medium\n"
475 | " customarily used for software interchange.\n"
476 | "\n"
477 | " b) Convey the object code in, or embodied in, a physical product\n"
478 | " (including a physical distribution medium), accompanied by a\n"
479 | " written offer, valid for at least three years and valid for as\n"
480 | " long as you offer spare parts or customer support for that product\n"
481 | " model, to give anyone who possesses the object code either (1) a\n"
482 | " copy of the Corresponding Source for all the software in the\n"
483 | " product that is covered by this License, on a durable physical\n"
484 | " medium customarily used for software interchange, for a price no\n"
485 | " more than your reasonable cost of physically performing this\n"
486 | " conveying of source, or (2) access to copy the\n"
487 | " Corresponding Source from a network server at no charge.\n"
488 | "\n"
489 | " c) Convey individual copies of the object code with a copy of the\n"
490 | " written offer to provide the Corresponding Source. This\n"
491 | " alternative is allowed only occasionally and noncommercially, and\n"
492 | " only if you received the object code with such an offer, in accord\n"
493 | " with subsection 6b.\n"
494 | "\n"
495 | " d) Convey the object code by offering access from a designated\n"
496 | " place (gratis or for a charge), and offer equivalent access to the\n"
497 | " Corresponding Source in the same way through the same place at no\n"
498 | " further charge. You need not require recipients to copy the\n"
499 | " Corresponding Source along with the object code. If the place to\n"
500 | " copy the object code is a network server, the Corresponding Source\n"
501 | " may be on a different server (operated by you or a third party)\n"
502 | " that supports equivalent copying facilities, provided you maintain\n"
503 | " clear directions next to the object code saying where to find the\n"
504 | " Corresponding Source. Regardless of what server hosts the\n"
505 | " Corresponding Source, you remain obligated to ensure that it is\n"
506 | " available for as long as needed to satisfy these requirements.\n"
507 | "\n"
508 | " e) Convey the object code using peer-to-peer transmission, provided\n"
509 | " you inform other peers where the object code and Corresponding\n"
510 | " Source of the work are being offered to the general public at no\n"
511 | " charge under subsection 6d.\n"
512 | "\n"
513 | " A separable portion of the object code, whose source code is excluded\n"
514 | "from the Corresponding Source as a System Library, need not be\n"
515 | "included in conveying the object code work.\n"
516 | "\n"
517 | " A \"User Product\" is either (1) a \"consumer product\", which means any\n"
518 | "tangible personal property which is normally used for personal, family,\n"
519 | "or household purposes, or (2) anything designed or sold for incorporation\n"
520 | "into a dwelling. In determining whether a product is a consumer product,\n"
521 | "doubtful cases shall be resolved in favor of coverage. For a particular\n"
522 | "product received by a particular user, \"normally used\" refers to a\n"
523 | "typical or common use of that class of product, regardless of the status\n"
524 | "of the particular user or of the way in which the particular user\n"
525 | "actually uses, or expects or is expected to use, the product. A product\n"
526 | "is a consumer product regardless of whether the product has substantial\n"
527 | "commercial, industrial or non-consumer uses, unless such uses represent\n"
528 | "the only significant mode of use of the product.\n"
529 | "\n"
530 | " \"Installation Information\" for a User Product means any methods,\n"
531 | "procedures, authorization keys, or other information required to install\n"
532 | "and execute modified versions of a covered work in that User Product from\n"
533 | "a modified version of its Corresponding Source. The information must\n"
534 | "suffice to ensure that the continued functioning of the modified object\n"
535 | "code is in no case prevented or interfered with solely because\n"
536 | "modification has been made.\n"
537 | "\n"
538 | " If you convey an object code work under this section in, or with, or\n"
539 | "specifically for use in, a User Product, and the conveying occurs as\n"
540 | "part of a transaction in which the right of possession and use of the\n"
541 | "User Product is transferred to the recipient in perpetuity or for a\n"
542 | "fixed term (regardless of how the transaction is characterized), the\n"
543 | "Corresponding Source conveyed under this section must be accompanied\n"
544 | "by the Installation Information. But this requirement does not apply\n"
545 | "if neither you nor any third party retains the ability to install\n"
546 | "modified object code on the User Product (for example, the work has\n"
547 | "been installed in ROM).\n"
548 | "\n"
549 | " The requirement to provide Installation Information does not include a\n"
550 | "requirement to continue to provide support service, warranty, or updates\n"
551 | "for a work that has been modified or installed by the recipient, or for\n"
552 | "the User Product in which it has been modified or installed. Access to a\n"
553 | "network may be denied when the modification itself materially and\n"
554 | "adversely affects the operation of the network or violates the rules and\n"
555 | "protocols for communication across the network.\n"
556 | "\n"
557 | " Corresponding Source conveyed, and Installation Information provided,\n"
558 | "in accord with this section must be in a format that is publicly\n"
559 | "documented (and with an implementation available to the public in\n"
560 | "source code form), and must require no special password or key for\n"
561 | "unpacking, reading or copying.\n"
562 | "\n"
563 | " 7. Additional Terms.\n"
564 | "\n"
565 | " \"Additional permissions\" are terms that supplement the terms of this\n"
566 | "License by making exceptions from one or more of its conditions.\n"
567 | "Additional permissions that are applicable to the entire Program shall\n"
568 | "be treated as though they were included in this License, to the extent\n"
569 | "that they are valid under applicable law. If additional permissions\n"
570 | "apply only to part of the Program, that part may be used separately\n"
571 | "under those permissions, but the entire Program remains governed by\n"
572 | "this License without regard to the additional permissions.\n"
573 | "\n"
574 | " When you convey a copy of a covered work, you may at your option\n"
575 | "remove any additional permissions from that copy, or from any part of\n"
576 | "it. (Additional permissions may be written to require their own\n"
577 | "removal in certain cases when you modify the work.) You may place\n"
578 | "additional permissions on material, added by you to a covered work,\n"
579 | "for which you have or can give appropriate copyright permission.\n"
580 | "\n"
581 | " Notwithstanding any other provision of this License, for material you\n"
582 | "add to a covered work, you may (if authorized by the copyright holders of\n"
583 | "that material) supplement the terms of this License with terms:\n"
584 | "\n"
585 | " a) Disclaiming warranty or limiting liability differently from the\n"
586 | " terms of sections 15 and 16 of this License; or\n"
587 | "\n"
588 | " b) Requiring preservation of specified reasonable legal notices or\n"
589 | " author attributions in that material or in the Appropriate Legal\n"
590 | " Notices displayed by works containing it; or\n"
591 | "\n"
592 | " c) Prohibiting misrepresentation of the origin of that material, or\n"
593 | " requiring that modified versions of such material be marked in\n"
594 | " reasonable ways as different from the original version; or\n"
595 | "\n"
596 | " d) Limiting the use for publicity purposes of names of licensors or\n"
597 | " authors of the material; or\n"
598 | "\n"
599 | " e) Declining to grant rights under trademark law for use of some\n"
600 | " trade names, trademarks, or service marks; or\n"
601 | "\n"
602 | " f) Requiring indemnification of licensors and authors of that\n"
603 | " material by anyone who conveys the material (or modified versions of\n"
604 | " it) with contractual assumptions of liability to the recipient, for\n"
605 | " any liability that these contractual assumptions directly impose on\n"
606 | " those licensors and authors.\n"
607 | "\n"
608 | " All other non-permissive additional terms are considered \"further\n"
609 | "restrictions\" within the meaning of section 10. If the Program as you\n"
610 | "received it, or any part of it, contains a notice stating that it is\n"
611 | "governed by this License along with a term that is a further\n"
612 | "restriction, you may remove that term. If a license document contains\n"
613 | "a further restriction but permits relicensing or conveying under this\n"
614 | "License, you may add to a covered work material governed by the terms\n"
615 | "of that license document, provided that the further restriction does\n"
616 | "not survive such relicensing or conveying.\n"
617 | "\n"
618 | " If you add terms to a covered work in accord with this section, you\n"
619 | "must place, in the relevant source files, a statement of the\n"
620 | "additional terms that apply to those files, or a notice indicating\n"
621 | "where to find the applicable terms.\n"
622 | "\n"
623 | " Additional terms, permissive or non-permissive, may be stated in the\n"
624 | "form of a separately written license, or stated as exceptions;\n"
625 | "the above requirements apply either way.\n"
626 | "\n"
627 | " 8. Termination.\n"
628 | "\n"
629 | " You may not propagate or modify a covered work except as expressly\n"
630 | "provided under this License. Any attempt otherwise to propagate or\n"
631 | "modify it is void, and will automatically terminate your rights under\n"
632 | "this License (including any patent licenses granted under the third\n"
633 | "paragraph of section 11).\n"
634 | "\n"
635 | " However, if you cease all violation of this License, then your\n"
636 | "license from a particular copyright holder is reinstated (a)\n"
637 | "provisionally, unless and until the copyright holder explicitly and\n"
638 | "finally terminates your license, and (b) permanently, if the copyright\n"
639 | "holder fails to notify you of the violation by some reasonable means\n"
640 | "prior to 60 days after the cessation.\n"
641 | "\n"
642 | " Moreover, your license from a particular copyright holder is\n"
643 | "reinstated permanently if the copyright holder notifies you of the\n"
644 | "violation by some reasonable means, this is the first time you have\n"
645 | "received notice of violation of this License (for any work) from that\n"
646 | "copyright holder, and you cure the violation prior to 30 days after\n"
647 | "your receipt of the notice.\n"
648 | "\n"
649 | " Termination of your rights under this section does not terminate the\n"
650 | "licenses of parties who have received copies or rights from you under\n"
651 | "this License. If your rights have been terminated and not permanently\n"
652 | "reinstated, you do not qualify to receive new licenses for the same\n"
653 | "material under section 10.\n"
654 | "\n"
655 | " 9. Acceptance Not Required for Having Copies.\n"
656 | "\n"
657 | " You are not required to accept this License in order to receive or\n"
658 | "run a copy of the Program. Ancillary propagation of a covered work\n"
659 | "occurring solely as a consequence of using peer-to-peer transmission\n"
660 | "to receive a copy likewise does not require acceptance. However,\n"
661 | "nothing other than this License grants you permission to propagate or\n"
662 | "modify any covered work. These actions infringe copyright if you do\n"
663 | "not accept this License. Therefore, by modifying or propagating a\n"
664 | "covered work, you indicate your acceptance of this License to do so.\n"
665 | "\n"
666 | " 10. Automatic Licensing of Downstream Recipients.\n"
667 | "\n"
668 | " Each time you convey a covered work, the recipient automatically\n"
669 | "receives a license from the original licensors, to run, modify and\n"
670 | "propagate that work, subject to this License. You are not responsible\n"
671 | "for enforcing compliance by third parties with this License.\n"
672 | "\n"
673 | " An \"entity transaction\" is a transaction transferring control of an\n"
674 | "organization, or substantially all assets of one, or subdividing an\n"
675 | "organization, or merging organizations. If propagation of a covered\n"
676 | "work results from an entity transaction, each party to that\n"
677 | "transaction who receives a copy of the work also receives whatever\n"
678 | "licenses to the work the party's predecessor in interest had or could\n"
679 | "give under the previous paragraph, plus a right to possession of the\n"
680 | "Corresponding Source of the work from the predecessor in interest, if\n"
681 | "the predecessor has it or can get it with reasonable efforts.\n"
682 | "\n"
683 | " You may not impose any further restrictions on the exercise of the\n"
684 | "rights granted or affirmed under this License. For example, you may\n"
685 | "not impose a license fee, royalty, or other charge for exercise of\n"
686 | "rights granted under this License, and you may not initiate litigation\n"
687 | "(including a cross-claim or counterclaim in a lawsuit) alleging that\n"
688 | "any patent claim is infringed by making, using, selling, offering for\n"
689 | "sale, or importing the Program or any portion of it.\n"
690 | "\n"
691 | " 11. Patents.\n"
692 | "\n"
693 | " A \"contributor\" is a copyright holder who authorizes use under this\n"
694 | "License of the Program or a work on which the Program is based. The\n"
695 | "work thus licensed is called the contributor's \"contributor version\".\n"
696 | "\n"
697 | " A contributor's \"essential patent claims\" are all patent claims\n"
698 | "owned or controlled by the contributor, whether already acquired or\n"
699 | "hereafter acquired, that would be infringed by some manner, permitted\n"
700 | "by this License, of making, using, or selling its contributor version,\n"
701 | "but do not include claims that would be infringed only as a\n"
702 | "consequence of further modification of the contributor version. For\n"
703 | "purposes of this definition, \"control\" includes the right to grant\n"
704 | "patent sublicenses in a manner consistent with the requirements of\n"
705 | "this License.\n"
706 | "\n"
707 | " Each contributor grants you a non-exclusive, worldwide, royalty-free\n"
708 | "patent license under the contributor's essential patent claims, to\n"
709 | "make, use, sell, offer for sale, import and otherwise run, modify and\n"
710 | "propagate the contents of its contributor version.\n"
711 | "\n"
712 | " In the following three paragraphs, a \"patent license\" is any express\n"
713 | "agreement or commitment, however denominated, not to enforce a patent\n"
714 | "(such as an express permission to practice a patent or covenant not to\n"
715 | "sue for patent infringement). To \"grant\" such a patent license to a\n"
716 | "party means to make such an agreement or commitment not to enforce a\n"
717 | "patent against the party.\n"
718 | "\n"
719 | " If you convey a covered work, knowingly relying on a patent license,\n"
720 | "and the Corresponding Source of the work is not available for anyone\n"
721 | "to copy, free of charge and under the terms of this License, through a\n"
722 | "publicly available network server or other readily accessible means,\n"
723 | "then you must either (1) cause the Corresponding Source to be so\n"
724 | "available, or (2) arrange to deprive yourself of the benefit of the\n"
725 | "patent license for this particular work, or (3) arrange, in a manner\n"
726 | "consistent with the requirements of this License, to extend the patent\n"
727 | "license to downstream recipients. \"Knowingly relying\" means you have\n"
728 | "actual knowledge that, but for the patent license, your conveying the\n"
729 | "covered work in a country, or your recipient's use of the covered work\n"
730 | "in a country, would infringe one or more identifiable patents in that\n"
731 | "country that you have reason to believe are valid.\n"
732 | "\n"
733 | " If, pursuant to or in connection with a single transaction or\n"
734 | "arrangement, you convey, or propagate by procuring conveyance of, a\n"
735 | "covered work, and grant a patent license to some of the parties\n"
736 | "receiving the covered work authorizing them to use, propagate, modify\n"
737 | "or convey a specific copy of the covered work, then the patent license\n"
738 | "you grant is automatically extended to all recipients of the covered\n"
739 | "work and works based on it.\n"
740 | "\n"
741 | " A patent license is \"discriminatory\" if it does not include within\n"
742 | "the scope of its coverage, prohibits the exercise of, or is\n"
743 | "conditioned on the non-exercise of one or more of the rights that are\n"
744 | "specifically granted under this License. You may not convey a covered\n"
745 | "work if you are a party to an arrangement with a third party that is\n"
746 | "in the business of distributing software, under which you make payment\n"
747 | "to the third party based on the extent of your activity of conveying\n"
748 | "the work, and under which the third party grants, to any of the\n"
749 | "parties who would receive the covered work from you, a discriminatory\n"
750 | "patent license (a) in connection with copies of the covered work\n"
751 | "conveyed by you (or copies made from those copies), or (b) primarily\n"
752 | "for and in connection with specific products or compilations that\n"
753 | "contain the covered work, unless you entered into that arrangement,\n"
754 | "or that patent license was granted, prior to 28 March 2007.\n"
755 | "\n"
756 | " Nothing in this License shall be construed as excluding or limiting\n"
757 | "any implied license or other defenses to infringement that may\n"
758 | "otherwise be available to you under applicable patent law.\n"
759 | "\n"
760 | " 12. No Surrender of Others' Freedom.\n"
761 | "\n"
762 | " If conditions are imposed on you (whether by court order, agreement or\n"
763 | "otherwise) that contradict the conditions of this License, they do not\n"
764 | "excuse you from the conditions of this License. If you cannot convey a\n"
765 | "covered work so as to satisfy simultaneously your obligations under this\n"
766 | "License and any other pertinent obligations, then as a consequence you may\n"
767 | "not convey it at all. For example, if you agree to terms that obligate you\n"
768 | "to collect a royalty for further conveying from those to whom you convey\n"
769 | "the Program, the only way you could satisfy both those terms and this\n"
770 | "License would be to refrain entirely from conveying the Program.\n"
771 | "\n"
772 | " 13. Use with the GNU Affero General Public License.\n"
773 | "\n"
774 | " Notwithstanding any other provision of this License, you have\n"
775 | "permission to link or combine any covered work with a work licensed\n"
776 | "under version 3 of the GNU Affero General Public License into a single\n"
777 | "combined work, and to convey the resulting work. The terms of this\n"
778 | "License will continue to apply to the part which is the covered work,\n"
779 | "but the special requirements of the GNU Affero General Public License,\n"
780 | "section 13, concerning interaction through a network will apply to the\n"
781 | "combination as such.\n"
782 | "\n"
783 | " 14. Revised Versions of this License.\n"
784 | "\n"
785 | " The Free Software Foundation may publish revised and/or new versions of\n"
786 | "the GNU General Public License from time to time. Such new versions will\n"
787 | "be similar in spirit to the present version, but may differ in detail to\n"
788 | "address new problems or concerns.\n"
789 | "\n"
790 | " Each version is given a distinguishing version number. If the\n"
791 | "Program specifies that a certain numbered version of the GNU General\n"
792 | "Public License \"or any later version\" applies to it, you have the\n"
793 | "option of following the terms and conditions either of that numbered\n"
794 | "version or of any later version published by the Free Software\n"
795 | "Foundation. If the Program does not specify a version number of the\n"
796 | "GNU General Public License, you may choose any version ever published\n"
797 | "by the Free Software Foundation.\n"
798 | "\n"
799 | " If the Program specifies that a proxy can decide which future\n"
800 | "versions of the GNU General Public License can be used, that proxy's\n"
801 | "public statement of acceptance of a version permanently authorizes you\n"
802 | "to choose that version for the Program.\n"
803 | "\n"
804 | " Later license versions may give you additional or different\n"
805 | "permissions. However, no additional obligations are imposed on any\n"
806 | "author or copyright holder as a result of your choosing to follow a\n"
807 | "later version.\n"
808 | "\n"
809 | " 15. Disclaimer of Warranty.\n"
810 | "\n"
811 | " THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n"
812 | "APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n"
813 | "HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\n"
814 | "OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n"
815 | "THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n"
816 | "PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n"
817 | "IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n"
818 | "ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n"
819 | "\n"
820 | " 16. Limitation of Liability.\n"
821 | "\n"
822 | " IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n"
823 | "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n"
824 | "THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n"
825 | "GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n"
826 | "USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n"
827 | "DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n"
828 | "PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n"
829 | "EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n"
830 | "SUCH DAMAGES.\n"
831 | "\n"
832 | " 17. Interpretation of Sections 15 and 16.\n"
833 | "\n"
834 | " If the disclaimer of warranty and limitation of liability provided\n"
835 | "above cannot be given local legal effect according to their terms,\n"
836 | "reviewing courts shall apply local law that most closely approximates\n"
837 | "an absolute waiver of all civil liability in connection with the\n"
838 | "Program, unless a warranty or assumption of liability accompanies a\n"
839 | "copy of the Program in return for a fee.\n"
840 | "\n"
841 | " END OF TERMS AND CONDITIONS";
842 |
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | PerMonitor
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #include "winres.h"
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | #undef APSTUDIO_READONLY_SYMBOLS
14 |
15 | /////////////////////////////////////////////////////////////////////////////
16 | // Deutsch (Deutschland) resources
17 |
18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
19 | LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
20 | #pragma code_page(1252)
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_ICON1 ICON "..\\res\\Irec.ico"
56 |
57 | #endif // Deutsch (Deutschland) resources
58 | /////////////////////////////////////////////////////////////////////////////
59 |
60 |
61 |
62 | #ifndef APSTUDIO_INVOKED
63 | /////////////////////////////////////////////////////////////////////////////
64 | //
65 | // Generated from the TEXTINCLUDE 3 resource.
66 | //
67 |
68 |
69 | /////////////////////////////////////////////////////////////////////////////
70 | #endif // not APSTUDIO_INVOKED
71 |
72 |
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32210.238
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MacroPlayer", "MacroPlayer.vcxproj", "{680A294F-175A-41A9-B5EF-28BDCCEA4DB2}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Debug|x64.ActiveCfg = Debug|x64
17 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Debug|x64.Build.0 = Debug|x64
18 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Debug|x86.ActiveCfg = Debug|Win32
19 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Debug|x86.Build.0 = Debug|Win32
20 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Release|x64.ActiveCfg = Release|x64
21 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Release|x64.Build.0 = Release|x64
22 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Release|x86.ActiveCfg = Release|Win32
23 | {680A294F-175A-41A9-B5EF-28BDCCEA4DB2}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {25B58F1B-0CD5-4E58-900D-D5D3B82F855B}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {680a294f-175a-41a9-b5ef-28bdccea4db2}
25 | MacroPlayer
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v143
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v143
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v143
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v143
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | false
78 |
79 |
80 | true
81 |
82 |
83 | false
84 |
85 |
86 |
87 | Level3
88 | true
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 | ..\zlib
92 |
93 |
94 | Console
95 | true
96 | zlibstaticd.lib;%(AdditionalDependencies)
97 | ..\zlib\build\Debug;%(AdditionalLibraryDirectories)
98 |
99 |
100 |
101 |
102 | Level3
103 | true
104 | true
105 | true
106 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
107 | true
108 | ..\zlib;%(AdditionalIncludeDirectories)
109 | MultiThreadedDLL
110 | Speed
111 |
112 |
113 | Console
114 | true
115 | true
116 | true
117 | ..\zlib\build\Release;%(AdditionalLibraryDirectories)
118 | zlibstatic.lib;%(AdditionalDependencies)
119 |
120 |
121 | MacroPlayer.exe.manifest %(AdditionalManifestFiles)
122 |
123 |
124 |
125 |
126 | Level3
127 | true
128 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
129 | true
130 | ..\zlib
131 |
132 |
133 | Console
134 | true
135 | zlibstaticd.lib;%(AdditionalDependencies)
136 | ..\zlib\build64\Debug;%(AdditionalLibraryDirectories)
137 |
138 |
139 |
140 |
141 | Level3
142 | true
143 | true
144 | true
145 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
146 | true
147 | ..\zlib;%(AdditionalIncludeDirectories)
148 | MultiThreadedDLL
149 | MaxSpeed
150 | Speed
151 |
152 |
153 | Console
154 | true
155 | true
156 | true
157 | ..\zlib\build64\Release;%(AdditionalLibraryDirectories)
158 | zlibstatic.lib;%(AdditionalDependencies)
159 |
160 |
161 | MacroPlayer.exe.manifest %(AdditionalManifestFiles)
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Quelldateien
20 |
21 |
22 |
23 |
24 | Headerdateien
25 |
26 |
27 | Headerdateien
28 |
29 |
30 | Headerdateien
31 |
32 |
33 | Headerdateien
34 |
35 |
36 |
37 |
38 | Ressourcendateien
39 |
40 |
41 |
42 |
43 | Ressourcendateien
44 |
45 |
46 |
47 |
48 | Ressourcendateien
49 |
50 |
51 |
--------------------------------------------------------------------------------
/MacroPlayer/MacroPlayer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MacroPlayer/macro.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #pragma once
21 |
22 | #include
23 | #include
24 |
25 | #include "winput.h"
26 |
27 | #define MACRO_INVALID_FORMAT -1
28 | #define MACRO_NON_SINGLE -2
29 | #define MACRO_INCOMPATIBLE -3
30 | #define MACRO_EMPTY -4
31 |
32 | #pragma pack(1)
33 |
34 | enum class PlaybackMode {PLAY, EXPLAIN};
35 |
36 | struct MacroConfig {
37 |
38 | static const byte VERSION = 1;
39 |
40 | byte version = VERSION;
41 |
42 | unsigned short screen_width;
43 |
44 | unsigned short screen_height;
45 | };
46 |
47 | struct MacroEvent {
48 | byte bytecode;
49 | };
50 |
51 | struct RawMousePositionEvent {
52 | byte bytecode = 'P';
53 |
54 | short x;
55 |
56 | short y;
57 |
58 | };
59 |
60 | struct MousePositionEvent {
61 | byte bytecode = 'P';
62 |
63 | MacroConfig config;
64 |
65 | short x;
66 |
67 | short y;
68 |
69 | MousePositionEvent(MacroConfig config, RawMousePositionEvent* bytes)
70 | : config{ config }, x{ bytes->x }, y{ bytes->y } {
71 |
72 | }
73 |
74 | void run() {
75 | set_mouse_pos(x, y);
76 | }
77 |
78 | void explain(char* buf, const size_t buf_size) {
79 | snprintf(buf, buf_size, "Set mouse position to (%d, %d)", (int)x, (int)y);
80 | }
81 |
82 | };
83 |
84 | struct MouseWheelMoveEvent {
85 | byte bytecode = 'V';
86 |
87 | char amount;
88 |
89 | void run() {
90 | move_mousewheel(amount);
91 | }
92 |
93 | void explain(char* buf, const size_t buf_size) {
94 | snprintf(buf, buf_size, "Move mousewheel by %d", (int)amount);
95 | }
96 | };
97 |
98 | struct MouseWheelHorizontalMoveEvent {
99 | byte bytecode = 'H';
100 |
101 | char amount;
102 |
103 | void run() {
104 | move_mousewheel_horizontal(amount);
105 | }
106 |
107 | void explain(char* buf, const size_t buf_size) {
108 | snprintf(buf, buf_size, "Move mousewheel horizontally by %d", (int)amount);
109 | }
110 | };
111 |
112 | struct MouseButtonPressEvent {
113 | byte bytecode = 'B';
114 |
115 | byte mouse_button;
116 |
117 | void run() {
118 | press_mouse_button(mouse_button);
119 | }
120 |
121 | void explain(char* buf, const size_t buf_size) {
122 | snprintf(buf, buf_size, "Press mouse button %d", (int)mouse_button);
123 | }
124 | };
125 |
126 | struct MouseButtonReleaseEvent {
127 | byte bytecode = 'b';
128 |
129 | byte mouse_button;
130 |
131 | void run() {
132 | release_mouse_button(mouse_button);
133 | }
134 |
135 | void explain(char* buf, const size_t buf_size) {
136 | snprintf(buf, buf_size, "Release mouse button %d", (int)mouse_button);
137 | }
138 | };
139 |
140 | struct KeyPressEvent {
141 | byte bytecode = 'K';
142 |
143 | WORD vk_code;
144 |
145 | void run() {
146 | press_key(vk_code);
147 | }
148 |
149 | void explain(char* buf, const size_t buf_size) {
150 | snprintf(buf, buf_size, "Press key %d", (int)vk_code);
151 | }
152 | };
153 |
154 | struct KeyReleaseEvent {
155 | byte bytecode = 'k';
156 |
157 | WORD vk_code;
158 |
159 | void run() {
160 | release_key(vk_code);
161 | }
162 |
163 | void explain(char* buf, const size_t buf_size) {
164 | snprintf(buf, buf_size, "Release key %d", (int)vk_code);
165 | }
166 | };
167 |
168 | int play_macro(unsigned int byte_count, byte* bytes, PlaybackMode mode) {
169 | if (byte_count < 1) {
170 | return MACRO_INVALID_FORMAT;
171 | }
172 |
173 | unsigned int index = 0;
174 |
175 | if (bytes[index] == (byte)'M') {
176 | return MACRO_NON_SINGLE;
177 | }
178 |
179 | if (bytes[index++] != (byte)'S') {
180 | return MACRO_INVALID_FORMAT;
181 | }
182 |
183 | if (index == byte_count) {
184 | return MACRO_INVALID_FORMAT;
185 | }
186 |
187 | // macro name
188 | byte name_length = bytes[index++];
189 | if (name_length <= 0 || index + name_length >= byte_count) {
190 | return MACRO_INVALID_FORMAT;
191 | }
192 |
193 | index += name_length;
194 |
195 | // macro config
196 | if (index + 1 + sizeof(MacroConfig) > byte_count || bytes[index] != sizeof(MacroConfig)) {
197 | return MACRO_INVALID_FORMAT;
198 | }
199 | index++;
200 | if (bytes[index] != MacroConfig::VERSION) {
201 | return MACRO_INCOMPATIBLE;
202 | }
203 | MacroConfig config = *(MacroConfig*)(bytes + index);
204 |
205 | index += sizeof(config);
206 |
207 | if (index == byte_count) {
208 | return MACRO_EMPTY;
209 | }
210 |
211 | auto start_time = std::chrono::high_resolution_clock::now();
212 |
213 | unsigned long long last_time_offset = 0;
214 |
215 | while (index < byte_count) {
216 | byte length = bytes[index++];
217 | if (index + length > byte_count) {
218 | return MACRO_INVALID_FORMAT;
219 | }
220 |
221 | unsigned long long time_offset = *(unsigned long long*)(bytes + index);
222 | index += sizeof(time_offset);
223 | byte bytecode = bytes[index];
224 |
225 | if (mode == PlaybackMode::PLAY) {
226 | long long diff;
227 |
228 | while ((diff = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start_time).count()) < (long long)time_offset) {
229 | long long time_to_wait = max(time_offset - diff - 1000000, 100000);
230 | std::this_thread::sleep_for(std::chrono::nanoseconds(time_to_wait));
231 | }
232 | }
233 | else if (mode == PlaybackMode::EXPLAIN) {
234 | unsigned long long diff = time_offset - last_time_offset;
235 |
236 | last_time_offset = time_offset;
237 |
238 | std::cout << "Wait " << diff / 1000000 << "ms" << std::endl;
239 | }
240 |
241 |
242 | char buffer[256];
243 |
244 | switch (bytecode) {
245 | case 'P':
246 | if (mode == PlaybackMode::PLAY)
247 | MousePositionEvent(config, reinterpret_cast(bytes + index)).run();
248 | else if (mode == PlaybackMode::EXPLAIN)
249 | MousePositionEvent(config, reinterpret_cast(bytes + index)).explain(buffer, sizeof(buffer));
250 | break;
251 | case 'V':
252 | if (mode == PlaybackMode::PLAY)
253 | reinterpret_cast(bytes + index)->run();
254 | else if (mode == PlaybackMode::EXPLAIN)
255 | reinterpret_cast(bytes + index)->explain(buffer, sizeof(buffer));
256 | break;
257 | case 'H':
258 | if (mode == PlaybackMode::PLAY)
259 | reinterpret_cast(bytes + index)->run();
260 | else if (mode == PlaybackMode::EXPLAIN)
261 | reinterpret_cast(bytes + index)->explain(buffer, sizeof(buffer));
262 | break;
263 | case 'B':
264 | if (mode == PlaybackMode::PLAY)
265 | reinterpret_cast(bytes + index)->run();
266 | else if (mode == PlaybackMode::EXPLAIN)
267 | reinterpret_cast(bytes + index)->explain(buffer, sizeof(buffer));
268 | break;
269 | case 'b':
270 | if (mode == PlaybackMode::PLAY)
271 | reinterpret_cast(bytes + index)->run();
272 | else if (mode == PlaybackMode::EXPLAIN)
273 | reinterpret_cast(bytes + index)->explain(buffer, sizeof(buffer));
274 | break;
275 | case 'K':
276 | if (mode == PlaybackMode::PLAY)
277 | reinterpret_cast(bytes + index)->run();
278 | else if (mode == PlaybackMode::EXPLAIN)
279 | reinterpret_cast(bytes + index)->explain(buffer, sizeof(buffer));
280 | break;
281 | case 'k':
282 | if (mode == PlaybackMode::PLAY)
283 | reinterpret_cast(bytes + index)->run();
284 | else if (mode == PlaybackMode::EXPLAIN)
285 | reinterpret_cast(bytes + index)->explain(buffer, sizeof(buffer));
286 | break;
287 | default:
288 | return MACRO_INVALID_FORMAT;
289 | }
290 |
291 | if (mode == PlaybackMode::EXPLAIN)
292 | std::cout << buffer << std::endl;
293 |
294 | index += length - sizeof(time_offset);
295 | }
296 | return 0;
297 | }
298 |
--------------------------------------------------------------------------------
/MacroPlayer/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Von Microsoft Visual C++ generierte Includedatei.
3 | // Verwendet durch MacroPlayer.rc
4 | //
5 | #define IDI_ICON1 102
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 103
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/MacroPlayer/winput.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | #pragma once
21 |
22 | #include
23 |
24 | #define LEFT_MOUSE_BUTTON 1
25 | #define MIDDLE_MOUSE_BUTTON 2
26 | #define RIGHT_MOUSE_BUTTON 4
27 | #define EXTRA_MOUSE_BUTTON1 8
28 | #define EXTRA_MOUSE_BUTTON2 16
29 |
30 | inline void set_mouse_pos(int x, int y) {
31 | SetCursorPos(x, y);
32 | }
33 |
34 | inline void _issue_mouse_event(DWORD dwFlags, DWORD mouseData) {
35 | MOUSEINPUT mi = { 0, 0, mouseData, dwFlags };
36 |
37 | INPUT input = { INPUT_MOUSE, mi };
38 |
39 | SendInput(1, &input, sizeof(input));
40 | }
41 |
42 | inline void _issue_keyboard_event(WORD wVk, DWORD dwFlags) {
43 | KEYBDINPUT ki = { wVk, 0, dwFlags };
44 |
45 | INPUT input = { INPUT_KEYBOARD };
46 |
47 | input.ki = ki;
48 |
49 | SendInput(1, &input, sizeof(input));
50 | }
51 |
52 | inline void press_mouse_button(int mouse_button) {
53 | DWORD dwFlags;
54 |
55 | switch (mouse_button) {
56 | case LEFT_MOUSE_BUTTON:
57 | dwFlags = 0x02;
58 | break;
59 | case MIDDLE_MOUSE_BUTTON:
60 | dwFlags = 0x08;
61 | break;
62 | case RIGHT_MOUSE_BUTTON:
63 | dwFlags = 0x20;
64 | break;
65 | case EXTRA_MOUSE_BUTTON1:
66 | case EXTRA_MOUSE_BUTTON2:
67 | dwFlags = 0x80;
68 | break;
69 |
70 | default:
71 | dwFlags = 0;
72 | break;
73 | }
74 |
75 | DWORD mouseData;
76 |
77 | if (dwFlags == 0x80) {
78 | if (mouse_button == EXTRA_MOUSE_BUTTON1) {
79 | mouseData = 0x1;
80 | }
81 | else {
82 | mouseData = 0x2;
83 | }
84 | }
85 | else {
86 | mouseData = 0;
87 | }
88 |
89 | _issue_mouse_event(dwFlags, mouseData);
90 | }
91 |
92 | inline void release_mouse_button(int mouse_button) {
93 | DWORD dwFlags;
94 |
95 | switch (mouse_button) {
96 | case LEFT_MOUSE_BUTTON:
97 | dwFlags = 0x004;
98 | break;
99 | case MIDDLE_MOUSE_BUTTON:
100 | dwFlags = 0x010;
101 | break;
102 | case RIGHT_MOUSE_BUTTON:
103 | dwFlags = 0x040;
104 | break;
105 | case EXTRA_MOUSE_BUTTON1:
106 | case EXTRA_MOUSE_BUTTON2:
107 | dwFlags = 0x100;
108 | break;
109 |
110 | default:
111 | dwFlags = 0;
112 | break;
113 | }
114 |
115 | DWORD mouseData;
116 |
117 | if (dwFlags == 0x100) {
118 | if (mouse_button == EXTRA_MOUSE_BUTTON1) {
119 | mouseData = 0x1;
120 | }
121 | else {
122 | mouseData = 0x2;
123 | }
124 | }
125 | else {
126 | mouseData = 0;
127 | }
128 |
129 | _issue_mouse_event(dwFlags, mouseData);
130 | }
131 |
132 | inline void move_mousewheel(DWORD amount) {
133 | _issue_mouse_event(0x800, amount * 120);
134 | }
135 |
136 | inline void move_mousewheel_horizontal(DWORD amount) {
137 | _issue_mouse_event(0x1000, amount * 120);
138 | }
139 |
140 | inline void press_key(WORD vk_code) {
141 | _issue_keyboard_event(vk_code, 0);
142 | }
143 |
144 | inline void release_key(WORD vk_code) {
145 | _issue_keyboard_event(vk_code, KEYEVENTF_KEYUP);
146 | }
147 |
--------------------------------------------------------------------------------
/MacroPlayer/zconf.h:
--------------------------------------------------------------------------------
1 | /* zconf.h -- configuration of the zlib compression library
2 | * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
3 | * For conditions of distribution and use, see copyright notice in zlib.h
4 | */
5 |
6 | /* @(#) $Id$ */
7 |
8 | #ifndef ZCONF_H
9 | #define ZCONF_H
10 |
11 | /*
12 | * If you *really* need a unique prefix for all types and library functions,
13 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
14 | * Even better than compiling with -DZ_PREFIX would be to use configure to set
15 | * this permanently in zconf.h using "./configure --zprefix".
16 | */
17 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
18 | # define Z_PREFIX_SET
19 |
20 | /* all linked symbols and init macros */
21 | # define _dist_code z__dist_code
22 | # define _length_code z__length_code
23 | # define _tr_align z__tr_align
24 | # define _tr_flush_bits z__tr_flush_bits
25 | # define _tr_flush_block z__tr_flush_block
26 | # define _tr_init z__tr_init
27 | # define _tr_stored_block z__tr_stored_block
28 | # define _tr_tally z__tr_tally
29 | # define adler32 z_adler32
30 | # define adler32_combine z_adler32_combine
31 | # define adler32_combine64 z_adler32_combine64
32 | # define adler32_z z_adler32_z
33 | # ifndef Z_SOLO
34 | # define compress z_compress
35 | # define compress2 z_compress2
36 | # define compressBound z_compressBound
37 | # endif
38 | # define crc32 z_crc32
39 | # define crc32_combine z_crc32_combine
40 | # define crc32_combine64 z_crc32_combine64
41 | # define crc32_z z_crc32_z
42 | # define deflate z_deflate
43 | # define deflateBound z_deflateBound
44 | # define deflateCopy z_deflateCopy
45 | # define deflateEnd z_deflateEnd
46 | # define deflateGetDictionary z_deflateGetDictionary
47 | # define deflateInit z_deflateInit
48 | # define deflateInit2 z_deflateInit2
49 | # define deflateInit2_ z_deflateInit2_
50 | # define deflateInit_ z_deflateInit_
51 | # define deflateParams z_deflateParams
52 | # define deflatePending z_deflatePending
53 | # define deflatePrime z_deflatePrime
54 | # define deflateReset z_deflateReset
55 | # define deflateResetKeep z_deflateResetKeep
56 | # define deflateSetDictionary z_deflateSetDictionary
57 | # define deflateSetHeader z_deflateSetHeader
58 | # define deflateTune z_deflateTune
59 | # define deflate_copyright z_deflate_copyright
60 | # define get_crc_table z_get_crc_table
61 | # ifndef Z_SOLO
62 | # define gz_error z_gz_error
63 | # define gz_intmax z_gz_intmax
64 | # define gz_strwinerror z_gz_strwinerror
65 | # define gzbuffer z_gzbuffer
66 | # define gzclearerr z_gzclearerr
67 | # define gzclose z_gzclose
68 | # define gzclose_r z_gzclose_r
69 | # define gzclose_w z_gzclose_w
70 | # define gzdirect z_gzdirect
71 | # define gzdopen z_gzdopen
72 | # define gzeof z_gzeof
73 | # define gzerror z_gzerror
74 | # define gzflush z_gzflush
75 | # define gzfread z_gzfread
76 | # define gzfwrite z_gzfwrite
77 | # define gzgetc z_gzgetc
78 | # define gzgetc_ z_gzgetc_
79 | # define gzgets z_gzgets
80 | # define gzoffset z_gzoffset
81 | # define gzoffset64 z_gzoffset64
82 | # define gzopen z_gzopen
83 | # define gzopen64 z_gzopen64
84 | # ifdef _WIN32
85 | # define gzopen_w z_gzopen_w
86 | # endif
87 | # define gzprintf z_gzprintf
88 | # define gzputc z_gzputc
89 | # define gzputs z_gzputs
90 | # define gzread z_gzread
91 | # define gzrewind z_gzrewind
92 | # define gzseek z_gzseek
93 | # define gzseek64 z_gzseek64
94 | # define gzsetparams z_gzsetparams
95 | # define gztell z_gztell
96 | # define gztell64 z_gztell64
97 | # define gzungetc z_gzungetc
98 | # define gzvprintf z_gzvprintf
99 | # define gzwrite z_gzwrite
100 | # endif
101 | # define inflate z_inflate
102 | # define inflateBack z_inflateBack
103 | # define inflateBackEnd z_inflateBackEnd
104 | # define inflateBackInit z_inflateBackInit
105 | # define inflateBackInit_ z_inflateBackInit_
106 | # define inflateCodesUsed z_inflateCodesUsed
107 | # define inflateCopy z_inflateCopy
108 | # define inflateEnd z_inflateEnd
109 | # define inflateGetDictionary z_inflateGetDictionary
110 | # define inflateGetHeader z_inflateGetHeader
111 | # define inflateInit z_inflateInit
112 | # define inflateInit2 z_inflateInit2
113 | # define inflateInit2_ z_inflateInit2_
114 | # define inflateInit_ z_inflateInit_
115 | # define inflateMark z_inflateMark
116 | # define inflatePrime z_inflatePrime
117 | # define inflateReset z_inflateReset
118 | # define inflateReset2 z_inflateReset2
119 | # define inflateResetKeep z_inflateResetKeep
120 | # define inflateSetDictionary z_inflateSetDictionary
121 | # define inflateSync z_inflateSync
122 | # define inflateSyncPoint z_inflateSyncPoint
123 | # define inflateUndermine z_inflateUndermine
124 | # define inflateValidate z_inflateValidate
125 | # define inflate_copyright z_inflate_copyright
126 | # define inflate_fast z_inflate_fast
127 | # define inflate_table z_inflate_table
128 | # ifndef Z_SOLO
129 | # define uncompress z_uncompress
130 | # define uncompress2 z_uncompress2
131 | # endif
132 | # define zError z_zError
133 | # ifndef Z_SOLO
134 | # define zcalloc z_zcalloc
135 | # define zcfree z_zcfree
136 | # endif
137 | # define zlibCompileFlags z_zlibCompileFlags
138 | # define zlibVersion z_zlibVersion
139 |
140 | /* all zlib typedefs in zlib.h and zconf.h */
141 | # define Byte z_Byte
142 | # define Bytef z_Bytef
143 | # define alloc_func z_alloc_func
144 | # define charf z_charf
145 | # define free_func z_free_func
146 | # ifndef Z_SOLO
147 | # define gzFile z_gzFile
148 | # endif
149 | # define gz_header z_gz_header
150 | # define gz_headerp z_gz_headerp
151 | # define in_func z_in_func
152 | # define intf z_intf
153 | # define out_func z_out_func
154 | # define uInt z_uInt
155 | # define uIntf z_uIntf
156 | # define uLong z_uLong
157 | # define uLongf z_uLongf
158 | # define voidp z_voidp
159 | # define voidpc z_voidpc
160 | # define voidpf z_voidpf
161 |
162 | /* all zlib structs in zlib.h and zconf.h */
163 | # define gz_header_s z_gz_header_s
164 | # define internal_state z_internal_state
165 |
166 | #endif
167 |
168 | #if defined(__MSDOS__) && !defined(MSDOS)
169 | # define MSDOS
170 | #endif
171 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
172 | # define OS2
173 | #endif
174 | #if defined(_WINDOWS) && !defined(WINDOWS)
175 | # define WINDOWS
176 | #endif
177 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
178 | # ifndef WIN32
179 | # define WIN32
180 | # endif
181 | #endif
182 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
183 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
184 | # ifndef SYS16BIT
185 | # define SYS16BIT
186 | # endif
187 | # endif
188 | #endif
189 |
190 | /*
191 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
192 | * than 64k bytes at a time (needed on systems with 16-bit int).
193 | */
194 | #ifdef SYS16BIT
195 | # define MAXSEG_64K
196 | #endif
197 | #ifdef MSDOS
198 | # define UNALIGNED_OK
199 | #endif
200 |
201 | #ifdef __STDC_VERSION__
202 | # ifndef STDC
203 | # define STDC
204 | # endif
205 | # if __STDC_VERSION__ >= 199901L
206 | # ifndef STDC99
207 | # define STDC99
208 | # endif
209 | # endif
210 | #endif
211 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
212 | # define STDC
213 | #endif
214 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
215 | # define STDC
216 | #endif
217 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
218 | # define STDC
219 | #endif
220 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
221 | # define STDC
222 | #endif
223 |
224 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
225 | # define STDC
226 | #endif
227 |
228 | #ifndef STDC
229 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
230 | # define const /* note: need a more gentle solution here */
231 | # endif
232 | #endif
233 |
234 | #if defined(ZLIB_CONST) && !defined(z_const)
235 | # define z_const const
236 | #else
237 | # define z_const
238 | #endif
239 |
240 | #ifdef Z_SOLO
241 | typedef unsigned long z_size_t;
242 | #else
243 | # define z_longlong long long
244 | # if defined(NO_SIZE_T)
245 | typedef unsigned NO_SIZE_T z_size_t;
246 | # elif defined(STDC)
247 | # include
248 | typedef size_t z_size_t;
249 | # else
250 | typedef unsigned long z_size_t;
251 | # endif
252 | # undef z_longlong
253 | #endif
254 |
255 | /* Maximum value for memLevel in deflateInit2 */
256 | #ifndef MAX_MEM_LEVEL
257 | # ifdef MAXSEG_64K
258 | # define MAX_MEM_LEVEL 8
259 | # else
260 | # define MAX_MEM_LEVEL 9
261 | # endif
262 | #endif
263 |
264 | /* Maximum value for windowBits in deflateInit2 and inflateInit2.
265 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
266 | * created by gzip. (Files created by minigzip can still be extracted by
267 | * gzip.)
268 | */
269 | #ifndef MAX_WBITS
270 | # define MAX_WBITS 15 /* 32K LZ77 window */
271 | #endif
272 |
273 | /* The memory requirements for deflate are (in bytes):
274 | (1 << (windowBits+2)) + (1 << (memLevel+9))
275 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
276 | plus a few kilobytes for small objects. For example, if you want to reduce
277 | the default memory requirements from 256K to 128K, compile with
278 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
279 | Of course this will generally degrade compression (there's no free lunch).
280 |
281 | The memory requirements for inflate are (in bytes) 1 << windowBits
282 | that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
283 | for small objects.
284 | */
285 |
286 | /* Type declarations */
287 |
288 | #ifndef OF /* function prototypes */
289 | # ifdef STDC
290 | # define OF(args) args
291 | # else
292 | # define OF(args) ()
293 | # endif
294 | #endif
295 |
296 | #ifndef Z_ARG /* function prototypes for stdarg */
297 | # if defined(STDC) || defined(Z_HAVE_STDARG_H)
298 | # define Z_ARG(args) args
299 | # else
300 | # define Z_ARG(args) ()
301 | # endif
302 | #endif
303 |
304 | /* The following definitions for FAR are needed only for MSDOS mixed
305 | * model programming (small or medium model with some far allocations).
306 | * This was tested only with MSC; for other MSDOS compilers you may have
307 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
308 | * just define FAR to be empty.
309 | */
310 | #ifdef SYS16BIT
311 | # if defined(M_I86SM) || defined(M_I86MM)
312 | /* MSC small or medium model */
313 | # define SMALL_MEDIUM
314 | # ifdef _MSC_VER
315 | # define FAR _far
316 | # else
317 | # define FAR far
318 | # endif
319 | # endif
320 | # if (defined(__SMALL__) || defined(__MEDIUM__))
321 | /* Turbo C small or medium model */
322 | # define SMALL_MEDIUM
323 | # ifdef __BORLANDC__
324 | # define FAR _far
325 | # else
326 | # define FAR far
327 | # endif
328 | # endif
329 | #endif
330 |
331 | #if defined(WINDOWS) || defined(WIN32)
332 | /* If building or using zlib as a DLL, define ZLIB_DLL.
333 | * This is not mandatory, but it offers a little performance increase.
334 | */
335 | # ifdef ZLIB_DLL
336 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
337 | # ifdef ZLIB_INTERNAL
338 | # define ZEXTERN extern __declspec(dllexport)
339 | # else
340 | # define ZEXTERN extern __declspec(dllimport)
341 | # endif
342 | # endif
343 | # endif /* ZLIB_DLL */
344 | /* If building or using zlib with the WINAPI/WINAPIV calling convention,
345 | * define ZLIB_WINAPI.
346 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
347 | */
348 | # ifdef ZLIB_WINAPI
349 | # ifdef FAR
350 | # undef FAR
351 | # endif
352 | # include
353 | /* No need for _export, use ZLIB.DEF instead. */
354 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */
355 | # define ZEXPORT WINAPI
356 | # ifdef WIN32
357 | # define ZEXPORTVA WINAPIV
358 | # else
359 | # define ZEXPORTVA FAR CDECL
360 | # endif
361 | # endif
362 | #endif
363 |
364 | #if defined (__BEOS__)
365 | # ifdef ZLIB_DLL
366 | # ifdef ZLIB_INTERNAL
367 | # define ZEXPORT __declspec(dllexport)
368 | # define ZEXPORTVA __declspec(dllexport)
369 | # else
370 | # define ZEXPORT __declspec(dllimport)
371 | # define ZEXPORTVA __declspec(dllimport)
372 | # endif
373 | # endif
374 | #endif
375 |
376 | #ifndef ZEXTERN
377 | # define ZEXTERN extern
378 | #endif
379 | #ifndef ZEXPORT
380 | # define ZEXPORT
381 | #endif
382 | #ifndef ZEXPORTVA
383 | # define ZEXPORTVA
384 | #endif
385 |
386 | #ifndef FAR
387 | # define FAR
388 | #endif
389 |
390 | #if !defined(__MACTYPES__)
391 | typedef unsigned char Byte; /* 8 bits */
392 | #endif
393 | typedef unsigned int uInt; /* 16 bits or more */
394 | typedef unsigned long uLong; /* 32 bits or more */
395 |
396 | #ifdef SMALL_MEDIUM
397 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
398 | # define Bytef Byte FAR
399 | #else
400 | typedef Byte FAR Bytef;
401 | #endif
402 | typedef char FAR charf;
403 | typedef int FAR intf;
404 | typedef uInt FAR uIntf;
405 | typedef uLong FAR uLongf;
406 |
407 | #ifdef STDC
408 | typedef void const *voidpc;
409 | typedef void FAR *voidpf;
410 | typedef void *voidp;
411 | #else
412 | typedef Byte const *voidpc;
413 | typedef Byte FAR *voidpf;
414 | typedef Byte *voidp;
415 | #endif
416 |
417 | #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
418 | # include
419 | # if (UINT_MAX == 0xffffffffUL)
420 | # define Z_U4 unsigned
421 | # elif (ULONG_MAX == 0xffffffffUL)
422 | # define Z_U4 unsigned long
423 | # elif (USHRT_MAX == 0xffffffffUL)
424 | # define Z_U4 unsigned short
425 | # endif
426 | #endif
427 |
428 | #ifdef Z_U4
429 | typedef Z_U4 z_crc_t;
430 | #else
431 | typedef unsigned long z_crc_t;
432 | #endif
433 |
434 | #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
435 | # define Z_HAVE_UNISTD_H
436 | #endif
437 |
438 | #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
439 | # define Z_HAVE_STDARG_H
440 | #endif
441 |
442 | #ifdef STDC
443 | # ifndef Z_SOLO
444 | # include /* for off_t */
445 | # endif
446 | #endif
447 |
448 | #if defined(STDC) || defined(Z_HAVE_STDARG_H)
449 | # ifndef Z_SOLO
450 | # include /* for va_list */
451 | # endif
452 | #endif
453 |
454 | #ifdef _WIN32
455 | # ifndef Z_SOLO
456 | # include /* for wchar_t */
457 | # endif
458 | #endif
459 |
460 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
461 | * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
462 | * though the former does not conform to the LFS document), but considering
463 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
464 | * equivalently requesting no 64-bit operations
465 | */
466 | #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
467 | # undef _LARGEFILE64_SOURCE
468 | #endif
469 |
470 | #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
471 | # define Z_HAVE_UNISTD_H
472 | #endif
473 | #ifndef Z_SOLO
474 | # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
475 | # include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
476 | # ifdef VMS
477 | # include /* for off_t */
478 | # endif
479 | # ifndef z_off_t
480 | # define z_off_t off_t
481 | # endif
482 | # endif
483 | #endif
484 |
485 | #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
486 | # define Z_LFS64
487 | #endif
488 |
489 | #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
490 | # define Z_LARGE64
491 | #endif
492 |
493 | #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
494 | # define Z_WANT64
495 | #endif
496 |
497 | #if !defined(SEEK_SET) && !defined(Z_SOLO)
498 | # define SEEK_SET 0 /* Seek from beginning of file. */
499 | # define SEEK_CUR 1 /* Seek from current position. */
500 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
501 | #endif
502 |
503 | #ifndef z_off_t
504 | # define z_off_t long
505 | #endif
506 |
507 | #if !defined(_WIN32) && defined(Z_LARGE64)
508 | # define z_off64_t off64_t
509 | #else
510 | # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
511 | # define z_off64_t __int64
512 | # else
513 | # define z_off64_t z_off_t
514 | # endif
515 | #endif
516 |
517 | /* MVS linker does not support external names larger than 8 bytes */
518 | #if defined(__MVS__)
519 | #pragma map(deflateInit_,"DEIN")
520 | #pragma map(deflateInit2_,"DEIN2")
521 | #pragma map(deflateEnd,"DEEND")
522 | #pragma map(deflateBound,"DEBND")
523 | #pragma map(inflateInit_,"ININ")
524 | #pragma map(inflateInit2_,"ININ2")
525 | #pragma map(inflateEnd,"INEND")
526 | #pragma map(inflateSync,"INSY")
527 | #pragma map(inflateSetDictionary,"INSEDI")
528 | #pragma map(compressBound,"CMBND")
529 | #pragma map(inflate_table,"INTABL")
530 | #pragma map(inflate_fast,"INFA")
531 | #pragma map(inflate_copyright,"INCOPY")
532 | #endif
533 |
534 | #endif /* ZCONF_H */
535 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [//]: # (generated using SlashBack 0.2.0)
2 |
3 | # Irec \- Input Recorder and Macro Suite
4 | **Record your keyboard and mouse inputs, store them as a macro and play them back at any time\!**
5 |
6 | 
7 |
8 | **Windows only\.**
9 | **Python 3\.8 or greater recommended\.**
10 |
11 | ## Features
12 |
13 | * **Record inputs** as macros
14 | * **Mouse inputs**
15 | * **Cursor** movement
16 | * **Mousewheel movement** \(vertical and horizontal\)
17 | * **Mouse button** events \(Left, Middle, Right, X1, X2\)
18 | * **Keyboard inputs**
19 | * **Key** events
20 | * **Play back macros**
21 | * Once or **repeatedly**
22 | * **Stop playback** by pressing a keyboard key
23 | * Two playback options
24 | * From the **GUI applicaion**
25 | * Using a **dedicated player application** \(``` MacroPlayer.exe ```\)
26 | * **Edit macros**
27 | * **Add inputs** to macros
28 | * **Remove inputs** from macros
29 | * **Change inputs**
30 | * **Change delays** between inputs
31 | * **Create macros**
32 | * **Save and load macros**
33 | * In **binary** format
34 | * In **JSON** format
35 | * **Automatically save macros**
36 | * Irec is **Free Software** \(GNU General Public License 3\.0\)
37 |
38 |
39 |
40 | ## Screenshots
41 | 
42 | 
--------------------------------------------------------------------------------
/README.sb:
--------------------------------------------------------------------------------
1 | \h1\Irec - Input Recorder and Macro Suite\h1\
2 | \b\Record your keyboard and mouse inputs, store them as a macro and play them back at any time!\b\
3 |
4 | \image screenshots/main-menu.png \\image\
5 |
6 | \b\Windows only.\b\
7 | \b\Python 3.8 or greater recommended.\b\
8 |
9 | \h2\Features\h2\
10 | \ul\
11 | \-\\b\Record inputs\b\ as macros
12 | \--\\b\Mouse inputs\b\
13 | \---\\b\Cursor\b\ movement
14 | \---\\b\Mousewheel movement\b\ (vertical and horizontal)
15 | \---\\b\Mouse button\b\ events (Left, Middle, Right, X1, X2)
16 | \--\\b\Keyboard inputs\b\
17 | \---\\b\Key\b\ events
18 | \-\\b\Play back macros\b\
19 | \--\Once or \b\repeatedly\b\
20 | \--\\b\Stop playback\b\ by pressing a keyboard key
21 | \--\Two playback options
22 | \---\From the \b\GUI applicaion\b\
23 | \---\Using a \b\dedicated player application\b\ (\code\MacroPlayer.exe\code\)
24 | \-\\b\Edit macros\b\
25 | \--\\b\Add inputs\b\ to macros
26 | \--\\b\Remove inputs\b\ from macros
27 | \--\\b\Change inputs\b\
28 | \--\\b\Change delays\b\ between inputs
29 | \-\\b\Create macros\b\
30 | \-\\b\Save and load macros\b\
31 | \--\In \b\binary\b\ format
32 | \--\In \b\JSON\b\ format
33 | \-\\b\Automatically save macros\b\
34 | \-\Irec is \b\Free Software\b\ (GNU General Public License 3.0)
35 | \ul\
36 |
37 |
38 | \h2\Screenshots\h2\
39 | \image screenshots/record-dialog.png \\image\
40 | \image screenshots/edit-dialog.gif \\image\
--------------------------------------------------------------------------------
/irec_module/__init__.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | """
19 |
--------------------------------------------------------------------------------
/irec_module/config.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | """
19 |
20 | import os, atexit, json
21 |
22 | CONFIG_FILE = "config.dict"
23 |
24 | __config = {}
25 |
26 | if os.path.exists(CONFIG_FILE):
27 | __file = open(CONFIG_FILE, "r", encoding="UTF8")
28 | content = __file.read().strip()
29 | __file.close()
30 |
31 | if not (content.startswith("{") and content.endswith("}")):
32 | raise Exception("Invalid config file!")
33 |
34 | __config = json.loads(content)
35 |
36 | def get(key, default = None):
37 | global __config
38 | return __config.get(key, default)
39 |
40 | def set(key, value):
41 | global __config
42 | __config[key] = value
43 |
44 | def __save():
45 | global __config
46 |
47 | __file = open(CONFIG_FILE, "w", encoding="UTF8")
48 | __file.write(json.dumps(__config))
49 | __file.close()
50 |
51 | atexit.register(__save)
52 |
--------------------------------------------------------------------------------
/irec_module/macro.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | """
19 |
20 | try:
21 | from . import config, util
22 | except ImportError:
23 | import config
24 |
25 | import winput, time, ctypes, zlib, json
26 |
27 | float_to_bytes = lambda f: bytes(ctypes.c_float(f))
28 | bytes_to_float = lambda b: ctypes.cast(b, ctypes.POINTER(ctypes.c_float)).contents.value
29 |
30 | perf_counter_ns = None
31 |
32 | if hasattr(time, "perf_counter_ns"):
33 | perf_counter_ns = time.perf_counter_ns
34 | elif hasattr(time, "perf_counter"):
35 | perf_counter_ns = lambda: int(time.perf_counter() * 1000000000.)
36 | else:
37 | perf_counter_ns = lambda: int(time.time() * 1000000000.)
38 |
39 | class MacroConfig:
40 | version = 1
41 |
42 | def __init__(self, screen_width, screen_height):
43 | assert type(screen_width) == type(screen_height) == int
44 |
45 | self.screen_width = screen_width
46 | self.screen_height = screen_height
47 |
48 | def to_dict(self):
49 | return {
50 | "version" : self.version,
51 | "screen_width" : self.screen_width,
52 | "screen_height" : self.screen_height
53 | }
54 |
55 | def to_json(self):
56 | return json.dumps()
57 |
58 | def to_bytes(self):
59 | data = self.version.to_bytes(1, "little") + self.screen_width.to_bytes(2, "little") + self.screen_height.to_bytes(2, "little")
60 |
61 | return len(data).to_bytes(1, "little") + data
62 |
63 | @classmethod
64 | def from_dict(cls, as_dict):
65 | assert "version" in as_dict and \
66 | "screen_width" in as_dict and \
67 | "screen_height" in as_dict
68 |
69 | assert as_dict["version"] == cls.version
70 |
71 | assert type(as_dict["screen_width"]) == int and as_dict["screen_width"] > 0
72 | assert type(as_dict["screen_height"]) == int and as_dict["screen_height"] > 0
73 |
74 | return cls(as_dict["screen_width"], as_dict["screen_height"])
75 |
76 | @classmethod
77 | def from_json(cls, string):
78 | return cls.from_dict(json.loads(string))
79 |
80 |
81 | @classmethod
82 | def from_bytes(cls, bytes_obj):
83 | assert type(bytes_obj) == bytes and len(bytes_obj) > 1 and int.from_bytes(bytes_obj[0:1], "little") + 1 == len(bytes_obj)
84 |
85 | assert int.from_bytes(bytes_obj[1:2], "little") == cls.version
86 |
87 | return cls(int.from_bytes(bytes_obj[2:4], "little"), int.from_bytes(bytes_obj[4:], "little"))
88 |
89 | class MacroEvent:
90 | def prepare(self):
91 | raise NotImplementedError()
92 |
93 | def execute(self):
94 | raise NotImplementedError()
95 |
96 | def to_bytes(self):
97 | raise NotImplementedError()
98 |
99 | def to_dict(self):
100 | raise NotImplementedError()
101 |
102 | def to_json(self):
103 | return json.dumps(self.to_dict())
104 |
105 | @classmethod
106 | def from_bytes(cls):
107 | raise NotImplementedError()
108 |
109 | @classmethod
110 | def from_dict(cls):
111 | raise NotImplementedError()
112 |
113 | @classmethod
114 | def from_json(cls, config, string):
115 | return cls.from_dict(config, json.loads(string))
116 |
117 | class MousePositionEvent(MacroEvent):
118 | bytecode = b"P"
119 |
120 | def __init__(self, config, x, y):
121 | self.config = config
122 | self.rel_x = float(x) / config.screen_width
123 | self.rel_y = float(y) / config.screen_height
124 |
125 | def copy(self):
126 | self.prepare()
127 | return self.__class__(self.config, self.x, self.y)
128 |
129 | def prepare(self):
130 | self.x = int(round(self.config.screen_width * self.rel_x, 0))
131 | self.y = int(round(self.config.screen_height * self.rel_y, 0))
132 |
133 | def execute(self):
134 | winput.set_mouse_pos(self.x, self.y)
135 |
136 | def to_dict(self):
137 | self.prepare()
138 | return {
139 | "type" : self.__class__.__name__,
140 | "x" : self.x,
141 | "y" : self.y
142 | }
143 |
144 | def to_bytes(self):
145 | self.prepare()
146 | return self.bytecode + self.x.to_bytes(2, "little", signed=True) + self.y.to_bytes(2, "little", signed=True)
147 |
148 | @classmethod
149 | def from_bytes(cls, config, bytes_obj):
150 | assert type(bytes_obj) == bytes and len(bytes_obj) == 5 and bytes_obj[0:1] == cls.bytecode
151 |
152 | return cls(config, int.from_bytes(bytes_obj[1:3], "little", signed=True), int.from_bytes(bytes_obj[3:], "little", signed=True))
153 |
154 | @classmethod
155 | def from_dict(cls, config, as_dict):
156 | assert "type" in as_dict and \
157 | "x" in as_dict and \
158 | "y" in as_dict
159 |
160 | assert as_dict["type"] == cls.__name__
161 |
162 | assert type(as_dict["x"]) == int
163 | assert type(as_dict["y"]) == int
164 |
165 | return cls(config, as_dict["x"], as_dict["y"])
166 |
167 | def __str__(self):
168 | return "Set mouse position to ({:.2f}%, {:.2f}%)".format(self.rel_x * 100, self.rel_y * 100)
169 |
170 | ### doesn't work right because of the mouse acceleration
171 | ##class MouseMoveEvent(MacroEvent):
172 | ## bytecode = b"M"
173 | ##
174 | ## def __init__(self, config, dx, dy):
175 | ## self.config = config
176 | ## self.rel_dx = float(dx) / config.screen_width
177 | ## self.rel_dy = float(dy) / config.screen_height
178 | ##
179 | ## def prepare(self):
180 | ## self.dx = int(round(self.config.screen_width * self.rel_dx, 0))
181 | ## self.dy = int(round(self.config.screen_height * self.rel_dy, 0))
182 | ##
183 | ## def execute(self):
184 | ## winput.move_mouse(self.dx, self.dy)
185 | ##
186 | ## def to_bytes(self):
187 | ## self.prepare()
188 | ## return self.bytecode + self.dx.to_bytes(2, "little", signed=True) + self.dy.to_bytes(2, "little", signed=True)
189 | ##
190 | ## @classmethod
191 | ## def from_bytes(cls, config, bytes_obj):
192 | ## assert type(bytes_obj) == bytes and len(bytes_obj) == 5 and bytes_obj[0:1] == cls.bytecode
193 | ##
194 | ## return cls(config, int.from_bytes(bytes_obj[1:3], "little", signed=True), int.from_bytes(bytes_obj[3:], "little", signed=True))
195 | ##
196 | ## def __str__(self):
197 | ## return "Move mouse by ({:.2f}%, {:.2f}%)".format(self.rel_dx, self.rel_dy)
198 |
199 | class MouseWheelEvent(MacroEvent):
200 | def __init__(self, amount):
201 | self.amount = amount
202 |
203 | def copy(self):
204 | return self.__class__(self.amount)
205 |
206 | def prepare(self):
207 | pass
208 |
209 | def to_dict(self):
210 | return {
211 | "type" : self.__class__.__name__,
212 | "amount": self.amount
213 | }
214 |
215 | def to_bytes(self):
216 | return self.bytecode + self.amount.to_bytes(1, "little", signed=True)
217 |
218 | @classmethod
219 | def from_bytes(cls, config, bytes_obj):
220 | assert type(bytes_obj) == bytes and len(bytes_obj) == 2 and bytes_obj[0:1] == cls.bytecode
221 |
222 | return cls(int.from_bytes(bytes_obj[1:], "little", signed=True))
223 |
224 | @classmethod
225 | def from_dict(cls, config, as_dict):
226 | assert "type" in as_dict and \
227 | "amount" in as_dict
228 |
229 | assert as_dict["type"] == cls.__name__
230 |
231 | assert type(as_dict["amount"]) == int
232 |
233 | return cls(as_dict["amount"])
234 |
235 | class MouseWheelMoveEvent(MouseWheelEvent):
236 | bytecode = b"V"
237 |
238 | def execute(self):
239 | winput.move_mousewheel(self.amount)
240 |
241 | def __str__(self):
242 | return "Move mousewheel by {:+1d}".format(int(self.amount))
243 |
244 | class MouseWheelHorizontalMoveEvent(MouseWheelEvent):
245 | bytecode = b"H"
246 |
247 | def execute(self):
248 | winput.move_mousewheel(self.amount, True)
249 |
250 | def __str__(self):
251 | return "Move mousewheel horizontally by {:+1d}".format(int(self.amount))
252 |
253 | class MouseButtonEvent(MacroEvent):
254 | def __init__(self, mouse_button):
255 | self.mouse_button = mouse_button
256 |
257 | def copy(self):
258 | return self.__class__(self.mouse_button)
259 |
260 | def prepare(self):
261 | pass
262 |
263 | def to_dict(self):
264 | return {
265 | "type" : self.__class__.__name__,
266 | "mouse_button": self.mouse_button
267 | }
268 |
269 | def to_bytes(self):
270 | return self.bytecode + self.mouse_button.to_bytes(1, "little")
271 |
272 | @classmethod
273 | def from_bytes(cls, config, bytes_obj):
274 | assert type(bytes_obj) == bytes and len(bytes_obj) == 2 and bytes_obj[0:1] == cls.bytecode
275 |
276 | return cls(int.from_bytes(bytes_obj[1:], "little"))
277 |
278 | @classmethod
279 | def from_dict(cls, config, as_dict):
280 | assert "type" in as_dict and \
281 | "mouse_button" in as_dict
282 |
283 | assert as_dict["type"] == cls.__name__
284 |
285 | assert type(as_dict["mouse_button"]) == int
286 |
287 | return cls(as_dict["mouse_button"])
288 |
289 | class MouseButtonPressEvent(MouseButtonEvent):
290 | bytecode = b"B"
291 |
292 | def execute(self):
293 | winput.press_mouse_button(self.mouse_button)
294 |
295 | def __str__(self):
296 | return "Press {} mouse button".format(util.mouse_button_to_name(self.mouse_button).lower())
297 |
298 | class MouseButtonReleaseEvent(MouseButtonEvent):
299 | bytecode = b"b"
300 |
301 | def execute(self):
302 | winput.release_mouse_button(self.mouse_button)
303 |
304 | def __str__(self):
305 | return "Release {} mouse button".format(util.mouse_button_to_name(self.mouse_button).lower())
306 |
307 | class KeyEvent(MacroEvent):
308 | def __init__(self, vk_code):
309 | self.vk_code = vk_code
310 |
311 | def copy(self):
312 | return self.__class__(self.vk_code)
313 |
314 | def prepare(self):
315 | pass
316 |
317 | def to_dict(self):
318 | return {
319 | "type" : self.__class__.__name__,
320 | "vk_code": self.vk_code
321 | }
322 |
323 | def to_bytes(self):
324 | return self.bytecode + self.vk_code.to_bytes(2, "little")
325 |
326 | @classmethod
327 | def from_bytes(cls, config, bytes_obj):
328 | assert type(bytes_obj) == bytes and len(bytes_obj) == 3 and bytes_obj[0:1] == cls.bytecode
329 |
330 | return cls(int.from_bytes(bytes_obj[1:], "little"))
331 |
332 | @classmethod
333 | def from_dict(cls, config, as_dict):
334 | assert "type" in as_dict and \
335 | "vk_code" in as_dict
336 |
337 | assert as_dict["type"] == cls.__name__
338 |
339 | assert type(as_dict["vk_code"]) == int
340 |
341 | return cls(as_dict["vk_code"])
342 |
343 | class KeyPressEvent(KeyEvent):
344 | bytecode = b"K"
345 |
346 | def execute(self):
347 | winput.press_key(self.vk_code)
348 |
349 | def __str__(self):
350 | return "Press {}".format(util.vk_code_to_key_name(self.vk_code))
351 |
352 | class KeyReleaseEvent(KeyEvent):
353 | bytecode = b"k"
354 |
355 | def execute(self):
356 | winput.release_key(self.vk_code)
357 |
358 | def __str__(self):
359 | return "Release {}".format(util.vk_code_to_key_name(self.vk_code))
360 |
361 | event_bytecode_class_map = {
362 | b"P" : MousePositionEvent,
363 | ## b"M" : MouseMoveEvent,
364 | b"V" : MouseWheelMoveEvent,
365 | b"H" : MouseWheelHorizontalMoveEvent,
366 | b"B" : MouseButtonPressEvent,
367 | b"b" : MouseButtonReleaseEvent,
368 | b"K" : KeyPressEvent,
369 | b"k" : KeyReleaseEvent,
370 | }
371 |
372 | class EventExecutor:
373 | def __init__(self, time_offset, event):
374 | assert type(time_offset) == int and isinstance(event, MacroEvent)
375 |
376 | self.time_offset = time_offset
377 | self.event = event
378 |
379 | def copy(self):
380 | return EventExecutor(self.time_offset, self.event.copy())
381 |
382 | def prepare(self):
383 | self.event.prepare()
384 |
385 | def execute_at_time_offset(self, start_time):
386 | global continue_playback, enable_playback_interruption
387 | now = perf_counter_ns()
388 |
389 | target_time = start_time + self.time_offset
390 |
391 | while now < target_time:
392 | diff_in_ms = (target_time - now) // 1000000
393 |
394 | if diff_in_ms > 10:
395 | time.sleep(diff_in_ms // 10 / 100.)
396 |
397 | else:
398 | time.sleep(1 / 1000.)
399 |
400 | if not continue_playback:
401 | return
402 |
403 | if enable_playback_interruption:
404 | winput.get_message()
405 |
406 | now = perf_counter_ns()
407 |
408 | if not continue_playback:
409 | return
410 |
411 | self.event.execute()
412 |
413 | def to_dict(self):
414 | return {
415 | "time_offset" : self.time_offset,
416 | "event" : self.event.to_dict()
417 | }
418 |
419 | def to_json(self):
420 | return json.dumps(self.to_dict())
421 |
422 | def to_bytes(self):
423 | data = self.time_offset.to_bytes(8, "little") + self.event.to_bytes()
424 |
425 | return len(data).to_bytes(1, "little") + data
426 |
427 | @classmethod
428 | def from_bytes(cls, config, bytes_obj):
429 | assert type(bytes_obj) == bytes and len(bytes_obj) >= 10 and bytes_obj[0] + 1 == len(bytes_obj)
430 |
431 | time_offset = int.from_bytes(bytes_obj[1:9], "little")
432 |
433 | event_type = bytes_obj[9:10]
434 |
435 | assert event_type in event_bytecode_class_map, "Unknown event bytecode '{}'".format(event_type)
436 |
437 | event_class = event_bytecode_class_map[event_type]
438 |
439 | event = event_class.from_bytes(config, bytes_obj[9:])
440 |
441 | return cls(time_offset, event)
442 |
443 | @classmethod
444 | def from_dict(cls, config, as_dict):
445 | assert "time_offset" in as_dict and \
446 | "event" in as_dict
447 |
448 | time_offset = as_dict["time_offset"]
449 | event_dict = as_dict["event"]
450 |
451 | assert type(time_offset) == int and time_offset >= 0
452 |
453 | assert "type" in event_dict
454 |
455 | glob = globals()
456 |
457 | assert event_dict["type"] in glob, "Unknown event type: {}".format(event_dict["type"])
458 |
459 | event_class = glob[event_dict["type"]]
460 | event = event_class.from_dict(config, event_dict)
461 |
462 | return cls(time_offset, event)
463 |
464 | @classmethod
465 | def from_json(cls, config, string):
466 | return cls.from_dict(config, json.loads(string))
467 |
468 | def __str__(self):
469 | return "Executing {} at {}".format(str(self.event), self.time_offset)
470 |
471 | class Macro:
472 | def __init__(self, name, config, event_executor_list):
473 | self.name = name
474 | self.config = config
475 | self.event_executor_list = event_executor_list
476 |
477 | def stop_playback_callback(self, key_event):
478 | global continue_playback
479 |
480 | if key_event.vkCode == self.stop_playback_vk_code:
481 | continue_playback = False
482 |
483 | def run(self):
484 | global continue_playback, enable_playback_interruption
485 |
486 | for executor in self.event_executor_list:
487 | executor.prepare()
488 |
489 | continue_playback = True
490 |
491 | enable_playback_interruption = config.get("enable_stop_playback_key", False)
492 |
493 | if enable_playback_interruption:
494 | self.stop_playback_vk_code = config.get("stop_playback_key", winput.VK_ESCAPE)
495 | winput.hook_keyboard(self.stop_playback_callback)
496 |
497 | start_time = perf_counter_ns()
498 | for executor in self.event_executor_list:
499 | executor.execute_at_time_offset(start_time)
500 |
501 | if not continue_playback:
502 | break
503 |
504 | if enable_playback_interruption:
505 | winput.unhook_keyboard()
506 |
507 | def to_bytes(self):
508 | name_encoded = self.name.encode()
509 | name_data = len(name_encoded).to_bytes(1, "little") + name_encoded
510 | return name_data + self.config.to_bytes() + b"".join(map(lambda ee: ee.to_bytes(), self.event_executor_list))
511 |
512 | def as_compressed_bytes(self):
513 | return zlib.compress(self.to_bytes(), 9)
514 |
515 | def to_dict(self):
516 | return {
517 | "name" : self.name,
518 | "config" : self.config.to_dict(),
519 | "event_executor_list" : list(map(lambda x: x.to_dict(), self.event_executor_list))
520 | }
521 |
522 | def to_json(self):
523 | return json.dumps(self.to_dict())
524 |
525 | @classmethod
526 | def from_dict(cls, as_dict):
527 | assert "name" in as_dict and \
528 | "config" in as_dict and \
529 | "event_executor_list" in as_dict
530 |
531 | name = as_dict["name"]
532 |
533 | config_dict = as_dict["config"]
534 |
535 | event_executor_dict_list = as_dict["event_executor_list"]
536 |
537 | assert type(name) == str and \
538 | type(config_dict) == dict and \
539 | type(event_executor_dict_list) == list
540 |
541 | config = MacroConfig.from_dict(config_dict)
542 |
543 | event_executor_list = list(map(lambda x: EventExecutor.from_dict(config, x), event_executor_dict_list))
544 |
545 | return cls(name, config, event_executor_list)
546 |
547 | @classmethod
548 | def from_json(cls, string):
549 | return cls.from_dict(json.loads(string))
550 |
551 | @classmethod
552 | def from_bytes(cls, bytes_obj):
553 | assert type(bytes_obj) == bytes and len(bytes_obj) > 1 and len(bytes_obj) > int.from_bytes(bytes_obj[0:1], "little")
554 |
555 | offset = bytes_obj[0] + 1
556 |
557 | name = bytes_obj[1:offset].decode()
558 |
559 | config_data_length = bytes_obj[offset] + 1
560 |
561 | config_data = bytes_obj[offset:offset+config_data_length]
562 |
563 | config = MacroConfig.from_bytes(config_data)
564 |
565 | offset += config_data_length
566 |
567 | event_executor_list = []
568 |
569 | while offset < len(bytes_obj):
570 | event_data_length = bytes_obj[offset] + 1
571 |
572 | assert offset + event_data_length <= len(bytes_obj)
573 |
574 | event_data = bytes_obj[offset : offset + event_data_length]
575 |
576 | event_executor_list.append(EventExecutor.from_bytes(config, event_data))
577 |
578 | offset += event_data_length
579 |
580 | return Macro(name, config, event_executor_list)
581 |
582 | @classmethod
583 | def from_compressed_bytes(cls, compressed_bytes_obj):
584 | return cls.from_bytes(zlib.decompress(compressed_bytes_obj))
585 |
586 | @staticmethod
587 | def from_raw_data(name, start_time, start_mouse_pos, screen_width, screen_height, raw_data):
588 | event_executor_list = []
589 |
590 | macro_config = MacroConfig(screen_width, screen_height)
591 |
592 | if start_mouse_pos:
593 | event_executor_list.append(EventExecutor(0, MousePositionEvent(macro_config, start_mouse_pos[0], start_mouse_pos[1])))
594 |
595 | last_mouse_pos = start_mouse_pos
596 |
597 | for timestamp, raw_event in raw_data:
598 | time_offset = timestamp - start_time
599 |
600 | event = None
601 |
602 | if type(raw_event) == winput.MouseEvent:
603 | if raw_event.action == winput.WM_MOUSEMOVE:
604 | event = MousePositionEvent(macro_config, raw_event.position[0], raw_event.position[1])
605 | last_mouse_pos = raw_event.position
606 |
607 | elif raw_event.action == winput.WM_LBUTTONDOWN:
608 | event = MouseButtonPressEvent(winput.LEFT_MOUSE_BUTTON)
609 |
610 | elif raw_event.action == winput.WM_LBUTTONUP:
611 | event = MouseButtonReleaseEvent(winput.LEFT_MOUSE_BUTTON)
612 |
613 | elif raw_event.action == winput.WM_RBUTTONDOWN:
614 | event = MouseButtonPressEvent(winput.RIGHT_MOUSE_BUTTON)
615 |
616 | elif raw_event.action == winput.WM_RBUTTONUP:
617 | event = MouseButtonReleaseEvent(winput.RIGHT_MOUSE_BUTTON)
618 |
619 | elif raw_event.action == winput.WM_MBUTTONDOWN:
620 | event = MouseButtonPressEvent(winput.MIDDLE_MOUSE_BUTTON)
621 |
622 | elif raw_event.action == winput.WM_MBUTTONUP:
623 | event = MouseButtonReleaseEvent(winput.MIDDLE_MOUSE_BUTTON)
624 |
625 | elif raw_event.action == winput.WM_XBUTTONDOWN:
626 | event = MouseButtonPressEvent(getattr(winput, "XMB" + str(raw_event.additional_data)))
627 |
628 | elif raw_event.action == winput.WM_XBUTTONUP:
629 | event = MouseButtonReleaseEvent(getattr(winput, "XMB" + str(raw_event.additional_data)))
630 |
631 | elif raw_event.action == winput.WM_MOUSEWHEEL:
632 | event = MouseWheelMoveEvent(int(raw_event.additional_data))
633 |
634 | elif raw_event.action == winput.WM_MOUSEHWHEEL:
635 | event = MouseWheelHorizontalMoveEvent(int(raw_event.additional_data))
636 |
637 | else:
638 | raise Exception("Unknown Mouse Event")
639 |
640 | elif type(raw_event) == winput.KeyboardEvent:
641 | if raw_event.action == winput.WM_KEYDOWN or raw_event.action == winput.WM_SYSKEYDOWN:
642 | event = KeyPressEvent(raw_event.vkCode)
643 |
644 | elif raw_event.action == winput.WM_KEYUP or raw_event.action == winput.WM_SYSKEYUP:
645 | event = KeyReleaseEvent(raw_event.vkCode)
646 |
647 | else:
648 | raise Exception("Unknown Keyboard Event")
649 |
650 | else:
651 | raise Exception("Unknown Event Type")
652 |
653 | event_executor_list.append(EventExecutor(time_offset, event))
654 |
655 | return Macro(name, macro_config, event_executor_list)
656 |
657 | def callback(event):
658 | global raw_data
659 |
660 | raw_data.append((perf_counter_ns(), event))
661 |
662 | def callback_with_stop_key(event):
663 | global stop_recording_key
664 |
665 | if event.vkCode == stop_recording_key:
666 | winput.stop()
667 |
668 | else:
669 | global raw_data
670 |
671 | raw_data.append((perf_counter_ns(), event))
672 |
673 | def callback_only_stop_key(event):
674 | global stop_recording_key
675 |
676 | if event.vkCode == stop_recording_key:
677 | winput.stop()
678 |
679 |
680 | def create_macro(name, start_at, screen_width, screen_height):
681 | global start, raw_data, stop_recording_key
682 |
683 | mode = config.get("recording_mode", "key")
684 |
685 | duration = config.get("recording_duration", 10)
686 |
687 | stop_recording_key = config.get("recording_stop_key", winput.VK_ESCAPE)
688 |
689 | mouse_enabled = config.get("record_mouse", True)
690 |
691 | keyboard_enabled = config.get("record_keyboard", True)
692 |
693 | assert mode in ("timer", "key")
694 |
695 | assert type(duration) in (float, int) and duration > 0
696 |
697 | assert type(stop_recording_key) == int and 0 <= stop_recording_key <= 2**15
698 |
699 | assert type(mouse_enabled) == type(keyboard_enabled) == bool
700 |
701 | assert mouse_enabled or keyboard_enabled
702 |
703 | raw_data = []
704 |
705 | while True:
706 | if time.time() > start_at:
707 | break
708 | time.sleep(0.0001)
709 |
710 | start = perf_counter_ns()
711 |
712 | start_mouse_pos = None
713 |
714 | if mode == "timer":
715 | if mouse_enabled:
716 | start_mouse_pos = winput.get_mouse_pos()
717 | winput.hook_mouse(callback)
718 |
719 | if keyboard_enabled:
720 | winput.hook_keyboard(callback)
721 |
722 | while True:
723 | now = perf_counter_ns()
724 |
725 | if now >= start + duration * 1000000000:
726 | break
727 |
728 | winput.get_message()
729 |
730 | elif mode == "key":
731 | if mouse_enabled:
732 | start_mouse_pos = winput.get_mouse_pos()
733 | winput.hook_mouse(callback)
734 |
735 | if keyboard_enabled:
736 | winput.hook_keyboard(callback_with_stop_key)
737 | else:
738 | winput.hook_keyboard(callback_only_stop_key)
739 |
740 | winput.wait_messages()
741 |
742 | winput.unhook_mouse()
743 | winput.unhook_keyboard()
744 |
745 | return Macro.from_raw_data(name, start, start_mouse_pos, screen_width, screen_height, raw_data)
746 |
747 | def macros_to_json(*macros, indent=None):
748 | assert macros and all(map(lambda m: isinstance(m, Macro), macros))
749 |
750 | macros_dict_list = list(map(lambda mcr: mcr.to_dict(), macros))
751 |
752 | return json.dumps(macros_dict_list, indent=indent)
753 |
754 | def macros_from_json(string):
755 | assert type(string) == str
756 |
757 | macros_dict_list = json.loads(string)
758 |
759 | return list(map(lambda md: Macro.from_dict(md), macros_dict_list))
760 |
761 | def macros_to_bytes(*macros, compressionlevel=9):
762 | assert macros and all(map(lambda m: isinstance(m, Macro), macros))
763 |
764 | data_array = []
765 |
766 | if len(macros) == 1:
767 | data_array.append(b"S")
768 | data_array.append(macros[0].to_bytes())
769 |
770 | else:
771 | data_array.append(b"M")
772 | data_array.append(len(macros).to_bytes(1, "little"))
773 |
774 | for macro in macros:
775 | macro_data = macro.to_bytes()
776 | data_array.append(len(macro_data).to_bytes(4, "little"))
777 | data_array.append(macro_data)
778 |
779 | uncompressed_data = b"".join(data_array)
780 |
781 | out_data = zlib.compress(uncompressed_data, compressionlevel)
782 |
783 | uncompressed_data_len = len(uncompressed_data)
784 |
785 | return uncompressed_data_len.to_bytes(4, "little") + out_data
786 |
787 | def macros_from_bytes(bytes_obj):
788 | assert type(bytes_obj) == bytes
789 |
790 | content = bytes_obj[4:]
791 |
792 | uncompressed_bytes = zlib.decompress(content)
793 |
794 | assert uncompressed_bytes and uncompressed_bytes[0:1] in (b"S", b"M")
795 |
796 | if uncompressed_bytes[0:1] == b"S":
797 | return [Macro.from_bytes(uncompressed_bytes[1:])]
798 |
799 | else:
800 | macros = []
801 |
802 | offset = 1
803 |
804 | macro_count = uncompressed_bytes[offset]
805 |
806 | offset += 1
807 |
808 | while offset < len(uncompressed_bytes):
809 | assert len(uncompressed_bytes) > offset + 3
810 |
811 | macro_data_length = int.from_bytes(uncompressed_bytes[offset : offset + 4], "little")
812 | offset += 4
813 | macro_data = uncompressed_bytes[offset : offset + macro_data_length]
814 |
815 | macros.append(Macro.from_bytes(macro_data))
816 |
817 | offset += macro_data_length
818 |
819 | assert len(macros) == macro_count
820 |
821 | return macros
822 |
823 | def request_key_callback(event):
824 | global requested_key
825 | requested_key = event.vkCode
826 |
827 | def request_key(timeout):
828 | global requested_key
829 |
830 | requested_key = None
831 |
832 | start = time.time()
833 |
834 | winput.hook_keyboard(request_key_callback)
835 |
836 | while not requested_key:
837 | now = time.time()
838 |
839 | if now >= start + timeout:
840 | break
841 |
842 | winput.get_message()
843 |
844 | winput.unhook_keyboard()
845 |
846 | return requested_key
847 |
848 | def request_mouse_callback(event):
849 | global last_request_position, last_request_timestamp
850 |
851 | last_request_position = event.position
852 |
853 | last_request_timestamp = time.time()
854 |
855 | def request_mouse_pos(timeout):
856 | global last_request_position, last_request_timestamp
857 |
858 | last_request_position = None
859 |
860 | last_request_timestamp = time.time()
861 |
862 | winput.hook_mouse(request_mouse_callback)
863 |
864 | while True:
865 | now = time.time()
866 |
867 | winput.get_message()
868 |
869 | if last_request_position and last_request_timestamp + timeout < now:
870 | break
871 |
872 | winput.unhook_mouse()
873 |
874 | return last_request_position
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
--------------------------------------------------------------------------------
/irec_module/util.py:
--------------------------------------------------------------------------------
1 |
2 | """
3 | Input Recorder - Record and play back keyboard and mouse input.
4 | Copyright (C) 2022 Zuzu_Typ
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | """
19 |
20 | import winput, re
21 |
22 | def vk_code_to_key_name(vk_code):
23 | name = winput.vk_code_dict.get(vk_code, "VK_UNKNOWN")
24 |
25 | if name.startswith("VK_"):
26 | name = name[3:]
27 |
28 | special_left_key_match = re.match("L(CONTROL|MENU|WIN|SHIFT)", name)
29 |
30 | if special_left_key_match:
31 | name = "LEFT " + special_left_key_match.group(1)
32 |
33 | special_right_key_match = re.match("R(CONTROL|MENU|WIN|SHIFT)", name)
34 |
35 | if special_right_key_match:
36 | name = "RIGHT " + special_right_key_match.group(1)
37 |
38 | name = name.replace("_", " ")
39 |
40 | name = " ".join((word.capitalize() for word in name.split(" ")))
41 |
42 | oem_match = re.fullmatch("(.*)OEM(.*)", name, re.IGNORECASE)
43 |
44 | if oem_match:
45 | name = oem_match.group(1) + "OEM" + oem_match.group(2)
46 |
47 | return name
48 |
49 | def mouse_button_to_name(button):
50 | return "Left" if button == winput.LMB else \
51 | "Right" if button == winput.RMB else \
52 | "Middle" if button == winput.MMB else \
53 | "X1" if button == winput.XMB1 else \
54 | "X2"
55 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | winput>=1.4.0
2 | Pillow
--------------------------------------------------------------------------------
/res/Irec.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/Irec.ico
--------------------------------------------------------------------------------
/res/Irec.ico LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 Zuzu_Typ
2 |
3 | Irec.ico is distributed via the Creative Commons Attribution-ShareAlike 3.0 Unported license.
4 | To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
5 | It uses art by Lordalpha1 (adapted by Beao) ( https://commons.wikimedia.org/wiki/File:Mouse-cursor-hand-pointer.svg ) and by JayWalsh ( https://commons.wikimedia.org/wiki/File:Keyboard-icon_Wikipedians.svg )
--------------------------------------------------------------------------------
/res/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/add.png
--------------------------------------------------------------------------------
/res/add2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/add2.png
--------------------------------------------------------------------------------
/res/delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/delete.png
--------------------------------------------------------------------------------
/res/delete2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/delete2.png
--------------------------------------------------------------------------------
/res/edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/edit.png
--------------------------------------------------------------------------------
/res/edit2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/edit2.png
--------------------------------------------------------------------------------
/res/load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/load.png
--------------------------------------------------------------------------------
/res/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/play.png
--------------------------------------------------------------------------------
/res/play2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/play2.png
--------------------------------------------------------------------------------
/res/rec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/rec.png
--------------------------------------------------------------------------------
/res/rec2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/rec2.png
--------------------------------------------------------------------------------
/res/save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/res/save.png
--------------------------------------------------------------------------------
/screenshots/edit-dialog.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/screenshots/edit-dialog.gif
--------------------------------------------------------------------------------
/screenshots/main-menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/screenshots/main-menu.png
--------------------------------------------------------------------------------
/screenshots/record-dialog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zuzu-Typ/Input-Recorder/83b34730d6375395e944cdd479834198800ebdb9/screenshots/record-dialog.png
--------------------------------------------------------------------------------