Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

LiveWindows: Watch Dialogboxes in Thumbnail


  • Please log in to reply
28 replies to this topic
holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
The purpose of this script is to watch Dialogboxes / Progressbars or any other user-triggered window in a tiny window and have live-updates (of even a portion of the window).

Posted Image

What is it good for?

You make a big file-copy and have these funny flying folder-animation. Now you would like to watch the progress, but continue with other things.
LiveWindows automatically detects the window-size of the dialog and shows it in a small transparent window so you see whats going on.

Or you have a download from the internet and have a progressbar, this also is shown in the small window.

you can also trigger your own windows to be watched by pressing "win-w" (for "(w)atch" ). now this window is put in the preview-window and updated every second. To release it press "win-q" over the active window you want to remove. dialogs are always shown.

Whats really cool about this is that the dialogboxes can be behind other windows and are previewed correctly.

the preview-window uses transparency so you dont loose to much screen space, also it looks more cool ;)

when you resize the window the contents is also resized. only width. height is automatically! with this effect you also have a zoom of the window. you even can magnify your dialogboxes ;)

You can now click on the thumbnail to bring this window to foreground (WinActivate).

If you want to go to the window behind LiveWindows you can hide and show it easily with win-a.

This script is compatible with deskman.ahk, which i run in parallel.

Hotkey:
win-w: add watch
win-q: remove watch
win-a: toggle gui show/hide
strg-shift MouseDown + Drag + MouseUp : define region

Usage:
Starting LiveWindows (right small Window, left is for demo)
Posted Image

Activating Watch with win+w:
Posted Image

Defining a region with strg-shift-Left-Click + Drag + Left-Mouseup: (sorry cant make a screenshot of tool-tip). This is after defining region:
Posted Image

It also works when the source-window is behind or even offscreen (on bottom only window-title shown, but minimized does not work!)
Posted Image

Notice:
The small window is updated in realtime (once every second) this is NO static screenshot! you can resize the with of the toolwindow and so optimize usage. (you can zoom the watched region to view it smaller or bigger! similar to desktop-loupe)
The toolwindow is always-on-top and transparent (for screenshots i made it solid) so you have it visible always, seeing your other applications in background.
If the source-window is closed or minimized it disappears from the toolwindow. if you reopen it or un-minimize it shows up again.
pressing win-q over the watched (source) window removes it from the toolwindow. (the region-definition is also reset for this ahk_id)
Dialog-Sized windows show up in Toolwindow automatically.

after selecting a region the window is minimized/moved to screenbottom. (behind taskbar?)
and can be restored with clicking on the thumbnail in the toolwindow.

have fun

Download:
livewindows.ahk (6kb)
livewindows.exe (compiled 188kb)

OnExit handle_exit
    
p_w = 200                                    ; thumbnail width
p_h = 150                                    ; height
Left    := A_ScreenWidth - p_w               ; initial position
Height1 := A_ScreenHeight / 4
Height2 := A_ScreenHeight - Height1
Trans :=  "Off"                         ; transparency level

Hotkey, #w, AddWatch
Hotkey, #q, RemoveWatch
Hotkey, #a, ShowHideGui
Hotkey, ^+LButton , define_region

Gui +AlwaysOnTop  +Owner +Resize +ToolWindow ; window for the dock

ypic =0
Loop 10,                                     ; prepare 10 thumbs to be clicked
{
  Gui, Add, Pic , gRestoreWin x0 y%ypic% w%p_w% h100 vPic%a_index%			; add dock-slots to gui
  ypic +=100
}

Gui Show, NoActivate w%p_w% h32 x%Left% y%Height2%, LiveWindows

WinGet LiveWindowsID, id, LiveWindows
WinSet, Transparent, %Trans%, LiveWindows       ; Make Window Transparent for coolness and usability

hdc_frame := DllCall( "GetDC", UInt, LiveWindowsID )
hdc_buffer := DllCall("gdi32.dll\CreateCompatibleDC", UInt,  hdc_frame)  ; buffer
hbm_buffer := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc_frame, Int,A_ScreenWidth, Int,A_ScreenHeight)
DllCall( "gdi32.dll\SelectObject", UInt,hdc_buffer, UInt,hbm_buffer)

