61BOOL CALLBACK zingers_enum_proc(
window_handle hwnd, LPARAM lParam)
63 const int MAX_TITLE = 1024;
65 int chars = GetWindowText(hwnd, win_name, MAX_TITLE - 1);
68 if (
astring(from_unicode_temp(win_name)).ifind(window_name_sought) >= 0) {
69 matching_window = hwnd;
76int main(
int argc,
char *argv[])
80 if ( (cmds.entries() < 2)
82 out.
log(cmds.program_name().basename().raw() +
" usage:\n"
83 "This takes at least two parameters. The first parameter is a window\n"
84 "handle that is to be contacted. Alternatively, the first parameter\n"
85 "can be the title of the window. The second parameter is a numerical\n"
86 "event that the window is to be zinged with. Zinging is synonymous\n"
87 "here with \"sending a message to the window\". Depending on the\n"
88 "message chosen, the window will behave in various different ways.\n"
89 "If there are a third or fourth parameter, then these are taken as\n"
90 "the extra data to send in the PostMessage call for zinging.");
91 out.
log(
a_sprintf(
"\nExample windows message values:\n\t"
92 "WM_CLOSE = %d\n\tWM_PAINT = %d", WM_CLOSE, WM_PAINT));
97 bool saw_hex_code =
false;
98 if (junk_text.
begins(
"0x")) {
105 sscanf(junk_text.
s(),
"%lx", &temp_handle);
107 sscanf(junk_text.
s(),
"%ld", &temp_handle);
111 #pragma warning(disable : 4312)
116 bool has_alpha =
false;
120 for (
int i = 0; i < junk_text.
length(); i++) {
121 if ( (junk_text[i] <
'0') || (junk_text[i] >
'9') ) {
130 window_name_sought = junk_text;
133 EnumWindows(zingers_enum_proc, 0);
134 if (!matching_window) {
135 out.
log(
"no matching window could be found. ignoring request.");
139 handle = matching_window;
142 junk_text = cmds.
get(1).text();
143 ULONG
event = (ULONG)junk_text.
convert(0);
146 if (cmds.entries() >= 3) {
147 junk_text = cmds.
get(2).text();
148 p1 = (ULONG)junk_text.
convert(0);
150 if (cmds.entries() >= 4) {
151 junk_text = cmds.
get(3).text();
152 p2 = (ULONG)junk_text.
convert(0);
155 if (!handle || !event) {
156 out.
log(
"the window handle or the event was invalid. ignoring request.");
160 PostMessage(handle, event, p1, p2);
162 out.
log(
a_sprintf(
"posted at 0x%lx the zing (%u %u %u)", handle, event,
169int main(
int argc,
char *argv[])
175#ifdef __BUILD_STATIC_APPLICATION__
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
virtual char get(int index) const
a constant peek at the string's internals at the specified index.
int convert(int default_value) const
Converts the string into a corresponding integer.
bool begins(const astring &maybe_prefix) const
Returns true if "this" string begins with "maybe_prefix".
int length() const
Returns the current length of the string.
virtual basis::outcome log(const basis::base_string &info, int filter)
sends the string "info" to the standard output device.
#define NULL_POINTER
The value representing a pointer to nothing.
Provides macros that implement the 'main' program of an application.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
Useful support functions for unit testing, especially within hoople.
Support for unicode builds.
int main(int argc, char *argv[])