Filter function examples

Example1

 

Assume that you have macro "Macro" that has trigger Cb (Ctrl+B), and you want that it would work only in Quick Macros window.

 

Open the Properties dialog and click the FF button. Click Copy and select "FFT_Window" from the drop-down list. It is a template filter function. Click OK, and OK again. New function "FF_Macro" is created. Select it. Initially, text is:

 

 /
function# iid FILTER&f

if(wintest(f.hwnd "WindowName" "WindowClass")) ret iid

 

Replace "WindowName" with "Quick Macros", and "WindowClass" with "QM_Editor" (you can see window name and class in the QM status bar while the mouse pointer is over that window). If you want to use only window name or only window class (it is recommended to use only class, unless it is not unique), delete other string, leaving empty quotes. After editing, the filter function may look:

 

 /
function# iid FILTER&f

if(wintest(f.hwnd "" "QM_Editor")) ret iid

 

Now, your filter function allows starting "Macro" when you press "Ctrl+B" in Quick Macros window, but discards it in other windows.

 

Example2

 

Assume that you have two macros ("M1" and "M2"), and you want that "M1" would run when you press F12 in "Notepad" window, and "M2" when you press the same key in "Internet Explorer".

 

Instead of assigning F12 trigger to each macro, we will create new filter function and assign F12 trigger to it. The macros should not have a trigger.

 

At first, create new filter function: menu File -> New -> Templates -> Filter Functions -> FF_Window_Dispatcher. Then open the Properties dialog and assign F12 trigger. Then open the Filter Function dialog, click "Use" and select the new function itself. Click OK, and OK again. Now, the new function has hotkey F12 and filter function itself assigned to it. Function's text is:

 

 /
function# iid FILTER&f

sel wintest(f.hwnd "Window1[]Window2[]Window3" "" "" 16)
	case 1 ret "Macro1"
	case 2 ret "Macro2"
	case 3 ret "Macro3"

 

After editing, it should be:

 

 /
function# iid FILTER&f

sel wintest(f.hwnd "Notepad[]Internet Explorer" "" "" 16)
	case 1 ret "M1"
	case 2 ret "M2"