; comment this line for speed but less quality
DllCall( "gdi32.dll\SetStretchBltMode", "uint", hdc_frame, "int", 4 )  ; Halftone better quality with stretch

SetTimer update_dock, 1000                   ; x sec update
                                             ; flow through 1st call (is efficient, but introduces bugs easily!)
update_dock:
  WinGetPos ,,, p_w2, p_h2, LiveWindows       ; get size of LiveWindows Window
  p_w2 := p_w2 -8                             ; adjust sizes (margins, borders ..)

  ypos= 0                                    ; offset for each thumbnail
  nr  = 0                                    ; which thumbnail

  WinGet ids, list,,,Program Manager         ; all active windows-tasks (processes)
  Loop %ids% {
     task_id := ids%a_index%                 ; id of this window
     WinGetPos ,,, w, h, ahk_id %task_id%
     WinGetTitle,title,ahk_id %task_id%

                                             ; try to match mediumsize dialog-boxes like alerts/copy or userdefined with #w
     if ( title <> "LiveWindows" and title <> "" and title <> " "  and (( w > 300 and h < 300 and h > 50 ) or watch_me_%task_id% = 1 ) )
     {              
      
      DllCall("PrintWindow", UInt,task_id, UInt,hdc_buffer, UInt,0)
      
      wx1 := watch_me_x1_%task_id%
      wy1 := watch_me_y1_%task_id%
      ww  := watch_me_w_%task_id%
      wh  := watch_me_h_%task_id%
      nr  += 1
      
      ; ToolTip, %task_id% %current_id% "..." %title% "x" %wx1% "v" %onoff%

       if  wx1 <>
       {
        h1 := wh * ( p_w2 / ww )                  ; autosize (seems not exaclty right?)
      
        DllCall("gdi32.dll\StretchBlt", UInt,hdc_frame, Int,0, Int,ypos, Int,p_w2, Int,h1
              , UInt,hdc_buffer, Int, wx1, Int,wy1, Int,ww, Int,wh ,UInt,0xCC0020) ; SRCCOPY
       }
       else
       {
         h1 := h * ( p_w2 / w )                  ; autosize (seems not exaclty right?)
         DllCall("gdi32.dll\StretchBlt", UInt,hdc_frame, Int,0, Int,ypos, Int,p_w2, Int,h1
              , UInt,hdc_buffer, Int,0, Int,0, Int,w, Int,h ,UInt,0xCC0020) ; SRCCOPY
       }

       watch_me_id_%nr% := task_id    ; store src-window id for later restore
       watch_me_title_%nr% := title

       GuiControl, Move, Pic%nr%, X0 Y%ypos% W%p_w2% H%h1%
       
       ypos += h1                          ; move down to next thumbnail-position
    }
  }
  WinMove LiveWindows,,,,,ypos +32         ; resize to make pseudo-transparent
Return

AddWatch:
    WinGet current_id , id , A         ; get ahk_id of foreground window
   
    watch_me_%current_id% = 1
Return

RemoveWatch:
    WinGet current_id , id , A         ; get ahk_id of foreground window

    watch_me_%current_id% =
    watch_me_x1_%current_id% = 
Return

RestoreWin: 
    StringReplace, pos , A_GuiControl, Pic
    xid    := watch_me_id_%pos%
    WinActivate, ahk_id %xid%
    Gosub, ScreenBottom
Return

ShowHideGui:
   if ( DllCall( "IsWindowVisible", "uint", LiveWindowsID ) )
      Gui, Hide
   else
      Gui, Show 
Return 


define_region:
   CoordMode, Mouse, Relative                ; relative to window not screen
   MouseGetPos, start_x, start_y             ; start position of mouse
   ToolTip, %A_Space%, start_x, start_y      ; pseudo layer
   WinSet, Transparent, 150, ahk_class tooltips_class32 ; draw "layer" as feedback
   SetTimer mouse, 50                        ; check every 50ms for mouseup
Return

