Hi Cüneyt

I shall split my suggestions into two messages, one about how
to code it (especially about the main structure of your script)
and another about the design of the visible end product.
This one is about the scripting.

[A] I notice you use locals for things which do not change
including applications' paths such as _ivbin
and options such as _use_leftdrag and _fontname.
That way, every time a program is minimised, the script
has to do a lot of work.
IMHO all those options should be statics which are set in
a separate @initialise routine at the end of the script.
It sets a static s_initialised = 1 so it will not be repeated
every time a window is mininmised.
The script should start with:
  If(not s_initialised)do
    [EMAIL PROTECTED]

[B] A change to cope with a situation where the user has
executed Window Min All, maybe affecting 10 windows.
We don't want 10 instances of the script running concurrently
asking Irfanview to do many jobs concurrently, so I introduced
the idea of a queue of handles waiting to be processed by only
one instance of the running script.

When the script starts, as early as possible we check whether
the same script is currently running. If so, add this next
handle to the queue and quit.

[C] You seem undecided about which window events to react to.
Only a minimise event (create a new ThumbMinBar) or also Close
and Restore events (remove its ThumbMinBar).

I think it's better to use a separate script for window events
for various reasons including: maybe the user already had some
window event processing (such as do something when ThisApp is
maximised). It will be easier to coordinate the event handling
in a separate WindowEvent.powerpro script. If the event is a
minimise, then send the handle to your ThumbMin script.

That way, we know that the ThumbMin script will only be called
with one arg (representing the window being minned),
because the usual 4 args from the HookWindowEvents
command list were handled by the WindowEvent script.

Note: I see you start all your vars with _
In the following script, I kept _var for locals,
and used s_var for statics.

;;----------------------------------------------

static s_running s_initialised s_queue
;; all the other statics will be set in @initialise

local _handle = ifelse(arg(1), win.handle(arg(1)), 
win.mainhandlefrompoint(xmouse, ymouse))

if(s_running)do
  s_queue = s_queue ++ _handle ++ " "
  quit
  ;; The running instance will process this handle from the queue.
endif

s_running = 1
;; Remember to set s_running = 0 before the final quit.

if(not s_initialised)do
  @initialise
endif

@queuecycle

;; Insert here the code to do a screen capture and make a ThumbMinBar
;; for the current _handle.

if(s_queue)do
  _handle = word(s_queue,1)
  s_queue = replacechars(s_queue, _handle ++ " ", "")
  jump queuecycle
  ;; Here I prefer jump instead of [EMAIL PROTECTED],
  ;; to avoid running multiple instances of the script,
  ;; which would only be waiting for a return so they can quit.
endif

s_running = 0
quit
;; That is the final quit after we have cycled through
;; all the queued handles waiting to be minimised.

@initialise
;; This will be run the first time the script is used.
;; Set most of the statics here.
;; The initial block of options from Cüneyt's script goes here
;; but we set statics instead of locals.
static s_initialised = 1
quit

@reset
;; you only need to run this if the script halted with an error 
;; and it won't work because s-running kept its value of 1

static s_running = 0
quit all

;;-----------------------------------------------

Before doing your screen shot, you make the target window ontop.
After the screen capture you make it notontop.

I suggest this before the capture:
  local _wastop = win.topmost(_handle)
  win.ontop(_handle, 1)

and after the capture:
  if(not _wastop)
    win.ontop(_handle, 0)



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