Howdy list,

As mentioned, some tips for using HookWindowEvents.  These are not 
actually my tips, but things from the archives & the PowerPro Help manual.


== 1. ======================
The first is from Ted Wall -- and it is a godsend for when you are 
working on a hook script, enabling you to easily stop the script should 
get stuck in an error loop, as well as see what values the args are 
taking on for each window event.

Ted's original message is here:  
http://article.gmane.org/gmane.comp.windows.power-pro/16503

Stick the following at the start of your hook script:
;----------
if (not bHookOn) do
    quit
elseif (bHookOn==2)
    win.debug(           ;;+
      "arg(1)="++arg(1), ;;+
      "arg(2)="++arg(2), ;;+
      "arg(3)="++arg(3), ;;+
      "arg(4)="++arg(4))
    quit
endif
;----------

Then create a hotkey (I use Win+space) with the following as the command:
   bHookOn=ifelse(bHookOn==0,1,ifelse(bHookOn==1,2,0))

And finally, set a Scheduler event for Start up to run the following:
   global bHookOn = 1

Now, you can cycle through 3 bHookOn states, where if:
  bHookOn=1, your hook script will be called for each window event
  bHookOn=2, arg values will be output to the debugger &
             hook script is not run
  bHookOn=0, hooks are off



== 2. ======================
Make use of the "Quit" statement throughout your script, so that 
PowerPro doesn't continue processing it after your window event has been 
processed.  Place a Quit statement at the end of each section, before 
the "endif".

e.g.  (from my own hook script)

;-- -- -- -- -- -- -- -- -- -- -- --
; Check for ashQuick closing & if xplorer2's
; console2 is open, close that too
;-- -- - -- -- -- -- -- -- -- -- --
if (arg(1)==4 && arg(4)=="avast! Quick Scanner") do
    window.close_("console*")
    quit
endif

;-- -- - -- -- -- -- -- -- -- -- --
; an empty example of another section
;-- -- - -- -- -- -- -- -- -- -- --
if (arg(1)==3 && arg(4)=="*Firefox") do
    ; do stuff
    quit
endif

Notice the "quit" 's before the close of each "section" there.



== 3. ======================
Once you've saved your hook script, create a PowerPro note with the 
following information:

----------------------
FileHook(arg(1), arg(2), arg(3), arg(4))
----------------------
THE ARGUMENTS
  arg(1) - integer event number from below
  arg(2) - the window handle
  arg(3) - the window class
  arg(4) - the window caption
         arbitrary when window first created: arg(1) = 3

----------------------
ARG(1) VALUES
  0 = A moving or sizing operation is completed using the GUI
  1 = A window is maximized or restored to normal using the GUI
  2 = A window is minimized using the GUI.
  3 = A new window is created.
  4 = A window is destroyed.
  5 = A window is activated (i.e. given focus)
----------------------

Set the category of the note to "!captionlist" where captionlist matches 
your hook script file when you're editing it.  Use a + instead of an * 
for the caption wildcard.

So, mine is: "!+FileHook.powerpro - metapad"  which has a wildcard in 
2nd spot there to cover times when I'm actually editing the file & 
metapad puts an asterisk in the window caption to indicate such.

Now, whenever you open your hook script, PowerPro will open your helper 
note, too.

See "PowerPro Help CHM > Built-in Commands > *Note > *Note Command > 
Showing Notes when specified programs or documents are active" for more 
info on this great PowerPro feature.



== 4. ======================
Ok, this last one actually is my own tip.  Not a great tip, but a tip, 
nonetheless.

I like to grab the window's exe name at each event for use in subsequent 
arg() comparisons, so I define a global variable, exe, at PowerPro 
startup that I then set each time my hook script is called, with the 
following line at the start:

   exe = win.exename(arg(2))

I also include that in my debug output from Ted's script in tip 1, too.



And that's it!  Hope they help someone.  :)

Cheers
Karen
 



Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to