mouse:
   MouseGetPos, current_x, current_y
   WinMove, ahk_class tooltips_class32, , , , % current_x - start_x, % current_y - start_y
   If GetKeyState("LButton", "P")
      Return
   SetTimer mouse, OFF
   ToolTip
   MouseGetPos, end_x, end_y
   ;TrayTip, ,you selected %start_x% %start_y% %end_x% %end_y%, , 5

   width := end_x - start_x
   height := end_y - start_y

   WinGet current_id , id , A         ; get ahk_id of foreground window

   ;WinGetTitle,title, ahk_id %current_id%
   ;tooltip, "current" %current_id% %title%


   watch_me_x1_%current_id% := start_x
   watch_me_x2_%current_id% := end_x
   watch_me_y1_%current_id% := start_y
   watch_me_y2_%current_id% := end_y
   watch_me_w_%current_id%  := width
   watch_me_h_%current_id%  := height

   ;WinGetPos ,src_x, src_y, src_w, src_h, A
   ;watch_me_src_y_%current_id% := src_y
   ;watch_me_src_x_%current_id% := src_x

    Gosub, ScreenBottom         ; make it minimized
return

ScreenBottom:
   ; when clicked then use current window
   WinGet current_id , id , A         ; get ahk_id of foreground window

   minimized := minimized_state_%current_id%
   screenborder_x := 
   screenborder_y := A_ScreenHeight - 24
   if minimized = 
   {
     minimized_state_%current_id% := 1
     WinGetPos ,wx,wy,ww,wh, ahk_id %current_id%
     minmized_x_%current_id% := wx
     minmized_y_%current_id% := wy

     WinMove , ahk_id %current_id%,, screenborder_x,screenborder_y       ; move to screenborder (keep x-pos)
   }
   else
   {
      x := minmized_x_%current_id% 
      y := minmized_y_%current_id% 

      WinMove , ahk_id %current_id%,, x,y       ; restore
      minimized_state_%current_id% :=
   }
return 

RestoreAll:
    WinGet, ids, list,,, Program Manager
	Loop, %ids%
	{
		StringTrimRight, id, ids%a_index%, 0				; find the id of this window
	    if minimized_state_%id% = 1
        {
          WinActivate, ahk_id %id%
          Gosub, ScreenBottom
        }    
	}
Return

GuiClose:
handle_exit:
   DllCall("gdi32.dll\DeleteObject", UInt,h_region )
   DllCall("gdi32.dll\DeleteObject", UInt,hbm_buffer)
   DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame )
   DllCall("gdi32.dll\DeleteDC", UInt,hdc_buffer)
   Gosub, RestoreAll
ExitApp 

Update: this version is newest, updated with feature to select a portion of the source-window to be watched. also bugfix to show the correct aspectratio.
2006-08-11: Added miminize to screenborder win-y or after selection

AiKscroll
  • Members
  • 179 posts
  • Last active: Feb 25 2007 03:10 AM
  • Joined: 06 Jun 2005
This is really nice!
_AiK

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
Impressive - the screenshot hardly does it justice.

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006

Impressive - the screenshot hardly does it justice.


thanks, perhaps i should try to make an animated gif, so you see it in action.

What could you think of using this tool? Watching File-Dialogs (copy/download) -Progressbars or do you prefer watching your own windows. Or are there other situations one could use it?

For any one interested, there is a similar tool. (there is an animation on the page, so i should go for animated-gif ;)
http://www.winplosio.../windowgrabber/
they use a different technique "not printwindow". i dont know how they do it.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
It seems useful for watching long downloads, video encoding, etc which takes a long time. This reminds me of something else I was wondering about recently - if it is possible to compare two images (and then notify upon a change) - probably not possible with this method of watching windows.

For uses other than watching "dialog" type windows - well some encoding type applications don't have a dialog window so watching the full window is necessary. Just the other day I was having difficulty getting to a web page and needed to watch it in the background to see if it eventually loaded.

Perhaps the best way to use it would be to have some window titles automatically watched for (built in ones could be internet explorer download windows, windows explorer copy/move) and automatically shown if they exist and the ability to add/remove windows temporarily with a hotkey.

