ebennetthill wrote:
> Karen, would you be able to walk through your script and tell me what
> your statements that include "arg()" are saying?
>
Hi Ben, sure thing. :)
PowerPro's HookWindowEvents feature watches for anything happening to
windows -- opening, closing, resizing, moving, etc -- and when one of
these events occurs, PowerPro can be set to do stuff.
Whenever such a window event occurs, PowerPro notes the details of the
event -- which window, what action , the window caption & window class
-- and then checks the command list HookWindowEvents to see if it needs
to do anything.
PowerPro passes the event details that it's noted to the
HookWindowEvents command list as arguments -- arg(1) to arg(4) -- and
these can therefore be used in comparison statements to make PowerPro do
stuff on specific events.
The arguments represent the following details of the window event:
arg(1) - integer event number [see below]
arg(2) - the window handle
arg(3) - the window class
arg(4) - the window caption [arbitrary when window first created,
i.e. if arg(1)==3]
The first argument, arg(1), takes on a numeric value which represents
the type of event that occurred, as follows:
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)
So, for example, if a Notepad window was maximised, the event details
noted by PowerPro are:
arg(1) = 1
arg(2) = 27384922 (the Notepad window's handle)
arg(3) = "Notepad" (the class of a Notepad window is also
called "Notepad")
arg(4) = "Untitled - Notepad" (for example)
Now, we PowerPro users can make use of this great feature by creating
scripts to do stuff for certain window events.
So, in the script from the other day...
> if (win.exename(arg(2))=="Opera") do
>
> if (arg(1)==3) do
> win.keys("%^2")
> quit
> endif
>
> if (arg(1)==4 && not(anywindow("=Opera"))
> win.keys("%^1")
> quit
> endif
>
> endif
The line:
if (win.exename(arg(2))=="Opera") do
is checking to see if the window that just did something is an Opera
window.
Note, as mentioned above, that when a window first opens, its caption is
often not set yet. Therefore, when a window first opens, arg(4) -- the
window caption -- is usually empty & we must use something other than
the caption to check what type of window it is that just did something.
I like to use the exe name, which I retrieve above via the Win plugin
command, win.exename(). [Check the file "win.txt" in the PowerPro
plugins directory for more info on the Win plugin.] So, the statement
above is checking if the exename from the window that just did something
is equal to Opera.
If it is, we move on to the next line:
if (arg(1)==3) do
which checks if what the Opera window just did was get created. If so,
we then go do some stuff.
Similarly, the line:
if (arg(1)==4 && not(anywindow("=Opera"))
is checking to see if the Opera window just closed, but here, we're also
checking to see that after the Opera window closed there are no other
Opera windows open. (Cos, for this partic. script, we don't want to
change the resolution back until there are no more Opera windows at all.)
So... that's my explanation of the script we're looking at now, let us
know if that doesn't make sense.
Here are some more examples of HookWindowEvents script lines:
---------
if ((arg(1)==0 || arg(1)==1) && win.exename(arg(2))=="xplorer2_UC") do
This line checks if an Xplorer2 window [that's my fave Win Explorer
replacement] has just been maximised/restored [arg(1)==1] or moved
[arg(1)==0].
---------
if (arg(1)==3 && arg(3)=="XPCOM:EventWindow" && ;;+
(exe== "firefox" || exe=="thunderbird" || exe=="thunde~1")) do
The above (over 2 lines, ";;+" allows a long command to be continued on
the next line) checks for Mozilla Firefox/Thunderbird dialogs. To
refine this to check for password dialogs only, I use the following:
;--- start ---
if (arg(1)==3 && arg(3)=="XPCOM:EventWindow" && ;;+
(exe== "firefox" || exe=="thunderbird" || exe=="thunde~1")) do
wait.for(10000, activewindow("Prompt"))
wait.for(500)
if (win.width("Prompt")==405 && ;;+
(win.height("Prompt")>140 || win.height("Prompt")<146))
win.sendkeys("{to ^Prompt}mypassword{en}")
endif
quit
endif
;--- end ---
Here I first note that a window has opened & check if it's a Moz
dialog. I then wait for the window caption to be determined & check if
it says Prompt. (Remember: captions don't get set at the moment of the
window opening, but shortly after.) Moz pw dialogs generally are always
titled "Prompt", however, so are other Moz dialogs, so I then check the
size of the opened window to determine if it's the Password window I'm
after, & if so I send my password & an <Enter> which closes the window.
The window size info I determined purely by actually measuring the
dialog, plus a bit of trial & error as I hit snags.
So, there you go! Hope that makes sense, hit me back with any q's.
I've got some HookWindowEvents tips I'll post later, too.
Have fun!
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/