Installing and using QM functions from the forum
Assume you have found code like this example:
Function GetWinXY
;/
function# hwnd [&x] [&y] [&width] [&height] [hwndparent]
;Stores window position and size to int variables x, y, width and height.
;Returns 1 if successful, 0 if not.
;hwnd - handle of the window. Can be top-level or child window.
;hwndparent - handle of the parent window. If used and not 0, the coordinates will be relative to the client area of hwndparent. Otherwise - coordinates in screen.
;EXAMPLE
;int x y cx cy
;GetWinXY(win("Quick Macros") x y cx cy)
;out "%i %i %i %i" x y cx cy
RECT r
if(!hwnd or !GetWindowRect(hwnd &r)) ret
if(hwndparent) MapWindowPoints(0 hwndparent +&r 2)
if(&x) x=r.left
if(&y) y=r.top
if(&width) width=r.right-r.left
if(&height) height=r.bottom-r.top
ret 1
Installing
1. Copy the code.
2. In QM, create new function. To create new function, click menu File -> New -> New Function. Name it GetWinXY, or whatever name is given above the code or in examples. If the name is not given, you can name the function as you like.
3. Paste the code in the new empty function. If displays 'Correct...' link, click it.
Learning
The code or/and the post usually contains information what the function does and how to use it. Only read the description. Don't need to learn or modify the code.
Testing (optional)
1. Create new macro.
2. If EXAMPLE code is given in the function code, copy it and paste in the macro. If several examples are given, copy/paste one of them. To uncomment, select the code and right click the selection bar at the left.
3. Run the macro.
Sometimes example code is not within the function code, but somewhere else in the post. Copy it and paste in the macro. If example code is missing, create it. Examples:
FunctionName
FunctionName somevalue somevalue2
somevariable=FunctionName
somevariable=FunctionName(somevalue somevalue2)
Using in your macros
You can use the function in your macros, functions, menus, etc. Don't paste the code there, but instead use the name, like in examples. In most cases you should not run the function or assign a trigger, but instead run your macros that call the function.
Member functions
Member functions are installed like functions, except that you have to use menu File -> New -> New Member Function.
These functions usually have . in the name, for example str.FunctionName. The part before . is the type of variables with which the function can be used. Examples of calling the function when the type is str:
str s
s.FunctionName
s.FunctionName(somevalue somevalue2)
somevariable=s.FunctionName
somevariable=s.FunctionName(somevalue somevalue2)
What item type it is (function, macro, etc)?
Usually item type is given in the post. If not, usually you can understand from the code or from the comments. For example, if the code looks like the above example function, or just contains
function at the beginning, it's probably function. Otherwise, if it's not menu or toolbar, it's probably macro.
Often there is only small code example, not entire function or macro. It can be placed anywhere. For testing, it is recommended to use a macro.
Triggers
Sometimes above the code is given the recommended trigger. It is an encoded trigger string. Select the trigger string (not including "Trigger "), copy, and paste in QM, into the Trigger field. The trigger field is on the toolbar, between the Properties and Save buttons.
Attached files
Sometimes code is in an attached file, not in the post text. Then installing is easier. Download the file and open. It opens in the QM file viewer. Click Import. It creates the function(s) for you.
_______________________________________
Learn about functions:
http://www.quickmacros.com/help/QM_Help ... NTIPS.html