Being able to click on the thumbnail image and activate the window would be useful.

Regarding the other program "WindowGrabber" - I would guess they use something similar to the video "mirror" driver used by UltraVNC.

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
A new Idea how to improve it and make it really useful.

this app is quite nice, but there is a little usability problem with the size of the thumbnails. they are small. but thats the nature of thumbnails ;)
the result is you can see not really much details until you make this window quite big.

so one idea would be combine it with
http://www.autohotke...opic.php?t=5206
http://www.autohotke...opic.php?t=5273
and make only a small selection of the source-window to be watched.
this way you can add a watch for example a changing number of a program. one idea could be to watch the speed or progress-number. you even could use the windows clock and watch only the analog-clock in the LiveWindows Toolwindow.

So now i have to figure out how to do it ;)
a) draw a selection on the active window, perhaps there isnt a rectangle needed but only tracking mousedown - mouseup after pressing win-w ?
B) remember this clip-region and apply it when copying with StrechBlt
UInt,hdc_frame, Int,0, Int,ypos, Int,p_w2, Int,h1
would be the clipped region instead of the whole window.
c) the saving of the clipped numbers is easy just add a watch_me_clip_x1_%current_id% = %mousex1%
etc.

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
It works, perhaps other things are broken ;)

this version is with cropping a region to be watched.

after adding a window to the watch "win-w".
select a region for this window with "strg-shift-leftclick" drag mouserelease.

this selected region is now watched.

cool!

the suggested windows-analog-clock in livewindows works.
this give new perspectives of using and watching windows ;)

is now merged with post 1. 


holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
Some new Ideas/Todos for improving the tool:

* (ok) Update first Thread-Post with current script-src again
* (ok) The selection / clipping function is stable enough
* (ok) make a series of small screenshots or animated gif to show LiveWindows in action and understand what it does
* (ok) example of how to show windows analog-clock
* (ok) find a way to make the ToolWindow "click through" so its on top but you can use the windows behind normally. (eg. using high level of transparency and have LiveWindows as an extra Layer of system-info)
(i found some techniques of "punching holes in windows" but this doesnt look right, there must be a betterway of not catching mouseclicks. )
Thanks, lazlo for the tipp, but i didnt get it to work. so now i choose an easier solution win-a toggles the visibilty of LiveWindows so one can "manually" clickthrough

* (ok) find a way to restore app, when clicked on the watched portion in the ToolWindow.
* (?) As livewindows only work when the window is not minimized, one way to move it out of view would be to move the window on bottom of the screen, WinMove y0=-32px after the region is selected. (saving window-position in variable for later restore!) perhaps another key-press, independant of LiveWindows ? low prio
* (todo) making hotkeys configurable with ini-file so one can customize the compiled script (livewindows.exe) for ones one hotkeys. medium prio. in the moment hotkey-definition is at the beginning of script.

(this list is a kind of reminder for the ideas , and also a todolist, and perhaps some people like to contribute?)

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

make the ToolWindow "click through" so its on top but you can use the windows behind normally.

