Compare commits
10 Commits
27fe79c7bb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ba460d66e3 | |||
| 9558c0330f | |||
| 0c96805b9d | |||
| 900098c959 | |||
| 7c1284333f | |||
| 6851268cf3 | |||
| f0b55c3bc4 | |||
| 91af6d2141 | |||
| 7ff9b7947f | |||
| b018971ec8 |
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" path="src/main/java"/>
|
|
||||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
|
||||||
<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
|
||||||
</classpath>
|
|
||||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,7 +1,7 @@
|
|||||||
build
|
|
||||||
bin
|
|
||||||
.gradle
|
.gradle
|
||||||
|
.maven
|
||||||
.settings
|
.settings
|
||||||
.project
|
|
||||||
.classpath
|
.classpath
|
||||||
/.settings
|
.project
|
||||||
|
bin
|
||||||
|
build
|
||||||
|
|||||||
18
.project
18
.project
@@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>jna-test</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
||||||
755
LICENSE
755
LICENSE
@@ -1,202 +1,619 @@
|
|||||||
Apache License
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2.0, January 2004
|
Version 3, 29 June 2007
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
1. Definitions.
|
Preamble
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
The GNU General Public License is a free, copyleft license for
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
software and other kinds of works.
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
The licenses for most software and other practical works are designed
|
||||||
the copyright owner that is granting the License.
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
When we speak of free software, we are referring to freedom, not
|
||||||
other entities that control, are controlled by, or are under common
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
control with that entity. For the purposes of this definition,
|
have the freedom to distribute copies of free software (and charge for
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
them if you wish), that you receive source code or can get it if you
|
||||||
direction or management of such entity, whether by contract or
|
want it, that you can change the software or use pieces of it in new
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
free programs, and that you know you can do these things.
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
To protect your rights, we need to prevent others from denying you
|
||||||
exercising permissions granted by this License.
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
For example, if you distribute copies of such a program, whether
|
||||||
including but not limited to software source code, documentation
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
source, and configuration files.
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
transformation or translation of a Source form, including but
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
not limited to compiled object code, generated documentation,
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
Object form, made available under the License, as indicated by a
|
that there is no warranty for this free software. For both users' and
|
||||||
copyright notice that is included in or attached to the work
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
(an example is provided in the Appendix below).
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
Some devices are designed to deny users access to install or run
|
||||||
form, that is based on (or derived from) the Work and for which the
|
modified versions of the software inside them, although the manufacturer
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
protecting users' freedom to change the software. The systematic
|
||||||
of this License, Derivative Works shall not include works that remain
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
the Work and Derivative Works thereof.
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
Finally, every program is threatened constantly by software patents.
|
||||||
the original version of the Work and any modifications or additions
|
States should not allow patents to restrict development and use of
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
avoid the special danger that patents applied to a free program could
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
patents cannot be used to render the program non-free.
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
The precise terms and conditions for copying, distribution and
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
modification follow.
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
TERMS AND CONDITIONS
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
0. Definitions.
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
Derivative Works a copy of this License; and
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
stating that You changed the files; and
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
that You distribute, all copyright, patent, trademark, and
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
attribution notices from the Source form of the Work,
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
excluding those notices that do not pertain to any part of
|
earlier work or a work "based on" the earlier work.
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
A "covered work" means either the unmodified Program or a work based
|
||||||
distribution, then any Derivative Works that You distribute must
|
on the Program.
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
To "propagate" a work means to do anything with it that, without
|
||||||
may provide additional or different license terms and conditions
|
permission, would make you directly or secondarily liable for
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
infringement under applicable copyright law, except executing it on a
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
distribution (with or without modification), making available to the
|
||||||
the conditions stated in this License.
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
To "convey" a work means any kind of propagation that enables other
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
to the extent that it includes a convenient and prominently visible
|
||||||
except as required for reasonable and customary use in describing the
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
1. Source Code.
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
The "source code" for a work means the preferred form of the work
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
for making modifications to it. "Object code" means any non-source
|
||||||
unless required by applicable law (such as deliberate and grossly
|
form of a work.
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
A "Standard Interface" means an interface that either is an official
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
standard defined by a recognized standards body, or, in the case of
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
interfaces specified for a particular programming language, one that
|
||||||
or other liability obligations and/or rights consistent with this
|
is widely used among developers working in that language.
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
The Corresponding Source need not include anything that users
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
can regenerate automatically from other parts of the Corresponding
|
||||||
replaced with your own identifying information. (Don't include
|
Source.
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
2. Basic Permissions.
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
You may make, run and propagate covered works that you do not
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
convey, without conditions so long as your license otherwise remains
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
in force. You may convey covered works to others for the sole purpose
|
||||||
See the License for the specific language governing permissions and
|
of having them make modifications exclusively for you, or provide you
|
||||||
limitations under the License.
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
11
build.gradle
11
build.gradle
@@ -1,5 +1,10 @@
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
apply plugin: 'maven'
|
||||||
|
|
||||||
|
group = 'com.github.boukefalos'
|
||||||
|
archivesBaseName = 'jlibwinapi'
|
||||||
|
version = '0.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -9,3 +14,9 @@ dependencies {
|
|||||||
compile 'net.java.dev.jna:jna:4.2.0'
|
compile 'net.java.dev.jna:jna:4.2.0'
|
||||||
compile 'net.java.dev.jna:platform:3.5.2'
|
compile 'net.java.dev.jna:platform:3.5.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uploadArchives {
|
||||||
|
repositories.mavenDeployer {
|
||||||
|
repository(url: uri('.maven'))
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 136 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 113 KiB |
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Thu Jun 23 21:23:59 BST 2016
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
|
||||||
164
gradlew
vendored
Normal file
164
gradlew
vendored
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||||
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
goto execute
|
||||||
|
|
||||||
|
:4NT_args
|
||||||
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
|
||||||
# Visual Studio 2010
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MsgHook", "MsgHook\MsgHook.vcxproj", "{8E038A94-7D02-49E9-B9F6-5224D9D11225}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SetMsgHook", "SetMsgHook\SetMsgHook.vcxproj", "{34A73B55-8A93-4FB5-83CE-7759C1D23348}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{8E038A94-7D02-49E9-B9F6-5224D9D11225}.Release|x64.Build.0 = Release|x64
|
|
||||||
{34A73B55-8A93-4FB5-83CE-7759C1D23348}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{34A73B55-8A93-4FB5-83CE-7759C1D23348}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{34A73B55-8A93-4FB5-83CE-7759C1D23348}.Debug|x64.ActiveCfg = Debug|Win32
|
|
||||||
{34A73B55-8A93-4FB5-83CE-7759C1D23348}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{34A73B55-8A93-4FB5-83CE-7759C1D23348}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{34A73B55-8A93-4FB5-83CE-7759C1D23348}.Release|x64.ActiveCfg = Release|Win32
|
|
||||||
{34A73B55-8A93-4FB5-83CE-7759C1D23348}.Release|x64.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
Binary file not shown.
@@ -1,261 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// MsgHook.cpp : Defines the exported functions for the DLL application.
|
|
||||||
//
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
//to fix export declaration had to add .def file
|
|
||||||
LRESULT CALLBACK CwpHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
COPYDATASTRUCT CDS;
|
|
||||||
HEVENT Event;
|
|
||||||
|
|
||||||
CDS.dwData = 0;
|
|
||||||
CDS.cbData = sizeof(Event);
|
|
||||||
CDS.lpData = &Event;
|
|
||||||
|
|
||||||
//if (nCode == HC_ACTION)
|
|
||||||
{
|
|
||||||
//For WH_CALLWNDPROC hook a pointer to a CWPSTRUCT structure that contains details about the message.
|
|
||||||
CWPSTRUCT *cwps = (CWPSTRUCT *)lParam;
|
|
||||||
Event.hWnd = cwps->hwnd;
|
|
||||||
Event.lParam = cwps->lParam;
|
|
||||||
Event.wParam = cwps->wParam;
|
|
||||||
Event.nCode = cwps->message;
|
|
||||||
Event.dwHookType = WH_CALLWNDPROC;
|
|
||||||
memset((void *)&Event.wParamStr, '\0', sizeof(TCHAR) * 25);
|
|
||||||
memset((void *)&Event.lParamStr, '\0', sizeof(TCHAR) * 25);
|
|
||||||
bool errorFlg = false;
|
|
||||||
if (cwps->message == WM_SETTEXT && cwps->lParam != 0 && cwps->wParam == 0)
|
|
||||||
{
|
|
||||||
if (IsWindowUnicode(Event.hWnd))
|
|
||||||
{
|
|
||||||
_tcsncpy_s(Event.lParamStr, 25, (const wchar_t*)Event.lParam, _TRUNCATE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int asciiSize = (int)strlen((const char*)Event.lParam);
|
|
||||||
int unicodeSize = (int)_tcslen((const wchar_t*)Event.lParam);
|
|
||||||
if (unicodeSize > asciiSize)
|
|
||||||
_tcsncpy_s(Event.lParamStr, 25, (const wchar_t*)Event.lParam, _TRUNCATE);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int tstrLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)cwps->lParam, (int)strlen((LPCSTR)cwps->lParam), NULL, 0); //get t len
|
|
||||||
if (tstrLen > 24)
|
|
||||||
tstrLen = 24;
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)cwps->lParam, (int)strlen((LPCSTR)cwps->lParam), Event.lParamStr, tstrLen); // convert char to tchar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//printf("debug: sending to hwnd (%ld) msg %d, wParam %ld, lParam %ld\n", pData->g_hWnd, Event.nCode, Event.wParam, Event.lParam);
|
|
||||||
if (cwps->hwnd != pData->g_hWnd)
|
|
||||||
{
|
|
||||||
BOOL bRes = (BOOL)SendMessage(pData->g_hWnd, WM_COPYDATA, 0, (LPARAM)(VOID*)&CDS); // ask the controlling program if the hook should be passed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CallNextHookEx(pData->g_CwpHook, nCode, wParam, lParam); // pass hook to next handler
|
|
||||||
//return bRes; // Don't tell the other hooks about this message.
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK MsgHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
COPYDATASTRUCT CDS;
|
|
||||||
HEVENT Event;
|
|
||||||
|
|
||||||
CDS.dwData = 0;
|
|
||||||
CDS.cbData = sizeof(Event);
|
|
||||||
CDS.lpData = &Event;
|
|
||||||
|
|
||||||
if (nCode >=0 && nCode == HC_ACTION)
|
|
||||||
{
|
|
||||||
//For WH_GETMESSAGE hook a pointer to a MSG structure that contains details about the message.
|
|
||||||
MSG *msg = (MSG *)lParam;
|
|
||||||
Event.hWnd = msg->hwnd;
|
|
||||||
Event.lParam = msg->lParam;
|
|
||||||
Event.wParam = msg->wParam;
|
|
||||||
Event.nCode = msg->message;
|
|
||||||
Event.dwHookType = WH_GETMESSAGE;
|
|
||||||
memset((void *)&Event.wParamStr, '\0', sizeof(TCHAR) * 25);
|
|
||||||
memset((void *)&Event.lParamStr, '\0', sizeof(TCHAR) * 25);
|
|
||||||
//if (msg->message == WM_SETTEXT && msg->lParam != 0)
|
|
||||||
// _tcscpy_s(Event.lParamStr, 25, (const wchar_t*)Event.lParam);
|
|
||||||
//if (msg->message == WM_COMMAND || msg->message == WM_MENUCOMMAND) //infinite loop?
|
|
||||||
if (msg->hwnd != pData->g_hWnd)
|
|
||||||
{
|
|
||||||
BOOL bRes = (BOOL)SendMessage(pData->g_hWnd, WM_COPYDATA, 0, (LPARAM)(VOID*)&CDS); // ask the controlling program if the hook should be passed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CallNextHookEx(pData->g_MsgHook, nCode, wParam, lParam); // pass hook to next handler
|
|
||||||
//return bRes; // Don't tell the other hooks about this message.
|
|
||||||
}
|
|
||||||
|
|
||||||
//support for 32-bit/64-bit apps means the dll might be different to match the process we want to see
|
|
||||||
extern "C" __declspec(dllexport) BOOL SetCustomMsgHookDll(const TCHAR * hookDll, const char * hookDllProcName)
|
|
||||||
{
|
|
||||||
HMODULE dll = LoadLibrary(hookDll); //should provide full dll path and filename
|
|
||||||
if (dll == NULL)
|
|
||||||
{
|
|
||||||
TCHAR errorStr[200];
|
|
||||||
_stprintf_s(errorStr, _T("Error loading hook library %s"), hookDll);
|
|
||||||
MessageBox(0, errorStr, _T("Set Hook Dll Error"), 0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
HOOKPROC addr = (HOOKPROC)GetProcAddress(dll, hookDllProcName); //should provide the 'CwpHookProc'
|
|
||||||
if (addr == NULL)
|
|
||||||
{
|
|
||||||
char errorStr[200];
|
|
||||||
sprintf_s(errorStr, "Error loading hook library procedure %s", hookDllProcName);
|
|
||||||
MessageBoxA(0, errorStr, "Set Hook Dll Error", 0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pData->g_hInstance = dll;
|
|
||||||
pData->g_CwpHookProc = addr;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) BOOL SetMsgHook(HWND callerHWnd, DWORD threadId)
|
|
||||||
{
|
|
||||||
// if(bStartingProcess) // if we're just starting the DLL for the first time,
|
|
||||||
{
|
|
||||||
pData->g_hWnd = callerHWnd; // remember the windows and hook handle for further instances
|
|
||||||
if (pData->g_CwpHookProc == NULL)
|
|
||||||
pData->g_CwpHookProc = (HOOKPROC)CwpHookProc;
|
|
||||||
pData->g_CwpHook = SetWindowsHookEx(WH_CALLWNDPROC, pData->g_CwpHookProc, (HINSTANCE)pData->g_hInstance, threadId);
|
|
||||||
//pData->g_MsgHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)MsgHookProc, (HINSTANCE)pData->g_hInstance, threadId);
|
|
||||||
if (pData->g_CwpHook == NULL) {
|
|
||||||
TCHAR tmp[100];
|
|
||||||
_stprintf_s(tmp, _T("Last Error # %ld on threadId %ld"), GetLastError(), threadId);
|
|
||||||
MessageBox(0, tmp, _T("Set Hook Error"), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (pData->g_CwpHook != NULL); //pData->g_CwpHook != NULL &&
|
|
||||||
}
|
|
||||||
/*else
|
|
||||||
{
|
|
||||||
//MessageBox(0, _T("Error: Not starting process"), _T("Set Hook Error"), 0);
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) HHOOK GetCurrentHookHandle()
|
|
||||||
{
|
|
||||||
return pData->g_CwpHook; //if NULL hook isn't running
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) void SetGlobalDLLInstance(HANDLE dllInstance)
|
|
||||||
{
|
|
||||||
pData->g_hInstance = dllInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) BOOL RemoveHook()
|
|
||||||
{
|
|
||||||
if (pData == NULL)
|
|
||||||
return false;
|
|
||||||
if(pData->g_MsgHook) // if the hook is defined
|
|
||||||
{
|
|
||||||
UnhookWindowsHookEx(pData->g_MsgHook);
|
|
||||||
pData->g_MsgHook = NULL;
|
|
||||||
}
|
|
||||||
if(pData->g_CwpHook) // if the hook is defined
|
|
||||||
{
|
|
||||||
BOOL ret = UnhookWindowsHookEx(pData->g_CwpHook);
|
|
||||||
pData->g_hWnd = NULL; // reset data
|
|
||||||
pData->g_CwpHook = NULL;
|
|
||||||
pData->g_CwpHookProc = NULL;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//testing if process 64 bit, needed to verify this dll can hook & attach to target process
|
|
||||||
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
|
|
||||||
LPFN_ISWOW64PROCESS fnIsWow64Process;
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) BOOL IsCurrentProcess64Bit()
|
|
||||||
{
|
|
||||||
return IsProcess64Bit(_getpid());
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) BOOL IsProcess64Bit(DWORD procId)
|
|
||||||
{
|
|
||||||
SYSTEM_INFO stInfo;
|
|
||||||
GetNativeSystemInfo(&stInfo); // if native system is x86 skip wow64 test
|
|
||||||
if (stInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
|
|
||||||
return false; //printf( "Processor Architecture: Intel x86\n");
|
|
||||||
|
|
||||||
BOOL bIsWow64 = FALSE;
|
|
||||||
//IsWow64Process is not available on all supported versions of Windows.
|
|
||||||
//Use GetModuleHandle to get a handle to the DLL that contains the function
|
|
||||||
//and GetProcAddress to get a pointer to the function if available.
|
|
||||||
|
|
||||||
fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
|
|
||||||
if(fnIsWow64Process != NULL)
|
|
||||||
{
|
|
||||||
HANDLE procHandle = NULL;//GetCurrentProcess();
|
|
||||||
procHandle = OpenProcess(PROCESS_QUERY_INFORMATION, false, procId);
|
|
||||||
if (!fnIsWow64Process(procHandle, &bIsWow64))
|
|
||||||
{
|
|
||||||
//handle error
|
|
||||||
}
|
|
||||||
CloseHandle(procHandle);
|
|
||||||
if (bIsWow64) // NOT a native 64bit process
|
|
||||||
return false;
|
|
||||||
return true;// is a native 64bit process
|
|
||||||
}
|
|
||||||
return false; //some error finding function "IsWow64Process" assume not 64-bit
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) DWORD GetProcessMainThreadId(DWORD procId)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifndef MAKEULONGLONG
|
|
||||||
#define MAKEULONGLONG(ldw, hdw) ((ULONGLONG(hdw) << 32) | ((ldw) & 0xFFFFFFFF))
|
|
||||||
#endif
|
|
||||||
#ifndef MAXULONGLONG
|
|
||||||
#define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DWORD dwMainThreadID = 0;
|
|
||||||
ULONGLONG ullMinCreateTime = MAXULONGLONG;
|
|
||||||
//includes all threads in the system
|
|
||||||
HANDLE hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
|
||||||
if (hThreadSnap != INVALID_HANDLE_VALUE) {
|
|
||||||
THREADENTRY32 th32;
|
|
||||||
th32.dwSize = sizeof(THREADENTRY32);
|
|
||||||
BOOL bOK = TRUE;
|
|
||||||
//Enumerate all threads in the system and filter on th32OwnerProcessID = pid
|
|
||||||
for (bOK = Thread32First(hThreadSnap, &th32); bOK ; bOK = Thread32Next(hThreadSnap, &th32)) {
|
|
||||||
//if (th32.dwSize >= FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(th32.th32OwnerProcessID)) {
|
|
||||||
if (th32.th32OwnerProcessID == procId && (th32.dwSize >= FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(th32.th32OwnerProcessID))) {
|
|
||||||
//_tprintf(_T("DEBUG Enumerate Process (%ld) Thread Id: %ld\n"), procId, th32.th32ThreadID);
|
|
||||||
HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, TRUE, th32.th32ThreadID);
|
|
||||||
if (hThread) {
|
|
||||||
FILETIME afTimes[4] = {0};
|
|
||||||
if (GetThreadTimes(hThread, &afTimes[0], &afTimes[1], &afTimes[2], &afTimes[3])) {
|
|
||||||
ULONGLONG ullTest = MAKEULONGLONG(afTimes[0].dwLowDateTime, afTimes[0].dwHighDateTime);
|
|
||||||
if (ullTest && ullTest < ullMinCreateTime) { //check each thread's creation time
|
|
||||||
ullMinCreateTime = ullTest;
|
|
||||||
dwMainThreadID = th32.th32ThreadID; // let it be main thread
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CloseHandle(hThread); //must close opened thread
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifndef UNDER_CE
|
|
||||||
CloseHandle(hThreadSnap); //close thread snapshot
|
|
||||||
#else
|
|
||||||
CloseToolhelp32Snapshot(hThreadSnap); //close thread snapshot
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return dwMainThreadID; //returns main thread id or returns 0 if can't find it
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
LIBRARY MsgHook
|
|
||||||
|
|
||||||
EXPORTS
|
|
||||||
CwpHookProc @1
|
|
||||||
MsgHookProc @2
|
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{8E038A94-7D02-49E9-B9F6-5224D9D11225}</ProjectGuid>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<RootNamespace>MsgHook</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MSGHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ModuleDefinitionFile>MsgHook.def</ModuleDefinitionFile>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MSGHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ModuleDefinitionFile>MsgHook.def</ModuleDefinitionFile>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MSGHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>MsgHook.def</ModuleDefinitionFile>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\MsgHook$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MSGHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<ModuleDefinitionFile>MsgHook.def</ModuleDefinitionFile>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\MsgHook$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="..\SetMsgHook\bin\SetMsgHook32.exe" />
|
|
||||||
<None Include="..\SetMsgHook\bin\SetMsgHook64.exe" />
|
|
||||||
<None Include="binary1.bin" />
|
|
||||||
<None Include="MsgHook.def" />
|
|
||||||
<None Include="MsgHookTest.ico" />
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
<None Include="small.ico" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="MsgLookup.h" />
|
|
||||||
<ClInclude Include="org_synthuse_MsgHook.h" />
|
|
||||||
<ClInclude Include="ResExtract.h" />
|
|
||||||
<ClInclude Include="resource.h" />
|
|
||||||
<ClInclude Include="stdafx.h" />
|
|
||||||
<ClInclude Include="targetver.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="dllmain.cpp">
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
|
||||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="MsgHook.cpp" />
|
|
||||||
<ClCompile Include="MsgHookWindow.cpp" />
|
|
||||||
<ClCompile Include="org_synthuse_MsgHook.cpp" />
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="MsgHookTest.rc" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
<None Include="MsgHookTest.ico">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="small.ico">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="MsgHook.def">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="binary1.bin">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="..\SetMsgHook\bin\SetMsgHook64.exe" />
|
|
||||||
<None Include="..\SetMsgHook\bin\SetMsgHook32.exe" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="stdafx.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="targetver.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="org_synthuse_MsgHook.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="resource.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="MsgLookup.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ResExtract.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="MsgHook.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="dllmain.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="org_synthuse_MsgHook.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="MsgHookWindow.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="MsgHookTest.rc">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</ResourceCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
</Project>
|
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
Binary file not shown.
@@ -1,635 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
// MsgHookTest.cpp : Defines the entry point for the application.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "resource.h"
|
|
||||||
#include "MsgLookup.h"
|
|
||||||
#include "ResExtract.h"
|
|
||||||
//#include "MsgHookTest.h"
|
|
||||||
//#include "MsgHook.h"
|
|
||||||
|
|
||||||
#define MAX_LOADSTRING 100
|
|
||||||
|
|
||||||
// Global Variables:
|
|
||||||
HINSTANCE hInst; // current instance
|
|
||||||
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
|
||||||
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
|
|
||||||
HWND mainHwnd = NULL;
|
|
||||||
HMENU mainMenu = NULL;
|
|
||||||
#define TXTBOX_LIMIT 700000
|
|
||||||
HWND txtbox = NULL;
|
|
||||||
HWND targetHwnd = NULL;
|
|
||||||
DWORD targetPid = 0;
|
|
||||||
const int txtboxSpacing = 2;
|
|
||||||
|
|
||||||
long msgCount = 0;
|
|
||||||
|
|
||||||
//message filters flags
|
|
||||||
bool filterWmCommand = false;
|
|
||||||
bool filterWmNotify = false;
|
|
||||||
bool filterCustom = false;
|
|
||||||
bool filterAbove = false;
|
|
||||||
|
|
||||||
TCHAR dll32bitName[500] = _T("");
|
|
||||||
TCHAR dll64bitName[500] = _T("");
|
|
||||||
char dllProcName[500] = "CwpHookProc";
|
|
||||||
|
|
||||||
//#define MAX_TEST_SIZE 100
|
|
||||||
//TCHAR targetClassname[MAX_TEST_SIZE] = _T("Notepad");
|
|
||||||
TCHAR targetProcessId[MAX_TEST_SIZE] = _T("");
|
|
||||||
TCHAR targetClassname[MAX_TEST_SIZE] = _T("");
|
|
||||||
TCHAR targetHwndStr[MAX_TEST_SIZE] = _T("");
|
|
||||||
TCHAR testWmSettextL[MAX_TEST_SIZE] = _T("This is a test");
|
|
||||||
TCHAR testWmSettextW[MAX_TEST_SIZE] = _T("0");
|
|
||||||
TCHAR testWmCommandL[MAX_TEST_SIZE] = _T("0");
|
|
||||||
TCHAR testWmCommandW[MAX_TEST_SIZE] = _T("1");
|
|
||||||
|
|
||||||
TCHAR customMsgStr[MAX_TEST_SIZE] = _T("WM_SETTEXT");
|
|
||||||
|
|
||||||
const int hotkeyIdOffset = 0;
|
|
||||||
const int pauseHotKey = 'P'; //P
|
|
||||||
bool isPaused = false;
|
|
||||||
|
|
||||||
// Forward declarations of functions included in this code module:
|
|
||||||
int APIENTRY StartWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);
|
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
|
||||||
BOOL InitInstance(HINSTANCE, int);
|
|
||||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
|
||||||
INT_PTR CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
|
|
||||||
|
|
||||||
void AppendText(HWND txtHwnd, LPCTSTR newText)
|
|
||||||
{
|
|
||||||
if (isPaused)
|
|
||||||
return;
|
|
||||||
DWORD len = GetWindowTextLength(txtHwnd);
|
|
||||||
if (len > (TXTBOX_LIMIT - 500))
|
|
||||||
{//need to truncate the beginning so the text doesn't go past it's limit
|
|
||||||
SendMessage(txtHwnd, EM_SETSEL, 0, 20000);
|
|
||||||
SendMessage(txtHwnd, EM_REPLACESEL, 0, (LPARAM)_T(""));
|
|
||||||
len = GetWindowTextLength(txtHwnd);
|
|
||||||
}
|
|
||||||
//DWORD l,r;
|
|
||||||
//SendMessage(txtHwnd, EM_GETSEL,(WPARAM)&l,(LPARAM)&r);
|
|
||||||
SendMessage(txtHwnd, EM_SETSEL, len, len);
|
|
||||||
SendMessage(txtHwnd, EM_REPLACESEL, 0, (LPARAM)newText);
|
|
||||||
len = GetWindowTextLength(txtHwnd);
|
|
||||||
SendMessage(txtHwnd, EM_SETSEL, len, len);
|
|
||||||
//SendMessage(txtHwnd, EM_SETSEL,l,r);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitMsgFiltersAndLookup()
|
|
||||||
{
|
|
||||||
if (!filterWmCommand && !filterAbove && !filterWmNotify && !filterCustom)
|
|
||||||
InitializeMsgLookup();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int allowList[4];
|
|
||||||
for (int i = 0; i < 4; i ++)
|
|
||||||
allowList[i] = -1;
|
|
||||||
|
|
||||||
if (filterWmCommand) {
|
|
||||||
AppendText(txtbox, _T("filtering on WM_COMMAND & WM_MENUCOMMAND\r\n"));
|
|
||||||
allowList[0] = WM_COMMAND;
|
|
||||||
allowList[1] = WM_MENUCOMMAND;
|
|
||||||
}
|
|
||||||
if (filterWmNotify)
|
|
||||||
{
|
|
||||||
AppendText(txtbox, _T("filtering on WM_NOTIFY\r\n"));
|
|
||||||
allowList[2] = WM_NOTIFY;
|
|
||||||
}
|
|
||||||
//if (filterAbove)
|
|
||||||
// allowList[0] = WM_COMMAND;
|
|
||||||
if (filterCustom && _tcslen(customMsgStr) > 0)
|
|
||||||
{
|
|
||||||
InitializeMsgLookup(); //initialize full msg list and do reverse lookup based on custom filter string
|
|
||||||
for (int x = 0; x < MAX_MSG_LOOKUP; x++)
|
|
||||||
{
|
|
||||||
if (_tcscmp(customMsgStr, MSG_LOOKUP[x]) == 0) {
|
|
||||||
TCHAR tmp[100];
|
|
||||||
_stprintf_s(tmp, _T("filtering on %s (%d)\r\n"), customMsgStr, x);
|
|
||||||
AppendText(txtbox, tmp);
|
|
||||||
allowList[3] = x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InitializeMsgLookup(allowList, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartMessageHook()
|
|
||||||
{
|
|
||||||
AppendText(txtbox, _T("Starting Message Hook\r\n"));
|
|
||||||
//targetHwnd = FindWindow(targetClassname, NULL);
|
|
||||||
|
|
||||||
TCHAR tmp[500];
|
|
||||||
|
|
||||||
DWORD tid = 0;
|
|
||||||
if (_tcscmp(targetHwndStr, _T("")) != 0) //if target HWND was used
|
|
||||||
{
|
|
||||||
TCHAR *stopStr;
|
|
||||||
targetHwnd = (HWND)_tcstol(targetHwndStr, &stopStr, 10);
|
|
||||||
tid = GetWindowThreadProcessId(targetHwnd, NULL);
|
|
||||||
_stprintf_s(tmp, _T("Target Handle: %ld, and Thread Id: %ld\r\n"), targetHwnd, tid);
|
|
||||||
}
|
|
||||||
|
|
||||||
targetPid = 0;
|
|
||||||
if (_tcscmp(targetProcessId, _T("")) != 0) //if target pid was used
|
|
||||||
{
|
|
||||||
TCHAR *stopStr;
|
|
||||||
targetPid = (DWORD)_tcstol(targetProcessId, &stopStr, 10);
|
|
||||||
tid = GetProcessMainThreadId(targetPid);
|
|
||||||
_stprintf_s(tmp, _T("Target PId: %ld, and Thread Id: %ld\r\n"), targetPid, tid);
|
|
||||||
}
|
|
||||||
|
|
||||||
InitMsgFiltersAndLookup();
|
|
||||||
//InitializeMsgLookup();
|
|
||||||
|
|
||||||
AppendText(txtbox, tmp);
|
|
||||||
|
|
||||||
//block self/global msg hook
|
|
||||||
if (tid == 0) {
|
|
||||||
AppendText(txtbox, _T("Target thread not found\r\n"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetPid != 0) // handle various types of bit matching
|
|
||||||
{
|
|
||||||
BOOL current64bit = IsCurrentProcess64Bit();
|
|
||||||
if (IsProcess64Bit(targetPid) && current64bit)
|
|
||||||
{
|
|
||||||
_stprintf_s(tmp, _T("Target PId (%ld) is a matching 64 bit process\r\n"), targetPid);
|
|
||||||
SetCustomMsgHookDll(dll64bitName, dllProcName);
|
|
||||||
}
|
|
||||||
else if(!IsProcess64Bit(targetPid) && !current64bit)
|
|
||||||
{
|
|
||||||
_stprintf_s(tmp, _T("Target PId (%ld) is a matching 32 bit process\r\n"), targetPid);
|
|
||||||
SetCustomMsgHookDll(dll32bitName, dllProcName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (current64bit)
|
|
||||||
_stprintf_s(tmp, _T("Target PId (%ld) is a not matching 64 bit process.\r\n"), targetPid);
|
|
||||||
else
|
|
||||||
_stprintf_s(tmp, _T("Target PId (%ld) is a not matching 32 bit process.\r\n"), targetPid);
|
|
||||||
AppendText(txtbox, tmp);
|
|
||||||
TCHAR *dllname = dll32bitName;
|
|
||||||
TCHAR *exename = _T("SetMsgHook32.exe");
|
|
||||||
int setMsgHookRes = IDR_SETMH32;
|
|
||||||
if (IsProcess64Bit(targetPid))
|
|
||||||
{
|
|
||||||
dllname = dll64bitName;
|
|
||||||
exename = _T("SetMsgHook64.exe");
|
|
||||||
setMsgHookRes = IDR_SETMH64;
|
|
||||||
}
|
|
||||||
_tcscat_s(tmp, 500, _T("Do you wish to open a new matching Message Hook Window?"));
|
|
||||||
int mbResult = MessageBox(mainHwnd, tmp, _T("Message Hook"), MB_ICONQUESTION | MB_YESNO);
|
|
||||||
if (mbResult == IDNO)
|
|
||||||
return ;
|
|
||||||
_stprintf_s(tmp, _T("%s %s 0 %d"), exename, dllname, targetPid);
|
|
||||||
RunResource(setMsgHookRes, tmp);
|
|
||||||
//EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_ENABLED);
|
|
||||||
//EnableMenuItem(mainMenu, ID_FILE_STARTHOOK, MF_DISABLED | MF_GRAYED);
|
|
||||||
_tcscat_s(tmp, 500, _T("\r\n"));
|
|
||||||
AppendText(txtbox, tmp);
|
|
||||||
PostQuitMessage(2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AppendText(txtbox, tmp);
|
|
||||||
}
|
|
||||||
if (SetMsgHook(mainHwnd, tid))
|
|
||||||
{
|
|
||||||
EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_ENABLED);
|
|
||||||
EnableMenuItem(mainMenu, ID_FILE_STARTHOOK, MF_DISABLED | MF_GRAYED);
|
|
||||||
AppendText(txtbox, _T("Hook successfully initialized\r\n"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
AppendText(txtbox, _T("Hook failed to initialize\r\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void StopMessageHook()
|
|
||||||
{
|
|
||||||
EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_DISABLED | MF_GRAYED);
|
|
||||||
EnableMenuItem(mainMenu, ID_FILE_STARTHOOK, MF_ENABLED);
|
|
||||||
AppendText(txtbox, TEXT("Stopping Message Hook\r\n"));
|
|
||||||
//KillHook();
|
|
||||||
RemoveHook();
|
|
||||||
msgCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OnCopyData(COPYDATASTRUCT* pCopyDataStruct) // WM_COPYDATA lParam will have this struct
|
|
||||||
{
|
|
||||||
if( pCopyDataStruct->cbData!=sizeof(HEVENT))
|
|
||||||
return false;
|
|
||||||
HEVENT Event;
|
|
||||||
memcpy(&Event, (HEVENT*)pCopyDataStruct->lpData, sizeof(HEVENT)); // transfer data to internal variable
|
|
||||||
if (Event.dwHookType == WH_KEYBOARD)
|
|
||||||
{
|
|
||||||
//KBDLLHOOKSTRUCT* pkh = (KBDLLHOOKSTRUCT*) Event.lParam;
|
|
||||||
//char tmp[50];
|
|
||||||
//return wkvn->KeyboardData(pkh->vkCode,Event.wParam);
|
|
||||||
}
|
|
||||||
else if (Event.dwHookType == WH_MOUSE)
|
|
||||||
{
|
|
||||||
//MSLLHOOKSTRUCT* pmh = (MSLLHOOKSTRUCT*) Event.lParam;
|
|
||||||
//char tmp[50];
|
|
||||||
//if (Event.wParam == WM_LBUTTONDOWN)
|
|
||||||
// return wkvn->MouseClickData(1,true);
|
|
||||||
// else
|
|
||||||
// return wkvn->MouseMoveData(pmh->pt.x,pmh->pt.y);
|
|
||||||
}
|
|
||||||
else if (Event.dwHookType == WH_CALLWNDPROC)
|
|
||||||
{
|
|
||||||
TCHAR *msgName = _T("unknown");
|
|
||||||
if (Event.nCode < MAX_MSG_LOOKUP)
|
|
||||||
msgName = MSG_LOOKUP[Event.nCode];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!filterAbove)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_tcscmp(msgName, _T("")) != 0)
|
|
||||||
{
|
|
||||||
++msgCount;
|
|
||||||
TCHAR msgHwndClassname[20];
|
|
||||||
GetClassName(Event.hWnd, msgHwndClassname, 20);
|
|
||||||
TCHAR tmp[200];
|
|
||||||
_stprintf_s(tmp, _T("<%07ld> hwnd: %ld (%s), msg: %s (%ld), wparam: '%s'[%ld], lparam: '%s'{%ld}\r\n"), msgCount, Event.hWnd, msgHwndClassname, msgName, Event.nCode, Event.wParamStr, Event.wParam, Event.lParamStr,Event.lParam);
|
|
||||||
AppendText(txtbox, tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendWmSettext() //ID_TESTMSGS_WM
|
|
||||||
{
|
|
||||||
//SetWindowText(targetHwnd, _T("This is a test"));
|
|
||||||
//TCHAR txt[] = _T("This is a test");
|
|
||||||
TCHAR *stopStr;
|
|
||||||
long wparam = _tcstol(testWmSettextW, &stopStr, 10);
|
|
||||||
SendMessage(targetHwnd, WM_SETTEXT, wparam, (LPARAM)testWmSettextL);
|
|
||||||
//PostMessage(targetHwnd, WM_SETTEXT, 0 , (LPARAM)txt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SendWmCommand() //ID_TESTMSGS_WM
|
|
||||||
{
|
|
||||||
TCHAR *stopStr;
|
|
||||||
HWND sendHwnd = targetHwnd;
|
|
||||||
if (_tcscmp(targetHwndStr, _T("")) != 0)
|
|
||||||
{
|
|
||||||
sendHwnd = (HWND)_tcstol(targetHwndStr, &stopStr, 10);
|
|
||||||
}
|
|
||||||
long wparam = _tcstol(testWmCommandW, &stopStr, 10);
|
|
||||||
long lparam = _tcstol(testWmCommandL, &stopStr, 10);
|
|
||||||
SendMessage(sendHwnd, WM_COMMAND, wparam, lparam);
|
|
||||||
|
|
||||||
/*
|
|
||||||
TCHAR tmp[500];
|
|
||||||
_stprintf_s(tmp, _T("hook handle %ld\r\n"), (long)GetCurrentHookHandle());
|
|
||||||
AppendText(txtbox, tmp); */
|
|
||||||
}
|
|
||||||
|
|
||||||
void HotKeyPressed(WPARAM wParam)
|
|
||||||
{
|
|
||||||
//AppendText(txtbox, _T("hotkey test"));
|
|
||||||
if (wParam == (pauseHotKey + hotkeyIdOffset))
|
|
||||||
{
|
|
||||||
if (!isPaused)
|
|
||||||
{
|
|
||||||
AppendText(txtbox, _T("Paused\r\n"));
|
|
||||||
isPaused = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
isPaused = false;
|
|
||||||
AppendText(txtbox, _T("Unpaused\r\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) void CreateMsgHookWindow(LPTSTR lpCmdLine)
|
|
||||||
{
|
|
||||||
//StartWinMain(GetModuleHandle(NULL), NULL, lpCmdLine, SW_SHOW);
|
|
||||||
StartWinMain((HINSTANCE)pData->g_hInstance, NULL, lpCmdLine, SW_SHOW);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int APIENTRY StartWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
|
||||||
{
|
|
||||||
// get this Dlls path, by default set both 32 and 64 bit names the same
|
|
||||||
if (_tcscmp(dll32bitName, _T("")) == 0 && _tcscmp(dll64bitName, _T("")) == 0)
|
|
||||||
{
|
|
||||||
HMODULE hm = NULL;
|
|
||||||
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,(LPCWSTR) &StartWinMain, &hm))
|
|
||||||
{
|
|
||||||
int ret = GetLastError();
|
|
||||||
fprintf(stderr, "GetModuleHandle returned %d\n", ret);
|
|
||||||
}
|
|
||||||
GetModuleFileName(hm, dll32bitName, sizeof(dll32bitName));
|
|
||||||
GetModuleFileName(hm, dll64bitName, sizeof(dll64bitName));
|
|
||||||
//MessageBox(0, dll32bitname, dll64bitname, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
|
||||||
|
|
||||||
// TODO: Place code here.
|
|
||||||
MSG msg;
|
|
||||||
HACCEL hAccelTable;
|
|
||||||
|
|
||||||
// Initialize global strings
|
|
||||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
|
||||||
LoadString(hInstance, IDC_MSGHOOKTEST, szWindowClass, MAX_LOADSTRING);
|
|
||||||
MyRegisterClass(hInstance);
|
|
||||||
|
|
||||||
// Perform application initialization:
|
|
||||||
if (!InitInstance (hInstance, nCmdShow))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MSGHOOKTEST));
|
|
||||||
|
|
||||||
if (lpCmdLine != NULL) //process command line args
|
|
||||||
{
|
|
||||||
if (_tcslen(lpCmdLine) > 0)
|
|
||||||
{
|
|
||||||
TCHAR *stopStr;
|
|
||||||
targetPid = (DWORD)_tcstol(lpCmdLine, &stopStr, 10);
|
|
||||||
_stprintf_s(targetProcessId, _T("%ld"), (long)targetPid);
|
|
||||||
StartMessageHook();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main message loop:
|
|
||||||
while (GetMessage(&msg, NULL, 0, 0))
|
|
||||||
{
|
|
||||||
//if (msg.message == WM_HOTKEY)
|
|
||||||
// HotKeyPressed(msg.wParam);
|
|
||||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnregisterHotKey(mainHwnd, pauseHotKey + hotkeyIdOffset);
|
|
||||||
|
|
||||||
return (int) msg.wParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// FUNCTION: MyRegisterClass()
|
|
||||||
//
|
|
||||||
// PURPOSE: Registers the window class.
|
|
||||||
//
|
|
||||||
// COMMENTS:
|
|
||||||
//
|
|
||||||
// This function and its usage are only necessary if you want this code
|
|
||||||
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
|
|
||||||
// function that was added to Windows 95. It is important to call this function
|
|
||||||
// so that the application will get 'well formed' small icons associated
|
|
||||||
// with it.
|
|
||||||
//
|
|
||||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
|
||||||
{
|
|
||||||
WNDCLASSEX wcex;
|
|
||||||
|
|
||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
|
||||||
|
|
||||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
|
||||||
wcex.lpfnWndProc = WndProc;
|
|
||||||
wcex.cbClsExtra = 0;
|
|
||||||
wcex.cbWndExtra = 0;
|
|
||||||
wcex.hInstance = hInstance;
|
|
||||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MSGHOOKICO));
|
|
||||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
||||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
|
||||||
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_MSGHOOKTEST);
|
|
||||||
wcex.lpszClassName = szWindowClass;
|
|
||||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
|
||||||
|
|
||||||
return RegisterClassEx(&wcex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// FUNCTION: InitInstance(HINSTANCE, int)
|
|
||||||
//
|
|
||||||
// PURPOSE: Saves instance handle and creates main window
|
|
||||||
//
|
|
||||||
// COMMENTS:
|
|
||||||
//
|
|
||||||
// In this function, we save the instance handle in a global variable and
|
|
||||||
// create and display the main program window.
|
|
||||||
//
|
|
||||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|
||||||
{
|
|
||||||
HWND hWnd;
|
|
||||||
|
|
||||||
hInst = hInstance; // Store instance handle in our global variable
|
|
||||||
|
|
||||||
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
|
||||||
CW_USEDEFAULT, 0, 700, 300, NULL, NULL, hInstance, NULL);
|
|
||||||
|
|
||||||
if (!hWnd) {
|
|
||||||
DWORD lastErr = GetLastError();
|
|
||||||
printf("Error Creating Window %d\n", lastErr);
|
|
||||||
_tprintf(_T("Window Class Name: %s, Instance: %ld\n"), szWindowClass, (long)hInstance);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
mainHwnd = hWnd;
|
|
||||||
|
|
||||||
RECT rect;
|
|
||||||
GetClientRect(hWnd, &rect);
|
|
||||||
// make the txtbox edit control almost the same size as the parent window
|
|
||||||
//WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL
|
|
||||||
txtbox = CreateWindow(TEXT("Edit"),TEXT(""), WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_READONLY,
|
|
||||||
txtboxSpacing, txtboxSpacing,rect.right-(txtboxSpacing*2), rect.bottom-(txtboxSpacing*2), hWnd, NULL, NULL, NULL);
|
|
||||||
SendMessage(txtbox, EM_SETLIMITTEXT, (WPARAM)TXTBOX_LIMIT, 0);
|
|
||||||
|
|
||||||
HFONT hFont = CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
||||||
OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
|
||||||
DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"));
|
|
||||||
SendMessage(txtbox, WM_SETFONT, (WPARAM)hFont, TRUE);
|
|
||||||
|
|
||||||
mainMenu = GetMenu(mainHwnd);
|
|
||||||
EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_DISABLED | MF_GRAYED);
|
|
||||||
|
|
||||||
RegisterHotKey(mainHwnd, pauseHotKey + hotkeyIdOffset, MOD_NOREPEAT | MOD_SHIFT | MOD_CONTROL, pauseHotKey);
|
|
||||||
|
|
||||||
ShowWindow(hWnd, nCmdShow);
|
|
||||||
UpdateWindow(hWnd);
|
|
||||||
|
|
||||||
//set always on top
|
|
||||||
SetWindowPos(mainHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE| SWP_NOMOVE);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
|
||||||
//
|
|
||||||
// PURPOSE: Processes messages for the main window.
|
|
||||||
//
|
|
||||||
// WM_COMMAND - process the application menu
|
|
||||||
// WM_PAINT - Paint the main window
|
|
||||||
// WM_DESTROY - post a quit message and return
|
|
||||||
//
|
|
||||||
//
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
int wmId, wmEvent;
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
HDC hdc;
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_CREATE:
|
|
||||||
//appendText(txtbox, TEXT("test\r\n"));
|
|
||||||
break;
|
|
||||||
case WM_COPYDATA:
|
|
||||||
return (OnCopyData((COPYDATASTRUCT *) lParam));
|
|
||||||
break;
|
|
||||||
case WM_COMMAND:
|
|
||||||
wmId = LOWORD(wParam);
|
|
||||||
wmEvent = HIWORD(wParam);
|
|
||||||
// Parse the menu selections:
|
|
||||||
switch (wmId)
|
|
||||||
{
|
|
||||||
case ID_FILE_STARTHOOK:
|
|
||||||
StartMessageHook();
|
|
||||||
break;
|
|
||||||
case ID_FILE_STOPHOOK:
|
|
||||||
StopMessageHook();
|
|
||||||
break;
|
|
||||||
case ID_TESTMSGS_WM:
|
|
||||||
SendWmSettext();
|
|
||||||
break;
|
|
||||||
case ID_TESTMSGS_WMCOM:
|
|
||||||
SendWmCommand();
|
|
||||||
break;
|
|
||||||
case ID_PROC64TEST:
|
|
||||||
if (_tcscmp(targetProcessId, _T("")) != 0) //if target pid was used
|
|
||||||
{
|
|
||||||
TCHAR tmp[500];
|
|
||||||
TCHAR *stopStr;
|
|
||||||
targetPid = (DWORD)_tcstol(targetProcessId, &stopStr, 10);
|
|
||||||
BOOL current64bit = IsCurrentProcess64Bit();
|
|
||||||
if (IsProcess64Bit(targetPid) && current64bit)
|
|
||||||
_stprintf_s(tmp, _T("Target pid (%ld) is a matching 64 bit process\r\n"), targetPid);
|
|
||||||
else if(!IsProcess64Bit(targetPid) && !current64bit)
|
|
||||||
_stprintf_s(tmp, _T("Target pid (%ld) is a matching 32 bit process\r\n"), targetPid);
|
|
||||||
else if (IsProcess64Bit(targetPid))
|
|
||||||
_stprintf_s(tmp, _T("Target pid (%ld) is 64 bit process\r\n"), targetPid);
|
|
||||||
else
|
|
||||||
_stprintf_s(tmp, _T("Target pid (%ld) is 32 bit process\r\n"), targetPid);
|
|
||||||
AppendText(txtbox, tmp);
|
|
||||||
//ExtractResource(IDR_SETMH32, _T("SetMsgHook32.exe"));
|
|
||||||
//_stprintf_s(tmp, _T(" %s %ld %d"), dll32bitName, (long)mainHwnd, targetPid);
|
|
||||||
//RunResource(IDR_SETMH32, tmp);
|
|
||||||
|
|
||||||
//MessageBox(0, , _T("64 bit Test"), 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ID_FILE_SETTINGS:
|
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, DlgProc);
|
|
||||||
break;
|
|
||||||
case IDM_ABOUT:
|
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, DlgProc);
|
|
||||||
break;
|
|
||||||
case ID_FILE_CLEAR:
|
|
||||||
SetWindowText(txtbox, _T(""));
|
|
||||||
break;
|
|
||||||
case IDM_EXIT:
|
|
||||||
DestroyWindow(hWnd);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WM_HOTKEY:
|
|
||||||
HotKeyPressed(wParam);
|
|
||||||
break;
|
|
||||||
case WM_PAINT:
|
|
||||||
hdc = BeginPaint(hWnd, &ps);
|
|
||||||
// TODO: Add any drawing code here...
|
|
||||||
EndPaint(hWnd, &ps);
|
|
||||||
break;
|
|
||||||
case WM_SIZE:
|
|
||||||
{ //resize the txtbox when the parent window size changes
|
|
||||||
int nWidth = LOWORD(lParam);
|
|
||||||
int nHeight = HIWORD(lParam);
|
|
||||||
SetWindowPos(txtbox, HWND_NOTOPMOST, txtboxSpacing, txtboxSpacing, nWidth-(txtboxSpacing*2), nHeight-(txtboxSpacing*2), SWP_NOZORDER|SWP_NOMOVE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WM_DESTROY:
|
|
||||||
PostQuitMessage(0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message handler for about box.
|
|
||||||
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
case WM_INITDIALOG:
|
|
||||||
{
|
|
||||||
//IDC_EDIT1
|
|
||||||
//SendDlgItemMessage(hDlg, IDC_EDIT1, WM_SETTEXT, 0 , (LPARAM)targetClassname);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_TARGETPID, WM_SETTEXT, 0 , (LPARAM)targetProcessId);
|
|
||||||
if (filterWmCommand)
|
|
||||||
SendDlgItemMessage(hDlg, IDC_CHECK_CMD, BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (filterWmNotify)
|
|
||||||
SendDlgItemMessage(hDlg, IDC_CHECK_NOT, BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (filterAbove)
|
|
||||||
SendDlgItemMessage(hDlg, IDC_CHECK_ABO, BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
if (filterCustom)
|
|
||||||
SendDlgItemMessage(hDlg, IDC_CUSTOMCHK, BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_WMCOMW, WM_SETTEXT, 0 , (LPARAM)testWmCommandW);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_WMCOML, WM_SETTEXT, 0 , (LPARAM)testWmCommandL);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_WMSETW, WM_SETTEXT, 0 , (LPARAM)testWmSettextW);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_WMSETL, WM_SETTEXT, 0 , (LPARAM)testWmSettextL);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_HWND, WM_SETTEXT, 0 , (LPARAM)targetHwndStr);
|
|
||||||
SendDlgItemMessage(hDlg, IDC_CUSTOMMSG, WM_SETTEXT, 0 , (LPARAM)customMsgStr);
|
|
||||||
}
|
|
||||||
return (INT_PTR)TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
if (LOWORD(wParam) == IDOK) //only save on OK
|
|
||||||
{
|
|
||||||
//GetDlgItemText(hDlg, IDC_EDIT1, targetClassname, MAX_TEST_SIZE);
|
|
||||||
GetDlgItemText(hDlg, IDC_TARGETPID, targetProcessId, MAX_TEST_SIZE);
|
|
||||||
GetDlgItemText(hDlg, IDC_WMCOMW, testWmCommandW, MAX_TEST_SIZE);
|
|
||||||
GetDlgItemText(hDlg, IDC_WMCOML, testWmCommandL, MAX_TEST_SIZE);
|
|
||||||
GetDlgItemText(hDlg, IDC_WMSETW, testWmSettextW, MAX_TEST_SIZE);
|
|
||||||
GetDlgItemText(hDlg, IDC_WMSETL, testWmSettextL, MAX_TEST_SIZE);
|
|
||||||
GetDlgItemText(hDlg, IDC_HWND, targetHwndStr, MAX_TEST_SIZE);
|
|
||||||
GetDlgItemText(hDlg, IDC_CUSTOMMSG, customMsgStr, MAX_TEST_SIZE);
|
|
||||||
// check filter options
|
|
||||||
filterWmCommand = (SendDlgItemMessage(hDlg, IDC_CHECK_CMD, BM_GETCHECK, 0, 0) == BST_CHECKED); // the hard way
|
|
||||||
filterWmNotify = (IsDlgButtonChecked(hDlg, IDC_CHECK_NOT) == BST_CHECKED);// the easy way
|
|
||||||
filterAbove = (IsDlgButtonChecked(hDlg, IDC_CHECK_ABO) == BST_CHECKED);
|
|
||||||
filterCustom = (IsDlgButtonChecked(hDlg, IDC_CUSTOMCHK) == BST_CHECKED);
|
|
||||||
|
|
||||||
InitMsgFiltersAndLookup();
|
|
||||||
}
|
|
||||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
|
||||||
{
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
return (INT_PTR)TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return (INT_PTR)FALSE;
|
|
||||||
}
|
|
||||||
@@ -1,250 +0,0 @@
|
|||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
// MSG Array LOOKUP
|
|
||||||
const int MAX_MSG_LOOKUP = 1024;
|
|
||||||
const int MAX_MSG_NAME = 21;
|
|
||||||
TCHAR MSG_LOOKUP[MAX_MSG_LOOKUP][MAX_MSG_NAME] = {
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//void InitializeMsgLookup() below
|
|
||||||
void InitializeMsgLookup(int allowList[], int allowSize)
|
|
||||||
{
|
|
||||||
for (int i = 0 ; i < MAX_MSG_LOOKUP ; i++)
|
|
||||||
{
|
|
||||||
bool allowFlg = true;
|
|
||||||
if (allowSize > 0)
|
|
||||||
allowFlg = false;
|
|
||||||
for (int a = 0 ; a < allowSize ; a++)
|
|
||||||
if (allowList[a] == i)
|
|
||||||
allowFlg = true;
|
|
||||||
if (!allowFlg)
|
|
||||||
{
|
|
||||||
memset((void *)&MSG_LOOKUP[i], '\0', sizeof(TCHAR) * MAX_MSG_NAME); //blank it
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case WM_NULL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NULL")); break;
|
|
||||||
case WM_CREATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CREATE")); break;
|
|
||||||
case WM_DESTROY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DESTROY")); break;
|
|
||||||
case WM_MOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOVE")); break;
|
|
||||||
case WM_SIZE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SIZE")); break;
|
|
||||||
case WM_ACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ACTIVATE")); break;
|
|
||||||
case WM_SETFOCUS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETFOCUS")); break;
|
|
||||||
case WM_KILLFOCUS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KILLFOCUS")); break;
|
|
||||||
case WM_ENABLE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENABLE")); break;
|
|
||||||
case WM_SETREDRAW: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETREDRAW")); break;
|
|
||||||
case WM_SETTEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETTEXT")); break;
|
|
||||||
case WM_GETTEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETTEXT")); break;
|
|
||||||
case WM_GETTEXTLENGTH: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETTEXTLENGTH")); break;
|
|
||||||
case WM_PAINT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PAINT")); break;
|
|
||||||
case WM_CLOSE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CLOSE")); break;
|
|
||||||
case WM_QUERYENDSESSION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYENDSESSION")); break;
|
|
||||||
case WM_QUIT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUIT")); break;
|
|
||||||
case WM_QUERYOPEN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYOPEN")); break;
|
|
||||||
case WM_ERASEBKGND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ERASEBKGND")); break;
|
|
||||||
case WM_SYSCOLORCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSCOLORCHANGE")); break;
|
|
||||||
case WM_ENDSESSION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENDSESSION")); break;
|
|
||||||
case 0x17: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSTEMERROR")); break;
|
|
||||||
case WM_SHOWWINDOW: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SHOWWINDOW")); break;
|
|
||||||
case 0x19: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLOR")); break;
|
|
||||||
case WM_WININICHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_WININICHANGE")); break;
|
|
||||||
//case WM_SETTINGCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETTINGCHANGE")); break;
|
|
||||||
case WM_DEVMODECHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DEVMODECHANGE")); break;
|
|
||||||
case WM_ACTIVATEAPP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ACTIVATEAPP")); break;
|
|
||||||
case WM_FONTCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_FONTCHANGE")); break;
|
|
||||||
case WM_TIMECHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_TIMECHANGE")); break;
|
|
||||||
case WM_CANCELMODE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CANCELMODE")); break;
|
|
||||||
case WM_SETCURSOR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETCURSOR")); break;
|
|
||||||
case WM_MOUSEACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEACTIVATE")); break;
|
|
||||||
case WM_CHILDACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHILDACTIVATE")); break;
|
|
||||||
case WM_QUEUESYNC: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUEUESYNC")); break;
|
|
||||||
case WM_GETMINMAXINFO: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETMINMAXINFO")); break;
|
|
||||||
case WM_PAINTICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PAINTICON")); break;
|
|
||||||
case WM_ICONERASEBKGND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ICONERASEBKGND")); break;
|
|
||||||
case WM_NEXTDLGCTL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NEXTDLGCTL")); break;
|
|
||||||
case WM_SPOOLERSTATUS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SPOOLERSTATUS")); break;
|
|
||||||
case WM_DRAWITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DRAWITEM")); break;
|
|
||||||
case WM_MEASUREITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MEASUREITEM")); break;
|
|
||||||
case WM_DELETEITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DELETEITEM")); break;
|
|
||||||
case WM_VKEYTOITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_VKEYTOITEM")); break;
|
|
||||||
case WM_CHARTOITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHARTOITEM")); break;
|
|
||||||
case WM_SETFONT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETFONT")); break;
|
|
||||||
case WM_GETFONT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETFONT")); break;
|
|
||||||
case WM_SETHOTKEY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETHOTKEY")); break;
|
|
||||||
case WM_GETHOTKEY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETHOTKEY")); break;
|
|
||||||
case WM_QUERYDRAGICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYDRAGICON")); break;
|
|
||||||
case WM_COMPAREITEM: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COMPAREITEM")); break;
|
|
||||||
case WM_COMPACTING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COMPACTING")); break;
|
|
||||||
case WM_WINDOWPOSCHANGING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_WINDOWPOSCHANGING")); break;
|
|
||||||
case WM_WINDOWPOSCHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_WINDOWPOSCHANGED")); break;
|
|
||||||
case WM_POWER: _tcscpy_s(MSG_LOOKUP[i], _T("WM_POWER")); break;
|
|
||||||
case WM_COPYDATA: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COPYDATA")); break;
|
|
||||||
case WM_CANCELJOURNAL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CANCELJOURNAL")); break;
|
|
||||||
case WM_NOTIFY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NOTIFY")); break;
|
|
||||||
case WM_INPUTLANGCHANGEREQUEST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INPUTLANGCHANGERE")); break;
|
|
||||||
case WM_INPUTLANGCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INPUTLANGCHANGE")); break;
|
|
||||||
case WM_TCARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_TCARD")); break;
|
|
||||||
case WM_HELP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HELP")); break;
|
|
||||||
case WM_USERCHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_USERCHANGED")); break;
|
|
||||||
case WM_NOTIFYFORMAT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NOTIFYFORMAT")); break;
|
|
||||||
case WM_CONTEXTMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CONTEXTMENU")); break;
|
|
||||||
case WM_STYLECHANGING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_STYLECHANGING")); break;
|
|
||||||
case WM_STYLECHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_STYLECHANGED")); break;
|
|
||||||
case WM_DISPLAYCHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DISPLAYCHANGE")); break;
|
|
||||||
case WM_GETICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETICON")); break;
|
|
||||||
case WM_SETICON: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SETICON")); break;
|
|
||||||
case WM_NCCREATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCCREATE")); break;
|
|
||||||
case WM_NCDESTROY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCDESTROY")); break;
|
|
||||||
case WM_NCCALCSIZE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCCALCSIZE")); break;
|
|
||||||
case WM_NCHITTEST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCHITTEST")); break;
|
|
||||||
case WM_NCPAINT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCPAINT")); break;
|
|
||||||
case WM_NCACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCACTIVATE")); break;
|
|
||||||
case WM_GETDLGCODE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_GETDLGCODE")); break;
|
|
||||||
case WM_NCMOUSEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMOUSEMOVE")); break;
|
|
||||||
case WM_NCLBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCLBUTTONDOWN")); break;
|
|
||||||
case WM_NCLBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCLBUTTONUP")); break;
|
|
||||||
case WM_NCLBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCLBUTTONDBLCLK")); break;
|
|
||||||
case WM_NCRBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCRBUTTONDOWN")); break;
|
|
||||||
case WM_NCRBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCRBUTTONUP")); break;
|
|
||||||
case WM_NCRBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCRBUTTONDBLCLK")); break;
|
|
||||||
case WM_NCMBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMBUTTONDOWN")); break;
|
|
||||||
case WM_NCMBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMBUTTONUP")); break;
|
|
||||||
case WM_NCMBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMBUTTONDBLCLK")); break;
|
|
||||||
//case WM_KEYFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYFIRST")); break;
|
|
||||||
case WM_KEYDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYDOWN")); break;
|
|
||||||
case WM_KEYUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYUP")); break;
|
|
||||||
case WM_CHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHAR")); break;
|
|
||||||
case WM_DEADCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DEADCHAR")); break;
|
|
||||||
case WM_SYSKEYDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSKEYDOWN")); break;
|
|
||||||
case WM_SYSKEYUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSKEYUP")); break;
|
|
||||||
case WM_SYSCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSCHAR")); break;
|
|
||||||
case WM_SYSDEADCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSDEADCHAR")); break;
|
|
||||||
case WM_KEYLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_KEYLAST")); break;
|
|
||||||
case WM_IME_STARTCOMPOSITION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_STARTCOMPOSIT")); break;
|
|
||||||
case WM_IME_ENDCOMPOSITION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_ENDCOMPOSITIO")); break;
|
|
||||||
case WM_IME_COMPOSITION: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_COMPOSITION")); break;
|
|
||||||
//case WM_IME_KEYLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_KEYLAST")); break;
|
|
||||||
case WM_INITDIALOG: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INITDIALOG")); break;
|
|
||||||
case WM_COMMAND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COMMAND")); break;
|
|
||||||
case WM_SYSCOMMAND: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SYSCOMMAND")); break;
|
|
||||||
case WM_TIMER: _tcscpy_s(MSG_LOOKUP[i], _T("WM_TIMER")); break;
|
|
||||||
case WM_HSCROLL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HSCROLL")); break;
|
|
||||||
case WM_VSCROLL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_VSCROLL")); break;
|
|
||||||
case WM_INITMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INITMENU")); break;
|
|
||||||
case WM_INITMENUPOPUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_INITMENUPOPUP")); break;
|
|
||||||
case WM_MENUSELECT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MENUSELECT")); break;
|
|
||||||
case WM_MENUCHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MENUCHAR")); break;
|
|
||||||
case WM_ENTERIDLE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENTERIDLE")); break;
|
|
||||||
case WM_CTLCOLORMSGBOX: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORMSGBOX")); break;
|
|
||||||
case WM_CTLCOLOREDIT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLOREDIT")); break;
|
|
||||||
case WM_CTLCOLORLISTBOX: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORLISTBOX")); break;
|
|
||||||
case WM_CTLCOLORBTN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORBTN")); break;
|
|
||||||
case WM_CTLCOLORDLG: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORDLG")); break;
|
|
||||||
case WM_CTLCOLORSCROLLBAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORSCROLLBAR")); break;
|
|
||||||
case WM_CTLCOLORSTATIC: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CTLCOLORSTATIC")); break;
|
|
||||||
//case WM_MOUSEFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEFIRST")); break;
|
|
||||||
case WM_MOUSEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEMOVE")); break;
|
|
||||||
case WM_LBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_LBUTTONDOWN")); break;
|
|
||||||
case WM_LBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_LBUTTONUP")); break;
|
|
||||||
case WM_LBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_LBUTTONDBLCLK")); break;
|
|
||||||
case WM_RBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RBUTTONDOWN")); break;
|
|
||||||
case WM_RBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RBUTTONUP")); break;
|
|
||||||
case WM_RBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RBUTTONDBLCLK")); break;
|
|
||||||
case WM_MBUTTONDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MBUTTONDOWN")); break;
|
|
||||||
case WM_MBUTTONUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MBUTTONUP")); break;
|
|
||||||
case WM_MBUTTONDBLCLK: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MBUTTONDBLCLK")); break;
|
|
||||||
case WM_MOUSEWHEEL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEWHEEL")); break;
|
|
||||||
case WM_MOUSEHWHEEL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEHWHEEL")); break;
|
|
||||||
case WM_PARENTNOTIFY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PARENTNOTIFY")); break;
|
|
||||||
case WM_ENTERMENULOOP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENTERMENULOOP")); break;
|
|
||||||
case WM_EXITMENULOOP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_EXITMENULOOP")); break;
|
|
||||||
case WM_NEXTMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NEXTMENU")); break;
|
|
||||||
case WM_SIZING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SIZING")); break;
|
|
||||||
case WM_CAPTURECHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CAPTURECHANGED")); break;
|
|
||||||
case WM_MOVING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOVING")); break;
|
|
||||||
case WM_POWERBROADCAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_POWERBROADCAST")); break;
|
|
||||||
case WM_DEVICECHANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DEVICECHANGE")); break;
|
|
||||||
case WM_MDICREATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDICREATE")); break;
|
|
||||||
case WM_MDIDESTROY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIDESTROY")); break;
|
|
||||||
case WM_MDIACTIVATE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIACTIVATE")); break;
|
|
||||||
case WM_MDIRESTORE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIRESTORE")); break;
|
|
||||||
case WM_MDINEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDINEXT")); break;
|
|
||||||
case WM_MDIMAXIMIZE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIMAXIMIZE")); break;
|
|
||||||
case WM_MDITILE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDITILE")); break;
|
|
||||||
case WM_MDICASCADE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDICASCADE")); break;
|
|
||||||
case WM_MDIICONARRANGE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIICONARRANGE")); break;
|
|
||||||
case WM_MDIGETACTIVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIGETACTIVE")); break;
|
|
||||||
case WM_MDISETMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDISETMENU")); break;
|
|
||||||
case WM_ENTERSIZEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ENTERSIZEMOVE")); break;
|
|
||||||
case WM_EXITSIZEMOVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_EXITSIZEMOVE")); break;
|
|
||||||
case WM_DROPFILES: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DROPFILES")); break;
|
|
||||||
case WM_MDIREFRESHMENU: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MDIREFRESHMENU")); break;
|
|
||||||
case WM_IME_SETCONTEXT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_SETCONTEXT")); break;
|
|
||||||
case WM_IME_NOTIFY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_NOTIFY")); break;
|
|
||||||
case WM_IME_CONTROL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_CONTROL")); break;
|
|
||||||
case WM_IME_COMPOSITIONFULL: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_COMPOSITIONFU")); break;
|
|
||||||
case WM_IME_SELECT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_SELECT")); break;
|
|
||||||
case WM_IME_CHAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_CHAR")); break;
|
|
||||||
case WM_IME_KEYDOWN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_KEYDOWN")); break;
|
|
||||||
case WM_IME_KEYUP: _tcscpy_s(MSG_LOOKUP[i], _T("WM_IME_KEYUP")); break;
|
|
||||||
case WM_MOUSEHOVER: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSEHOVER")); break;
|
|
||||||
case WM_NCMOUSELEAVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_NCMOUSELEAVE")); break;
|
|
||||||
case WM_MOUSELEAVE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_MOUSELEAVE")); break;
|
|
||||||
case WM_CUT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CUT")); break;
|
|
||||||
case WM_COPY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COPY")); break;
|
|
||||||
case WM_PASTE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PASTE")); break;
|
|
||||||
case WM_CLEAR: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CLEAR")); break;
|
|
||||||
case WM_UNDO: _tcscpy_s(MSG_LOOKUP[i], _T("WM_UNDO")); break;
|
|
||||||
case WM_RENDERFORMAT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RENDERFORMAT")); break;
|
|
||||||
case WM_RENDERALLFORMATS: _tcscpy_s(MSG_LOOKUP[i], _T("WM_RENDERALLFORMATS")); break;
|
|
||||||
case WM_DESTROYCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DESTROYCLIPBOARD")); break;
|
|
||||||
case WM_DRAWCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DRAWCLIPBOARD")); break;
|
|
||||||
case WM_PAINTCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PAINTCLIPBOARD")); break;
|
|
||||||
case WM_VSCROLLCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_VSCROLLCLIPBOARD")); break;
|
|
||||||
case WM_SIZECLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_SIZECLIPBOARD")); break;
|
|
||||||
case WM_ASKCBFORMATNAME: _tcscpy_s(MSG_LOOKUP[i], _T("WM_ASKCBFORMATNAME")); break;
|
|
||||||
case WM_CHANGECBCHAIN: _tcscpy_s(MSG_LOOKUP[i], _T("WM_CHANGECBCHAIN")); break;
|
|
||||||
case WM_HSCROLLCLIPBOARD: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HSCROLLCLIPBOARD")); break;
|
|
||||||
case WM_QUERYNEWPALETTE: _tcscpy_s(MSG_LOOKUP[i], _T("WM_QUERYNEWPALETTE")); break;
|
|
||||||
case WM_PALETTEISCHANGING: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PALETTEISCHANGING")); break;
|
|
||||||
case WM_PALETTECHANGED: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PALETTECHANGED")); break;
|
|
||||||
case WM_HOTKEY: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HOTKEY")); break;
|
|
||||||
case WM_PRINT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PRINT")); break;
|
|
||||||
case WM_PRINTCLIENT: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PRINTCLIENT")); break;
|
|
||||||
case WM_HANDHELDFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HANDHELDFIRST")); break;
|
|
||||||
case WM_HANDHELDLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_HANDHELDLAST")); break;
|
|
||||||
case WM_PENWINFIRST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PENWINFIRST")); break;
|
|
||||||
case WM_PENWINLAST: _tcscpy_s(MSG_LOOKUP[i], _T("WM_PENWINLAST")); break;
|
|
||||||
case 0x390: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COALESCE_FIRST")); break;
|
|
||||||
case 0x39F: _tcscpy_s(MSG_LOOKUP[i], _T("WM_COALESCE_LAST")); break;
|
|
||||||
case 0x3E0: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_FIRST")); break;
|
|
||||||
//case 0x3E0: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_INITIATE")); break;
|
|
||||||
case 0x3E1: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_TERMINATE")); break;
|
|
||||||
case 0x3E2: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_ADVISE")); break;
|
|
||||||
case 0x3E3: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_UNADVISE")); break;
|
|
||||||
case 0x3E4: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_ACK")); break;
|
|
||||||
case 0x3E5: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_DATA")); break;
|
|
||||||
case 0x3E6: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_REQUEST")); break;
|
|
||||||
case 0x3E7: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_POKE")); break;
|
|
||||||
case 0x3E8: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_EXECUTE")); break;
|
|
||||||
//case 0x3E8: _tcscpy_s(MSG_LOOKUP[i], _T("WM_DDE_LAST")); break;
|
|
||||||
|
|
||||||
//case : _tcscpy_s(MSG_LOOKUP[i], _T("")); break;
|
|
||||||
default:
|
|
||||||
memset((void *)&MSG_LOOKUP[i], '\0', sizeof(TCHAR) * MAX_MSG_NAME);
|
|
||||||
//_tcscpy_s(MSG_LOOKUP[i], 20, _T(""));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitializeMsgLookup()
|
|
||||||
{
|
|
||||||
int allowList[1];
|
|
||||||
allowList[0] = -1;
|
|
||||||
InitializeMsgLookup(allowList, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
========================================================================
|
|
||||||
DYNAMIC LINK LIBRARY : MsgHook Project Overview
|
|
||||||
========================================================================
|
|
||||||
|
|
||||||
AppWizard has created this MsgHook DLL for you.
|
|
||||||
|
|
||||||
This file contains a summary of what you will find in each of the files that
|
|
||||||
make up your MsgHook application.
|
|
||||||
|
|
||||||
|
|
||||||
MsgHook.vcxproj
|
|
||||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the version of Visual C++ that generated the file, and
|
|
||||||
information about the platforms, configurations, and project features selected with the
|
|
||||||
Application Wizard.
|
|
||||||
|
|
||||||
MsgHook.vcxproj.filters
|
|
||||||
This is the filters file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the association between the files in your project
|
|
||||||
and the filters. This association is used in the IDE to show grouping of files with
|
|
||||||
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
|
|
||||||
"Source Files" filter).
|
|
||||||
|
|
||||||
MsgHook.cpp
|
|
||||||
This is the main DLL source file.
|
|
||||||
|
|
||||||
When created, this DLL does not export any symbols. As a result, it
|
|
||||||
will not produce a .lib file when it is built. If you wish this project
|
|
||||||
to be a project dependency of some other project, you will either need to
|
|
||||||
add code to export some symbols from the DLL so that an export library
|
|
||||||
will be produced, or you can set the Ignore Input Library property to Yes
|
|
||||||
on the General propert page of the Linker folder in the project's Property
|
|
||||||
Pages dialog box.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Other standard files:
|
|
||||||
|
|
||||||
StdAfx.h, StdAfx.cpp
|
|
||||||
These files are used to build a precompiled header (PCH) file
|
|
||||||
named MsgHook.pch and a precompiled types file named StdAfx.obj.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Other notes:
|
|
||||||
|
|
||||||
AppWizard uses "TODO:" comments to indicate parts of the source code you
|
|
||||||
should add to or customize.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
//This function will extract a binary resource.
|
|
||||||
//
|
|
||||||
//IDR_SETMH64 BINARY MOVEABLE PURE "..\\SetMsgHook\\bin\\SetMsgHook64.exe"
|
|
||||||
//IDR_SETMH32 BINARY MOVEABLE PURE "..\\SetMsgHook\\bin\\SetMsgHook32.exe"
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
void ExtractResource(const WORD nID, LPCTSTR szFilename)
|
|
||||||
{
|
|
||||||
const HINSTANCE hInstance = (HINSTANCE)pData->g_hInstance;//GetModuleHandle(NULL);
|
|
||||||
HRSRC hResource = FindResource(hInstance, MAKEINTRESOURCE(nID), _T("BINARY"));// _ASSERTE(hResource);
|
|
||||||
if (hResource == NULL) // no resource found.
|
|
||||||
{
|
|
||||||
//MessageBoxA(0, "error, no resource found", "error", 0);
|
|
||||||
printf("error, resource %d not found\n", nID);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HGLOBAL hFileResource = LoadResource(hInstance, hResource);// _ASSERTE(hFileResource);
|
|
||||||
LPVOID lpFile = LockResource(hFileResource);
|
|
||||||
|
|
||||||
DWORD dwSize = SizeofResource(hInstance, hResource);
|
|
||||||
|
|
||||||
// Open the file and filemap
|
|
||||||
HANDLE hFile = CreateFile(szFilename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
HANDLE hFilemap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwSize, NULL);
|
|
||||||
|
|
||||||
// Get a pointer to write to
|
|
||||||
LPVOID lpBaseAddress = MapViewOfFile(hFilemap, FILE_MAP_WRITE, 0, 0, 0);
|
|
||||||
|
|
||||||
// Write the file
|
|
||||||
CopyMemory(lpBaseAddress, lpFile, dwSize);
|
|
||||||
|
|
||||||
// Unmap the file and close the handles
|
|
||||||
UnmapViewOfFile(lpBaseAddress);
|
|
||||||
CloseHandle(hFilemap);
|
|
||||||
CloseHandle(hFile);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunResource(const WORD nID, LPWSTR params)
|
|
||||||
{
|
|
||||||
TCHAR tmpFilename[500];
|
|
||||||
TCHAR tmpPath[500];
|
|
||||||
GetTempPath(500, tmpPath);
|
|
||||||
if (GetTempFileName(tmpPath, _T(""), 0, tmpFilename) == 0)
|
|
||||||
{
|
|
||||||
MessageBox(0,_T("Error getting temp file name"), _T("Error"), 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtractResource(nID, tmpFilename);
|
|
||||||
//MessageBox(0, tmpFilename, _T("tmp file2"), 0);
|
|
||||||
|
|
||||||
STARTUPINFO si;
|
|
||||||
ZeroMemory( &si, sizeof(si) );
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
|
|
||||||
PROCESS_INFORMATION pi;
|
|
||||||
ZeroMemory( &pi, sizeof(pi) );
|
|
||||||
|
|
||||||
si.wShowWindow = SW_MINIMIZE;
|
|
||||||
|
|
||||||
// Start the child process.
|
|
||||||
if(!CreateProcess(tmpFilename, // No module name (use command line)
|
|
||||||
params, // Command line
|
|
||||||
NULL, // Process handle not inheritable
|
|
||||||
NULL, // Thread handle not inheritable
|
|
||||||
FALSE, // Set handle inheritance to FALSE
|
|
||||||
0, // No creation flags
|
|
||||||
NULL, // Use parent's environment block
|
|
||||||
NULL, // Use parent's starting directory
|
|
||||||
&si, // Pointer to STARTUPINFO structure
|
|
||||||
&pi )) // Pointer to PROCESS_INFORMATION structure
|
|
||||||
{
|
|
||||||
MessageBox(0, _T("CreateProcess failed"), _T("error"), 0);
|
|
||||||
printf( "CreateProcess failed (%d).\n", GetLastError() );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//MessageBox(0, tmpFilename, _T("tmp file3"), 0);
|
|
||||||
|
|
||||||
// Wait until child process exits.
|
|
||||||
//WaitForSingleObject( pi.hProcess, INFINITE );
|
|
||||||
// Close process and thread handles.
|
|
||||||
//CloseHandle( pi.hProcess );
|
|
||||||
//CloseHandle( pi.hThread );
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
REM set path=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;%path%
|
|
||||||
|
|
||||||
%WinDir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:configuration=release /p:platform=x64 %*
|
|
||||||
%WinDir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:configuration=release /p:platform=win32 %*
|
|
||||||
|
|
||||||
pause
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
// dllmain.cpp : Defines the entry point for the DLL application.
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
HANDLE hMappedFile;
|
|
||||||
GLOBALDATA* pData;
|
|
||||||
bool bStartingProcess = false;
|
|
||||||
|
|
||||||
|
|
||||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
|
||||||
DWORD ul_reason_for_call,
|
|
||||||
LPVOID lpReserved
|
|
||||||
)
|
|
||||||
{
|
|
||||||
switch (ul_reason_for_call)
|
|
||||||
{
|
|
||||||
case DLL_PROCESS_ATTACH:
|
|
||||||
{
|
|
||||||
//printf("debug DLL_PROCESS_ATTACH hModule: %ld\n", (long)hModule);
|
|
||||||
TCHAR szBaseName[_MAX_FNAME], szTmp[_MAX_FNAME];
|
|
||||||
memset((void *)&szBaseName, '\0', sizeof(TCHAR) * _MAX_FNAME);
|
|
||||||
|
|
||||||
if (GetModuleBaseName(GetCurrentProcess(), (HMODULE)hModule, szTmp, sizeof(szTmp)))// compute MMF-filename from current module base name, uses Psapi
|
|
||||||
_wsplitpath_s(szTmp, NULL, NULL, szBaseName, _MAX_FNAME, NULL, NULL, NULL, NULL);
|
|
||||||
//_wsplitpath(szTmp, NULL, NULL, szBaseName, NULL);
|
|
||||||
|
|
||||||
wcscat_s(szBaseName, TEXT("MsgHookSharedMem")); // add specifier string
|
|
||||||
if (IsCurrentProcess64Bit())
|
|
||||||
wcscat_s(szBaseName, TEXT("64")); // add bit specifier
|
|
||||||
else
|
|
||||||
wcscat_s(szBaseName, TEXT("32")); // add bit specifier
|
|
||||||
|
|
||||||
hMappedFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(GLOBALDATA), szBaseName);
|
|
||||||
pData = (GLOBALDATA*)MapViewOfFile(hMappedFile, FILE_MAP_WRITE, 0, 0, 0);
|
|
||||||
bStartingProcess = (hMappedFile != NULL) && (GetLastError() != ERROR_ALREADY_EXISTS);
|
|
||||||
|
|
||||||
if(bStartingProcess) // if the MMF doesn't exist, we have the first instance
|
|
||||||
{
|
|
||||||
pData->g_hInstance = hModule; // so set the instance handle
|
|
||||||
pData->g_hWnd = NULL; // and initialize the other handles
|
|
||||||
pData->g_CwpHook = NULL;
|
|
||||||
pData->g_MsgHook = NULL;
|
|
||||||
pData->g_CwpHookProc = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//open
|
|
||||||
hMappedFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, szBaseName);
|
|
||||||
pData = (GLOBALDATA*)MapViewOfFile(hMappedFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
|
||||||
}
|
|
||||||
DisableThreadLibraryCalls((HMODULE)hModule);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DLL_THREAD_ATTACH:
|
|
||||||
case DLL_THREAD_DETACH:
|
|
||||||
case DLL_PROCESS_DETACH:
|
|
||||||
CloseHandle(hMappedFile); // on detaching the DLL, close the MMF
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "org_synthuse_MsgHook.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: initialize
|
|
||||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_initialize(JNIEnv *env, jobject obj, jstring jdll32bitname, jstring jdll64bitname)
|
|
||||||
{
|
|
||||||
const char *tdll32bitname = env->GetStringUTFChars(jdll32bitname, 0);//convert string
|
|
||||||
|
|
||||||
memset((void *)&dll32bitName, '\0', sizeof(TCHAR) * MAX_TEST_SIZE); // set TCHAR array to all 0
|
|
||||||
int tstrLen = MultiByteToWideChar(CP_UTF8, 0, tdll32bitname, (int)strlen(tdll32bitname), NULL, 0); //get t len
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, tdll32bitname, (int)strlen(tdll32bitname), dll32bitName, tstrLen); // convert char to tchar
|
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(jdll32bitname, tdll32bitname); //release string
|
|
||||||
|
|
||||||
const char *tdll64bitname = env->GetStringUTFChars(jdll64bitname, 0);//convert string
|
|
||||||
|
|
||||||
memset((void *)&dll64bitName, '\0', sizeof(TCHAR) * MAX_TEST_SIZE); // set TCHAR array to all 0
|
|
||||||
tstrLen = MultiByteToWideChar(CP_UTF8, 0, tdll64bitname, (int)strlen(tdll64bitname), NULL, 0); //get t len
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, tdll64bitname, (int)strlen(tdll64bitname), dll64bitName, tstrLen); // convert char to tchar
|
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(jdll64bitname, tdll64bitname); //release string
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: createMsgHookWindow
|
|
||||||
* Signature: ()Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_createMsgHookWindow(JNIEnv *env, jobject obj)
|
|
||||||
{
|
|
||||||
CreateMsgHookWindow(NULL);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: setMsgHookWindowTargetHwnd
|
|
||||||
* Signature: (I)Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetHwnd(JNIEnv *env, jobject obj, jint jhwnd)
|
|
||||||
{
|
|
||||||
_stprintf_s(targetHwndStr, _T("%ld"), (long)jhwnd);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: setMsgHookWindowTargetClass
|
|
||||||
* Signature: (Ljava/lang/String;)Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetClass(JNIEnv *env, jobject obj, jstring jclassname)
|
|
||||||
{
|
|
||||||
const char *classname = env->GetStringUTFChars(jclassname, 0);//convert string
|
|
||||||
|
|
||||||
memset((void *)&targetClassname, '\0', sizeof(TCHAR) * MAX_TEST_SIZE); // set TCHAR array to all 0
|
|
||||||
int tstrLen = MultiByteToWideChar(CP_UTF8, 0, classname, (int)strlen(classname), NULL, 0); //get t len
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, classname, (int)strlen(classname), targetClassname, tstrLen); // convert char to tchar
|
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(jclassname, classname); //release string
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetPid(JNIEnv *env, jobject obj, jint jpid)
|
|
||||||
{
|
|
||||||
_stprintf_s(targetProcessId, _T("%ld"), (long)jpid);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: setMessageHook
|
|
||||||
* Signature: (JJ)Z
|
|
||||||
*/
|
|
||||||
//JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMessageHook(JNIEnv *env, jobject obj, jlong jhWnd, jlong jthreadId)
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMessageHook(JNIEnv *env, jobject obj, jint jhWnd, jint jthreadId)
|
|
||||||
{
|
|
||||||
return SetMsgHook((HWND)jhWnd, (DWORD)jthreadId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: removeMessageHook
|
|
||||||
* Signature: ()Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_removeMessageHook(JNIEnv *env, jobject obj)
|
|
||||||
{
|
|
||||||
return RemoveHook();
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
|
||||||
#include <jni.h>
|
|
||||||
/* Header for class org_synthuse_MsgHook */
|
|
||||||
|
|
||||||
#ifndef _Included_org_synthuse_MsgHook
|
|
||||||
#define _Included_org_synthuse_MsgHook
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: initialize
|
|
||||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_initialize
|
|
||||||
(JNIEnv *, jobject, jstring, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: createMsgHookWindow
|
|
||||||
* Signature: ()Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_createMsgHookWindow
|
|
||||||
(JNIEnv *, jobject);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: setMsgHookWindowTargetHwnd
|
|
||||||
* Signature: (I)Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetHwnd
|
|
||||||
(JNIEnv *, jobject, jint);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: setMsgHookWindowTargetPid
|
|
||||||
* Signature: (I)Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMsgHookWindowTargetPid
|
|
||||||
(JNIEnv *, jobject, jint);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: setMessageHook
|
|
||||||
* Signature: (II)Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_setMessageHook
|
|
||||||
(JNIEnv *, jobject, jint, jint);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_MsgHook
|
|
||||||
* Method: removeMessageHook
|
|
||||||
* Signature: ()Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_synthuse_MsgHook_removeMessageHook
|
|
||||||
(JNIEnv *, jobject);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
@@ -1,8 +0,0 @@
|
|||||||
// stdafx.cpp : source file that includes just the standard includes
|
|
||||||
// MsgHook.pch will be the pre-compiled header
|
|
||||||
// stdafx.obj will contain the pre-compiled type information
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
// TODO: reference any additional headers you need in STDAFX.H
|
|
||||||
// and not in this file
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
// stdafx.h : include file for standard system include files,
|
|
||||||
// or project specific include files that are used frequently, but
|
|
||||||
// are changed infrequently
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "targetver.h"
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
||||||
// Windows Header Files:
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <Psapi.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <tlhelp32.h> //CreateToolhelp32Snapshot
|
|
||||||
|
|
||||||
#pragma comment( lib, "psapi.lib" )
|
|
||||||
//#pragma comment( lib, "kernel32.lib" )
|
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
HWND hWnd;
|
|
||||||
int nCode;
|
|
||||||
DWORD dwHookType;
|
|
||||||
WPARAM wParam;
|
|
||||||
LPARAM lParam;
|
|
||||||
TCHAR wParamStr[25];
|
|
||||||
TCHAR lParamStr[25];
|
|
||||||
}HEVENT;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
HHOOK g_CwpHook;
|
|
||||||
HHOOK g_MsgHook;
|
|
||||||
//HHOOK g_hHook;
|
|
||||||
HWND g_hWnd;
|
|
||||||
HANDLE g_hInstance;
|
|
||||||
HOOKPROC g_CwpHookProc;
|
|
||||||
}GLOBALDATA;
|
|
||||||
|
|
||||||
#ifndef GLOBAL_VARS_H // header guards
|
|
||||||
#define GLOBAL_VARS_H
|
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) void CreateMsgHookWindow(LPTSTR lpCmdLine);
|
|
||||||
extern "C" __declspec(dllexport) BOOL SetCustomMsgHookDll(const TCHAR * hookDll, const char * hookDllProcName);
|
|
||||||
extern "C" __declspec(dllexport) BOOL SetMsgHook(HWND callerHWnd, DWORD threadId);
|
|
||||||
extern "C" __declspec(dllexport) HHOOK GetCurrentHookHandle();
|
|
||||||
extern "C" __declspec(dllexport) void SetGlobalDLLInstance(HANDLE dllInstance);
|
|
||||||
extern "C" __declspec(dllexport) BOOL RemoveHook();
|
|
||||||
extern "C" __declspec(dllexport) BOOL IsCurrentProcess64Bit();
|
|
||||||
extern "C" __declspec(dllexport) BOOL IsProcess64Bit(DWORD procId);
|
|
||||||
extern "C" __declspec(dllexport) DWORD GetProcessMainThreadId(DWORD procId);
|
|
||||||
|
|
||||||
//void ExtractResource(const WORD nID, LPCTSTR szFilename);
|
|
||||||
|
|
||||||
//Global variables , remember not to initialize here
|
|
||||||
extern HANDLE hMappedFile;
|
|
||||||
extern GLOBALDATA* pData;
|
|
||||||
extern bool bStartingProcess;
|
|
||||||
|
|
||||||
#define MAX_TEST_SIZE 100
|
|
||||||
extern TCHAR targetHwndStr[MAX_TEST_SIZE];
|
|
||||||
extern TCHAR targetProcessId[MAX_TEST_SIZE];
|
|
||||||
extern TCHAR targetClassname[MAX_TEST_SIZE];
|
|
||||||
extern TCHAR dll32bitName[500];
|
|
||||||
extern TCHAR dll64bitName[500];
|
|
||||||
extern char dllProcName[500];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
|
||||||
|
|
||||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
|
||||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
|
||||||
|
|
||||||
#include <SDKDDKVer.h>
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
HHOOK g_CwpHook;
|
|
||||||
HHOOK g_MsgHook;
|
|
||||||
//HHOOK g_hHook;
|
|
||||||
HWND g_hWnd;
|
|
||||||
HANDLE g_hInstance;
|
|
||||||
HOOKPROC g_CwpHookProc;
|
|
||||||
}GLOBALDATA;
|
|
||||||
|
|
||||||
//#define MSGHOOKER_FILE TEXT("MsgHook.dll")
|
|
||||||
TCHAR MSGHOOK_DLL_NAME[MAX_NAME_SIZE] = _T("MsgHook.dll");
|
|
||||||
|
|
||||||
HINSTANCE msgHookDll;
|
|
||||||
|
|
||||||
//void CreateMsgHookWindow(LPTSTR lpCmdLine)
|
|
||||||
typedef VOID (* CREATEMSGHOOKWINDOW)(LPTSTR);
|
|
||||||
CREATEMSGHOOKWINDOW CreateMsgHookWindow;
|
|
||||||
|
|
||||||
//BOOL SetCustomMsgHookDll(const TCHAR * hookDll, const char * hookDllProcName)
|
|
||||||
typedef BOOL (* SETCUSTOMMSGHOOKDLL)(LPCTSTR, LPCSTR);
|
|
||||||
SETCUSTOMMSGHOOKDLL SetCustomMsgHookDll;
|
|
||||||
|
|
||||||
//BOOL SetMsgHook(HWND callerHWnd, DWORD threadId)
|
|
||||||
typedef BOOL (* SETMSGHOOK)(HWND, DWORD);
|
|
||||||
SETMSGHOOK SetMsgHook;
|
|
||||||
|
|
||||||
//HHOOK GetCurrentHookHandle()
|
|
||||||
typedef HHOOK (* GETCURRENTHOOKHANDLE)(VOID);
|
|
||||||
GETCURRENTHOOKHANDLE GetCurrentHookHandle;
|
|
||||||
|
|
||||||
//void SetGlobalDLLInstance(HANDLE dllInstance)
|
|
||||||
typedef VOID (* SETGLOBALDLLINSTANCE)(HANDLE);
|
|
||||||
SETGLOBALDLLINSTANCE SetGlobalDLLInstance;
|
|
||||||
|
|
||||||
//BOOL RemoveHook()
|
|
||||||
typedef BOOL (* REMOVEHOOK)(VOID);
|
|
||||||
REMOVEHOOK RemoveHook;
|
|
||||||
|
|
||||||
// DWORD GetProcessMainThreadId(DWORD procId)
|
|
||||||
typedef DWORD (* GETPROCESSMAINTHREADID)(DWORD);
|
|
||||||
GETPROCESSMAINTHREADID GetProcessMainThreadId;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
HWND hWnd;
|
|
||||||
int nCode;
|
|
||||||
DWORD dwHookType;
|
|
||||||
WPARAM wParam;
|
|
||||||
LPARAM lParam;
|
|
||||||
TCHAR wParamStr[25];
|
|
||||||
TCHAR lParamStr[25];
|
|
||||||
}HEVENT;
|
|
||||||
|
|
||||||
/*
|
|
||||||
typedef struct {
|
|
||||||
DWORD vkCode;
|
|
||||||
DWORD scanCode;
|
|
||||||
DWORD flags;
|
|
||||||
DWORD time;
|
|
||||||
ULONG_PTR dwExtraInfo;
|
|
||||||
} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
|
|
||||||
*/
|
|
||||||
|
|
||||||
void MsgHook_CreateMsgHookWindow(LPTSTR args)
|
|
||||||
{
|
|
||||||
msgHookDll = LoadLibrary(MSGHOOK_DLL_NAME);
|
|
||||||
if (msgHookDll != NULL)
|
|
||||||
{
|
|
||||||
CreateMsgHookWindow = (CREATEMSGHOOKWINDOW)GetProcAddress(msgHookDll, "CreateMsgHookWindow");
|
|
||||||
SetGlobalDLLInstance = (SETGLOBALDLLINSTANCE)GetProcAddress(msgHookDll, "SetGlobalDLLInstance");
|
|
||||||
if (CreateMsgHookWindow)
|
|
||||||
{
|
|
||||||
SetGlobalDLLInstance(msgHookDll);
|
|
||||||
CreateMsgHookWindow(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (msgHookDll != NULL)
|
|
||||||
FreeLibrary(msgHookDll);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL MsgHook_SetMsgHook(HWND hw, int threadId)
|
|
||||||
{
|
|
||||||
msgHookDll = LoadLibrary(MSGHOOK_DLL_NAME);
|
|
||||||
if (msgHookDll != NULL)
|
|
||||||
{
|
|
||||||
SetMsgHook = (SETMSGHOOK)GetProcAddress(msgHookDll, "SetMsgHook");
|
|
||||||
GetCurrentHookHandle = (GETCURRENTHOOKHANDLE)GetProcAddress(msgHookDll, "GetCurrentHookHandle");
|
|
||||||
SetGlobalDLLInstance = (SETGLOBALDLLINSTANCE)GetProcAddress(msgHookDll, "SetGlobalDLLInstance");
|
|
||||||
RemoveHook = (REMOVEHOOK)GetProcAddress(msgHookDll, "RemoveHook");
|
|
||||||
if (SetMsgHook)
|
|
||||||
{
|
|
||||||
//printf("LoadLibrary MSGHOOK %ld\n", (long)msgHookDll);
|
|
||||||
SetGlobalDLLInstance(msgHookDll);
|
|
||||||
return SetMsgHook(hw, threadId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MsgHook_RemoveHook()
|
|
||||||
{
|
|
||||||
if (RemoveHook)
|
|
||||||
RemoveHook();
|
|
||||||
|
|
||||||
if (msgHookDll != NULL)
|
|
||||||
FreeLibrary(msgHookDll);
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD MsgHook_GetProcessMainThreadId(DWORD procId)
|
|
||||||
{
|
|
||||||
msgHookDll = LoadLibrary(MSGHOOK_DLL_NAME);
|
|
||||||
if (msgHookDll != NULL)
|
|
||||||
{
|
|
||||||
GetProcessMainThreadId = (GETPROCESSMAINTHREADID)GetProcAddress(msgHookDll, "GetProcessMainThreadId");
|
|
||||||
if (GetProcessMainThreadId)
|
|
||||||
{
|
|
||||||
return GetProcessMainThreadId(procId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("error, failed loading library");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
========================================================================
|
|
||||||
CONSOLE APPLICATION : SetMsgHook Project Overview
|
|
||||||
========================================================================
|
|
||||||
|
|
||||||
AppWizard has created this SetMsgHook application for you.
|
|
||||||
|
|
||||||
This file contains a summary of what you will find in each of the files that
|
|
||||||
make up your SetMsgHook application.
|
|
||||||
|
|
||||||
|
|
||||||
SetMsgHook.vcxproj
|
|
||||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the version of Visual C++ that generated the file, and
|
|
||||||
information about the platforms, configurations, and project features selected with the
|
|
||||||
Application Wizard.
|
|
||||||
|
|
||||||
SetMsgHook.vcxproj.filters
|
|
||||||
This is the filters file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the association between the files in your project
|
|
||||||
and the filters. This association is used in the IDE to show grouping of files with
|
|
||||||
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
|
|
||||||
"Source Files" filter).
|
|
||||||
|
|
||||||
SetMsgHook.cpp
|
|
||||||
This is the main application source file.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Other standard files:
|
|
||||||
|
|
||||||
StdAfx.h, StdAfx.cpp
|
|
||||||
These files are used to build a precompiled header (PCH) file
|
|
||||||
named SetMsgHook.pch and a precompiled types file named StdAfx.obj.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Other notes:
|
|
||||||
|
|
||||||
AppWizard uses "TODO:" comments to indicate parts of the source code you
|
|
||||||
should add to or customize.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
// SetMsgHook.cpp : Defines the entry point for the console application.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "MsgHook.h"
|
|
||||||
|
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
|
||||||
{
|
|
||||||
if (argc == 1) //no args passed, show MsgHook Viewer gui
|
|
||||||
{
|
|
||||||
MsgHook_CreateMsgHookWindow(NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HWND hookHwnd = NULL;
|
|
||||||
long procId = 0;
|
|
||||||
TCHAR *stopStr;
|
|
||||||
|
|
||||||
for (int i = 1 ; i < argc ; i++)
|
|
||||||
{
|
|
||||||
if (_tcscmp(argv[i], _T("?")) == 0 || _tcscmp(argv[i], _T("-?")) == 0 || argc == 3 || argc > 4)
|
|
||||||
{
|
|
||||||
printf("SetMsgHook version 1.0 by Edward Jakubowski \n\n");
|
|
||||||
printf("Usage: SetMsgHook.exe [(MSG_HOOK_DLL) (MSG_HOOK_HWND_OR_ZERO) (TARGET_PID)] [MSG_HOOK_DLL] [?] \n\n");
|
|
||||||
printf(" Additional Notes:\n");
|
|
||||||
printf(" Message Hook Viewer Gui - To open the gui you must provide the path to the msg hook dll as the ");
|
|
||||||
printf("only argument when running SetMsgHook.exe. Also setting the (MSG_HOOK_HWND) argument to 0 (zero) ");
|
|
||||||
printf("will start the gui and message hook on the given Process Id.\n\n");
|
|
||||||
HWND currentHwnd = FindWindow(_T("MSGHOOKVIEW"), NULL);
|
|
||||||
printf(" Current MSG_HOOK_HWND: %ld\n", (long)currentHwnd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (i == 1)
|
|
||||||
_tcsncpy_s(MSGHOOK_DLL_NAME, MAX_NAME_SIZE, argv[i], _TRUNCATE);
|
|
||||||
if (i == 2)
|
|
||||||
hookHwnd = (HWND)_tcstol(argv[i], &stopStr, 10);
|
|
||||||
if (i == 3)
|
|
||||||
procId = (long)_tcstol(argv[i], &stopStr, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc == 2) //one arg passed (dll), show MsgHook Viewer gui
|
|
||||||
{
|
|
||||||
printf("Starting msg hook viewer...");
|
|
||||||
MsgHook_CreateMsgHookWindow(NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (argc == 4 && hookHwnd == 0)
|
|
||||||
{
|
|
||||||
printf("Starting msg hook viewer on pid %ld...", (long)procId);
|
|
||||||
TCHAR tmp[100];
|
|
||||||
_stprintf_s(tmp, _T("%ld"), (long)procId);
|
|
||||||
MsgHook_CreateMsgHookWindow(tmp);
|
|
||||||
//_getch();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char tmp[MAX_NAME_SIZE];
|
|
||||||
size_t convertedCnt = 0;
|
|
||||||
wcstombs_s(&convertedCnt, tmp, MAX_NAME_SIZE, MSGHOOK_DLL_NAME, _TRUNCATE);
|
|
||||||
printf("MsgHook DLL: %s, HWND: %ld, PID: %ld", tmp, (long)hookHwnd, procId);
|
|
||||||
DWORD threadId = MsgHook_GetProcessMainThreadId(procId);
|
|
||||||
printf(", ThreadId: %ld\n", (long)threadId);
|
|
||||||
|
|
||||||
if (MsgHook_SetMsgHook(hookHwnd, threadId))
|
|
||||||
printf("Hook successfully initialized\n");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Hook failed to initialize\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//don't exit SetMsgHook until hooked process exits
|
|
||||||
HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, procId);
|
|
||||||
while(WaitForSingleObject(process, 0) == WAIT_TIMEOUT)
|
|
||||||
{
|
|
||||||
Sleep(1000); //check once per second
|
|
||||||
if (GetCurrentHookHandle() == NULL)
|
|
||||||
{
|
|
||||||
printf("unhooked.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CloseHandle(process);
|
|
||||||
MsgHook_RemoveHook();
|
|
||||||
|
|
||||||
//_getch();
|
|
||||||
printf("done.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{34A73B55-8A93-4FB5-83CE-7759C1D23348}</ProjectGuid>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<RootNamespace>SetMsgHook</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\SetMsgHook$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\SetMsgHook$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\SetMsgHook$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\SetMsgHook$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="MsgHook.h" />
|
|
||||||
<ClInclude Include="stdafx.h" />
|
|
||||||
<ClInclude Include="targetver.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="SetMsgHook.cpp" />
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="stdafx.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="targetver.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="MsgHook.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SetMsgHook.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
</Project>
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
REM set path=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;%path%
|
|
||||||
|
|
||||||
%WinDir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:configuration=release /p:platform=x64 %*
|
|
||||||
%WinDir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:configuration=release /p:platform=win32 %*
|
|
||||||
|
|
||||||
pause
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// stdafx.cpp : source file that includes just the standard includes
|
|
||||||
// SetMsgHook.pch will be the pre-compiled header
|
|
||||||
// stdafx.obj will contain the pre-compiled type information
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
// TODO: reference any additional headers you need in STDAFX.H
|
|
||||||
// and not in this file
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
// stdafx.h : include file for standard system include files,
|
|
||||||
// or project specific include files that are used frequently, but
|
|
||||||
// are changed infrequently
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "targetver.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <conio.h>
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
|
||||||
|
|
||||||
#ifndef GLOBAL_VARS_H // header guards
|
|
||||||
#define GLOBAL_VARS_H
|
|
||||||
|
|
||||||
#define MAX_NAME_SIZE 500
|
|
||||||
extern TCHAR MSGHOOK_DLL_NAME[MAX_NAME_SIZE];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
|
||||||
|
|
||||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
|
||||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
|
||||||
|
|
||||||
#include <SDKDDKVer.h>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
|
||||||
# Visual Studio 2010
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uiabridge", "uiabridge\uiabridge.vcxproj", "{BAC1B079-7B87-4396-B17F-91A86DF1AE29}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uiabtest", "uiabtest\uiabtest.vcxproj", "{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{BAC1B079-7B87-4396-B17F-91A86DF1AE29}.Release|x64.Build.0 = Release|x64
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}.Release|x64.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
Binary file not shown.
@@ -1,40 +0,0 @@
|
|||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Reflection;
|
|
||||||
using namespace System::Runtime::CompilerServices;
|
|
||||||
using namespace System::Runtime::InteropServices;
|
|
||||||
using namespace System::Security::Permissions;
|
|
||||||
|
|
||||||
//
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
//
|
|
||||||
[assembly:AssemblyTitleAttribute("uiabridge")];
|
|
||||||
[assembly:AssemblyDescriptionAttribute("")];
|
|
||||||
[assembly:AssemblyConfigurationAttribute("")];
|
|
||||||
[assembly:AssemblyCompanyAttribute("na")];
|
|
||||||
[assembly:AssemblyProductAttribute("uiabridge")];
|
|
||||||
[assembly:AssemblyCopyrightAttribute("Copyright (c) na 2014")];
|
|
||||||
[assembly:AssemblyTrademarkAttribute("")];
|
|
||||||
[assembly:AssemblyCultureAttribute("")];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the value or you can default the Revision and Build Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
|
|
||||||
[assembly:AssemblyVersionAttribute("1.0.*")];
|
|
||||||
|
|
||||||
[assembly:ComVisible(false)];
|
|
||||||
|
|
||||||
[assembly:CLSCompliantAttribute(true)];
|
|
||||||
|
|
||||||
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "Global.h"
|
|
||||||
#include "uiabridge.h"
|
|
||||||
using namespace uiabridge;
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
#include "uiabridge.h"
|
|
||||||
using namespace uiabridge;
|
|
||||||
namespace Globals
|
|
||||||
{
|
|
||||||
using namespace System;
|
|
||||||
|
|
||||||
public ref class Global
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static AutomationBridge ^AUTO_BRIDGE = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
========================================================================
|
|
||||||
DYNAMIC LINK LIBRARY : uiabridge Project Overview
|
|
||||||
========================================================================
|
|
||||||
Created By Edward Jakubowski ejakubowski7@gmail.com
|
|
||||||
|
|
||||||
Description:
|
|
||||||
This is a bridge for java to access .net 4 UI Automation libraries. This
|
|
||||||
library enables Synthuse to access and automate WinForms, WPF and Silverlight apps.
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
// stdafx.cpp : source file that includes just the standard includes
|
|
||||||
// uiabridge.pch will be the pre-compiled header
|
|
||||||
// stdafx.obj will contain the pre-compiled type information
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include <msclr/marshal.h>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
// stdafx.h : include file for standard system include files,
|
|
||||||
// or project specific include files that are used frequently,
|
|
||||||
// but are changed infrequently
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
REM set path=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;%path%
|
|
||||||
|
|
||||||
%WinDir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:configuration=release /p:platform=x64 %*
|
|
||||||
%WinDir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:configuration=release /p:platform=win32 %*
|
|
||||||
|
|
||||||
pause
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include <msclr/marshal.h> //using namespace msclr::interop;
|
|
||||||
#include "org_synthuse_UiaBridge.h"
|
|
||||||
#include "uiabridge.h"
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Windows::Automation;
|
|
||||||
using namespace msclr::interop;
|
|
||||||
using namespace Globals;
|
|
||||||
using namespace uiabridge;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: initialize
|
|
||||||
* Signature: (Ljava/lang/String;)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_initialize(JNIEnv *env, jobject obj, jstring jproperties)
|
|
||||||
{
|
|
||||||
const char *properties = env->GetStringUTFChars(jproperties, 0);//convert string
|
|
||||||
Global::AUTO_BRIDGE = gcnew AutomationBridge(marshal_as<String ^>(properties));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: shutdown
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_shutdown(JNIEnv *env, jobject obj)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: useCachedRequests
|
|
||||||
* Signature: (Z)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_useCachedRequests(JNIEnv *env, jobject obj, jboolean jcacheRequestsFlg)
|
|
||||||
{
|
|
||||||
Global::AUTO_BRIDGE->useCachedRequests((bool)(jcacheRequestsFlg == JNI_TRUE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: addEnumFilter
|
|
||||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
|
|
||||||
*/
|
|
||||||
JNIEXPORT jint JNICALL Java_org_synthuse_UiaBridge_addEnumFilter(JNIEnv *env, jobject obj, jstring jpropertyName, jstring jpropertyValue)
|
|
||||||
{
|
|
||||||
const char *propertyName = env->GetStringUTFChars(jpropertyValue, 0);//convert string
|
|
||||||
const char *propertyValue = env->GetStringUTFChars(jpropertyValue, 0);//convert string
|
|
||||||
return (jint)Global::AUTO_BRIDGE->addEnumFilter(marshal_as<String ^>(propertyName), marshal_as<String ^>(propertyValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: clearEnumFilters
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_clearEnumFilters(JNIEnv *env, jobject obj)
|
|
||||||
{
|
|
||||||
Global::AUTO_BRIDGE->clearEnumFilters();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: enumWindowInfo
|
|
||||||
* Signature: (Ljava/lang/String;)[Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobjectArray JNICALL Java_org_synthuse_UiaBridge_enumWindowInfo__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring jproperties)
|
|
||||||
{
|
|
||||||
const char *properties = env->GetStringUTFChars(jproperties, 0);//convert string
|
|
||||||
array<System::String ^> ^mwinInfo = Global::AUTO_BRIDGE->enumWindowInfo(marshal_as<String ^>(properties));
|
|
||||||
if (mwinInfo == nullptr)
|
|
||||||
return NULL;
|
|
||||||
//create result object array to the same size as the managed children Ids string array
|
|
||||||
jclass stringClass = env->FindClass("java/lang/String");
|
|
||||||
jobjectArray results = env->NewObjectArray(mwinInfo->Length, stringClass, 0);
|
|
||||||
marshal_context context; //lets you marshal managed classes to unmanaged types
|
|
||||||
//char **childrenIds = new char *[mchildrenIds->Length];
|
|
||||||
for(int i = 0 ; i < mwinInfo->Length ; i++)
|
|
||||||
{
|
|
||||||
//childrenIds[i] = (char *)context.marshal_as<const char *>(mchildrenIds[i]);
|
|
||||||
//env->SetObjectArrayElement(results, i, env->GetStringUTFChars(childrenIds[i], 0)
|
|
||||||
env->SetObjectArrayElement(results, i, env->NewStringUTF(context.marshal_as<const char *>(mwinInfo[i])));
|
|
||||||
}
|
|
||||||
//delete[] childrenIds;
|
|
||||||
env->ReleaseStringUTFChars(jproperties, properties); //release string
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: enumWindowInfo
|
|
||||||
* Signature: (ILjava/lang/String;)[Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobjectArray JNICALL Java_org_synthuse_UiaBridge_enumWindowInfo__ILjava_lang_String_2(JNIEnv *env, jobject obj, jint jwindowHandle, jstring jproperties)
|
|
||||||
{
|
|
||||||
const char *properties = env->GetStringUTFChars(jproperties, 0);//convert string
|
|
||||||
array<System::String ^> ^mwinInfo = Global::AUTO_BRIDGE->enumWindowInfo(System::IntPtr(jwindowHandle), marshal_as<String ^>(properties));
|
|
||||||
if (mwinInfo == nullptr)
|
|
||||||
return NULL;
|
|
||||||
//create result object array to the same size as the managed children Ids string array
|
|
||||||
jclass stringClass = env->FindClass("java/lang/String");
|
|
||||||
jobjectArray results = env->NewObjectArray(mwinInfo->Length, stringClass, 0);
|
|
||||||
marshal_context context; //lets you marshal managed classes to unmanaged types
|
|
||||||
//char **childrenIds = new char *[mchildrenIds->Length];
|
|
||||||
for(int i = 0 ; i < mwinInfo->Length ; i++)
|
|
||||||
{
|
|
||||||
//childrenIds[i] = (char *)context.marshal_as<const char *>(mchildrenIds[i]);
|
|
||||||
//env->SetObjectArrayElement(results, i, env->GetStringUTFChars(childrenIds[i], 0)
|
|
||||||
env->SetObjectArrayElement(results, i, env->NewStringUTF(context.marshal_as<const char *>(mwinInfo[i])));
|
|
||||||
}
|
|
||||||
//delete[] childrenIds;
|
|
||||||
env->ReleaseStringUTFChars(jproperties, properties); //release string
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: getWindowInfo
|
|
||||||
* Signature: (IILjava/lang/String;)Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_synthuse_UiaBridge_getWindowInfo__IILjava_lang_String_2(JNIEnv *env, jobject obj, jint jx, jint jy, jstring jproperties)
|
|
||||||
{
|
|
||||||
const char *properties = env->GetStringUTFChars(jproperties, 0);//convert string
|
|
||||||
System::String ^mwinInfo = Global::AUTO_BRIDGE->getWindowInfo(jx, jy, marshal_as<String ^>(properties));
|
|
||||||
env->ReleaseStringUTFChars(jproperties, properties); //release string
|
|
||||||
marshal_context context;
|
|
||||||
return env->NewStringUTF(context.marshal_as<const char *>(mwinInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: getWindowInfo
|
|
||||||
* Signature: (ILjava/lang/String;)Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_synthuse_UiaBridge_getWindowInfo__ILjava_lang_String_2(JNIEnv *env, jobject obj, jint jwindowHandle, jstring jproperties)
|
|
||||||
{
|
|
||||||
const char *properties = env->GetStringUTFChars(jproperties, 0);//convert string
|
|
||||||
System::String ^mwinInfo = Global::AUTO_BRIDGE->getWindowInfo(System::IntPtr(jwindowHandle), marshal_as<String ^>(properties));
|
|
||||||
env->ReleaseStringUTFChars(jproperties, properties); //release string
|
|
||||||
marshal_context context;
|
|
||||||
return env->NewStringUTF(context.marshal_as<const char *>(mwinInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: getWindowInfo
|
|
||||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_synthuse_UiaBridge_getWindowInfo__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring jruntimeIdStr, jstring jproperties)
|
|
||||||
{
|
|
||||||
const char *properties = env->GetStringUTFChars(jproperties, 0);//convert string
|
|
||||||
const char *runtimeIdStr = env->GetStringUTFChars(jruntimeIdStr, 0);//convert string
|
|
||||||
System::String ^mwinInfo = Global::AUTO_BRIDGE->getWindowInfo(marshal_as<String ^>(runtimeIdStr), marshal_as<String ^>(properties));
|
|
||||||
env->ReleaseStringUTFChars(jruntimeIdStr, runtimeIdStr); //release string
|
|
||||||
env->ReleaseStringUTFChars(jproperties, properties); //release string
|
|
||||||
marshal_context context;
|
|
||||||
return env->NewStringUTF(context.marshal_as<const char *>(mwinInfo));
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
|
||||||
#include <jni.h>
|
|
||||||
/* Header for class org_synthuse_UiaBridge */
|
|
||||||
|
|
||||||
#ifndef _Included_org_synthuse_UiaBridge
|
|
||||||
#define _Included_org_synthuse_UiaBridge
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: initialize
|
|
||||||
* Signature: (Ljava/lang/String;)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_initialize
|
|
||||||
(JNIEnv *, jobject, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: shutdown
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_shutdown
|
|
||||||
(JNIEnv *, jobject);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: useCachedRequests
|
|
||||||
* Signature: (Z)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_useCachedRequests
|
|
||||||
(JNIEnv *, jobject, jboolean);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: addEnumFilter
|
|
||||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
|
|
||||||
*/
|
|
||||||
JNIEXPORT jint JNICALL Java_org_synthuse_UiaBridge_addEnumFilter
|
|
||||||
(JNIEnv *, jobject, jstring, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: clearEnumFilters
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_synthuse_UiaBridge_clearEnumFilters
|
|
||||||
(JNIEnv *, jobject);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: enumWindowInfo
|
|
||||||
* Signature: (Ljava/lang/String;)[Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobjectArray JNICALL Java_org_synthuse_UiaBridge_enumWindowInfo__Ljava_lang_String_2
|
|
||||||
(JNIEnv *, jobject, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: enumWindowInfo
|
|
||||||
* Signature: (ILjava/lang/String;)[Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jobjectArray JNICALL Java_org_synthuse_UiaBridge_enumWindowInfo__ILjava_lang_String_2
|
|
||||||
(JNIEnv *, jobject, jint, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: getWindowInfo
|
|
||||||
* Signature: (IILjava/lang/String;)Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_synthuse_UiaBridge_getWindowInfo__IILjava_lang_String_2
|
|
||||||
(JNIEnv *, jobject, jint, jint, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: getWindowInfo
|
|
||||||
* Signature: (ILjava/lang/String;)Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_synthuse_UiaBridge_getWindowInfo__ILjava_lang_String_2
|
|
||||||
(JNIEnv *, jobject, jint, jstring);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_synthuse_UiaBridge
|
|
||||||
* Method: getWindowInfo
|
|
||||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
||||||
*/
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_synthuse_UiaBridge_getWindowInfo__Ljava_lang_String_2Ljava_lang_String_2
|
|
||||||
(JNIEnv *, jobject, jstring, jstring);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Visual C++ generated include file.
|
|
||||||
// Used by app.rc
|
|
||||||
@@ -1,497 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
// This is the main DLL file.
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "uiabridge.h"
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Collections::Generic;
|
|
||||||
using namespace System::Windows::Automation;
|
|
||||||
using namespace uiabridge;
|
|
||||||
|
|
||||||
AutomationBridge::AutomationBridge()
|
|
||||||
{
|
|
||||||
enumFilters = gcnew Dictionary<System::String ^, System::String ^>();
|
|
||||||
cacheRequest = nullptr;
|
|
||||||
useCache = true;
|
|
||||||
initializeCache("");
|
|
||||||
}
|
|
||||||
|
|
||||||
AutomationBridge::AutomationBridge(System::String ^cachedProperties)
|
|
||||||
{
|
|
||||||
enumFilters = gcnew Dictionary<System::String ^, System::String ^>();
|
|
||||||
cacheRequest = nullptr;
|
|
||||||
useCache = true;
|
|
||||||
initializeCache(cachedProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
AutomationBridge::~AutomationBridge()
|
|
||||||
{
|
|
||||||
enumFilters->Clear();
|
|
||||||
if (cacheRequest != nullptr)
|
|
||||||
cacheRequest->Pop(); //disable UI Automation Cache
|
|
||||||
//Console::WriteLine("disposing of AutomationBridge");
|
|
||||||
}
|
|
||||||
|
|
||||||
void AutomationBridge::useCachedRequests(System::Boolean cacheRequestsFlg)
|
|
||||||
{
|
|
||||||
useCache = cacheRequestsFlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AutomationBridge::initializeCache(System::String ^cachedProperties)
|
|
||||||
{
|
|
||||||
cacheRequest = gcnew CacheRequest();
|
|
||||||
//cacheRequest->AutomationElementMode = AutomationElementMode::Full;
|
|
||||||
cacheRequest->TreeFilter = Automation::RawViewCondition;
|
|
||||||
cacheRequest->TreeScope = TreeScope::Element;// | TreeScope::Children;
|
|
||||||
/*
|
|
||||||
cacheRequest->Add(AutomationElement::RuntimeIdProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::ProcessIdProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::FrameworkIdProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::LocalizedControlTypeProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::ControlTypeProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::ClassNameProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::NameProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::BoundingRectangleProperty);
|
|
||||||
*/
|
|
||||||
System::String ^cachedPropStr = cachedProperties;
|
|
||||||
if (cachedPropStr == nullptr) // check if blank/null we need to use DEFAULT_CACHED_PROPS;
|
|
||||||
cachedPropStr = DEFAULT_CACHED_PROPS;
|
|
||||||
else if (cachedPropStr->Equals(""))
|
|
||||||
cachedPropStr = DEFAULT_CACHED_PROPS;
|
|
||||||
array<AutomationProperty^> ^rootProperties = AutomationElement::RootElement->GetSupportedProperties();
|
|
||||||
List<AutomationProperty^> ^cacheList = gcnew List<AutomationProperty^>();
|
|
||||||
if (cachedPropStr->Contains(L"NativeWindowHandleProperty")) //special property not in the root property list
|
|
||||||
{
|
|
||||||
cacheList->Add(AutomationElement::NativeWindowHandleProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::NativeWindowHandleProperty);
|
|
||||||
}
|
|
||||||
if (cachedPropStr->Contains(L"ValueProperty")) //special property not in the root property list
|
|
||||||
{
|
|
||||||
cacheList->Add(ValuePattern::ValueProperty);
|
|
||||||
cacheRequest->Add(AutomationElement::IsValuePatternAvailableProperty);
|
|
||||||
cacheRequest->Add(ValuePattern::ValueProperty);
|
|
||||||
cacheRequest->Add(ValuePattern::Pattern);
|
|
||||||
}
|
|
||||||
for each(AutomationProperty ^ap in rootProperties) //loop through all supported Properties for a child
|
|
||||||
{
|
|
||||||
System::String ^currentPropertyStr = L""; //current property values
|
|
||||||
System::String ^shortPropName = L" null ";
|
|
||||||
if (ap->ProgrammaticName->Contains(L".")) //get short Property name
|
|
||||||
shortPropName = ap->ProgrammaticName->Substring(ap->ProgrammaticName->IndexOf(L".") + 1);
|
|
||||||
if (cachedPropStr->Contains(shortPropName) || cachedPropStr->Contains(ap->ProgrammaticName))
|
|
||||||
{
|
|
||||||
cacheList->Add(ap);// add property to cachedRootProperties
|
|
||||||
cacheRequest->Add(ap); // add property to cacheRequest
|
|
||||||
//Console::WriteLine("caching property {0}", ap->ProgrammaticName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cachedRootProperties = cacheList->ToArray();
|
|
||||||
cacheRequest->Push(); //enable UI Automation Cache
|
|
||||||
//cachedRootProperties = AutomationElement::RootElement->GetSupportedProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
int AutomationBridge::addEnumFilter(System::String ^propertyName, System::String ^propertyValue)
|
|
||||||
{
|
|
||||||
enumFilters->Add(propertyName, propertyValue);
|
|
||||||
return enumFilters->Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AutomationBridge::clearEnumFilters()
|
|
||||||
{
|
|
||||||
enumFilters->Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean AutomationBridge::isElementFiltered(System::Windows::Automation::AutomationElement ^element)
|
|
||||||
{
|
|
||||||
return isElementFiltered(element, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean AutomationBridge::isElementFiltered(System::Windows::Automation::AutomationElement ^element, List<System::String ^> ^filterModifierList)
|
|
||||||
{
|
|
||||||
Boolean result = false;
|
|
||||||
int filterMatchCount = 0;
|
|
||||||
if (enumFilters->Count == 0)
|
|
||||||
return result;
|
|
||||||
//array<AutomationProperty^> ^aps = cachedRootProperties;//element->GetSupportedProperties();
|
|
||||||
for each(AutomationProperty ^ap in cachedRootProperties) //loop through all supported Properties for a child
|
|
||||||
{
|
|
||||||
System::String ^currentPropertyStr = L""; //current property values
|
|
||||||
System::String ^shortPropName = L" null ";
|
|
||||||
if (ap->ProgrammaticName->Contains(L".")) //get short Property name
|
|
||||||
shortPropName = ap->ProgrammaticName->Substring(ap->ProgrammaticName->IndexOf(L".") + 1);
|
|
||||||
//System::Console::WriteLine("property: {0}", shortPropName);
|
|
||||||
for each(System::String ^key in enumFilters->Keys)
|
|
||||||
{
|
|
||||||
if (filterModifierList != nullptr)
|
|
||||||
if (filterModifierList->Contains(key) && key->StartsWith(PARENT_MODIFIER+ "/") ) // modifier has been applied and filters should be ignored
|
|
||||||
{
|
|
||||||
++filterMatchCount;
|
|
||||||
//System::Console::WriteLine("PARENT_MODIFIER {0}", key);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if(filterModifierList->Contains(key) && key->StartsWith(FIRST_MODIFIER+ "/")) //first already found stop!
|
|
||||||
{
|
|
||||||
//System::Console::WriteLine("FIRST_MODIFIER {0}", key);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
System::String ^filterProp = key;
|
|
||||||
System::String ^modifier = L"";
|
|
||||||
int pos = key->IndexOf(L"/");
|
|
||||||
if (pos != -1)//tree modifier
|
|
||||||
{
|
|
||||||
modifier = filterProp->Substring(0, pos);
|
|
||||||
filterProp = filterProp->Substring(pos+1);
|
|
||||||
//System::Console::WriteLine("modifier: {0}, {1}, {2}", modifier, filterProp, key);
|
|
||||||
}
|
|
||||||
if (shortPropName->Equals(filterProp) || ap->ProgrammaticName->Equals(filterProp))
|
|
||||||
{//this element has a matching filter property
|
|
||||||
//System::Console::WriteLine("matched property: {0}", filterProp);
|
|
||||||
System::String ^valStr = L"";
|
|
||||||
if (ap->ProgrammaticName->Equals(L"AutomationElementIdentifiers.RuntimeIdProperty"))
|
|
||||||
{//runtimeId are int array so need to test it differently
|
|
||||||
array<System::Int32> ^idArray = (array<System::Int32> ^)element->GetCurrentPropertyValue(ap);
|
|
||||||
for each(System::Int32 val in idArray)
|
|
||||||
{
|
|
||||||
valStr += System::Convert::ToString(val) + L"-";
|
|
||||||
}
|
|
||||||
valStr = valStr->TrimEnd('-');
|
|
||||||
//System::Console::WriteLine("runtimeId: {0}", valStr);
|
|
||||||
}
|
|
||||||
else //all other property types that are strings
|
|
||||||
{
|
|
||||||
if (useCache)
|
|
||||||
valStr = element->GetCachedPropertyValue(ap)->ToString();
|
|
||||||
else
|
|
||||||
valStr = element->GetCurrentPropertyValue(ap)->ToString();
|
|
||||||
//valStr = element->GetCurrentPropertyValue(ap)->ToString();
|
|
||||||
}
|
|
||||||
//System::Console::WriteLine("test property vals: {0} , {1}", valStr, enumFilters[key]);
|
|
||||||
|
|
||||||
if (valStr->Equals(enumFilters[key])) // value matches filter value
|
|
||||||
{
|
|
||||||
//System::Console::WriteLine("matched property vals: {0} , {1}", valStr, enumFilters[key]);
|
|
||||||
//result = false;
|
|
||||||
++filterMatchCount;
|
|
||||||
if (filterModifierList != nullptr)
|
|
||||||
if (modifier->Equals(PARENT_MODIFIER)) //if modifier is parent then add to modifier list
|
|
||||||
{
|
|
||||||
//System::Console::WriteLine("modifier added1 {0}", key);
|
|
||||||
filterModifierList->Add(key);
|
|
||||||
}
|
|
||||||
else if(modifier->Equals(FIRST_MODIFIER)) {
|
|
||||||
//System::Console::WriteLine("first modifier added1 {0} {1}", key, filterModifierList->Count);
|
|
||||||
//for each (System::String ^mod in filterModifierList)
|
|
||||||
// System::Console::WriteLine("mod {0}", mod);
|
|
||||||
filterModifierList->Add(key);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else// not matched
|
|
||||||
if (filterModifierList != nullptr)
|
|
||||||
if (modifier->Equals(ALL_MODIFIER)) //doesn't matter if ALL modifier doesn't match, need to keep searching
|
|
||||||
{
|
|
||||||
//System::Console::WriteLine("modifier added2 {0}", key);
|
|
||||||
filterModifierList->Add(key);
|
|
||||||
}
|
|
||||||
else if(modifier->Equals(FIRST_MODIFIER))
|
|
||||||
filterModifierList->Add(ALL_MODIFIER + "/" + filterProp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//System::Console::WriteLine("filterMatchCount: {0}", filterMatchCount);
|
|
||||||
if (filterMatchCount > 0)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
//return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AutomationBridge::processFilterModifier(Boolean filtered, Boolean modifierChanged, List<System::String ^> ^filterModifierList)
|
|
||||||
{
|
|
||||||
if (!filtered) //not filtered so return element
|
|
||||||
{
|
|
||||||
//winInfoList->Add(getWindowInfo(currentElement, properties));
|
|
||||||
//winInfoList->AddRange(enumWindowInfo(currentElement, properties, filterModifierList));
|
|
||||||
if (modifierChanged && filterModifierList[filterModifierList->Count - 1]->StartsWith(FIRST_MODIFIER) == false) //modifier was added and needs to be removed
|
|
||||||
{// don't remove First modifier
|
|
||||||
//System::Console::WriteLine("modifier removed1 {0}", filterModifierList[filterModifierList->Count - 1]);
|
|
||||||
filterModifierList->RemoveAt(filterModifierList->Count - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else //filtered, but if modifier used keep searching children
|
|
||||||
{
|
|
||||||
if (modifierChanged) //modifier was added and needs to be removed (ALL)
|
|
||||||
{
|
|
||||||
//winInfoList->AddRange(enumWindowInfo(currentElement, properties, filterModifierList));
|
|
||||||
if (filterModifierList[filterModifierList->Count - 1]->StartsWith(FIRST_MODIFIER) == false)// don't remove First modifier
|
|
||||||
{
|
|
||||||
//System::Console::WriteLine("modifier removed2 {0}", filterModifierList[filterModifierList->Count - 1]);
|
|
||||||
filterModifierList->RemoveAt(filterModifierList->Count - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
System::String ^ AutomationBridge::getRuntimeIdFromElement(System::Windows::Automation::AutomationElement ^element)
|
|
||||||
{
|
|
||||||
System::String ^result = L"";
|
|
||||||
System::Object ^currentVal = element->GetCurrentPropertyValue(AutomationElement::RuntimeIdProperty);
|
|
||||||
if (currentVal != nullptr)
|
|
||||||
{
|
|
||||||
array<System::Int32> ^idArray = (array<System::Int32> ^)currentVal;
|
|
||||||
for each(System::Int32 val in idArray)
|
|
||||||
{
|
|
||||||
result += System::Convert::ToString(val) + L"-";
|
|
||||||
}
|
|
||||||
result = result->TrimEnd('-');
|
|
||||||
//System::Console::WriteLine("id: {0}", result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
array<System::String ^> ^ AutomationBridge::enumWindowInfo(System::String ^properties)
|
|
||||||
{
|
|
||||||
return enumWindowInfo(AutomationElement::RootElement, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
array<System::String ^> ^ AutomationBridge::enumWindowInfo(System::IntPtr windowHandle, System::String ^properties)
|
|
||||||
{
|
|
||||||
List<System::String ^> ^winInfoList = gcnew List<System::String ^>();
|
|
||||||
AutomationElement ^element = nullptr;
|
|
||||||
try {
|
|
||||||
element = AutomationElement::FromHandle(windowHandle);
|
|
||||||
} catch (Exception ^ex) {
|
|
||||||
output(ex, "");
|
|
||||||
return winInfoList->ToArray();
|
|
||||||
}
|
|
||||||
if (element == nullptr)
|
|
||||||
return winInfoList->ToArray();
|
|
||||||
if (!isElementFiltered(element)) //test parent should be filtered
|
|
||||||
winInfoList->Add(getWindowInfo(element, properties, nullptr));
|
|
||||||
winInfoList->AddRange(enumWindowInfo(element, properties));
|
|
||||||
return winInfoList->ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
array<System::String ^> ^ AutomationBridge::enumWindowInfo(AutomationElement ^element, System::String ^properties)
|
|
||||||
{
|
|
||||||
List<System::String ^> ^filterModifierList = gcnew List<System::String ^>(); //can change descendants filters based on parent's filters
|
|
||||||
return enumWindowInfo(element, properties, filterModifierList);
|
|
||||||
}
|
|
||||||
|
|
||||||
array<System::String ^> ^ AutomationBridge::enumWindowInfo(AutomationElement ^parentElement, System::String ^properties, List<System::String ^> ^filterModifierList)
|
|
||||||
{
|
|
||||||
List<System::String ^> ^winInfoList = gcnew List<System::String ^>();
|
|
||||||
if (parentElement == nullptr)
|
|
||||||
return winInfoList->ToArray();
|
|
||||||
TreeWalker ^tw = TreeWalker::RawViewWalker;
|
|
||||||
//System::Console::WriteLine("get info: {0}", getWindowInfo(element, properties));
|
|
||||||
//AutomationElement ^currentElement = tw->GetFirstChild(element, cacheRequest);
|
|
||||||
AutomationElement ^currentElement = nullptr;
|
|
||||||
|
|
||||||
if (useCache)
|
|
||||||
currentElement = tw->GetFirstChild(parentElement, cacheRequest);
|
|
||||||
else
|
|
||||||
currentElement = tw->GetFirstChild(parentElement);
|
|
||||||
|
|
||||||
if (currentElement == nullptr)
|
|
||||||
{
|
|
||||||
//System::Console::WriteLine("no children {0}", element->CachedChildren->Count);
|
|
||||||
//System::Console::WriteLine("no children");
|
|
||||||
return winInfoList->ToArray();
|
|
||||||
}
|
|
||||||
//else
|
|
||||||
// System::Console::WriteLine("yes children");
|
|
||||||
|
|
||||||
while (currentElement != nullptr)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int fmlOriginalSize = filterModifierList->Count;
|
|
||||||
Boolean filtered = isElementFiltered(currentElement, filterModifierList);
|
|
||||||
Boolean modifierChanged = fmlOriginalSize != filterModifierList->Count;
|
|
||||||
if (!filtered) //not filtered so return element
|
|
||||||
{
|
|
||||||
winInfoList->Add(getWindowInfo(currentElement, properties, parentElement));
|
|
||||||
winInfoList->AddRange(enumWindowInfo(currentElement, properties, filterModifierList));
|
|
||||||
}
|
|
||||||
else //filtered, but if modifier used keep searching children
|
|
||||||
{
|
|
||||||
if (modifierChanged) //modifier was added search children
|
|
||||||
winInfoList->AddRange(enumWindowInfo(currentElement, properties, filterModifierList));
|
|
||||||
}
|
|
||||||
processFilterModifier(filtered, modifierChanged, filterModifierList); //cleans filterModifierList
|
|
||||||
//System::Console::WriteLine("element: {0}", currentElement);
|
|
||||||
//currentElement->
|
|
||||||
} catch (Exception ^ex)
|
|
||||||
{
|
|
||||||
output(ex, "");
|
|
||||||
}
|
|
||||||
if (useCache)
|
|
||||||
currentElement = tw->GetNextSibling(currentElement, cacheRequest);
|
|
||||||
else
|
|
||||||
currentElement = tw->GetNextSibling(currentElement);
|
|
||||||
}
|
|
||||||
return winInfoList->ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
System::String ^ AutomationBridge::getWindowInfo(AutomationElement ^element, System::String ^properties, AutomationElement ^optionalParentElement)
|
|
||||||
{
|
|
||||||
System::String ^resultProperties = L"";
|
|
||||||
System::String ^propertyNameErrorCheck = L"";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//when wildcard is enabled it will pull all property names & values
|
|
||||||
System::Boolean wildcardEnabled = false;
|
|
||||||
if (properties->Equals(L"*"))
|
|
||||||
wildcardEnabled = true;
|
|
||||||
|
|
||||||
//setup parentElement
|
|
||||||
System::String ^parentRuntimeId = L"";
|
|
||||||
if (wildcardEnabled || properties->Contains(L"ParentRuntimeIdProperty"))
|
|
||||||
{
|
|
||||||
if (optionalParentElement == nullptr)
|
|
||||||
{
|
|
||||||
TreeWalker ^tw = TreeWalker::ControlViewWalker;
|
|
||||||
parentRuntimeId = getRuntimeIdFromElement(tw->GetParent(element, cacheRequest));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
parentRuntimeId = getRuntimeIdFromElement(optionalParentElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
//create array for keeping order of properties
|
|
||||||
System::String ^delim = L",";
|
|
||||||
array<System::String ^> ^propSpltArray = properties->Split(delim->ToCharArray());
|
|
||||||
System::Int32 count = 0;
|
|
||||||
//array<AutomationProperty^> ^aps = cachedRootProperties;//element->GetSupportedProperties();
|
|
||||||
array<System::String ^> ^propValues = gcnew array<System::String ^>(propSpltArray->Length);//keep order
|
|
||||||
System::String ^wildcardProperties = L"";
|
|
||||||
if (wildcardEnabled) {
|
|
||||||
wildcardProperties += "ParentRuntimeIdProperty:" + parentRuntimeId + ",";
|
|
||||||
//propValues = gcnew array<System::String ^>(aps->Length +1 );//add one for parent property since it doesn't exist
|
|
||||||
}
|
|
||||||
for(int i=0 ; i < propValues->Length ; i++)
|
|
||||||
{
|
|
||||||
propValues[i] = L"";
|
|
||||||
if (propSpltArray[i]->Equals("ParentRuntimeIdProperty"))//custom property for getting parent
|
|
||||||
{
|
|
||||||
propValues[i] = parentRuntimeId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for each(AutomationProperty ^ap in cachedRootProperties) //loop through all supported Properties for a child
|
|
||||||
{
|
|
||||||
propertyNameErrorCheck = ap->ProgrammaticName;//debug purposes
|
|
||||||
System::String ^currentPropertyStr = L""; //current property values
|
|
||||||
//System::Console::WriteLine("property: {0}", ap->ProgrammaticName);
|
|
||||||
System::String ^shortPropName = L" null ";
|
|
||||||
if (ap->ProgrammaticName->Contains(L"."))
|
|
||||||
shortPropName = ap->ProgrammaticName->Substring(ap->ProgrammaticName->IndexOf(L".") + 1);
|
|
||||||
if (properties->Contains(shortPropName) || properties->Contains(ap->ProgrammaticName) || ap->ProgrammaticName->Equals(properties) || wildcardEnabled)
|
|
||||||
{
|
|
||||||
//System::Console::WriteLine("shortPropName: {0}", shortPropName);
|
|
||||||
//System::Object ^currentVal = element->GetCurrentPropertyValue(ap);
|
|
||||||
System::Object ^currentVal = nullptr;
|
|
||||||
if (shortPropName->Equals("ValueProperty")) //check if Value Pattern is an Available Property
|
|
||||||
{
|
|
||||||
if (((Boolean)element->GetCurrentPropertyValue(element->IsValuePatternAvailableProperty)) == false)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
currentVal = element->GetCurrentPropertyValue(ap); //cached pattern was having issues;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useCache)
|
|
||||||
currentVal = element->GetCachedPropertyValue(ap);
|
|
||||||
else
|
|
||||||
currentVal = element->GetCurrentPropertyValue(ap);
|
|
||||||
|
|
||||||
if (currentVal == nullptr)
|
|
||||||
continue;
|
|
||||||
if (ap->ProgrammaticName->Equals(L"AutomationElementIdentifiers.RuntimeIdProperty"))
|
|
||||||
{
|
|
||||||
array<System::Int32> ^idArray = (array<System::Int32> ^)currentVal;
|
|
||||||
for each(System::Int32 val in idArray)
|
|
||||||
{
|
|
||||||
currentPropertyStr += System::Convert::ToString(val) + L"-";
|
|
||||||
}
|
|
||||||
currentPropertyStr = currentPropertyStr->TrimEnd('-');
|
|
||||||
//System::Console::WriteLine("id: {0}", result);
|
|
||||||
}
|
|
||||||
else//not runtimeId which is an Int32[]
|
|
||||||
{
|
|
||||||
currentPropertyStr = currentVal->ToString();
|
|
||||||
currentPropertyStr = currentPropertyStr->Replace(",",",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currentPropertyStr->Equals(L"")) //if there isn't a value skip
|
|
||||||
continue;
|
|
||||||
if (wildcardEnabled) {
|
|
||||||
wildcardProperties += shortPropName + ":" +currentPropertyStr + ",";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//System::Console::WriteLine("currentPropertyStr: {0}", currentPropertyStr);
|
|
||||||
//find the correct order to return this property
|
|
||||||
for(int i=0 ; i < propSpltArray->Length ; i++)
|
|
||||||
{
|
|
||||||
if (propSpltArray[i]->Equals(shortPropName) || propSpltArray[i]->Equals(ap->ProgrammaticName))
|
|
||||||
propValues[i] = currentPropertyStr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//output properties in the correct order
|
|
||||||
for(int i=0 ; i < propSpltArray->Length ; i++)
|
|
||||||
resultProperties += propValues[i] + L",";
|
|
||||||
if (wildcardEnabled)
|
|
||||||
resultProperties += wildcardProperties;
|
|
||||||
} catch (Exception ^ex) //when some elements close during enumeration it might cause valid exceptions
|
|
||||||
{
|
|
||||||
output(ex, " getWindowInfo on " + propertyNameErrorCheck + ", results: " + resultProperties);
|
|
||||||
}
|
|
||||||
return resultProperties;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
System::String ^ AutomationBridge::getWindowInfo(System::Int32 x, System::Int32 y, System::String ^properties)
|
|
||||||
{
|
|
||||||
AutomationElement ^element = AutomationElement::FromPoint(System::Windows::Point(x, y));
|
|
||||||
if (element == nullptr)
|
|
||||||
return "";
|
|
||||||
return getWindowInfo(element, properties, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
System::String ^ AutomationBridge::getWindowInfo(System::IntPtr windowHandle, System::String ^properties)
|
|
||||||
{
|
|
||||||
AutomationElement ^element = nullptr;
|
|
||||||
try {
|
|
||||||
AutomationElement ^element = AutomationElement::FromHandle(windowHandle);
|
|
||||||
} catch (Exception ^ex) {
|
|
||||||
output(ex, "");
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (element == nullptr)
|
|
||||||
return "";
|
|
||||||
return getWindowInfo(element, properties, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
System::String ^ AutomationBridge::getWindowInfo(System::String ^runtimeIdStr, System::String ^properties)
|
|
||||||
{
|
|
||||||
System::String ^filter = L"First/RuntimeIdProperty"; //get first matching runtimeIdProperty
|
|
||||||
enumFilters->Add(filter, runtimeIdStr);
|
|
||||||
array<System::String ^> ^props = enumWindowInfo(properties);
|
|
||||||
enumFilters->Remove(filter);
|
|
||||||
if (props->Length > 0) //if result array has a match return first result
|
|
||||||
return props[0];
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
//return getWindowInfo(element, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AutomationBridge::output(Exception ^ex, System::String ^message)
|
|
||||||
{
|
|
||||||
System::Console::WriteLine("Exception ({0}): {1} \n{2}", message, ex->Message, ex->StackTrace);
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
// uiabridge.h
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Collections::Generic;
|
|
||||||
using namespace System::Windows::Automation;
|
|
||||||
|
|
||||||
namespace uiabridge {
|
|
||||||
|
|
||||||
public ref class AutomationBridge
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AutomationBridge(void);
|
|
||||||
AutomationBridge(System::String ^cachedProperties);
|
|
||||||
~AutomationBridge();
|
|
||||||
void useCachedRequests(System::Boolean cacheRequestsFlg);
|
|
||||||
int addEnumFilter(System::String ^propertyName, System::String ^propertyValue);
|
|
||||||
void clearEnumFilters();
|
|
||||||
Boolean isElementFiltered(System::Windows::Automation::AutomationElement ^element);
|
|
||||||
Boolean isElementFiltered(System::Windows::Automation::AutomationElement ^element, List<System::String ^> ^filterModifierList);
|
|
||||||
System::String ^ getRuntimeIdFromElement(System::Windows::Automation::AutomationElement ^element);
|
|
||||||
array<System::String ^> ^ enumWindowInfo(System::String ^properties);
|
|
||||||
array<System::String ^> ^ enumWindowInfo(System::IntPtr windowHandle, System::String ^properties);
|
|
||||||
array<System::String ^> ^ enumWindowInfo(AutomationElement ^element, System::String ^properties);
|
|
||||||
array<System::String ^> ^ enumWindowInfo(AutomationElement ^element, System::String ^properties, List<System::String ^> ^filterModifierList);
|
|
||||||
System::String ^ getWindowInfo(AutomationElement ^element, System::String ^properties, AutomationElement ^optionalParentElement);
|
|
||||||
System::String ^ getWindowInfo(System::Int32 x, System::Int32 y, System::String ^properties);
|
|
||||||
System::String ^ getWindowInfo(System::IntPtr windowHandle, System::String ^properties);
|
|
||||||
System::String ^ getWindowInfo(System::String ^runtimeIdStr, System::String ^properties);
|
|
||||||
|
|
||||||
static System::String ^ALL_MODIFIER = L"All";// find all matching elements of this filter
|
|
||||||
static System::String ^PARENT_MODIFIER = L"Parent";//find all children of this matching parent filter
|
|
||||||
static System::String ^FIRST_MODIFIER = L"First"; //find first element matching this filter then stop
|
|
||||||
static System::String ^DEFAULT_CACHED_PROPS = L"RuntimeIdProperty,ParentRuntimeIdProperty,NativeWindowHandleProperty,ProcessIdProperty,FrameworkIdProperty,LocalizedControlTypeProperty,ControlTypeProperty,ClassNameProperty,NameProperty,BoundingRectangleProperty,ValueProperty";
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initializeCache(System::String ^cachedProperties);
|
|
||||||
void output(Exception ^ex, System::String ^message);
|
|
||||||
Dictionary<System::String ^, System::String ^> ^enumFilters;
|
|
||||||
void AutomationBridge::processFilterModifier(Boolean filtered, Boolean modifierChanged, List<System::String ^> ^filterModifierList);
|
|
||||||
CacheRequest ^cacheRequest;
|
|
||||||
System::Boolean useCache;
|
|
||||||
array<AutomationProperty^> ^cachedRootProperties;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{BAC1B079-7B87-4396-B17F-91A86DF1AE29}</ProjectGuid>
|
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
|
||||||
<Keyword>ManagedCProj</Keyword>
|
|
||||||
<RootNamespace>uiabridge</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<IncludePath>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\uiabridge$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
<PostBuildEvent>
|
|
||||||
<Command>mkdir "$(ProjectDir)bin"
|
|
||||||
copy /Y "$(TargetPath)" "$(ProjectDir)bin\uiabridge$(PlatformArchitecture)$(TargetExt)"</Command>
|
|
||||||
</PostBuildEvent>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
<Reference Include="UIAutomationClient" />
|
|
||||||
<Reference Include="UIAutomationClientsideProviders" />
|
|
||||||
<Reference Include="UIAutomationProvider" />
|
|
||||||
<Reference Include="UIAutomationTypes" />
|
|
||||||
<Reference Include="WindowsBase" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Global.h" />
|
|
||||||
<ClInclude Include="org_synthuse_UiaBridge.h" />
|
|
||||||
<ClInclude Include="resource.h" />
|
|
||||||
<ClInclude Include="Stdafx.h" />
|
|
||||||
<ClInclude Include="uiabridge.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="AssemblyInfo.cpp" />
|
|
||||||
<ClCompile Include="Global.cpp" />
|
|
||||||
<ClCompile Include="org_synthuse_UiaBridge.cpp" />
|
|
||||||
<ClCompile Include="Stdafx.cpp">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="uiabridge.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="app.ico" />
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="app.rc" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="uiabridge.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Stdafx.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="resource.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="org_synthuse_UiaBridge.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Global.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="uiabridge.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="AssemblyInfo.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Stdafx.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="org_synthuse_UiaBridge.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Global.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
<None Include="app.ico">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="app.rc">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</ResourceCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
</Project>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Reflection;
|
|
||||||
using namespace System::Runtime::CompilerServices;
|
|
||||||
using namespace System::Runtime::InteropServices;
|
|
||||||
using namespace System::Security::Permissions;
|
|
||||||
|
|
||||||
//
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
//
|
|
||||||
[assembly:AssemblyTitleAttribute("uiabtest")];
|
|
||||||
[assembly:AssemblyDescriptionAttribute("")];
|
|
||||||
[assembly:AssemblyConfigurationAttribute("")];
|
|
||||||
[assembly:AssemblyCompanyAttribute("na")];
|
|
||||||
[assembly:AssemblyProductAttribute("uiabtest")];
|
|
||||||
[assembly:AssemblyCopyrightAttribute("Copyright (c) na 2014")];
|
|
||||||
[assembly:AssemblyTrademarkAttribute("")];
|
|
||||||
[assembly:AssemblyCultureAttribute("")];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the value or you can default the Revision and Build Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
|
|
||||||
[assembly:AssemblyVersionAttribute("1.0.*")];
|
|
||||||
|
|
||||||
[assembly:ComVisible(false)];
|
|
||||||
|
|
||||||
[assembly:CLSCompliantAttribute(true)];
|
|
||||||
|
|
||||||
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
========================================================================
|
|
||||||
APPLICATION : uiabtest Project Overview
|
|
||||||
========================================================================
|
|
||||||
|
|
||||||
AppWizard has created this uiabtest Application for you.
|
|
||||||
|
|
||||||
This file contains a summary of what you will find in each of the files that
|
|
||||||
make up your uiabtest application.
|
|
||||||
|
|
||||||
uiabtest.vcxproj
|
|
||||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the version of Visual C++ that generated the file, and
|
|
||||||
information about the platforms, configurations, and project features selected with the
|
|
||||||
Application Wizard.
|
|
||||||
|
|
||||||
uiabtest.vcxproj.filters
|
|
||||||
This is the filters file for VC++ projects generated using an Application Wizard.
|
|
||||||
It contains information about the association between the files in your project
|
|
||||||
and the filters. This association is used in the IDE to show grouping of files with
|
|
||||||
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
|
|
||||||
"Source Files" filter).
|
|
||||||
|
|
||||||
uiabtest.cpp
|
|
||||||
This is the main application source file.
|
|
||||||
|
|
||||||
AssemblyInfo.cpp
|
|
||||||
Contains custom attributes for modifying assembly metadata.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Other notes:
|
|
||||||
|
|
||||||
AppWizard uses "TODO:" to indicate parts of the source code you
|
|
||||||
should add to or customize.
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
@@ -1,5 +0,0 @@
|
|||||||
REM set path=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;%path%
|
|
||||||
|
|
||||||
%WinDir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:configuration=release /p:platform=win32 %*
|
|
||||||
|
|
||||||
pause
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Visual C++ generated include file.
|
|
||||||
// Used by app.rc
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
// stdafx.cpp : source file that includes just the standard includes
|
|
||||||
// uiabtest.pch will be the pre-compiled header
|
|
||||||
// stdafx.obj will contain the pre-compiled type information
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
// stdafx.h : include file for standard system include files,
|
|
||||||
// or project specific include files that are used frequently, but
|
|
||||||
// are changed infrequently
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <conio.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014, Synthuse.org
|
|
||||||
* Released under the Apache Version 2.0 License.
|
|
||||||
*
|
|
||||||
* last modified by ejakubowski7@gmail.com
|
|
||||||
*/
|
|
||||||
// uiabtest.cpp : main project file.
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
using namespace System;
|
|
||||||
using namespace System::Windows::Automation;
|
|
||||||
using namespace uiabridge;
|
|
||||||
|
|
||||||
void outputResults(array<System::String ^> ^winInfo)
|
|
||||||
{
|
|
||||||
System::IO::StreamWriter ^file = gcnew System::IO::StreamWriter("c:\\temp.txt");
|
|
||||||
for each(System::String ^prop in winInfo)
|
|
||||||
{
|
|
||||||
Console::WriteLine(prop);
|
|
||||||
file->WriteLine(prop);
|
|
||||||
}
|
|
||||||
file->Flush();
|
|
||||||
file->Close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void runBasicTests(AutomationBridge ^ab, System::String ^propList)
|
|
||||||
{
|
|
||||||
array<System::String ^> ^winInfo = nullptr;
|
|
||||||
System::DateTime start;
|
|
||||||
System::Double seconds = 0;
|
|
||||||
|
|
||||||
start = System::DateTime::Now;
|
|
||||||
ab->clearEnumFilters();
|
|
||||||
ab->addEnumFilter("Parent/FrameworkIdProperty", "WinForm");
|
|
||||||
winInfo = ab->enumWindowInfo(propList);
|
|
||||||
//outputResults(winInfo);
|
|
||||||
seconds = System::Math::Round(System::DateTime::Now.Subtract(start).TotalSeconds, 4);
|
|
||||||
Console::WriteLine(L"Total WinForm Elements: {0} in {1} seconds", winInfo->Length, seconds);
|
|
||||||
|
|
||||||
start = System::DateTime::Now;
|
|
||||||
ab->clearEnumFilters();
|
|
||||||
ab->addEnumFilter("Parent/FrameworkIdProperty", "WPF");
|
|
||||||
winInfo = ab->enumWindowInfo(propList);
|
|
||||||
//outputResults(winInfo);
|
|
||||||
seconds = System::Math::Round(System::DateTime::Now.Subtract(start).TotalSeconds, 4);
|
|
||||||
Console::WriteLine(L"Total WPF Elements: {0} in {1} seconds", winInfo->Length, seconds);
|
|
||||||
|
|
||||||
start = System::DateTime::Now;
|
|
||||||
ab->clearEnumFilters();
|
|
||||||
winInfo = ab->enumWindowInfo(propList);
|
|
||||||
//outputResults(winInfo);
|
|
||||||
seconds = System::Math::Round(System::DateTime::Now.Subtract(start).TotalSeconds, 4);
|
|
||||||
Console::WriteLine(L"Total All Elements: {0} in {1} seconds", winInfo->Length, seconds);
|
|
||||||
Console::WriteLine(L"---------------------------------------");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(array<System::String ^> ^args)
|
|
||||||
{
|
|
||||||
Console::WriteLine(L"UI Automation Bridge Test");
|
|
||||||
//System::String ^propList = L"RuntimeIdProperty,ProcessIdProperty,FrameworkIdProperty,LocalizedControlTypeProperty,ClassNameProperty,NameProperty";
|
|
||||||
System::String ^propList = L"RuntimeIdProperty,ParentRuntimeIdProperty,NativeWindowHandleProperty,ProcessIdProperty,FrameworkIdProperty,LocalizedControlTypeProperty,ControlTypeProperty,ClassNameProperty,NameProperty,ValueProperty,BoundingRectangleProperty";
|
|
||||||
AutomationBridge ^ab = gcnew AutomationBridge(propList);
|
|
||||||
//System::String ^propList = L"RuntimeIdProperty,BoundingRectangleProperty";
|
|
||||||
Console::WriteLine(propList);
|
|
||||||
Console::WriteLine(L"\nCached Requests Enabled");
|
|
||||||
ab->useCachedRequests(true);//disable cache
|
|
||||||
runBasicTests(ab, propList);
|
|
||||||
runBasicTests(ab, propList);
|
|
||||||
runBasicTests(ab, propList);
|
|
||||||
|
|
||||||
Console::WriteLine(L"Cached Requests Disabled");
|
|
||||||
ab->useCachedRequests(false);//disable cache
|
|
||||||
runBasicTests(ab, propList);
|
|
||||||
runBasicTests(ab, propList);
|
|
||||||
runBasicTests(ab, propList);
|
|
||||||
|
|
||||||
//System::String ^winInfo1 = ab->getWindowInfo(System::IntPtr(3409618), propList);
|
|
||||||
//ab->addEnumFilter("Parent/ClassNameProperty", "Notepad");
|
|
||||||
//ab->addEnumFilter("First/RuntimeIdProperty", "42-4784952");
|
|
||||||
//ab->addEnumFilter("ClassNameProperty", "Notepad");
|
|
||||||
//ab->addEnumFilter("All/ClassNameProperty", "Edit");
|
|
||||||
//ab->addEnumFilter("All/LocalizedControlTypeProperty", "menu item");
|
|
||||||
//ab->addEnumFilter("Parent/FrameworkIdProperty", "WinForm");
|
|
||||||
//ab->addEnumFilter("Parent/FrameworkIdProperty", "WPF");
|
|
||||||
//ab->addEnumFilter("Parent/ClassNameProperty", "WindowsForms10.Window.8.app.0.2bf8098_r13_ad1");
|
|
||||||
//array<System::String ^> ^winInfo = ab->enumWindowInfo(propList); //L"*"
|
|
||||||
//ab->clearEnumFilters();
|
|
||||||
//ab->addEnumFilter("Parent/FrameworkIdProperty", "WinForm");
|
|
||||||
//array<System::String ^> ^winInfo = ab->enumWindowInfo(System::IntPtr(3409618), propList); //L"*"
|
|
||||||
//array<System::String ^> ^winInfo = ab->enumWindowInfo(System::IntPtr(12977932), propList); //L"*"
|
|
||||||
//Console::WriteLine("enumWindowInfo x,y: {0}", ab->getWindowInfo(100,100, propList); //L"*"
|
|
||||||
|
|
||||||
//outputResults(winInfo);
|
|
||||||
//Globals::Global::AUTO_BRIDGE->clearEnumFilters();
|
|
||||||
//winInfo = nullptr;
|
|
||||||
//winInfo = Globals::Global::AUTO_BRIDGE->enumWindowInfo(System::IntPtr(7603636), propList);
|
|
||||||
//Console::WriteLine("winInfo length: {0}", winInfo->Length);
|
|
||||||
//winInfo = Globals::Global::AUTO_BRIDGE->enumWindowInfo(System::IntPtr(7603636), propList);
|
|
||||||
//Console::WriteLine("winInfo length: {0}", winInfo->Length);
|
|
||||||
|
|
||||||
//Console::WriteLine("getWindowInfo RuntimeIdProperty: {0}", ab->getWindowInfo("42-4784952", propList));
|
|
||||||
|
|
||||||
//System::Threading::Thread::Sleep(10000); //10 seconds sleep
|
|
||||||
//array<System::String ^> ^winInfo2 = ab->enumWindowInfo(propList); //L"*"
|
|
||||||
//outputResults(winInfo2);
|
|
||||||
|
|
||||||
//System::Double seconds = System::Math::Round(System::DateTime::Now.Subtract(start).TotalSeconds, 4);
|
|
||||||
//Console::WriteLine(L"Total Elements: {0} in {1} seconds", winInfo->Length, seconds);
|
|
||||||
Console::WriteLine(L"press any key to exit");
|
|
||||||
_getch();//wait for user input
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{7958D1B7-F169-40FA-A7A0-10E8E0F90CDA}</ProjectGuid>
|
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
|
||||||
<Keyword>ManagedCProj</Keyword>
|
|
||||||
<RootNamespace>uiabtest</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<CLRSupport>true</CLRSupport>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>
|
|
||||||
</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
<Reference Include="UIAutomationClient" />
|
|
||||||
<Reference Include="UIAutomationClientsideProviders" />
|
|
||||||
<Reference Include="UIAutomationProvider" />
|
|
||||||
<Reference Include="UIAutomationTypes" />
|
|
||||||
<Reference Include="WindowsBase" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="app.ico" />
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="resource.h" />
|
|
||||||
<ClInclude Include="stdafx.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="app.rc" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="AssemblyInfo.cpp" />
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="uiabtest.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\uiabridge\uiabridge.vcxproj">
|
|
||||||
<Project>{bac1b079-7b87-4396-b17f-91a86df1ae29}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Source Files">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resource Files">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ReadMe.txt" />
|
|
||||||
<None Include="app.ico">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="stdafx.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="resource.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="app.rc">
|
|
||||||
<Filter>Resource Files</Filter>
|
|
||||||
</ResourceCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="uiabtest.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="AssemblyInfo.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="stdafx.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
</Project>
|
|
||||||
13
src/Test.java
Normal file
13
src/Test.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import main.java.Test.CTest;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
CTest ctest = (CTest) Native.loadLibrary("ctest", CTest.class);
|
||||||
|
ctest.helloFromC();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
738
src/main/java/org/synthuse/Api.java
Normal file
738
src/main/java/org/synthuse/Api.java
Normal file
@@ -0,0 +1,738 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Synthuse.org
|
||||||
|
* Released under the Apache Version 2.0 License.
|
||||||
|
*
|
||||||
|
* last modified by ejakubowski7@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.synthuse;
|
||||||
|
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.synthuse.interfaces.Gdi32Ex;
|
||||||
|
import org.synthuse.interfaces.Kernel32Ex;
|
||||||
|
import org.synthuse.interfaces.PsapiEx;
|
||||||
|
import org.synthuse.interfaces.User32Ex;
|
||||||
|
import org.synthuse.objects.LVITEM_VISTA;
|
||||||
|
import org.synthuse.objects.MenuItem;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.platform.win32.Advapi32Util;
|
||||||
|
import com.sun.jna.platform.win32.BaseTSD.SIZE_T;
|
||||||
|
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HMENU;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HPEN;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.RECT;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.WPARAM;
|
||||||
|
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||||
|
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||||
|
import com.sun.jna.platform.win32.WinReg;
|
||||||
|
import com.sun.jna.platform.win32.WinUser;
|
||||||
|
import com.sun.jna.ptr.IntByReference;
|
||||||
|
import com.sun.jna.ptr.PointerByReference;
|
||||||
|
|
||||||
|
public class Api {
|
||||||
|
public static boolean EXACT = false;
|
||||||
|
|
||||||
|
public static int WM_SETTEXT = 0x000c;
|
||||||
|
public static int WM_GETTEXT = 0x000D;
|
||||||
|
public static int WM_GETTEXTLENGTH = 0x000E;
|
||||||
|
public static int WM_MOUSEMOVE = 0x200;
|
||||||
|
public static int WM_LBUTTONDOWN = 0x0201;
|
||||||
|
public static int WM_LBUTTONUP = 0x0202;
|
||||||
|
public static int WM_LBUTTONDBLCLK = 0x203;
|
||||||
|
public static int WM_RBUTTONDOWN = 0x0204;
|
||||||
|
public static int WM_RBUTTONUP = 0x0205;
|
||||||
|
public static int WM_RBUTTONDBLCLK = 0x206;
|
||||||
|
public static int WM_MBUTTONDOWN = 0x207;
|
||||||
|
public static int WM_MBUTTONUP = 0x208;
|
||||||
|
public static int WM_MBUTTONDBLCLK = 0x209;
|
||||||
|
public static int WM_MOUSEWHEEL = 0x20A;
|
||||||
|
public static int WM_MOUSEHWHEEL = 0x20E;
|
||||||
|
public static int WM_MOUSEHOVER = 0x2A1;
|
||||||
|
public static int WM_NCMOUSELEAVE = 0x2A2;
|
||||||
|
public static int WM_MOUSELEAVE = 0x2A3;
|
||||||
|
|
||||||
|
public static int WM_CLOSE = 0x10;
|
||||||
|
public static int WM_DESTROY = 0x0002;
|
||||||
|
public static int WM_NCDESTROY = 0x0082;
|
||||||
|
public static int WM_QUIT = 0x12;
|
||||||
|
|
||||||
|
public static int WM_SETFOCUS = 0x0007;
|
||||||
|
public static int WM_NEXTDLGCTL = 0x0028;
|
||||||
|
public static int WM_ENABLE = 0x000A;
|
||||||
|
public static int WM_KEYFIRST = 0x100;
|
||||||
|
public static int WM_KEYDOWN = 0x100;
|
||||||
|
public static int WM_KEYUP = 0x101;
|
||||||
|
public static int WM_CHAR = 0x102;
|
||||||
|
public static int WM_DEADCHAR = 0x103;
|
||||||
|
public static int WM_SYSKEYDOWN = 0x104;
|
||||||
|
public static int WM_SYSKEYUP = 0x105;
|
||||||
|
public static int WM_SYSCHAR = 0x106;
|
||||||
|
|
||||||
|
public static int WM_CUT = 0x300;
|
||||||
|
public static int WM_COPY = 0x301;
|
||||||
|
public static int WM_PASTE = 0x302;
|
||||||
|
public static int WM_CLEAR = 0x303;
|
||||||
|
public static int WM_UNDO = 0x304;
|
||||||
|
|
||||||
|
public static int PROCESS_QUERY_INFORMATION = 0x0400;
|
||||||
|
public static int PROCESS_VM_READ = 0x0010;
|
||||||
|
public static int PROCESS_VM_WRITE = 0x0020;
|
||||||
|
public static int PROCESS_VM_OPERATION = 0x0008;
|
||||||
|
|
||||||
|
public static int PS_SOLID = 0x0;
|
||||||
|
public static int PS_DASH = 0x1;
|
||||||
|
public static int PS_DOT = 0x2;
|
||||||
|
public static int PS_DASHDOT = 0x3;
|
||||||
|
public static int PS_DASHDOTDOT = 0x4;
|
||||||
|
public static int PS_NULL = 0x5;
|
||||||
|
public static int PS_INSIDEFRAME = 0x6;
|
||||||
|
|
||||||
|
public static int HOLLOW_BRUSH = 0x5;
|
||||||
|
|
||||||
|
public static int WM_PAINT = 0x0F;
|
||||||
|
public static int WM_SETREDRAW = 0x0B;
|
||||||
|
public static int WM_ERASEBKGND = 0x14;
|
||||||
|
|
||||||
|
public static int RDW_FRAME = 0x0400;
|
||||||
|
public static int RDW_INVALIDATE = 0x0001;
|
||||||
|
public static int RDW_UPDATENOW = 0x0100;
|
||||||
|
public static int RDW_ALLCHILDREN = 0x0080;
|
||||||
|
|
||||||
|
public static int TB_GETBUTTONTEXTA = (0x0400 + 45);
|
||||||
|
public static int TB_GETBUTTONTEXTW = (0x0400 + 75);
|
||||||
|
public static int TB_GETRECT = (0x0400 + 51);
|
||||||
|
public static int TB_GETTOOLTIPS = (0x0400 + 35);
|
||||||
|
public static int TB_BUTTONCOUNT = 0x0418;
|
||||||
|
|
||||||
|
public static int LVM_FIRST = 0x1000;
|
||||||
|
public static int LVM_GETITEMCOUNT = LVM_FIRST + 4;
|
||||||
|
public static int LVM_GETITEM = LVM_FIRST + 75;
|
||||||
|
public static int LVIF_TEXT = 0x0001;
|
||||||
|
public static int LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50);
|
||||||
|
public static int LVM_SETITEMSTATE = (LVM_FIRST + 43);
|
||||||
|
public static int LVM_GETITEMSTATE = (LVM_FIRST + 44);
|
||||||
|
public static int LVIS_SELECTED = 0x0002;
|
||||||
|
public static int LVIS_FOCUSED = 0x0001;
|
||||||
|
|
||||||
|
public static int LB_GETCOUNT = 0x18B;
|
||||||
|
public static int LB_GETCURSEL = 0x0188;
|
||||||
|
public static int LB_SETCURSEL = 0x0186;
|
||||||
|
public static int LB_GETTEXT = 0x0189;
|
||||||
|
public static int LB_GETTEXTLEN = 0x018A;
|
||||||
|
public static int LB_SELECTSTRING = 396;
|
||||||
|
|
||||||
|
public static int CB_GETCOUNT = 0x146;
|
||||||
|
|
||||||
|
public static int TV_FIRST = 0x1100;
|
||||||
|
public static int TVM_GETCOUNT = TV_FIRST + 5;
|
||||||
|
|
||||||
|
public static int VK_SHIFT = 16;
|
||||||
|
public static int VK_LSHIFT = 0xA0;
|
||||||
|
public static int VK_RSHIFT = 0xA1;
|
||||||
|
public static int VK_CONTROL = 17;
|
||||||
|
public static int VK_LCONTROL = 0xA2;
|
||||||
|
public static int VK_RCONTROL = 0xA3;
|
||||||
|
public static int VK_MENU = 18;
|
||||||
|
public static int VK_LMENU = 0xA4;
|
||||||
|
public static int VK_RMENU = 0xA5;
|
||||||
|
|
||||||
|
public static int WM_COMMAND = 0x111;
|
||||||
|
public static int MN_GETHMENU = 0x01E1;
|
||||||
|
|
||||||
|
public static int CWP_ALL = 0x0000; // Does not skip any child windows
|
||||||
|
|
||||||
|
public static int PAGE_READWRITE = 0x04;
|
||||||
|
|
||||||
|
public static int MEM_COMMIT = 0x1000;
|
||||||
|
public static int MEM_RESERVE = 0x2000;
|
||||||
|
public static int MEM_RELEASE = 0x8000;
|
||||||
|
public static int MEM_FREE = 0x10000;
|
||||||
|
public static int MEM_DECOMMIT = 0x4000;
|
||||||
|
|
||||||
|
public static int MF_BYCOMMAND = 0x000000;
|
||||||
|
public static int MF_BYPOSITION = 0x000004;
|
||||||
|
|
||||||
|
public User32Ex user32;
|
||||||
|
public PsapiEx psapi;
|
||||||
|
public Kernel32Ex kernel32;
|
||||||
|
|
||||||
|
protected HashMap<HWND, HMENU> windowMap;
|
||||||
|
protected HashMap<MenuItem, WPARAM> menuItemMap;
|
||||||
|
protected HWND hWndFound;
|
||||||
|
|
||||||
|
public static final int POINT_Y(long i) {
|
||||||
|
return (int) (i >> 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int POINT_X(long i) {
|
||||||
|
return (int) (i & 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long MAKELONG(int low, int high) {
|
||||||
|
return ((long) (((short) ((int) (low) & 0xffff)) | ((int) ((short) ((int) (high) & 0xffff))) << 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Api() {
|
||||||
|
user32 = User32Ex.instance;
|
||||||
|
psapi = PsapiEx.instance;
|
||||||
|
kernel32 = Kernel32Ex.instance;
|
||||||
|
windowMap = new HashMap<HWND, HMENU>();
|
||||||
|
menuItemMap = new HashMap<MenuItem, WPARAM>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long GetHandleAsLong(HWND hWnd) {
|
||||||
|
if (hWnd == null)
|
||||||
|
return (long) 0;
|
||||||
|
// String longHexStr = hWnd.toString().substring("native@".length());
|
||||||
|
String longHexStr = hWnd.getPointer().toString().substring("native@".length());
|
||||||
|
return Long.decode(longHexStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetHandleAsString(HWND hWnd) {
|
||||||
|
return GetHandleAsLong(hWnd).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HWND GetHandleFromString(String hWnd) {
|
||||||
|
if (hWnd == null)
|
||||||
|
return null;
|
||||||
|
if (hWnd.isEmpty())
|
||||||
|
return null;
|
||||||
|
String cleanNumericHandle = hWnd.replaceAll("[^\\d.]", "");
|
||||||
|
try {
|
||||||
|
return (new HWND(new Pointer(Long.parseLong(cleanNumericHandle))));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getWindowClassName(HWND hWnd) {
|
||||||
|
char[] buffer = new char[1026];
|
||||||
|
User32Ex.instance.GetClassName(hWnd, buffer, 1026);
|
||||||
|
return Native.toString(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getWindowText(HWND hWnd) {
|
||||||
|
String text = "";
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
User32Ex.instance.GetWindowTextA(hWnd, buffer, buffer.length);
|
||||||
|
text = Native.toString(buffer);
|
||||||
|
if (text.isEmpty())
|
||||||
|
text = new Api().sendWmGetText(hWnd);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point getCursorPos() {
|
||||||
|
|
||||||
|
long[] getPos = new long[1];
|
||||||
|
User32Ex.instance.GetCursorPos(getPos);
|
||||||
|
return new Point(POINT_X(getPos[0]), POINT_Y(getPos[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HWND getWindowFromCursorPos() {
|
||||||
|
long[] getPos = new long[1];
|
||||||
|
User32Ex.instance.GetCursorPos(getPos);
|
||||||
|
HWND hwnd = User32Ex.instance.WindowFromPoint(getPos[0]);
|
||||||
|
HWND childHwnd = getHiddenChildWindowFromPoint(hwnd, getPos[0]);
|
||||||
|
hwnd = childHwnd;
|
||||||
|
// System.out.println(getPos[0] + "," + getPos[1] + " int: " + x + ", "
|
||||||
|
// + y);
|
||||||
|
// System.out.println("child: " + GetHandleAsString(childHwnd) + " " +
|
||||||
|
// POINT_X(getPos[0]) +", " + POINT_Y(getPos[0]));
|
||||||
|
return hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HWND getHiddenChildWindowFromPoint(HWND inHwnd, long point) {
|
||||||
|
// int x = POINT_X(point);int y = POINT_Y(point);
|
||||||
|
|
||||||
|
long[] getPos = new long[1];
|
||||||
|
getPos[0] = point;
|
||||||
|
// if (!User32.instance.ClientToScreen(inHwnd, getPos)) return lHWND;
|
||||||
|
// x = POINT_X(getPos[0]);y = POINT_Y(getPos[0]);
|
||||||
|
// System.out.println("ClientToScreen " + GetHandleAsString(inHwnd) +
|
||||||
|
// ", " + x + ", " + y);
|
||||||
|
|
||||||
|
if (!User32Ex.instance.ScreenToClient(inHwnd, getPos))
|
||||||
|
return inHwnd; // if point is not correct use original hwnd.
|
||||||
|
// x = POINT_X(getPos[0]);y = POINT_Y(getPos[0]);
|
||||||
|
// System.out.println("ScreenToClient " + GetHandleAsString(inHwnd) +
|
||||||
|
// ", " + x + ", " + y);
|
||||||
|
|
||||||
|
HWND childHwnd = User32Ex.instance.ChildWindowFromPointEx(inHwnd, getPos[0], CWP_ALL);
|
||||||
|
// System.out.println("ChildWindowFromPointEx2 " +
|
||||||
|
// GetHandleAsString(inHwnd) + ", " + x + ", " + y + " = " +
|
||||||
|
// GetHandleAsString(childHwnd));
|
||||||
|
|
||||||
|
if (childHwnd == null) // if childHwnd is not correct use original hwnd.
|
||||||
|
return inHwnd;
|
||||||
|
|
||||||
|
return childHwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HWND findWindowByTitle(String title) {
|
||||||
|
HWND handle = user32.FindWindow(null, title);
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean activateWindow(HWND handle) {
|
||||||
|
boolean result = user32.SetForegroundWindow(handle);
|
||||||
|
user32.SetFocus(handle);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDialogFocus(HWND hdlg, HWND hwndControl) {
|
||||||
|
WPARAM wp = new WPARAM(hwndControl.getPointer().getLong(0));
|
||||||
|
LPARAM lp = new LPARAM(1);
|
||||||
|
user32.SendMessage(hdlg, WM_NEXTDLGCTL, wp, lp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean showWindow(HWND handle) {
|
||||||
|
return user32.ShowWindow(handle, WinUser.SW_SHOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hideWindow(HWND handle) {
|
||||||
|
return user32.ShowWindow(handle, WinUser.SW_HIDE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean minimizeWindow(HWND handle) {
|
||||||
|
return user32.ShowWindow(handle, WinUser.SW_MINIMIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean maximizeWindow(HWND handle) {
|
||||||
|
return user32.ShowWindow(handle, WinUser.SW_MAXIMIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean restoreWindow(HWND handle) {
|
||||||
|
return user32.ShowWindow(handle, WinUser.SW_RESTORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean closeWindow(HWND handle) {
|
||||||
|
// return user32.DestroyWindow(handle);
|
||||||
|
// user32.SendMessage(handle, WM_CLOSE , null, null);
|
||||||
|
user32.PostMessage(handle, WM_CLOSE, null, null);
|
||||||
|
// user32.SendMessage(handle, WM_NCDESTROY , null, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchToThisWindow(HWND handle, boolean fAltTab) {
|
||||||
|
user32.SwitchToThisWindow(handle, fAltTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String sendWmGetText(HWND handle) {
|
||||||
|
int bufSize = 8192;
|
||||||
|
byte[] lParamStr = new byte[bufSize];
|
||||||
|
user32.SendMessageA(handle, WM_GETTEXT, bufSize, lParamStr);
|
||||||
|
return (Native.toString(lParamStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWmSetText(HWND handle, String text) {
|
||||||
|
user32.SendMessageA(handle, WM_SETTEXT, 0, Native.toByteArray(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendClick(HWND handle) {
|
||||||
|
user32.SendMessageA(handle, WM_LBUTTONDOWN, 0, null);
|
||||||
|
user32.SendMessageA(handle, WM_LBUTTONUP, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendDoubleClick(HWND handle) {
|
||||||
|
user32.SendMessageA(handle, WM_LBUTTONDBLCLK, 0, null);
|
||||||
|
// user32.SendMessageA(handle, WM_LBUTTONUP, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendRightClick(HWND handle) {
|
||||||
|
user32.SendMessageA(handle, WM_RBUTTONDOWN, 0, null);
|
||||||
|
user32.SendMessageA(handle, WM_RBUTTONUP, 0, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendKeyDown(HWND handle, int keyCode) {
|
||||||
|
user32.SendMessageA(handle, WM_KEYDOWN, keyCode, null);
|
||||||
|
// user32.SendMessageA(handle, WM_KEYUP, keyCode, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendKeyUp(HWND handle, int keyCode) {
|
||||||
|
// user32.SendMessageA(handle, WM_KEYDOWN, keyCode, null);
|
||||||
|
user32.SendMessageA(handle, WM_KEYUP, keyCode, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String GetMenuItemText(HMENU hmenu, int position) {
|
||||||
|
if (user32.IsMenu(hmenu) == false)
|
||||||
|
return "";
|
||||||
|
char[] buffer = new char[256];
|
||||||
|
user32.GetMenuString(hmenu, position, buffer, 256, 0x0400);
|
||||||
|
return Native.toString(buffer);
|
||||||
|
/*
|
||||||
|
* Api.WinDefExt.MENUITEMINFO mii = new Api.WinDefExt.MENUITEMINFO(); //
|
||||||
|
* = (MENUITEMINFO)Api.MENUITEMINFO.newInstance(Api.MENUITEMINFO.class);
|
||||||
|
* mii.fMask = Api.WinDefExt.MENUITEMINFO.MIIM_TYPE; mii.fType =
|
||||||
|
* Api.WinDefExt.MENUITEMINFO.MFT_STRING; mii.cch = 0; mii.dwTypeData =
|
||||||
|
* "";
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("unused") boolean result =
|
||||||
|
* Api.User32.instance.GetMenuItemInfoA(hmenu, position, true, mii);
|
||||||
|
* //System.out.println(position + " GetMenuItemInfo (" + result +
|
||||||
|
* ") : " + mii.cch + " " + mii.dwTypeData); mii.fMask =
|
||||||
|
* Api.WinDefExt.MENUITEMINFO.MIIM_TYPE; mii.fType =
|
||||||
|
* Api.WinDefExt.MENUITEMINFO.MFT_STRING; mii.cch += 1; mii.dwTypeData =
|
||||||
|
* "";//new String(new char[mii.cch]).replace("\0", " "); //buffer
|
||||||
|
* string with spaces result =
|
||||||
|
* Api.User32.instance.GetMenuItemInfoA(hmenu, position, true, mii);
|
||||||
|
* //System.out.println(position + " GetMenuItemInfo2 (" + result +
|
||||||
|
* ") Text: " + mii.dwTypeData + " " + mii.cch + " " + mii.wID);
|
||||||
|
* //System.out.println("last error: " +
|
||||||
|
* Api.Kernel32.instance.GetLastError()); return mii.dwTypeData;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point getWindowPosition(HWND handle) {
|
||||||
|
Point windowPoint = new Point();
|
||||||
|
RECT rect = new RECT();
|
||||||
|
user32.GetWindowRect(handle, rect);
|
||||||
|
// System.out.println("rect: l" + rect.left + ",t" + rect.top + ",r" +
|
||||||
|
// rect.right + ",b" + rect.bottom);
|
||||||
|
// user32.MapWindowPoints(user32.GetDesktopWindow(),
|
||||||
|
// user32.GetParent(handle), rect, 2);
|
||||||
|
windowPoint.x = ((rect.right - rect.left) / 2) + rect.left;
|
||||||
|
windowPoint.y = ((rect.bottom - rect.top) / 2) + rect.top;
|
||||||
|
return windowPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point getMenuItemPosition(HWND handle, HMENU hMenu, int pos) {
|
||||||
|
Point windowPoint = new Point();
|
||||||
|
RECT rect = new RECT();
|
||||||
|
user32.GetMenuItemRect(handle, hMenu, pos, rect);
|
||||||
|
// System.out.println("rect: l" + rect.left + ",t" + rect.top + ",r" +
|
||||||
|
// rect.right + ",b" + rect.bottom);
|
||||||
|
// user32.MapWindowPoints(user32.GetDesktopWindow(),
|
||||||
|
// user32.GetParent(handle), rect, 2);
|
||||||
|
windowPoint.x = ((rect.right - rect.left) / 2) + rect.left;
|
||||||
|
windowPoint.y = ((rect.bottom - rect.top) / 2) + rect.top;
|
||||||
|
return windowPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDiskUsedPercentage() {
|
||||||
|
return getDiskUsedPercentage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDiskUsedPercentage(String target) {
|
||||||
|
LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference();
|
||||||
|
LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference();
|
||||||
|
LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference();
|
||||||
|
Kernel32Ex.instance.GetDiskFreeSpaceEx(target, lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes);
|
||||||
|
double freeBytes = lpTotalNumberOfFreeBytes.getValue();
|
||||||
|
double totalBytes = lpTotalNumberOfBytes.getValue();
|
||||||
|
// System.out.println("freespace " + humanReadableByteCount(freeBytes) +
|
||||||
|
// "/ totalspace " + humanReadableByteCount(totalBytes));
|
||||||
|
return (int) (((totalBytes - freeBytes) / totalBytes) * 100.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String humanReadableByteCount(double bytes) {
|
||||||
|
boolean si = true;
|
||||||
|
int unit = si ? 1000 : 1024;
|
||||||
|
if (bytes < unit)
|
||||||
|
return bytes + " B";
|
||||||
|
int exp = (int) (Math.log(bytes) / Math.log(unit));
|
||||||
|
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
|
||||||
|
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void highlightWindow(HWND hwnd) {
|
||||||
|
RECT rect = new RECT();
|
||||||
|
User32Ex.instance.GetWindowRect(hwnd, rect);
|
||||||
|
// System.out.println("RECT: " + rect.left + "," + rect.top + "," +
|
||||||
|
// (rect.right - rect.left) + "," + (rect.bottom - rect.top));
|
||||||
|
highlightWindow(hwnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
// creates highlight around selected window
|
||||||
|
public static void highlightWindow(HWND hwnd, int x, int y, int x2, int y2) {
|
||||||
|
// COLORREF i.e. 0x00804070 Red = 0x70 green = 0x40 blue = 0x80
|
||||||
|
// g_hRectanglePen = CreatePen (PS_SOLID, 3, RGB(256, 0, 0));
|
||||||
|
HPEN rectPen = Gdi32Ex.instance.CreatePen(PS_SOLID, 3, 0x00000099); // RGB(255,
|
||||||
|
// 0,
|
||||||
|
// 0)
|
||||||
|
HDC dc = User32Ex.instance.GetWindowDC(hwnd);
|
||||||
|
if (dc != null) {
|
||||||
|
// Select our created pen into the DC and backup the previous pen.
|
||||||
|
HANDLE prevPen = Gdi32Ex.instance.SelectObject(dc, rectPen);
|
||||||
|
|
||||||
|
// Select a transparent brush into the DC and backup the previous
|
||||||
|
// brush.
|
||||||
|
HANDLE prevBrush = Gdi32Ex.instance.SelectObject(dc, Gdi32Ex.instance.GetStockObject(HOLLOW_BRUSH));
|
||||||
|
|
||||||
|
// Draw a rectangle in the DC covering the entire window area of the
|
||||||
|
// found window.
|
||||||
|
Gdi32Ex.instance.Rectangle(dc, x, y, x2, y2);
|
||||||
|
|
||||||
|
// Reinsert the previous pen and brush into the found window's DC.
|
||||||
|
Gdi32Ex.instance.SelectObject(dc, prevPen);
|
||||||
|
Gdi32Ex.instance.SelectObject(dc, prevBrush);
|
||||||
|
|
||||||
|
// Finally release the DC.
|
||||||
|
User32Ex.instance.ReleaseDC(hwnd, dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshWindow(HWND hwnd) {
|
||||||
|
User32Ex.instance.InvalidateRect(hwnd, 0, true);
|
||||||
|
User32Ex.instance.UpdateWindow(hwnd);
|
||||||
|
User32Ex.instance.RedrawWindow(hwnd, 0, 0, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDotNet4Installed() {
|
||||||
|
try {
|
||||||
|
int installed = Advapi32Util.registryGetIntValue(WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4.0\\Client", "Install");
|
||||||
|
// System.out.println("isDotNet4Installed: " + installed);
|
||||||
|
return (installed == 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int installed = Advapi32Util.registryGetIntValue(WinReg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Client", "Install");
|
||||||
|
// System.out.println("isDotNet4Installed: " + installed);
|
||||||
|
return (installed == 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProcess64bit(int pid) {
|
||||||
|
try {
|
||||||
|
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
|
||||||
|
Kernel32Ex.instance.GetNativeSystemInfo(lpSystemInfo);
|
||||||
|
if (lpSystemInfo.processorArchitecture.dwOemID.intValue() == 0) {
|
||||||
|
System.out.println("intel x86"); // not a 64 bit os
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pointer process = Kernel32Ex.instance.OpenProcess(Api.PROCESS_QUERY_INFORMATION | Api.PROCESS_VM_READ, false, new Pointer(pid));
|
||||||
|
IntByReference isWow64 = new IntByReference(0);
|
||||||
|
if (!Kernel32Ex.instance.IsWow64Process(new HANDLE(process), isWow64)) {
|
||||||
|
// handle error
|
||||||
|
}
|
||||||
|
// System.out.println("isProcess64bit " + pid + " = " +
|
||||||
|
// isWow64.getValue());
|
||||||
|
Kernel32Ex.instance.CloseHandle(new HANDLE(process));
|
||||||
|
if (isWow64.getValue() == 1)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
// CloseHandle()
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HWND FindMainWindowFromPid(final long targetProcessId) {
|
||||||
|
final List<HWND> resultList = new ArrayList<HWND>();
|
||||||
|
class ParentWindowCallback implements WinUser.WNDENUMPROC {
|
||||||
|
@Override
|
||||||
|
public boolean callback(HWND hWnd, Pointer lParam) {
|
||||||
|
PointerByReference pointer = new PointerByReference();
|
||||||
|
User32Ex.instance.GetWindowThreadProcessId(hWnd, pointer);
|
||||||
|
long pid = pointer.getPointer().getInt(0);
|
||||||
|
if (pid == targetProcessId)
|
||||||
|
if (resultList.isEmpty())
|
||||||
|
resultList.add(hWnd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
User32Ex.instance.EnumWindows(new ParentWindowCallback(), 0);
|
||||||
|
if (!resultList.isEmpty())
|
||||||
|
return resultList.get(0);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SelectListViewItemByIndex(HWND listViewHwnd, int index) {
|
||||||
|
/*
|
||||||
|
* HANDLE hProcess = OpenProcess(PROCESS_VM_WRITE |
|
||||||
|
* PROCESS_VM_OPERATION, FALSE, 0x0000c130); LPVOID epLvi =
|
||||||
|
* VirtualAllocEx(hProcess, NULL, 4096, MEM_RESERVE | MEM_COMMIT,
|
||||||
|
* PAGE_READWRITE);
|
||||||
|
*
|
||||||
|
* LVITEM lvi; lvi.state = LVIS_FOCUSED | LVIS_SELECTED; lvi.stateMask =
|
||||||
|
* LVIS_FOCUSED | LVIS_SELECTED; SIZE_T cbWritten = 0;
|
||||||
|
* WriteProcessMemory(hProcess, epLvi, &lvi, sizeof(lvi), &cbWritten);
|
||||||
|
* DWORD dw = SendMessage((HWND)0x00020C4C, LVM_SETITEMSTATE, 1,
|
||||||
|
* (LPARAM)epLvi);
|
||||||
|
*
|
||||||
|
* VirtualFreeEx(hProcess, epLvi, 4096, MEM_DECOMMIT | MEM_RELEASE);
|
||||||
|
* CloseHandle(hProcess);
|
||||||
|
*/
|
||||||
|
PointerByReference pointer = new PointerByReference();
|
||||||
|
User32Ex.instance.GetWindowThreadProcessId(listViewHwnd, pointer);
|
||||||
|
int pid = pointer.getPointer().getInt(0);
|
||||||
|
Pointer process = Kernel32Ex.instance.OpenProcess(Api.PROCESS_VM_WRITE | Api.PROCESS_VM_OPERATION, false, new Pointer(pid));
|
||||||
|
IntByReference addr = new IntByReference(0);
|
||||||
|
SIZE_T size = new SIZE_T(4096);
|
||||||
|
IntByReference epLvi = Kernel32Ex.instance.VirtualAllocEx(new HANDLE(process), addr, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
|
||||||
|
LVITEM_VISTA lvitem = new LVITEM_VISTA();
|
||||||
|
lvitem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
|
||||||
|
lvitem.state = LVIS_FOCUSED | LVIS_SELECTED;
|
||||||
|
IntByReference bytesWritten = new IntByReference();
|
||||||
|
Kernel32Ex.instance.WriteProcessMemory(new HANDLE(process), epLvi, lvitem.getPointer(), lvitem.size(), bytesWritten);
|
||||||
|
User32Ex.instance.SendMessage(listViewHwnd, LVM_SETITEMSTATE, new WPARAM(index), lvitem);
|
||||||
|
|
||||||
|
Kernel32Ex.instance.VirtualFreeEx(new HANDLE(process), epLvi, new SIZE_T(4096), new DWORD(MEM_DECOMMIT | MEM_RELEASE));
|
||||||
|
Kernel32Ex.instance.CloseHandle(new HANDLE(process));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SelectListItemByIndex(HWND listHwnd, int index) {
|
||||||
|
// com.sun.jna.platform.win32.User32.INSTANCE
|
||||||
|
User32Ex.instance.SendMessage(listHwnd, LB_SETCURSEL, new WPARAM(index), new LPARAM(0));
|
||||||
|
SelectListViewItemByIndex(listHwnd, index);
|
||||||
|
// GetListViewItemByIndex(listHwnd, index);
|
||||||
|
// LVITEM lvitem = new LVITEM();
|
||||||
|
// lvitem.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
|
||||||
|
// lvitem.state = LVIS_FOCUSED | LVIS_SELECTED;
|
||||||
|
// JOptionPane.showMessageDialog(null, "lvitem size: " + lvitem.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public WPARAM loadMenuItem(HWND hWnd, HMENU hMenu, boolean exact, String... path) throws Exception {
|
||||||
|
boolean found = false;
|
||||||
|
int itemID = -1;
|
||||||
|
int pathLength = path.length;
|
||||||
|
for (int i = 0; i < pathLength; ++i) {
|
||||||
|
String search = path[i];
|
||||||
|
int count = user32.GetMenuItemCount(hMenu);
|
||||||
|
found = false;
|
||||||
|
for (int position = 0; position < count; ++position) {
|
||||||
|
String menuItemText = GetMenuItemText(hMenu, position);
|
||||||
|
if (exact ? menuItemText.equals(search) : menuItemText.contains(search)) {
|
||||||
|
found = true;
|
||||||
|
if (i < pathLength - 1) {
|
||||||
|
hMenu = user32.GetSubMenu(hMenu, position);
|
||||||
|
} else {
|
||||||
|
itemID = user32.GetMenuItemID(hMenu, position);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
throw new Exception("Menu item not found!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new WPARAM(itemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HWND findTopWindow(String text, String className) {
|
||||||
|
return findTopWindow(text, EXACT, className);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HWND findTopWindow(String text, boolean exact, String className) {
|
||||||
|
hWndFound = null;
|
||||||
|
user32.EnumWindows(new WinUser.WNDENUMPROC() {
|
||||||
|
public boolean callback(HWND hWnd, Pointer lParam) {
|
||||||
|
String windowText = getWindowText(hWnd);
|
||||||
|
System.out.println(windowText);
|
||||||
|
if (exact ? windowText.equals(text) : windowText.contains(text)) {
|
||||||
|
hWndFound = hWnd;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
return hWndFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HWND findChildWindow(HWND hWnd, String text) {
|
||||||
|
return findChildWindow(hWnd, EXACT, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HWND findChildWindow(HWND hWnd, boolean exact, String text) {
|
||||||
|
hWndFound = null;
|
||||||
|
user32.EnumChildWindows(hWnd, new WinUser.WNDENUMPROC() {
|
||||||
|
public boolean callback(HWND hWnd, Pointer lParam) {
|
||||||
|
if (exact ? Api.getWindowText(hWnd).equals(text) : Api.getWindowText(hWnd).contains(text)) {
|
||||||
|
hWndFound = hWnd;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, null);
|
||||||
|
return hWndFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HWND findChildWindow(HWND hWnd, String... path) {
|
||||||
|
return findChildWindow(hWnd, EXACT, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HWND findChildWindow(HWND hWnd, boolean exact, String... path) {
|
||||||
|
for (String search : path) {
|
||||||
|
hWnd = findChildWindow(hWnd, exact, search);
|
||||||
|
}
|
||||||
|
return hWnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HWND[] findAllChildWindow(HWND hWnd, String search) {
|
||||||
|
return findAllChildWindow(hWnd, EXACT, search);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HWND[] findAllChildWindow(HWND hWnd, boolean exact, String search) {
|
||||||
|
ArrayList<HWND> hwndList = new ArrayList<HWND>();
|
||||||
|
user32.EnumChildWindows(hWnd, new WinUser.WNDENUMPROC() {
|
||||||
|
public boolean callback(HWND hWnd, Pointer lParam) {
|
||||||
|
String text = Api.getWindowText(hWnd);
|
||||||
|
if (exact ? text.equals(search) : text.contains(search)) {
|
||||||
|
hwndList.add(hWnd);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}, null);
|
||||||
|
return hwndList.toArray(new HWND[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean activateItem(MenuItem menuItem) throws Exception {
|
||||||
|
HWND hWnd = menuItem.hWnd;
|
||||||
|
HMENU hMenu = menuItem.hMenu;
|
||||||
|
String[] path = menuItem.path;
|
||||||
|
boolean exact = menuItem.exact;
|
||||||
|
WPARAM wParam;
|
||||||
|
if (menuItemMap.containsKey(menuItem)) {
|
||||||
|
wParam = menuItemMap.get(menuItem);
|
||||||
|
} else {
|
||||||
|
wParam = loadMenuItem(hWnd, hMenu, exact, path);
|
||||||
|
}
|
||||||
|
return user32.PostMessage(hWnd, Api.WM_COMMAND, wParam, null).intValue() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean activateItem(HWND hWnd, boolean exact, String... path) throws Exception {
|
||||||
|
MenuItem menuItem = loadMenuItem(hWnd, exact, path);
|
||||||
|
return activateItem(menuItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuItem loadMenuItem(HWND hWnd, boolean exact, String... path) throws Exception {
|
||||||
|
HMENU hMenu;
|
||||||
|
if (windowMap.containsKey(hWnd)) {
|
||||||
|
hMenu = windowMap.get(hWnd);
|
||||||
|
} else {
|
||||||
|
hMenu = user32.GetMenu(hWnd);
|
||||||
|
windowMap.put(hWnd, hMenu);
|
||||||
|
}
|
||||||
|
MenuItem menuItem = new MenuItem(hWnd, hMenu, path);
|
||||||
|
WPARAM wParam = loadMenuItem(hWnd, hMenu, exact, path);
|
||||||
|
menuItemMap.put(menuItem, wParam);
|
||||||
|
return menuItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected WPARAM loadMenuItem(MenuItem menuItem) throws Exception {
|
||||||
|
HWND hWnd = menuItem.hWnd;
|
||||||
|
HMENU hMenu = menuItem.hMenu;
|
||||||
|
String[] path = menuItem.path;
|
||||||
|
boolean exact = menuItem.exact;
|
||||||
|
return loadMenuItem(hWnd, hMenu, exact, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
363
src/main/java/org/synthuse/KeyboardHook.java
Normal file
363
src/main/java/org/synthuse/KeyboardHook.java
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Synthuse.org
|
||||||
|
* Released under the Apache Version 2.0 License.
|
||||||
|
*
|
||||||
|
* last modified by ejakubowski7@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.synthuse;
|
||||||
|
|
||||||
|
//import java.awt.event.KeyEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.jna.*;
|
||||||
|
import com.sun.jna.platform.win32.User32;
|
||||||
|
import com.sun.jna.platform.win32.WinDef;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||||
|
import com.sun.jna.platform.win32.WinUser.*;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.*;
|
||||||
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
|
public class KeyboardHook implements Runnable {
|
||||||
|
|
||||||
|
// Keyboard event class, interface, and array list
|
||||||
|
public static class TargetKeyPress {
|
||||||
|
int idNumber;
|
||||||
|
int targetKeyCode;
|
||||||
|
boolean withShift, withCtrl, withAlt;
|
||||||
|
|
||||||
|
public TargetKeyPress(int targetKeyCode) {
|
||||||
|
this.targetKeyCode = targetKeyCode;
|
||||||
|
this.withShift = false;
|
||||||
|
this.withCtrl = false;
|
||||||
|
this.withAlt = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TargetKeyPress(int idNumber, int targetKeyCode, boolean withShift, boolean withCtrl, boolean withAlt) {
|
||||||
|
this.idNumber = idNumber;
|
||||||
|
this.targetKeyCode = targetKeyCode;
|
||||||
|
this.withShift = withShift;
|
||||||
|
this.withCtrl = withCtrl;
|
||||||
|
this.withAlt = withAlt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TargetKeyPress(int targetKeyCode, boolean withShift, boolean withCtrl, boolean withAlt) {
|
||||||
|
this.targetKeyCode = targetKeyCode;
|
||||||
|
this.withShift = withShift;
|
||||||
|
this.withCtrl = withCtrl;
|
||||||
|
this.withAlt = withAlt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<TargetKeyPress> targetList = Collections.synchronizedList(new ArrayList<TargetKeyPress>());// all
|
||||||
|
// keys
|
||||||
|
// we
|
||||||
|
// want
|
||||||
|
// to
|
||||||
|
// throw
|
||||||
|
// events
|
||||||
|
// on
|
||||||
|
|
||||||
|
public static interface KeyboardEvents {
|
||||||
|
void keyPressed(TargetKeyPress target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyboardEvents events = new KeyboardEvents() {
|
||||||
|
public void keyPressed(TargetKeyPress target) {
|
||||||
|
// System.out.println("target key pressed: " +
|
||||||
|
// target.targetKeyCode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// JNA constants and functions
|
||||||
|
public static final int WH_KEYBOARD_LL = 13;
|
||||||
|
// Modifier key vkCode constants
|
||||||
|
public static final int VK_SHIFT = 0x10;
|
||||||
|
public static final int VK_CONTROL = 0x11;
|
||||||
|
public static final int VK_MENU = 0x12;
|
||||||
|
public static final int VK_CAPITAL = 0x14;
|
||||||
|
|
||||||
|
public static final int MOD_ALT = 0x0001;
|
||||||
|
public static final int MOD_CONTROL = 0x0002;
|
||||||
|
public static final int MOD_NOREPEAT = 0x4000;
|
||||||
|
public static final int MOD_SHIFT = 0x0004;
|
||||||
|
public static final int MOD_WIN = 0x0008;
|
||||||
|
|
||||||
|
public static final int QS_HOTKEY = 0x0080;
|
||||||
|
public static final int INFINITE = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
public static HHOOK hHook = null;
|
||||||
|
public static LowLevelKeyboardProc lpfn;
|
||||||
|
public static volatile boolean quit = false;
|
||||||
|
|
||||||
|
private static Thread khThread = null;
|
||||||
|
|
||||||
|
public interface User32Ex extends W32APIOptions {
|
||||||
|
User32Ex instance = (User32Ex) Native.loadLibrary("user32", User32Ex.class, DEFAULT_OPTIONS);
|
||||||
|
|
||||||
|
LRESULT LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HMODULE hMod, int dwThreadId);
|
||||||
|
|
||||||
|
LRESULT CallNextHookEx(HHOOK idHook, int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
LRESULT CallNextHookEx(HHOOK idHook, int nCode, WPARAM wParam, Pointer lParam);
|
||||||
|
|
||||||
|
boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
|
||||||
|
|
||||||
|
boolean UnhookWindowsHookEx(HHOOK idHook);
|
||||||
|
|
||||||
|
short GetKeyState(int nVirtKey);
|
||||||
|
|
||||||
|
short GetAsyncKeyState(int nVirtKey);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DWORD WINAPI MsgWaitForMultipleObjects( __in DWORD nCount, //The
|
||||||
|
* number of object handles in the array pointed to by pHandles. __in
|
||||||
|
* const HANDLE *pHandles, //An array of object handles. __in BOOL
|
||||||
|
* bWaitAll, //If this parameter is TRUE, the function returns when the
|
||||||
|
* states of all objects in the pHandles array have been set to signaled
|
||||||
|
* and an input event has been received. __in DWORD dwMilliseconds, //if
|
||||||
|
* dwMilliseconds is INFINITE, the function will return only when the
|
||||||
|
* specified objects are signaled. __in DWORD dwWakeMask //The input
|
||||||
|
* types for which an input event object handle will be added to the
|
||||||
|
* array of object handles. );
|
||||||
|
*/
|
||||||
|
int MsgWaitForMultipleObjects(int nCount, Pointer pHandles, boolean bWaitAll, int dwMilliSeconds, int dwWakeMask);
|
||||||
|
|
||||||
|
boolean RegisterHotKey(Pointer hWnd, int id, int fsModifiers, int vk);
|
||||||
|
|
||||||
|
// public static interface HOOKPROC extends StdCallCallback {
|
||||||
|
// LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT lParam);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Kernel32 extends W32APIOptions {
|
||||||
|
Kernel32 instance = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class, DEFAULT_OPTIONS);
|
||||||
|
|
||||||
|
HMODULE GetModuleHandle(String name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create Global Windows Keyboard hook and wait until quit == true
|
||||||
|
public void createGlobalKeyboardHook() {
|
||||||
|
|
||||||
|
if (hHook != null)
|
||||||
|
return; // hook already running don't add anymore
|
||||||
|
System.out.println("starting global keyboard hook");
|
||||||
|
HMODULE hMod = Kernel32.instance.GetModuleHandle(null);
|
||||||
|
HOOKPROC lpfn = new HOOKPROC() {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT lParam) {
|
||||||
|
// System.out.println("here " + lParam.vkCode);
|
||||||
|
TargetKeyPress target = getTargetKeyPressed(lParam.vkCode); // find
|
||||||
|
// if
|
||||||
|
// this
|
||||||
|
// is
|
||||||
|
// a
|
||||||
|
// target
|
||||||
|
// key
|
||||||
|
// pressed
|
||||||
|
if (target != null)
|
||||||
|
events.keyPressed(target);
|
||||||
|
// if (lParam.vkCode == 87) //w
|
||||||
|
// quit = true;
|
||||||
|
return User32.INSTANCE.CallNextHookEx(hHook, nCode, wParam, lParam.getPointer());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
hHook = User32.INSTANCE.SetWindowsHookEx(WH_KEYBOARD_LL, lpfn, hMod, 0);
|
||||||
|
if (hHook == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// System.out.println("starting message loop");
|
||||||
|
MSG msg = new MSG();
|
||||||
|
try {
|
||||||
|
|
||||||
|
while (!quit) {
|
||||||
|
User32.INSTANCE.PeekMessage(msg, null, 0, 0, 1);
|
||||||
|
if (msg.message == User32.WM_HOTKEY) { // &&
|
||||||
|
// msg.wParam.intValue()
|
||||||
|
// == 1
|
||||||
|
// System.out.println("Hot key pressed!");
|
||||||
|
msg = new MSG(); // must clear msg so it doesn't repeat
|
||||||
|
}
|
||||||
|
Thread.sleep(10);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// System.out.println("message loop stopped");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create HotKeys Windows hook and wait until quit == true
|
||||||
|
public void createHotKeysHook() {
|
||||||
|
registerAllHotKeys();
|
||||||
|
// User32Ex.instance.MsgWaitForMultipleObjects(0, Pointer.NULL, true,
|
||||||
|
// INFINITE, QS_HOTKEY);
|
||||||
|
|
||||||
|
// System.out.println("starting message loop");
|
||||||
|
MSG msg = new MSG();
|
||||||
|
try {
|
||||||
|
|
||||||
|
while (!quit) {
|
||||||
|
User32.INSTANCE.PeekMessage(msg, null, 0, 0, 1);
|
||||||
|
if (msg.message == User32.WM_HOTKEY) { // &&
|
||||||
|
// msg.wParam.intValue()
|
||||||
|
// == 1
|
||||||
|
// System.out.println("Hot key pressed " + msg.wParam);
|
||||||
|
TargetKeyPress target = findTargetKeyPressById(msg.wParam.intValue());
|
||||||
|
if (target != null)
|
||||||
|
events.keyPressed(target);
|
||||||
|
msg = new MSG(); // must clear msg so it doesn't repeat
|
||||||
|
}
|
||||||
|
Thread.sleep(10);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
unregisterAllHotKeys();
|
||||||
|
// System.out.println("message loop stopped");
|
||||||
|
}
|
||||||
|
|
||||||
|
// unhook the Global Windows Keyboard hook
|
||||||
|
public void unhook() {
|
||||||
|
if (hHook == null)
|
||||||
|
return;
|
||||||
|
if (!User32.INSTANCE.UnhookWindowsHookEx(hHook))
|
||||||
|
System.out.println("Failed to unhook");
|
||||||
|
// System.out.println("Unhooked");
|
||||||
|
hHook = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stops Keyboard hook and causes the unhook command to be called
|
||||||
|
public static void stopKeyboardHook() {
|
||||||
|
quit = true;
|
||||||
|
if (khThread != null) {
|
||||||
|
try {
|
||||||
|
khThread.join();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// search target keyboard event list for a match and return it otherwise
|
||||||
|
// return null if no match
|
||||||
|
|
||||||
|
private TargetKeyPress getTargetKeyPressed(int keyCode) {
|
||||||
|
TargetKeyPress target = null;
|
||||||
|
for (TargetKeyPress tkp : KeyboardHook.targetList) {
|
||||||
|
if (tkp.targetKeyCode != keyCode)
|
||||||
|
continue;
|
||||||
|
if (!tkp.withShift || ((User32Ex.instance.GetKeyState(VK_SHIFT) & 0x8000) != 0)) {
|
||||||
|
if (!tkp.withCtrl || ((User32Ex.instance.GetKeyState(VK_CONTROL) & 0x8000) != 0)) {
|
||||||
|
if (!tkp.withAlt || ((User32Ex.instance.GetKeyState(VK_MENU) & 0x8000) != 0)) {
|
||||||
|
return tkp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TargetKeyPress findTargetKeyPressById(int idNumber) {
|
||||||
|
TargetKeyPress target = null;
|
||||||
|
for (TargetKeyPress tkp : KeyboardHook.targetList) {
|
||||||
|
if (tkp.idNumber == idNumber)
|
||||||
|
return tkp;
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear all target keys to watch for
|
||||||
|
public static void clearKeyEvent() {
|
||||||
|
KeyboardHook.targetList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add more target keys to watch for
|
||||||
|
public static void addKeyEvent(int targetKeyCode, boolean withShift, boolean withCtrl, boolean withAlt) {
|
||||||
|
KeyboardHook.targetList.add(new TargetKeyPress(KeyboardHook.targetList.size() + 1, targetKeyCode, withShift, withCtrl, withAlt));
|
||||||
|
}
|
||||||
|
|
||||||
|
// add more target keys to watch for
|
||||||
|
public static void addKeyEvent(int targetKeyCode) {
|
||||||
|
KeyboardHook.targetList.add(new TargetKeyPress(targetKeyCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerAllHotKeys() // must register hot keys in the same
|
||||||
|
// thread that is watching for hotkey
|
||||||
|
// messages
|
||||||
|
{
|
||||||
|
// System.out.println("registering hotkeys");
|
||||||
|
for (TargetKeyPress tkp : KeyboardHook.targetList) {
|
||||||
|
// BOOL WINAPI RegisterHotKey(HWND hWnd, int id, UINT fsModifiers,
|
||||||
|
// UINT vk);
|
||||||
|
int modifiers = User32.MOD_NOREPEAT;
|
||||||
|
if (tkp.withShift)
|
||||||
|
modifiers = modifiers | User32.MOD_SHIFT;
|
||||||
|
if (tkp.withCtrl)
|
||||||
|
modifiers = modifiers | User32.MOD_CONTROL;
|
||||||
|
if (tkp.withAlt)
|
||||||
|
modifiers = modifiers | User32.MOD_ALT;
|
||||||
|
// System.out.println("RegisterHotKey " + tkp.idNumber + "," +
|
||||||
|
// modifiers + ", " + tkp.targetKeyCode);
|
||||||
|
|
||||||
|
if (!User32.INSTANCE.RegisterHotKey(new WinDef.HWND(Pointer.NULL), tkp.idNumber, modifiers, tkp.targetKeyCode)) {
|
||||||
|
System.out.println("Couldn't register hotkey " + tkp.targetKeyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unregisterAllHotKeys() // must register hot keys in the same
|
||||||
|
// thread that is watching for hotkey
|
||||||
|
// messages
|
||||||
|
{
|
||||||
|
// System.out.println("unregistering hotkeys");
|
||||||
|
for (TargetKeyPress tkp : KeyboardHook.targetList) {
|
||||||
|
if (!User32.INSTANCE.UnregisterHotKey(Pointer.NULL, tkp.idNumber)) {
|
||||||
|
System.out.println("Couldn't unregister hotkey " + tkp.targetKeyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// createGlobalKeyboardHook();
|
||||||
|
createHotKeysHook();
|
||||||
|
// System.out.println("Unhooking Global Keyboard Hook");
|
||||||
|
unhook();// wait for quit == true then unhook
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyboardHook() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyboardHook(KeyboardEvents events) {
|
||||||
|
this.events = events;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void StartKeyboardHookThreaded(KeyboardEvents events) {
|
||||||
|
quit = false;
|
||||||
|
khThread = new Thread(new KeyboardHook(events));
|
||||||
|
khThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* // testing public static void main(String[] args) throws Exception {
|
||||||
|
* //add target keys KeyboardHook.addKeyEvent(KeyEvent.VK_3, true, true,
|
||||||
|
* false); KeyboardHook.addKeyEvent(KeyEvent.VK_5, false, true, false);
|
||||||
|
* KeyboardHook.addKeyEvent(KeyEvent.VK_Q);
|
||||||
|
*
|
||||||
|
* //add global hook and event
|
||||||
|
* KeyboardHook.StartGlobalKeyboardHookThreaded(new
|
||||||
|
* KeyboardHook.KeyboardEvents() {
|
||||||
|
*
|
||||||
|
* @Override public void keyPressed(KeyboardHook.TargetKeyPress target) {
|
||||||
|
* System.out.println("target key pressed " + target.targetKeyCode); if
|
||||||
|
* (target.targetKeyCode == KeyEvent.VK_Q){ // if Q was pressed then unhook
|
||||||
|
* KeyboardHook.stopGlobalKeyboardHook(); System.out.println("unhooking"); }
|
||||||
|
* } }); }
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
677
src/main/java/org/synthuse/RobotMacro.java
Normal file
677
src/main/java/org/synthuse/RobotMacro.java
Normal file
@@ -0,0 +1,677 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Synthuse.org
|
||||||
|
* Released under the Apache Version 2.0 License.
|
||||||
|
*
|
||||||
|
* last modified by ejakubowski
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.synthuse;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class RobotMacro {
|
||||||
|
|
||||||
|
public static Exception lastException = null;
|
||||||
|
|
||||||
|
public static boolean executeCommand(String cmd) {
|
||||||
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
try {
|
||||||
|
runtime.exec(cmd);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void delay(int time) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.delay(time);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void moveMouse(int x, int y) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mouseMove(x, y);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void leftClickMouse() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void doubleClickMouse() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||||
|
robot.delay(100);
|
||||||
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void rightClickMouse() {
|
||||||
|
try {
|
||||||
|
// System.out.println("rightClickMouse");
|
||||||
|
Robot robot = new Robot();
|
||||||
|
// robot.mouseMove(200, 200);
|
||||||
|
// robot.delay(1000);
|
||||||
|
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||||
|
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||||
|
// System.out.println("rightClickMouse good");
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void leftMouseDown() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void leftMouseUp() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void rightMouseDown() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mousePress(InputEvent.BUTTON3_MASK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void rightMouseUp() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mouseRelease(InputEvent.BUTTON3_MASK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void mouseMove(int x, int y) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.mouseMove(x, y);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyKey() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||||
|
robot.keyPress(KeyEvent.VK_C);
|
||||||
|
robot.keyRelease(KeyEvent.VK_C);
|
||||||
|
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pasteKey() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||||
|
robot.keyPress(KeyEvent.VK_V);
|
||||||
|
robot.keyRelease(KeyEvent.VK_V);
|
||||||
|
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void escapeKey() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||||
|
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void functionKey(int functionNum) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
int keyCode = 0;
|
||||||
|
switch (functionNum) {
|
||||||
|
case 1:
|
||||||
|
keyCode = KeyEvent.VK_F1;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
keyCode = KeyEvent.VK_F2;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
keyCode = KeyEvent.VK_F3;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
keyCode = KeyEvent.VK_F4;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
keyCode = KeyEvent.VK_F5;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
keyCode = KeyEvent.VK_F6;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
keyCode = KeyEvent.VK_F7;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
keyCode = KeyEvent.VK_F8;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
keyCode = KeyEvent.VK_F9;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
keyCode = KeyEvent.VK_F10;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
keyCode = KeyEvent.VK_F11;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
keyCode = KeyEvent.VK_F12;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
robot.keyPress(keyCode);
|
||||||
|
robot.keyRelease(keyCode);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void tildeKey() {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_QUOTE });
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SendKeys Special Keys List {BACKSPACE}, {BS}, or {BKSP} {BREAK}
|
||||||
|
* {CAPSLOCK} {DELETE} or {DEL} {DOWN} {END} {ENTER} or ~ {ESC} {HELP}
|
||||||
|
* {HOME} {INSERT} or {INS} {LEFT} {NUMLOCK} {PGDN} {PGUP} {PRTSC} (reserved
|
||||||
|
* for future use) {RIGHT} {SCROLLLOCK} {TAB} {UP} {F1} {F2} {F3} {F4} {F5}
|
||||||
|
* {F6} {F7} {F8} {F9} {F10} {F11} {F12} {F13} {F14} {F15} {F16} {ADD}
|
||||||
|
* {SUBTRACT} {MULTIPLY} {DIVIDE} {{} {}} SHIFT + CTRL ^ ALT %
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static boolean sendKeys(String keyCommands) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
boolean specialKeyFlag = false;
|
||||||
|
String specialKey = "";
|
||||||
|
boolean modifierKeyFlag = false;
|
||||||
|
String modifierKeys = "";
|
||||||
|
for (int i = 0; i < keyCommands.length(); i++) {
|
||||||
|
char key = keyCommands.charAt(i);
|
||||||
|
if (specialKeyFlag)
|
||||||
|
specialKey += key;
|
||||||
|
if (key == '{' && specialKeyFlag == false) {
|
||||||
|
specialKeyFlag = true;
|
||||||
|
specialKey = "{";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!specialKeyFlag) { // not special key(tab,enter,...) just
|
||||||
|
// press normal keys and modifiers
|
||||||
|
// Modifier key logic
|
||||||
|
if (key == '+' || key == '^' || key == '%') { // shift alt
|
||||||
|
// or ctrl
|
||||||
|
if (!modifierKeyFlag) {
|
||||||
|
modifierKeys = key + "";
|
||||||
|
modifierKeyFlag = true;
|
||||||
|
} else
|
||||||
|
modifierKeys += key + ""; // append multiple
|
||||||
|
// modifiers
|
||||||
|
if (key == '+')
|
||||||
|
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||||
|
if (key == '^')
|
||||||
|
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||||
|
if (key == '%')
|
||||||
|
robot.keyPress(KeyEvent.VK_ALT);
|
||||||
|
continue; // skip to next key
|
||||||
|
}
|
||||||
|
pressKeyCodes(robot, getKeyCode(key));
|
||||||
|
}
|
||||||
|
if (specialKeyFlag) {
|
||||||
|
if (specialKey.equals("{ENTER}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_ENTER });
|
||||||
|
} else if (specialKey.equals("{ESC}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_ESCAPE });
|
||||||
|
} else if (specialKey.equals("{HOME}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_HOME });
|
||||||
|
} else if (specialKey.equals("{END}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_END });
|
||||||
|
} else if (specialKey.equals("{PGDN}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_PAGE_DOWN });
|
||||||
|
} else if (specialKey.equals("{PGUP}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_PAGE_UP });
|
||||||
|
} else if (specialKey.equals("{TAB}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_TAB });
|
||||||
|
} else if (specialKey.equals("{UP}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_UP });
|
||||||
|
} else if (specialKey.equals("{DOWN}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_DOWN });
|
||||||
|
} else if (specialKey.equals("{LEFT}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_LEFT });
|
||||||
|
} else if (specialKey.equals("{RIGHT}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_RIGHT });
|
||||||
|
} else if (specialKey.equals("{PRTSC}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_PRINTSCREEN });
|
||||||
|
} else if (specialKey.equals("{DELETE}") || specialKey.equals("{DEL}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_DELETE });
|
||||||
|
} else if (specialKey.equals("{BACKSPACE}") || specialKey.equals("{BS}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_BACK_SPACE });
|
||||||
|
} else if (specialKey.equals("{F1}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F1 });
|
||||||
|
} else if (specialKey.equals("{F2}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F2 });
|
||||||
|
} else if (specialKey.equals("{F3}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F3 });
|
||||||
|
} else if (specialKey.equals("{F4}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F4 });
|
||||||
|
} else if (specialKey.equals("{F5}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F5 });
|
||||||
|
} else if (specialKey.equals("{F6}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F6 });
|
||||||
|
} else if (specialKey.equals("{F7}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F7 });
|
||||||
|
} else if (specialKey.equals("{F8}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F8 });
|
||||||
|
} else if (specialKey.equals("{F9}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F9 });
|
||||||
|
} else if (specialKey.equals("{F10}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F10 });
|
||||||
|
} else if (specialKey.equals("{F11}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F11 });
|
||||||
|
} else if (specialKey.equals("{F12}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F12 });
|
||||||
|
} else if (specialKey.equals("{F13}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F13 });
|
||||||
|
} else if (specialKey.equals("{F14}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F14 });
|
||||||
|
} else if (specialKey.equals("{F15}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F15 });
|
||||||
|
} else if (specialKey.equals("{F16}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_F16 });
|
||||||
|
} else if (specialKey.equals("{PRTSC}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_PRINTSCREEN });
|
||||||
|
} else if (specialKey.equals("{ADD}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_ADD });
|
||||||
|
} else if (specialKey.equals("{SUBTRACT}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_SUBTRACT });
|
||||||
|
} else if (specialKey.equals("{MULTIPLY}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_MULTIPLY });
|
||||||
|
} else if (specialKey.equals("{DIVIDE}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_DIVIDE });
|
||||||
|
} else if (specialKey.equals("{PERCENT}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_5 });
|
||||||
|
} else if (specialKey.equals("{CARROT}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_6 });
|
||||||
|
} else if (specialKey.equals("{INSERT}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_INSERT });
|
||||||
|
} else if (specialKey.equals("{BREAK}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_CANCEL });
|
||||||
|
} else if (specialKey.equals("{BAR}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SLASH });
|
||||||
|
} else if (specialKey.equals("{{}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_OPEN_BRACKET });
|
||||||
|
} else if (specialKey.equals("{}}")) {
|
||||||
|
specialKeyFlag = false;
|
||||||
|
pressKeyCodes(robot, new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_CLOSE_BRACKET });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modifierKeyFlag) { // time to release all the modifier keys
|
||||||
|
modifierKeyFlag = false;
|
||||||
|
for (int m = 0; m < modifierKeys.length(); m++) {
|
||||||
|
char mkey = modifierKeys.charAt(m);
|
||||||
|
if (mkey == '+')
|
||||||
|
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||||
|
if (mkey == '^')
|
||||||
|
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||||
|
if (mkey == '%')
|
||||||
|
robot.keyRelease(KeyEvent.VK_ALT);
|
||||||
|
}
|
||||||
|
modifierKeys = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean pressKey(char key) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
int[] keyCode = getKeyCode(key);
|
||||||
|
pressKeyCodes(robot, keyCode);
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean keyDown(char key) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
int[] keyCodes = getKeyCode(key);
|
||||||
|
for (int i = 0; i < keyCodes.length; i++) {
|
||||||
|
robot.keyPress(keyCodes[i]);
|
||||||
|
// System.out.println("pressed: " + keyCodes[i]);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean keyUp(char key) {
|
||||||
|
try {
|
||||||
|
Robot robot = new Robot();
|
||||||
|
int[] keyCodes = getKeyCode(key);
|
||||||
|
for (int i = keyCodes.length - 1; i >= 0; i--) {
|
||||||
|
robot.keyRelease(keyCodes[i]);
|
||||||
|
// System.out.println("released: " + keyCodes[i]);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
lastException = e;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pressKeyCodes(Robot robot, int[] keyCodes) {
|
||||||
|
for (int i = 0; i < keyCodes.length; i++) {
|
||||||
|
robot.keyPress(keyCodes[i]);
|
||||||
|
// System.out.println("pressed: " + keyCodes[i]);
|
||||||
|
}
|
||||||
|
// robot.delay(50);
|
||||||
|
for (int i = keyCodes.length - 1; i >= 0; i--) {
|
||||||
|
robot.keyRelease(keyCodes[i]);
|
||||||
|
// System.out.println("released: " + keyCodes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] getKeyCode(char key) {
|
||||||
|
switch (key) {
|
||||||
|
case 'a':
|
||||||
|
return (new int[] { KeyEvent.VK_A });
|
||||||
|
case 'b':
|
||||||
|
return (new int[] { KeyEvent.VK_B });
|
||||||
|
case 'c':
|
||||||
|
return (new int[] { KeyEvent.VK_C });
|
||||||
|
case 'd':
|
||||||
|
return (new int[] { KeyEvent.VK_D });
|
||||||
|
case 'e':
|
||||||
|
return (new int[] { KeyEvent.VK_E });
|
||||||
|
case 'f':
|
||||||
|
return (new int[] { KeyEvent.VK_F });
|
||||||
|
case 'g':
|
||||||
|
return (new int[] { KeyEvent.VK_G });
|
||||||
|
case 'h':
|
||||||
|
return (new int[] { KeyEvent.VK_H });
|
||||||
|
case 'i':
|
||||||
|
return (new int[] { KeyEvent.VK_I });
|
||||||
|
case 'j':
|
||||||
|
return (new int[] { KeyEvent.VK_J });
|
||||||
|
case 'k':
|
||||||
|
return (new int[] { KeyEvent.VK_K });
|
||||||
|
case 'l':
|
||||||
|
return (new int[] { KeyEvent.VK_L });
|
||||||
|
case 'm':
|
||||||
|
return (new int[] { KeyEvent.VK_M });
|
||||||
|
case 'n':
|
||||||
|
return (new int[] { KeyEvent.VK_N });
|
||||||
|
case 'o':
|
||||||
|
return (new int[] { KeyEvent.VK_O });
|
||||||
|
case 'p':
|
||||||
|
return (new int[] { KeyEvent.VK_P });
|
||||||
|
case 'q':
|
||||||
|
return (new int[] { KeyEvent.VK_Q });
|
||||||
|
case 'r':
|
||||||
|
return (new int[] { KeyEvent.VK_R });
|
||||||
|
case 's':
|
||||||
|
return (new int[] { KeyEvent.VK_S });
|
||||||
|
case 't':
|
||||||
|
return (new int[] { KeyEvent.VK_T });
|
||||||
|
case 'u':
|
||||||
|
return (new int[] { KeyEvent.VK_U });
|
||||||
|
case 'v':
|
||||||
|
return (new int[] { KeyEvent.VK_V });
|
||||||
|
case 'w':
|
||||||
|
return (new int[] { KeyEvent.VK_W });
|
||||||
|
case 'x':
|
||||||
|
return (new int[] { KeyEvent.VK_X });
|
||||||
|
case 'y':
|
||||||
|
return (new int[] { KeyEvent.VK_Y });
|
||||||
|
case 'z':
|
||||||
|
return (new int[] { KeyEvent.VK_Z });
|
||||||
|
case 'A':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_A });
|
||||||
|
case 'B':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_B });
|
||||||
|
case 'C':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_C });
|
||||||
|
case 'D':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_D });
|
||||||
|
case 'E':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_E });
|
||||||
|
case 'F':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_F });
|
||||||
|
case 'G':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_G });
|
||||||
|
case 'H':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_H });
|
||||||
|
case 'I':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_I });
|
||||||
|
case 'J':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_J });
|
||||||
|
case 'K':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_K });
|
||||||
|
case 'L':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_L });
|
||||||
|
case 'M':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_M });
|
||||||
|
case 'N':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_N });
|
||||||
|
case 'O':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_O });
|
||||||
|
case 'P':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_P });
|
||||||
|
case 'Q':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_Q });
|
||||||
|
case 'R':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_R });
|
||||||
|
case 'S':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_S });
|
||||||
|
case 'T':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_T });
|
||||||
|
case 'U':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_U });
|
||||||
|
case 'V':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_V });
|
||||||
|
case 'W':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_W });
|
||||||
|
case 'X':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_X });
|
||||||
|
case 'Y':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_Y });
|
||||||
|
case 'Z':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_Z });
|
||||||
|
case '`':
|
||||||
|
return (new int[] { KeyEvent.VK_BACK_QUOTE });
|
||||||
|
case '0':
|
||||||
|
return (new int[] { KeyEvent.VK_0 });
|
||||||
|
case '1':
|
||||||
|
return (new int[] { KeyEvent.VK_1 });
|
||||||
|
case '2':
|
||||||
|
return (new int[] { KeyEvent.VK_2 });
|
||||||
|
case '3':
|
||||||
|
return (new int[] { KeyEvent.VK_3 });
|
||||||
|
case '4':
|
||||||
|
return (new int[] { KeyEvent.VK_4 });
|
||||||
|
case '5':
|
||||||
|
return (new int[] { KeyEvent.VK_5 });
|
||||||
|
case '6':
|
||||||
|
return (new int[] { KeyEvent.VK_6 });
|
||||||
|
case '7':
|
||||||
|
return (new int[] { KeyEvent.VK_7 });
|
||||||
|
case '8':
|
||||||
|
return (new int[] { KeyEvent.VK_8 });
|
||||||
|
case '9':
|
||||||
|
return (new int[] { KeyEvent.VK_9 });
|
||||||
|
case '-':
|
||||||
|
return (new int[] { KeyEvent.VK_MINUS });
|
||||||
|
case '=':
|
||||||
|
return (new int[] { KeyEvent.VK_EQUALS });
|
||||||
|
case '~':
|
||||||
|
return (new int[] { KeyEvent.VK_ENTER });// return(new
|
||||||
|
// int[]{KeyEvent.VK_SHIFT,
|
||||||
|
// KeyEvent.VK_BACK_QUOTE});
|
||||||
|
case '!':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_1 });
|
||||||
|
case '@':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_2 });
|
||||||
|
case '#':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_3 });
|
||||||
|
case '$':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_4 });
|
||||||
|
case '%':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_5 });
|
||||||
|
case '^':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_6 });
|
||||||
|
case '&':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_7 });
|
||||||
|
case '*':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_8 });
|
||||||
|
case '(':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_9 });
|
||||||
|
case ')':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_0 });
|
||||||
|
case '_':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_MINUS });
|
||||||
|
case '+':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_EQUALS });
|
||||||
|
case '\t':
|
||||||
|
return (new int[] { KeyEvent.VK_TAB });
|
||||||
|
case '\n':
|
||||||
|
return (new int[] { KeyEvent.VK_ENTER });
|
||||||
|
case '[':
|
||||||
|
return (new int[] { KeyEvent.VK_OPEN_BRACKET });
|
||||||
|
case ']':
|
||||||
|
return (new int[] { KeyEvent.VK_CLOSE_BRACKET });
|
||||||
|
case '\\':
|
||||||
|
return (new int[] { KeyEvent.VK_BACK_SLASH });
|
||||||
|
case '{':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_OPEN_BRACKET });
|
||||||
|
case '}':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_CLOSE_BRACKET });
|
||||||
|
case '|':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SLASH });
|
||||||
|
case ';':
|
||||||
|
return (new int[] { KeyEvent.VK_SEMICOLON });
|
||||||
|
case ':':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_SEMICOLON });
|
||||||
|
case '\'':
|
||||||
|
return (new int[] { KeyEvent.VK_QUOTE });
|
||||||
|
case '"':
|
||||||
|
return (new int[] { KeyEvent.VK_QUOTEDBL });
|
||||||
|
case ',':
|
||||||
|
return (new int[] { KeyEvent.VK_COMMA });
|
||||||
|
case '<':
|
||||||
|
return (new int[] { KeyEvent.VK_LESS });
|
||||||
|
case '.':
|
||||||
|
return (new int[] { KeyEvent.VK_PERIOD });
|
||||||
|
case '>':
|
||||||
|
return (new int[] { KeyEvent.VK_GREATER });
|
||||||
|
case '/':
|
||||||
|
return (new int[] { KeyEvent.VK_SLASH });
|
||||||
|
case '?':
|
||||||
|
return (new int[] { KeyEvent.VK_SHIFT, KeyEvent.VK_SLASH }); // needs
|
||||||
|
// Shift
|
||||||
|
case ' ':
|
||||||
|
return (new int[] { KeyEvent.VK_SPACE });
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Cannot find Key Code for character " + key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/main/java/org/synthuse/interfaces/Gdi32Ex.java
Normal file
19
src/main/java/org/synthuse/interfaces/Gdi32Ex.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package org.synthuse.interfaces;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HPEN;
|
||||||
|
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||||
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
|
public interface Gdi32Ex extends W32APIOptions {
|
||||||
|
Gdi32Ex instance = (Gdi32Ex) Native.loadLibrary("gdi32", Gdi32Ex.class, DEFAULT_OPTIONS);
|
||||||
|
|
||||||
|
HANDLE SelectObject(HDC hdc, HANDLE hgdiobj);
|
||||||
|
|
||||||
|
HANDLE GetStockObject(int fnObject);
|
||||||
|
|
||||||
|
boolean Rectangle(HDC hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
|
||||||
|
|
||||||
|
HPEN CreatePen(int fnPenStyle, int nWidth, int crColor);
|
||||||
|
}
|
||||||
54
src/main/java/org/synthuse/interfaces/Kernel32Ex.java
Normal file
54
src/main/java/org/synthuse/interfaces/Kernel32Ex.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package org.synthuse.interfaces;
|
||||||
|
|
||||||
|
import org.synthuse.objects.LVITEM_VISTA;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.platform.win32.BaseTSD.SIZE_T;
|
||||||
|
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||||
|
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||||
|
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||||
|
import com.sun.jna.ptr.IntByReference;
|
||||||
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
|
public interface Kernel32Ex extends W32APIOptions {
|
||||||
|
Kernel32Ex instance = (Kernel32Ex) Native.loadLibrary("kernel32", Kernel32Ex.class, DEFAULT_OPTIONS);
|
||||||
|
|
||||||
|
boolean GetDiskFreeSpaceEx(String lpDirectoryName, LARGE_INTEGER.ByReference lpFreeBytesAvailable, LARGE_INTEGER.ByReference lpTotalNumberOfBytes, LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes);
|
||||||
|
|
||||||
|
int GetLastError();
|
||||||
|
|
||||||
|
Pointer OpenProcess(int dwDesiredAccess, boolean bInheritHandle, Pointer pointer);
|
||||||
|
|
||||||
|
// int OpenProcess(int dwDesiredAccess, boolean bInheritHandle, Pointer
|
||||||
|
// pointer);
|
||||||
|
boolean CloseHandle(HANDLE hObject);
|
||||||
|
|
||||||
|
void GetNativeSystemInfo(SYSTEM_INFO lpSystemInfo);
|
||||||
|
|
||||||
|
boolean IsWow64Process(HANDLE hProcess, IntByReference Wow64Process);
|
||||||
|
|
||||||
|
// LPVOID VirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T
|
||||||
|
// dwSize, DWORD flAllocationType, DWORD flProtect);
|
||||||
|
|
||||||
|
// int VirtualAllocEx(HANDLE hProcess, int lpAddress, int dwSize, DWORD
|
||||||
|
// flAllocationType, DWORD flProtect);
|
||||||
|
IntByReference VirtualAllocEx(HANDLE hProc, IntByReference addr, SIZE_T size, int allocType, int prot);
|
||||||
|
|
||||||
|
Pointer VirtualAllocEx(HANDLE hProc, int i, int lngMemLen2, int allocType, int pAGE_READWRITE);
|
||||||
|
|
||||||
|
boolean VirtualFreeEx(HANDLE hProcess, IntByReference lpAddress, SIZE_T dwSize, DWORD dwFreeType);
|
||||||
|
|
||||||
|
boolean WriteProcessMemory(HANDLE hProcess, IntByReference lpBaseAddress, Pointer lpBuffer, int len, IntByReference bytesWritten);
|
||||||
|
|
||||||
|
// boolean WriteProcessMemory(Pointer p, long address, Pointer buffer,
|
||||||
|
// int size, IntByReference written);
|
||||||
|
boolean ReadProcessMemory(Pointer hProcess, long inBaseAddress, Pointer outputBuffer, int nSize, IntByReference outNumberOfBytesRead);
|
||||||
|
|
||||||
|
int WriteProcessMemory(HANDLE handle, Pointer lngMemVar2, LVITEM_VISTA lvi, int lngMemLen2, IntByReference byteIO);
|
||||||
|
|
||||||
|
int ReadProcessMemory(HANDLE handle, Pointer lngMemVar1, Pointer lngVarPtr1, int lngMemLen1, IntByReference byteIO);
|
||||||
|
|
||||||
|
int VirtualFreeEx(HANDLE hProcess, Pointer lngMemVar1, int i, int mEM_RELEASE);
|
||||||
|
}
|
||||||
11
src/main/java/org/synthuse/interfaces/PsapiEx.java
Normal file
11
src/main/java/org/synthuse/interfaces/PsapiEx.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package org.synthuse.interfaces;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
|
public interface PsapiEx extends W32APIOptions {
|
||||||
|
PsapiEx instance = (PsapiEx) Native.loadLibrary("psapi", PsapiEx.class, DEFAULT_OPTIONS);
|
||||||
|
|
||||||
|
int GetModuleBaseNameW(Pointer hProcess, Pointer hmodule, char[] lpBaseName, int size);
|
||||||
|
}
|
||||||
138
src/main/java/org/synthuse/interfaces/User32Ex.java
Normal file
138
src/main/java/org/synthuse/interfaces/User32Ex.java
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
package org.synthuse.interfaces;
|
||||||
|
|
||||||
|
import org.synthuse.objects.LVITEM_VISTA;
|
||||||
|
|
||||||
|
import com.sun.jna.Callback;
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.platform.win32.BaseTSD.LONG_PTR;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HMENU;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.LRESULT;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.RECT;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.WPARAM;
|
||||||
|
import com.sun.jna.platform.win32.WinUser.WNDENUMPROC;
|
||||||
|
import com.sun.jna.ptr.PointerByReference;
|
||||||
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
|
public interface User32Ex extends W32APIOptions {
|
||||||
|
User32Ex instance = (User32Ex) Native.loadLibrary("user32", User32Ex.class, DEFAULT_OPTIONS);
|
||||||
|
|
||||||
|
int SetWindowLongPtr(HWND hWnd, int nIndex, Callback callback);
|
||||||
|
|
||||||
|
LRESULT CallWindowProc(LONG_PTR proc, HWND hWnd, int uMsg, WPARAM uParam, LPARAM lParam);
|
||||||
|
|
||||||
|
boolean ShowWindow(HWND hWnd, int nCmdShow);
|
||||||
|
|
||||||
|
boolean SetForegroundWindow(HWND hWnd);
|
||||||
|
|
||||||
|
void SwitchToThisWindow(HWND hWnd, boolean fAltTab);
|
||||||
|
|
||||||
|
HWND SetFocus(HWND hWnd);
|
||||||
|
|
||||||
|
HWND FindWindow(String winClass, String title);
|
||||||
|
|
||||||
|
LRESULT PostMessage(HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
LRESULT SendMessage(HWND hWnd, int Msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
LRESULT SendMessage(HWND hWnd, int Msg, WPARAM wParam, LVITEM_VISTA lParam);
|
||||||
|
|
||||||
|
LRESULT SendMessageA(HWND editHwnd, int wmGettext, long l, byte[] lParamStr);
|
||||||
|
|
||||||
|
boolean DestroyWindow(HWND hWnd);
|
||||||
|
|
||||||
|
boolean EnumWindows(WNDENUMPROC wndenumproc, int lParam);
|
||||||
|
|
||||||
|
boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data);
|
||||||
|
|
||||||
|
HWND GetParent(HWND hWnd);
|
||||||
|
|
||||||
|
boolean IsWindowVisible(HWND hWnd);
|
||||||
|
|
||||||
|
boolean IsWindow(HWND hWnd);
|
||||||
|
|
||||||
|
int GetWindowRect(HWND hWnd, RECT r);
|
||||||
|
|
||||||
|
int MapWindowPoints(HWND hWndFrom, HWND hWndTo, RECT r, int cPoints);
|
||||||
|
|
||||||
|
HWND GetDesktopWindow();
|
||||||
|
|
||||||
|
HDC GetWindowDC(HWND hWnd);
|
||||||
|
|
||||||
|
int ReleaseDC(HWND hWnd, HDC hDC);
|
||||||
|
|
||||||
|
boolean InvalidateRect(HWND hWnd, long lpRect, boolean bErase);
|
||||||
|
|
||||||
|
boolean UpdateWindow(HWND hWnd);
|
||||||
|
|
||||||
|
boolean RedrawWindow(HWND hWnd, long lprcUpdate, long hrgnUpdate, int flags);
|
||||||
|
|
||||||
|
void GetWindowTextA(HWND hWnd, byte[] buffer, int buflen);
|
||||||
|
|
||||||
|
int GetTopWindow(HWND hWnd);
|
||||||
|
|
||||||
|
int GetWindow(HWND hWnd, int flag);
|
||||||
|
|
||||||
|
final int GW_HWNDNEXT = 2;
|
||||||
|
|
||||||
|
int GetClassName(HWND hWnd, char[] buffer2, int i);
|
||||||
|
|
||||||
|
int GetWindowModuleFileName(HWND hWnd, char[] buffer2, int i);
|
||||||
|
|
||||||
|
int GetWindowThreadProcessId(HWND hWnd, PointerByReference pref);
|
||||||
|
|
||||||
|
// int GetWindowThreadProcessId(HWND hWnd, IntByReference
|
||||||
|
// lpdwProcessId);
|
||||||
|
|
||||||
|
boolean GetCursorPos(long[] lpPoint); // use macros POINT_X() and
|
||||||
|
// POINT_Y() on long lpPoint[0]
|
||||||
|
|
||||||
|
HWND WindowFromPoint(long point);
|
||||||
|
|
||||||
|
HWND ChildWindowFromPointEx(HWND hwndParent, long point, int uFlags);
|
||||||
|
|
||||||
|
boolean ClientToScreen(HWND hWnd, long[] lpPoint);// use macros
|
||||||
|
// POINT_X() and
|
||||||
|
// POINT_Y() on long
|
||||||
|
// lpPoint[0]
|
||||||
|
|
||||||
|
boolean ScreenToClient(HWND hWnd, long[] lpPoint);// use macros
|
||||||
|
// POINT_X() and
|
||||||
|
// POINT_Y() on long
|
||||||
|
// lpPoint[0]
|
||||||
|
// HWND WindowFromPoint(int xPoint, int yPoint);
|
||||||
|
// HWND WindowFromPoint(POINT point);
|
||||||
|
|
||||||
|
HMENU GetMenu(HWND hWnd);
|
||||||
|
|
||||||
|
HMENU GetSystemMenu(HWND hWnd, boolean bRevert);
|
||||||
|
|
||||||
|
boolean IsMenu(HMENU hMenu);
|
||||||
|
|
||||||
|
int GetMenuString(HMENU hMenu, int uIDItem, char[] buffer, int nMaxCount, int uFlag);
|
||||||
|
|
||||||
|
HMENU GetSubMenu(HMENU hMenu, int nPos);
|
||||||
|
|
||||||
|
int GetMenuItemCount(HMENU hMenu);
|
||||||
|
|
||||||
|
int GetMenuItemID(HMENU hMenu, int nPos);
|
||||||
|
|
||||||
|
// BOOL WINAPI GetMenuItemInfo(_In_ HMENU hMenu, _In_ UINT uItem, _In_
|
||||||
|
// BOOL fByPosition, _Inout_ LPMENUITEMINFO lpmii);
|
||||||
|
boolean GetMenuItemInfoA(HMENU hMenu, int uItem, boolean fByPosition, WinDefEx.MENUITEMINFO mii); // MENUITEMINFO
|
||||||
|
|
||||||
|
boolean TrackPopupMenu(HMENU hMenu, int uFlags, int x, int y, int nReserved, HWND hWnd, long prcRect);
|
||||||
|
|
||||||
|
boolean GetMenuItemRect(HWND hWnd, HMENU hMenu, int uItem, RECT rect);
|
||||||
|
|
||||||
|
int GetDlgCtrlID(HWND hwndCtl);
|
||||||
|
|
||||||
|
int GetDlgItemText(HWND hDlg, int nIDDlgItem, byte[] buffer, int nMaxCount);
|
||||||
|
|
||||||
|
int GetMenuState(HMENU hMenuTopMenu, int uId, int uFlags);
|
||||||
|
|
||||||
|
HWND GetDlgItem(HWND hDlg, int nIDDlgItem);
|
||||||
|
}
|
||||||
11
src/main/java/org/synthuse/interfaces/WNDPROC.java
Normal file
11
src/main/java/org/synthuse/interfaces/WNDPROC.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package org.synthuse.interfaces;
|
||||||
|
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.LRESULT;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.WPARAM;
|
||||||
|
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
|
||||||
|
|
||||||
|
interface WNDPROC extends StdCallCallback {
|
||||||
|
LRESULT callback(HWND hWnd, int uMsg, WPARAM uParam, LPARAM lParam);
|
||||||
|
}
|
||||||
80
src/main/java/org/synthuse/interfaces/WinDefEx.java
Normal file
80
src/main/java/org/synthuse/interfaces/WinDefEx.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package org.synthuse.interfaces;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.Structure;
|
||||||
|
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR;
|
||||||
|
|
||||||
|
public interface WinDefEx extends com.sun.jna.platform.win32.WinDef {
|
||||||
|
// Structures
|
||||||
|
public class MENUITEMINFO extends Structure {
|
||||||
|
public static final int MFS_CHECKED = 0x00000008;
|
||||||
|
public static final int MFS_DEFAULT = 0x00001000;
|
||||||
|
public static final int MFS_DISABLED = 0x00000003;
|
||||||
|
public static final int MFS_ENABLED = 0x00000000;
|
||||||
|
public static final int MFS_GRAYED = 0x00000003;
|
||||||
|
public static final int MFS_HILITE = 0x00000080;
|
||||||
|
public static final int MFS_UNCHECKED = 0x00000000;
|
||||||
|
public static final int MFS_UNHILITE = 0x00000000;
|
||||||
|
public static final int MFT_STRING = 0x0000;
|
||||||
|
public static final int MIIM_DATA = 0x00000020;
|
||||||
|
public static final int MIIM_STRING = 0x0040;
|
||||||
|
public static final int MIIM_SUBMENU = 0x0004;
|
||||||
|
public static final int MIIM_TYPE = 0x0010;
|
||||||
|
|
||||||
|
public static class ByValue extends MENUITEMINFO implements Structure.ByValue {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ByReference extends MENUITEMINFO implements Structure.ByReference {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MENUITEMINFO() {
|
||||||
|
cbSize = size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MENUITEMINFO(Pointer p) {
|
||||||
|
super(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<?> getFieldOrder() {
|
||||||
|
return Arrays.asList(new String[] { "cbSize", "fMask", "fType", "fState", "wID", "hSubMenu", "hbmpChecked", "hbmpUnchecked", "dwItemData", "dwTypeData", "cch", "hbmpItem" });
|
||||||
|
}
|
||||||
|
|
||||||
|
public int cbSize; // The size of the structure, in bytes. The
|
||||||
|
// caller must set this member to
|
||||||
|
// sizeof(MENUITEMINFO).
|
||||||
|
public int fMask; // Indicates the members to be retrieved or set.
|
||||||
|
// MIIM_STRING or MIIM_SUBMENU or ...
|
||||||
|
public int fType; // The menu item type. fType is used only if fMask
|
||||||
|
// has a value of MIIM_FTYPE.
|
||||||
|
public int fState; // The menu item state. This member can be one or
|
||||||
|
// more of these values. Set fMask to MIIM_STATE
|
||||||
|
// to use fState.
|
||||||
|
public int wID; // An application-defined value that identifies the
|
||||||
|
// menu item. Set fMask to MIIM_ID to use wID.
|
||||||
|
public HMENU hSubMenu; // A handle to the drop-down menu or submenu
|
||||||
|
// associated with the menu item. Or NULL
|
||||||
|
public HBITMAP hbmpChecked; // A handle to the bitmap to display
|
||||||
|
// next to the item if it is selected.
|
||||||
|
public HBITMAP hbmpUnchecked; // A handle to the bitmap to display
|
||||||
|
// next to the item if it is not
|
||||||
|
// selected.
|
||||||
|
public ULONG_PTR dwItemData; // An application-defined value
|
||||||
|
// associated with the menu item. Set
|
||||||
|
// fMask to MIIM_DATA
|
||||||
|
// public byte[] dwTypeData = new byte[256];
|
||||||
|
public String dwTypeData; // The contents of the menu item, depends
|
||||||
|
// on the value of fType and is used only
|
||||||
|
// if the MIIM_TYPE flag is set in the
|
||||||
|
// fMask member
|
||||||
|
public int cch; // The length of the menu item text, in characters,
|
||||||
|
// when information is received about a menu item of
|
||||||
|
// the MFT_STRING type.
|
||||||
|
public HBITMAP hbmpItem; // A handle to the bitmap to be displayed,
|
||||||
|
// or it can be one of the values in the
|
||||||
|
// following table.
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/main/java/org/synthuse/objects/COPYDATASTRUCT.java
Normal file
42
src/main/java/org/synthuse/objects/COPYDATASTRUCT.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package org.synthuse.objects;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.Structure;
|
||||||
|
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR;
|
||||||
|
|
||||||
|
public class COPYDATASTRUCT extends Structure {
|
||||||
|
// The by-reference version of this structure.
|
||||||
|
public static class ByReference extends COPYDATASTRUCT implements Structure.ByReference {
|
||||||
|
}
|
||||||
|
|
||||||
|
public COPYDATASTRUCT() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instantiates a new COPYDATASTRUCT with existing data given the
|
||||||
|
// address of that data.
|
||||||
|
public COPYDATASTRUCT(final long pointer) {
|
||||||
|
this(new Pointer(pointer));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instantiates a new COPYDATASTRUCT with existing data given a
|
||||||
|
// pointer to that data.
|
||||||
|
public COPYDATASTRUCT(final Pointer memory) {
|
||||||
|
super(memory);
|
||||||
|
read();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ULONG_PTR dwData; // The data to be passed to the receiving
|
||||||
|
// application.
|
||||||
|
public int cbData; // The size, in bytes, of the data pointed to by
|
||||||
|
// the lpData
|
||||||
|
public Pointer lpData;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
@Override
|
||||||
|
protected final List getFieldOrder() {
|
||||||
|
return Arrays.asList(new String[] { "dwData", "cbData", "lpData" });
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/main/java/org/synthuse/objects/LVITEM_VISTA.java
Normal file
34
src/main/java/org/synthuse/objects/LVITEM_VISTA.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package org.synthuse.objects;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.Structure;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||||
|
|
||||||
|
// 64bit LVITEM size 88
|
||||||
|
// 32bit LVITEM size 60
|
||||||
|
public class LVITEM_VISTA extends Structure {
|
||||||
|
public int mask;
|
||||||
|
public int iItem;
|
||||||
|
public int iSubItem;
|
||||||
|
public int state;
|
||||||
|
public int stateMask;
|
||||||
|
public Pointer pszText;
|
||||||
|
public int cchTextMax;
|
||||||
|
public int iImage;
|
||||||
|
public LPARAM lParam;
|
||||||
|
public int iIndent;
|
||||||
|
public int iGoupId;
|
||||||
|
public int cColumns;
|
||||||
|
public Pointer puColumns;
|
||||||
|
// NTDDI_VERSION >= NTDDI_VISTA
|
||||||
|
public Pointer piColFmt;
|
||||||
|
public int iGroup;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<?> getFieldOrder() {
|
||||||
|
return Arrays.asList(new String[] { "mask", "iItem", "iSubItem", "state", "stateMask", "pszText", "cchTextMax", "iImage", "lParam", "iIndent", "iGoupId", "cColumns", "puColumns", "piColFmt", "iGroup" });
|
||||||
|
}
|
||||||
|
}
|
||||||
104
src/main/java/org/synthuse/objects/MenuInfo.java
Normal file
104
src/main/java/org/synthuse/objects/MenuInfo.java
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Synthuse.org
|
||||||
|
* Released under the Apache Version 2.0 License.
|
||||||
|
*
|
||||||
|
* last modified by ejakubowski7@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.synthuse.objects;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import org.synthuse.Api;
|
||||||
|
|
||||||
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.*;
|
||||||
|
|
||||||
|
public class MenuInfo {
|
||||||
|
public HMENU hmenu = null;
|
||||||
|
public String hmenuStr = "";
|
||||||
|
public String hwndStr = "";
|
||||||
|
public int menuCount = 0;
|
||||||
|
public String text = "";
|
||||||
|
public String unaltered = "";
|
||||||
|
public int id = 0;
|
||||||
|
public int position = 0;
|
||||||
|
public boolean hasSubMenu = false;
|
||||||
|
public HMENU submenu = null;
|
||||||
|
public String submenuStr = "";
|
||||||
|
public int submenuCount = 0;
|
||||||
|
public String center = "";
|
||||||
|
|
||||||
|
public MenuInfo(String hwndStr, HMENU hmenu) {
|
||||||
|
this.hwndStr = hwndStr;
|
||||||
|
loadMenuBase(hmenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuInfo(String hwndStr, HMENU hmenu, int position) {
|
||||||
|
this.hwndStr = hwndStr;
|
||||||
|
loadMenuBase(hmenu);
|
||||||
|
if (this.menuCount > 0)
|
||||||
|
loadMenuDetails(hmenu, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadMenuBase(HMENU hmenu) {
|
||||||
|
Api api = new Api();
|
||||||
|
this.hmenu = hmenu;
|
||||||
|
this.hmenuStr = GetHandleMenuAsString(hmenu);
|
||||||
|
this.menuCount = api.user32.GetMenuItemCount(hmenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadMenuDetails(HMENU hmenu, int position) {
|
||||||
|
Api api = new Api();
|
||||||
|
this.position = position;
|
||||||
|
this.unaltered = api.GetMenuItemText(hmenu, position);
|
||||||
|
this.text = unaltered;
|
||||||
|
if (this.unaltered.contains("\t"))
|
||||||
|
this.text = this.text.substring(0, this.text.indexOf("\t"));
|
||||||
|
this.text = text.replaceAll("[^a-zA-Z0-9.,\\+ ]", "");
|
||||||
|
this.id = api.user32.GetMenuItemID(hmenu, position);
|
||||||
|
/*
|
||||||
|
* HWND hWnd = Api.GetHandleFromString(hwndStr); RECT rect = new RECT();
|
||||||
|
* api.user32.GetMenuItemRect(hWnd, hmenu, position, rect); int centerX
|
||||||
|
* = ((rect.right - rect.left) / 2) + rect.left; int centerY =
|
||||||
|
* ((rect.bottom - rect.top) / 2) + rect.top; this.center = centerX +
|
||||||
|
* "," + centerY;
|
||||||
|
*/
|
||||||
|
HMENU submenu = api.user32.GetSubMenu(hmenu, position);
|
||||||
|
if (submenu != null) {
|
||||||
|
int subCount = api.user32.GetMenuItemCount(submenu);
|
||||||
|
if (subCount > 0) {
|
||||||
|
this.hasSubMenu = true;
|
||||||
|
this.submenu = submenu;
|
||||||
|
this.submenuStr = GetHandleMenuAsString(submenu);
|
||||||
|
this.submenuCount = subCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetHandleMenuAsString(HMENU hmenu) {
|
||||||
|
if (hmenu == null)
|
||||||
|
return "0";
|
||||||
|
// String longHexStr = hWnd.toString().substring("native@".length());
|
||||||
|
// String longHexStr = hmenu.getPointer()
|
||||||
|
String longHexStr = hmenu.getPointer().toString().substring("native@0x".length());
|
||||||
|
long l = new BigInteger(longHexStr, 16).longValue();
|
||||||
|
return l + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HMENU GetHandleMenuFromString(String hmenu) {
|
||||||
|
if (hmenu == null)
|
||||||
|
return null;
|
||||||
|
if (hmenu.isEmpty())
|
||||||
|
return null;
|
||||||
|
String cleanNumericHandle = hmenu.replaceAll("[^\\d.]", "");
|
||||||
|
try {
|
||||||
|
return (new HMENU(new Pointer(Long.parseLong(cleanNumericHandle))));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/java/org/synthuse/objects/MenuItem.java
Normal file
24
src/main/java/org/synthuse/objects/MenuItem.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package org.synthuse.objects;
|
||||||
|
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HMENU;
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||||
|
|
||||||
|
public class MenuItem {
|
||||||
|
public static final boolean EXACT = false;
|
||||||
|
|
||||||
|
public HWND hWnd;
|
||||||
|
public HMENU hMenu;
|
||||||
|
public String[] path;
|
||||||
|
public boolean exact;
|
||||||
|
|
||||||
|
public MenuItem(HWND hWnd, HMENU hMenu, String... path) {
|
||||||
|
this(hWnd, hMenu, EXACT, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuItem(HWND hWnd, HMENU hMenu, boolean exact, String... path) {
|
||||||
|
this.hWnd = hWnd;
|
||||||
|
this.hMenu = hMenu;
|
||||||
|
this.exact = exact;
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/main/java/org/synthuse/objects/WinPtr.java
Normal file
69
src/main/java/org/synthuse/objects/WinPtr.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Synthuse.org
|
||||||
|
* Released under the Apache Version 2.0 License.
|
||||||
|
*
|
||||||
|
* last modified by ejakubowski7@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.synthuse.objects;
|
||||||
|
|
||||||
|
import org.synthuse.Api;
|
||||||
|
|
||||||
|
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||||
|
|
||||||
|
public class WinPtr {
|
||||||
|
|
||||||
|
public HWND hWnd = null;
|
||||||
|
public String hWndStr = "";
|
||||||
|
public String runtimeId = "";
|
||||||
|
|
||||||
|
public String hmenuStr = "";// store menu handle
|
||||||
|
public int hmenuPos = -1;// store menu position or id
|
||||||
|
|
||||||
|
public WinPtr() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WinPtr(HWND hWnd) {
|
||||||
|
this.hWnd = hWnd;
|
||||||
|
this.hWndStr = Api.GetHandleAsString(hWnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WinPtr(String runtimeId) {
|
||||||
|
this.runtimeId = runtimeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWin32() {
|
||||||
|
return (hWnd != null || !hWndStr.equals(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWpf() {
|
||||||
|
return (!runtimeId.equals(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return (hWnd == null && hWndStr.equals("") && runtimeId.equals(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWpfRuntimeIdFormat(String runtimeIdTest) {
|
||||||
|
return (runtimeIdTest.contains("-"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void convertToNativeHwnd() {
|
||||||
|
if (isWpfRuntimeIdFormat(runtimeId)) {
|
||||||
|
hWndStr = runtimeId.split("-")[1];
|
||||||
|
hWnd = Api.GetHandleFromString(hWndStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
if (isWin32() && !hWndStr.equals(""))
|
||||||
|
return hWndStr;
|
||||||
|
else if (isWin32() && hWnd != null) {
|
||||||
|
hWndStr = Api.GetHandleAsString(hWnd);
|
||||||
|
return hWndStr;
|
||||||
|
} else if (isWpf())
|
||||||
|
return runtimeId;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user