Core Function GUIMsgFilter
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> GUIMsgFilter( <gui>, <command> ) </pre> === Description === Use a function to recieve all messages windows sends to the GUI window (HWND, MSG, WPARAM, LPARAM). === Param...") |
m (1 revision) |
||
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
− | GUIMsgFilter( <gui>, <command> ) | + | GUIMsgFilter( <gui object>, <command> ) |
</pre> | </pre> | ||
=== Description === | === Description === | ||
− | Use a function to | + | Use a function to receive all messages windows sends to the GUI object (HWND, MSG, WPARAM, LPARAM). |
=== Parameters === | === Parameters === | ||
Line 11: | Line 11: | ||
==== gui ==== | ==== gui ==== | ||
− | The GUI to link the MsgFilter to. | + | The GUI Object to link the MsgFilter to can be a Window,Button etc. |
==== command ==== | ==== command ==== | ||
Line 19: | Line 19: | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns | + | Success: Returns true. |
− | Failure: Returns | + | |
+ | Failure: Returns false. | ||
=== Examples === | === Examples === | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | // Create | + | // Create the Design Window |
− | + | $Window = GUICreate("Window", "Test GUI", 640, 482, 0, 0); | |
− | + | // Show the Design Window | |
+ | GUILoad( $Window ); | ||
// Create the GUI objects | // Create the GUI objects | ||
− | $b1 = | + | $b1 = GUICreate("Button", $Window, "Send", 8, 8); |
− | // Add a | + | // Add a link |
− | GUILink($b1, | + | GUILink($b1, "Click", 'Send();'); |
// Create the GUI msgFilter | // Create the GUI msgFilter | ||
− | GUIMsgFilter($ | + | GUIMsgFilter($Window, 'myMsgFilter($HWND, $MSG, $WParam, $LParam);'); |
− | + | ||
− | // | + | // Keep the GUI running as long as long as the window is open |
− | + | While ( GUIStatus( $Window ) ) DoEvents( ); | |
− | + | ||
− | + | ||
− | + | ||
// When you create a msgfilter 4 variables are automatically created for you | // When you create a msgfilter 4 variables are automatically created for you | ||
Line 50: | Line 49: | ||
// $LPARAM | // $LPARAM | ||
// All them names should be familiar to you | // All them names should be familiar to you | ||
− | Function myMsgFilter() | + | Function myMsgFilter($HWND, $MSG, $WParam, $LParam) |
{ | { | ||
println("HWND: " . $HWND . " | MSG: " . $MSG . " | WParam: " . $WParam . " | LParam: " . $LParam); | println("HWND: " . $HWND . " | MSG: " . $MSG . " | WParam: " . $WParam . " | LParam: " . $LParam); | ||
Line 59: | Line 58: | ||
Function Send() | Function Send() | ||
{ | { | ||
− | $Handle = GUIGetProp($ | + | my $Handle = GUIGetProp($Window, "Handle"); // Get the HWND of our window |
// Send a message to the window containing 2 unique numbers 777 and 1337 | // Send a message to the window containing 2 unique numbers 777 and 1337 | ||
// Just to see if they appear in the filter | // Just to see if they appear in the filter | ||
− | DLLCall("user32.dll", "PostMessage", "Int32", " | + | DLLCall("user32.dll", "PostMessage", "Int32", "tItt", "Ansi", $Handle, 160, 777, 1337); |
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:37, 14 June 2015
GUIMsgFilter( <gui object>, <command> )
Contents |
Description
Use a function to receive all messages windows sends to the GUI object (HWND, MSG, WPARAM, LPARAM).
Parameters
gui
The GUI Object to link the MsgFilter to can be a Window,Button etc.
command
Either a command to execute or a function to call etc.
Return Value
Success: Returns true.
Failure: Returns false.
Examples
// Create the Design Window $Window = GUICreate("Window", "Test GUI", 640, 482, 0, 0); // Show the Design Window GUILoad( $Window ); // Create the GUI objects $b1 = GUICreate("Button", $Window, "Send", 8, 8); // Add a link GUILink($b1, "Click", 'Send();'); // Create the GUI msgFilter GUIMsgFilter($Window, 'myMsgFilter($HWND, $MSG, $WParam, $LParam);'); // Keep the GUI running as long as long as the window is open While ( GUIStatus( $Window ) ) DoEvents( ); // When you create a msgfilter 4 variables are automatically created for you // $HWND // $MSG // $WPARAM // $LPARAM // All them names should be familiar to you Function myMsgFilter($HWND, $MSG, $WParam, $LParam) { println("HWND: " . $HWND . " | MSG: " . $MSG . " | WParam: " . $WParam . " | LParam: " . $LParam); return 0; // If you return HIGHER than 0 the msgfilter will be removed } // The button click goes here this will simply just be something to test out the msgFilter Function Send() { my $Handle = GUIGetProp($Window, "Handle"); // Get the HWND of our window // Send a message to the window containing 2 unique numbers 777 and 1337 // Just to see if they appear in the filter DLLCall("user32.dll", "PostMessage", "Int32", "tItt", "Ansi", $Handle, 160, 777, 1337); }