You can find a rudimentary solution here.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
Just a word of caution about moving windows off the screen (I've used it in my Alt-Tab script to move them mostly off-screen except for a few pixels) - I noticed that some programs, when closed, remember their previous position, which can be a problem if they close before they are restored to a visible/sensible size/position. I think notepad might be one of the "guilty" apps as I recall.

Also, personally I'm not a big fan of transparent windows, so an option to not use transparency would be nice :wink:

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006

Just a word of caution about moving windows off the screen (I've used it in my Alt-Tab script to move them mostly off-screen except for a few pixels) - I noticed that some programs, when closed, remember their previous position, which can be a problem if they close before they are restored to a visible/sensible size/position. I think notepad might be one of the "guilty" apps as I recall.

Also, personally I'm not a big fan of transparent windows, so an option to not use transparency would be nice :wink:


i will make this move offscreen optional with another hotkey. by default no windows are moved.

you can turn off transparency easily by changing 150 to "Off" (with quotes).
in future this will be in config file or config gui. if i manage to add the nice config gui of this forum.

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006

Being able to click on the thumbnail image and activate the window would be useful.


the restore-feature is added, took me some time to get it working. i use some fake Pic for the clicks. and the pics are moved to match the thumbnail.

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006
New feature added:

Now if you select a region for the window after activating watch with win-w and drag-select, the window is minimized/moved to bottom of screen. (normally behind the taskbar, or visible if you have taskbar on right)
(similar to the show-desktop function of TopDesk.exe)

then if you click on the thumbnail in the toolbarwindow you can show-hide the window.

on exit all hidden windows get restored.

In theory it would be possible to simulate PrintWindow with a Make Windows on Top and "WinSet Region" Selected Region. but then you dont have titlebar for moving and no way to zoom the window. but it would be more efficient as the window would not be copied but you would see the real thing (only clipped) like the cutaway.ahk
Cutaway: http://www.autohotke...t=winset region
or
Clock: http://www.autohotke...pic.php?t=11642
also LiveWindows "collects" your watched window in one window with title, you may like it or not.

With this move to screenborder one could simulate "spring loaded folders" from apple somehow, combined with hotcorners: http://www.autohotke...ght=hot corners

Terrapin
  • Members
  • 107 posts
  • Last active: Feb 06 2007 03:38 PM
  • Joined: 15 Aug 2005
This is amazing... never seen anything like it. There seem to me to be a number of applications for what you're doing.

I ran across a couple of problems you've probably already noticed yourself. One is dragging a window to overlap a watched window, when you move the dragged window away, it can leave artifacts. The other I'm not sure about, but upon launch of LiveWindows, it automatically picks up a window from a utility I use, called goScreen.

I've had lots of fun playing with it! Thanks. I found this from the screen capture utility thread. You may have already done it, but it was very simple to add 'wingetactivestats....' and place the resulting variables to get a shot of the active window, instead of the whole screen. Great for getting shots of a gui.

Bob

holomind
  • Members
  • 341 posts
  • Last active: Aug 23 2015 03:27 PM
  • Joined: 11 Mar 2006

This is amazing... never seen anything like it. There seem to me to be a number of applications for what you're doing.

Would be nice if you could give some examples what you use it for. I mainly watch Windows like download or mail. But in terms of mail i changed my using of windows and have it now in upper-right-corner with gesture_winmove.ahk

I ran across a couple of problems you've probably already noticed yourself. One is dragging a window to overlap a watched window, when you move the dragged window away, it can leave artifacts. The other I'm not sure about, but upon launch of LiveWindows, it automatically picks up a window from a utility I use, called goScreen.

Yes i also noticed this, exspecially the internetexplorer has problems with scrolling if watched with livewindows. (the source-window) calling the dll-function PrintWindow forces a refresh of the current window, and IE seems not to like it if it is already half way in a Repaint of the current Page. If you could get a virtual screen of eg. 1000x5000px you could get a screenshot of your whole website with one simple Printwindow-Call.
Making screenshots you need to apply the right size when you create the CreateCompatibleBuffer (the one with size-parameters) as this defines your resulting size in saving.

goScreen is picked up as the LiveWindows watches for special sizes which are dialogs. it was easier for me to autodetect them instead of selecting them each one. (instead of size one could do this with title (eg "IE.. download" or a list of ahk_classes)

I've had lots of fun playing with it! Thanks. I found this from the screen capture utility thread. You may have already done it, but it was very simple to add 'wingetactivestats....' and place the resulting variables to get a shot of the active window, instead of the whole screen. Great for getting shots of a gui.

Bob


Hmm, with printwindow you already are limited to your windowsize, if you copy the hdc from the printwindow call directly. making screenshots of offscreen or staying-behind windows. but the wingetactivestats is usefull if grabbing the window directly from desktop-dc without printwindow.

Copying Content with BitBlt or StrechBlt is faster than PrintWindow, as the window is not forced to repaint, as its on foreground already.

you should also try my other scripts like gesture_movewin.ahk, deskman.ahk, magnifier.ahk etc. if you liked this one. (search for holomind in forum)