AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

real expose clone
Goto page Previous  1, 2, 3, 4, 5, 6 ... 15, 16, 17  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Terrapin



Joined: 15 Aug 2005
Posts: 107
Location: North Carolina

PostPosted: Wed Oct 04, 2006 9:39 am    Post subject: Reply with quote

I worked on several ideas for creating a border around the selected window (selected with TAB as in a z-order). I came up with this, but I'm afraid it may slow things down? It is difficult for me to tell how much. I am just checking back since I last posted, so I haven't tried the newer scripts.

I'm just going to post my code, and the only other of mine is one line, right before the timer starts:
Code:
gosub, create_overlay


oops, forgot this, I made the thumbnails slightly smaller. Right after the calculation of the thumbnail size. It also saves the thumbnail sizes for use later.

Code:
      thumb_x_%win_now% := x1
      thumb_y_%win_now% := y1
      thumb_w_%win_now% := thumb_w2
      thumb_h_%win_now% := thumb_h2
      x1+=2
      y1+=2
      thumb_w2-=4
      thumb_h2-=4


Code:
create_overlay:
  gui, 4:Destroy
  gui, 4:+AlwaysOnTop -Caption +ToolWindow
  gui, 4:Color, 0xcccc66
  gui, 4:+LastFound
  WinSet, Region, 0-0 w0 h0
  gui, 4:Show, x0 y0 w%a_ScreenWidth% h%a_ScreenHeight%, ExposeOverLay
  olayID := WinActive()
  i := 1
  SelItem := 1
move_it:
  xx1 := thumb_x_%i%+2
  yy1 := thumb_y_%i%+2
  xx2 := thumb_x_%i%+thumb_w_%i%-4
  yy2 := yy1
  xx3 := thumb_x_%i%+thumb_w_%i%-4
  yy3 := thumb_y_%i%+thumb_h_%i%-4
  xx4 := thumb_x_%i%+2
  yy4 := thumb_y_%i%+thumb_h_%i%-4

  xx6 := thumb_x_%i%
  yy6 := thumb_y_%i%
  xx7 := thumb_x_%i%+thumb_w_%i%
  yy7 := thumb_y_%i%
  xx8 := thumb_x_%i%+thumb_w_%i%
  yy8 := thumb_y_%i%+thumb_h_%i%
  xx9 := thumb_x_%i%
  yy9 := thumb_y_%i%+thumb_h_%i%
  WinSet, Region, %xx1%-%yy1% %xx2%-%yy2% %xx3%-%yy3% %xx4%-%yy4% %xx1%-%yy1% %xx6%-%yy6% %xx7%-%yy7% %xx8%-%yy8% %xx9%-%yy9% %xx6%-%yy6%, ahk_id %olayID%
 
return
 


#IfWinExist, Expose
Tab::
  WinSet, Region, 0-0 w0 h0, ahk_id %olayID%

  SelItem++
  If SelItem > %num_win%
    SelItem := 1
  i := SelItem
  GoSub, move_it 
return 

Enter::
  clicked_on_pic_id := task_ids_%SelItem%
  clicked_on_pic := true
  goto, destroy_gui
#IfWinExist


@Laszlo & all: I did code it once, such that there are simply numbers, above or to the left of each thumbnail. The selected one (by TAB) being turned green, with the others red. I really enjoyed solving this problem of wanting to border the selected thumbnail... not sure if it is worth it or not, as it does not look quite right, due I think to the 3D effect of each window thumbnail.

Thanks,

Bob
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Wed Oct 04, 2006 9:48 am    Post subject: Reply with quote

Are you Bob or are you Terrapin ?
_________________
Back to top
View user's profile Send private message MSN Messenger
Terrapin



Joined: 15 Aug 2005
Posts: 107
Location: North Carolina

PostPosted: Wed Oct 04, 2006 11:28 am    Post subject: Reply with quote

majkinetor:
Quote:
Are you Bob or are you Terrapin ?


Either is fine with me..

Bob
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Wed Oct 04, 2006 12:49 pm    Post subject: Reply with quote

3thd approach

For this AHK will not be enough since I will use system hooks (maybe one day in AHK)

This thing can be made real time if we create thumbnails on TOP LEVEL window activation and destroy them on window close. So, we will have the picture ready for display at any time. This will introduce very low system performance loss cuz of nature of activation but the display part would be instantious.

I didn't find anythihg useful yet for the real time preview of window contest...
_________________
Back to top
View user's profile Send private message MSN Messenger
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Wed Oct 04, 2006 1:15 pm    Post subject: Reply with quote

what about bitblitting or xor-ing a border for the selection. we already have a formular for the coordinates. there are some nice gdi functions we could use to modify the dc (virtual-bitmap) would be a lot faster than winset region i think. also no additional gui is needed. the nice thing with xor is that if you apply the same function twice its reversed to the original state. xor would invert the colors. i you have a small black border around the windows it could be made white ...
or one simpyl draws rectangles with a "brush" (i think msdn calls them this way) and remove it later. or even much cooler simply zoom the window with strechblit (wouldnt be too fast).
i tried a bit to store the dc into a virtual buffer so the thumbnails could be stored until the next show:gui of expose but i didnt manage it yet.
a hard way would be to store the screenshots a real images (bmp/png) and load them back into the gui.

ooh, and some time i need to merge all the changes back into first post. we should use subversion or cvs to work on the same copy in realtime Wink
Back to top
View user's profile Send private message Visit poster's website
Terrapin



Joined: 15 Aug 2005
Posts: 107
Location: North Carolina

PostPosted: Wed Oct 04, 2006 1:21 pm    Post subject: Reply with quote

I have corrected and cleaned up some things in my code, and now the border which shows 'focused' thumbnail looks very cool. I don't think it slows down anything, other than a millisec or so. I'd be happy if someone looked at it. I've been working with the version Da0nlyfreez posted. I think it could be inserted fairly easily into any version.

There are 'phantom' windows, I haven't investigated why, maybe they are excluded, maybe just dropped. But upon activation, the active window is now usually the focused thumbnail. When it is not, I *think* it is due to trying to focus on a thumbnail which does not exist.

Either type of selection (click or press enter) works fine, all the time, as far as I can see. I could add shift-tab... whatever. I may add back the window numbers, but not sure they are necessary.

Thanks for hearing me.

Code:
#SingleInstance force
#NoEnv
SetBatchLines -1
SetWinDelay 0

OnExit handle_exit

; config
fade_delay           = 0    ; msec to wait for next animation frame
fade_steps           = 4    ; steps in animation, 2 = fast, 10 = slow (smooth)
fadeout_steps       = 4
min_w                = 110  ; min width of windows to be shown
min_h                = 110  ; min height of windows to be shown (hides taskbar etc)
trans_color         = #998877
focus_color        = 0xcc6666  ; color of focused thumbnail - must contrast with background
translevel           = 255  ; transparency of end of animation
translevel_start     = 0    ; transparency of start of animation (see offscreen painting)
translevel_stop_solid= 0    ; 0/1 turn off transparency at end of fade_in to hide background
scale_thumb_space    = 1
live_repaint         = 500 ;1000 ; msec repaint the windows in expose mode, 0 = off

;init values
gui_active           = 0    ; gui is hidden at startup
pics_added           = 0    ; onclicks are not yet registered
Return

+F12::
handle_exit:
   Gosub destroy_gui
ExitApp

GuiEscape:
  Goto destroy_gui
Return

!r::Reload

F12::
MButton::
  If gui_active = 1        ; toggle off if already active
    GoTo destroy_gui
  WinGet prev_active_id, id, A
  gui_active = 1           ; show gui
  GoSub calculate_sizes    ; sets "cols" , "rows"
  If (num_win = "" or num_win = 1)  ; do nothing if no active windows
      Return                         ; or only 1
  GoSub create_wall         ; create bgwindow with current wallpaper
  GoSub create_gui         ; prepare gui to draw onto it
  GoSub draw_thumbnails
  GoSub fade_in
  SetTimer draw_thumbnails, %live_repaint%
  GoSub, create_overlay 
Return


create_overlay:
  gui, 4:Destroy
  gui, 4:+AlwaysOnTop -Caption +ToolWindow
  gui, 4:Color, %focus_color%
  gui, 4:+LastFound
  WinSet, Region, 0-0 w0 h0
  gui, 4:Show, x0 y0 w%a_ScreenWidth% h%a_ScreenHeight%
  olayID := WinActive()
  if !SelItem
    SelItem := 1
change_focus: 
  i := SelItem
  xx1 := thumb_x_%i%
  yy1 := thumb_y_%i%
  xx2 := thumb_x_%i%+thumb_w_%i%
  yy2 := yy1
  xx3 := xx2
  yy3 := thumb_y_%i%+thumb_h_%i%
  xx4 := xx1
  yy4 := yy3

  xx6 := xx1-3
  yy6 := yy1-3
  xx7 := xx2+3
  yy7 := yy2-3
  xx8 := xx3+3
  yy8 := yy3+3
  xx9 := xx1-3
  yy9 := yy3+3
  WinSet, Region, %xx1%-%yy1% %xx2%-%yy2% %xx3%-%yy3% %xx4%-%yy4% %xx1%-%yy1% %xx6%-%yy6% %xx7%-%yy7% %xx8%-%yy8% %xx9%-%yy9% %xx6%-%yy6%, ahk_id %olayID%
 
return
 


#IfWinExist, Expose
Tab::
  WinSet, Region, 0-0 w0 h0, ahk_id %olayID%
  SelItem++
  tooltip, SelItem %SelItem%`nnum_win %num_thumbs%
  If ( SelItem > num_thumbs )
    SelItem := 1
  GoSub, change_focus 
return 

Enter::
  clicked_on_pic_id := task_ids_%SelItem%
  clicked_on_pic := true
  goto, destroy_gui
#IfWinExist

create_wall:
  RegRead, wall_path, HKCU, Control Panel\Desktop, Wallpaper
  Gui, 2:Destroy
  Gui, 2:+AlwaysOnTop -Caption
  Gui, 2:Add, Picture, gClickedOnWall x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%
                    , %wall_path%
  Gui, 2:Show, Hide NA x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%
Return

calculate_sizes:
   num_win := get_wins()
   cols := ceil( sqrt( num_win ))
   rows := ceil( sqrt( num_win ))
   If (cols * (rows-1) >= num_win )
       rows--
   thumb_w := A_ScreenWidth  // cols
   thumb_h := A_ScreenHeight // rows
   ratio_of_screen := A_ScreenWidth / A_ScreenHeight * rows / cols
Return

draw_thumbnails:
  pos_x := 0
  pos_y := 0
  win_now := 0
  task_ids =
  Loop %ids%                           ; ids has been set up in calculate_sizes
      task_ids := task_ids "," ids%a_index%
  Sort task_ids, D,                    ; keep positions of thumbnails
  Loop Parse, task_ids, `,
  {
    task_id = %A_LoopField%
    WinGetTitle title, ahk_id %task_id%
    WinGetPos,,, w, h, ahk_id %task_id%
    If (!is_excluded_win() ) {         ; small windows not shown (eg taskbar)
      win_now++
      task_ids_%win_now% := task_id    ; for activation

      If ! SelItem
        if ( task_id = prev_active_id )
          SelItem := win_now


      if !pics_added
         Gui Add, Pic, gActivateWin x%pos_x% y%pos_y% w%thumb_w% h%thumb_h% vPic%win_now% ; register "onclick"
      sleep 10                         ; prevent missing windows
      pwin := DllCall("PrintWindow", UInt,task_id, UInt,hdc_buffer, UInt,0)

      ratio_of_win := w / h

      if ( scale_thumb_space  )  {
         if ( ratio_of_win < ratio_of_screen ) {   ; tall window
            thumb_h2 := thumb_h
            thumb_w2 := thumb_w * ratio_of_win  / ratio_of_screen
         } Else {                                  ; wide window
            thumb_w2 := thumb_w
            thumb_h2 := thumb_h / ratio_of_win  * ratio_of_screen
         }
      }
      x1 := pos_x + (thumb_w - thumb_w2 ) / 2
      y1 := pos_y + (thumb_h - thumb_h2 ) / 2
     

      x1+=2
      y1+=2
      thumb_w2-=4
      thumb_h2-=4
      thumb_x_%win_now% := x1
      thumb_y_%win_now% := y1
      thumb_w_%win_now% := thumb_w2
      thumb_h_%win_now% := thumb_h2

     
     
     
      DllCall("gdi32.dll\StretchBlt"
                          , UInt, hdc_frame
                          , Int, x1
                          , Int, y1
                          , Int, thumb_w2
                          , Int, thumb_h2
                          , UInt, hdc_buffer
                          , Int, 0
                          , Int, 0
                          , Int, w
                          , Int, h
                          , UInt, 0xCC0020) ; SRCCOPY
                         


      pos_x += thumb_w
      if ( pos_x >= A_ScreenWidth ) {
         pos_x :=0
         pos_y += thumb_h
      }
    } ; If !excluded
  } ; Loop task_ids
  pics_added := 1
  num_thumbs := win_now ; cannot find this anywhere else just now
Return

is_excluded_win() {
   Global
   Return w < min_w or h < min_h or title ="Expose" or title =""
}

fade_in:
   Loop %fade_steps%  {
    intrans := A_Index * translevel / fade_steps
     WinSet, TransColor, %trans_color% %intrans%, ahk_id %hw_frame%
    Sleep %fade_delay%
   }
   If translevel_stop_solid
      WinSet Transparent, off
  intrans =
Return

fade_out:
   Loop %fadeout_steps%  {
      outtrans := translevel - A_Index * translevel / fadeout_steps
      WinSet, TransColor, %trans_color% %outtrans%, ahk_id %hw_frame%
      Sleep %fade_delay%
   }
   outtrans =
Return

get_wins() {
   Local x
   WinGet ids, list,,,Program Manager     ; all active windows-tasks (processes)
   Loop %ids% {
     task_id := ids%a_index%               ; id of this window
     WinGetTitle title, ahk_id %task_id%
     WinGetPos,,, w, h, ahk_id %task_id%
     If !is_excluded_win()                ; small windows not shown (eg taskbar)
       x++
   }
   Return x
}

; *** Create Expose Gui
create_gui:
  Gui Destroy   ; clear old stuff if expose hotkey is running in background
  Gui +AlwaysOnTop +LastFound
  Gui Color, %trans_color%, 0xcc4444
  WinSet, TransColor, %trans_color%
  Gui -Caption
  WinSet, Transparent, %translevel_start%
  Gui Show, w%A_ScreenWidth% h%A_ScreenHeight% x0 y0, Expose
  WinGet hw_frame, id, Expose

  hdc_frame := DllCall( "GetDC"
                        , UInt, hw_frame )

  DllCall( "gdi32.dll\SetStretchBltMode"
                        , "uint", hdc_frame
                        , "int", 4 ) ; Halftone better quality with stretch

  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)

  pics_added := 0
Return


; *** Actions on selection made
; on click on picture
ActivateWin:
  StringReplace pos, A_GuiControl, Pic    ; find the clicked pic-id
  clicked_on_pic_id := task_ids_%pos%
  clicked_on_pic = true
; -- continue
 
; on click on wallpaper
ClickedOnWall:
  WinActivate, ahk_id %hw_frame%
; -- continue

; fade out
destroy_gui:
  SetTimer draw_thumbnails, OFF
  Gui, 4:Destroy
  GoSub fade_out
  Gui, 2:Destroy
  Gui, 1:Destroy
  gui_active := 0
  pics_added := 0
  DllCall("gdi32.dll\DeleteObject", UInt,hbm_buffer)
  DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame )
  DllCall("gdi32.dll\DeleteDC", UInt,hdc_buffer)
  If clicked_on_pic_id != "" and if clicked_on_pic = true
    WinActivate ahk_id %clicked_on_pic_id%
  Else
    WinActivate ahk_id %prev_active_id%
  SelItem              = 0    ; prepare to show focus   
  clicked_on_pic_id =
  clicked_on_pic = false
Return
; /*** Actions on selection made
Back to top
View user's profile Send private message
SanskritFritz



Joined: 17 Feb 2005
Posts: 283
Location: Hungary, Budapest

PostPosted: Wed Oct 04, 2006 1:30 pm    Post subject: Reply with quote

Code:
#IfWinExist, Expose
... drove me crazy, as i had the file open in my editor, so even after hiding expose i had a window with that name, successfully rendering my enter and tab and leftclick unusable...
_________________
Is there another word for synonym?
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Wed Oct 04, 2006 1:38 pm    Post subject: Reply with quote

Quote:
what about bitblitting or xor-ing a border for the selection. we already have a formular for the coordinates. there are some nice gdi functions we could use to modify the dc (virtual-bitmap) would be a lot faster than winset region i think.

Of course, this will be done with no additional GUis or whatsoever.

Anayway, there are number of potential bug places, like the one Sans disocovered. If you people still want to extend this ideas with some nice features, you can do it, but I will rewrite entire code anyway, add setup gui, add exclusions, speed up some things a little etc...

So, I will add this functions for final script
- Highlighting via surrounding rectangle
- Selecting via keyboard and tracking selection via mouse
- Titles bellow windows
- Setup - all the thing currently set as options + some more, like hotkeys etc..
- Better window handling (small windows are enlargen now, some windows are dropped, list of all windows obtained is not very nice etc...)
- Mergable script (to avoid starting AHK for it)


So if you would like to continue your examinations you should do it on some different plane not already taken into account. Otherwise, we will do the same thing.
_________________
Back to top
View user's profile Send private message MSN Messenger
Laszlo



Joined: 14 Feb 2005
Posts: 4065
Location: Pittsburgh

PostPosted: Wed Oct 04, 2006 3:45 pm    Post subject: Reply with quote

SanskritFritz wrote:
For me it simply disables my mouse left clicks!
If you have the latest AHK, this could happen, if you have another matching window, with a title starting "Expose". Since our window title is not visible, change it to something like "»Expose«", which less likely conflicts with other titles.

majkinetor wrote:
I have all kind of artifacts on the screen sometimes
Cursor in editor is also frozen after usage... strange indeed...
Try to minimize and restore the affected window. If it helps, the WinDelay value should be increased, or WinActivate be replaced with WinMinimize followed by WinRestore; or WinMove; etc., which forces a redraw of the window.
Back to top
View user's profile Send private message
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Wed Oct 04, 2006 5:47 pm    Post subject: Reply with quote

the artefacts only come from the usage of printwindow() which we use in a very fast way. perhaps also the time when the dc is relased has some effects. i noticed bigger artefacts in IE und FF in their browser renering engine, also i get more black frames when i use topdesk at the same time as this programm grabbs some printwindows at the same time ?!
grabbing the frontwindow with bitblt never gave me artefacts. perhaps its internal with the way windows-os refreshes windows. and if you just a second before painted it with printwindow() it believes there is no need to repaint again (but it was another user/gui Wink

in terms of speed there is a noticable difference in using strechblt with antializing or not. but without antializing the quality is below usable. as this is all bits and bytes i thought if it would be faster if strechblt is a fracton of the screen like half, quarter etc. would this be faster than odd numbers like 5 ?

the idea to draw all thumbnails on an uber-big screen and then resize them all at once sound nice, but as much as i understand the gdi documentation bitblt only works on the visible screen, so you also cant make a screenshot from printwindow which is bigger than your screen (monitorsize). i hope i am wrong because then i could build some nice virtual-destop manager etc.

my plan is to extract the core gdi calls into a library and make then easy to use. so one could build something like expose, deskman, lifewindows, screenshot (a portion) to bmp or thumbnail, etc. without knowing the bits and bytes of gdi and msdn. ... i like to have a core engine which takes the thumbnails in regular intervalls and buffers them and then one can use this dc-buffers when needed to build some fancy things which are announced for windows-vista or os/x. also i like to find a way to use opengl or directx in a similar way i use gdi now, and do some animations. i know there are basic lanuages out there allowing easy access to directx. but i like to do it directly. for some simple effects. (not programming games, but litte ahk-tools...) eg. screenshot from video with help of direct-x etc.
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4065
Location: Pittsburgh

PostPosted: Wed Oct 04, 2006 5:59 pm    Post subject: Reply with quote

I found a potential problem: the original script first activated the selected window and only closed the GUI afterwards. It is safer to do it the other way. I could reduce WinDelay to 0 this way, and still got stable behavior. The slight speed improvement is probably not noticeable, but in my PC the script is stable.
Code:
; Thumbnails of windows in full screen table

#SingleInstance Force
#NoEnv
SetBatchLines -1
SetWinDelay 0               ; larger values also fail under heavy load, changing windows
Process Priority,,High

OnExit handle_exit
fade_delay           = 0    ; msec to wait for next animation frame
fade_steps           = 30   ; steps in animation, 1 = crude, 30 = slow (smooth)
min_w                = 110  ; min width of windows to be shown
min_h                = 110  ; min height of windows to be shown (hides taskbar etc)
translevel           = 240  ; transparency at end of animation
translevel_start     = 100  ; transparency at start of animation
scale_thumb_space    = 0    ; scale thumbnail to fit box?
live_repaint         = 1000 ; msec repaint thumbnails, = OFF turns it off
BackGroundColor      = 004E98
Return

#TAB::                      ; WIN-TAB hotkey (~ Alt-TAB)
MButton::
   IfWinExist »Expose«      ; toggle off if already active
      GoTo destroy_gui
   GoSub create_gui         ; prepare gui to draw onto it
   GoSub win_list           ; list window IDs, sizes, etc.
   GoSub draw_thumbnails
   GoSub fade_in
   SetTimer draw_thumbnails, %live_repaint%
Return

win_list:
   WinGet ids, list,,,Program Manager      ; all active windows-tasks (processes)
   task_info =
   num_win = 0
   Loop %ids% {
      task_id := ids%A_Index%              ; id of this window
      WinGetTitle title, ahk_id %task_id%
      WinGetPos,,, w, h, ahk_id %task_id%
      If is_excluded_win()                 ; small windows not shown (eg taskbar)
         Continue
      num_win++
      task_info := task_info ids%A_Index% "|" w "|" h ","
   }
   StringTrimRight task_info, task_info, 1
   Sort task_info, D,                      ; keep positions of thumbnails
   cols := ceil(sqrt(num_win))
   rows := ceil(sqrt(num_win))
   If (cols*(rows-1) >= num_win)
       rows--
   thumb_w := A_ScreenWidth  // cols
   thumb_h := A_ScreenHeight // rows
   ratio_of_screen := A_ScreenWidth / A_ScreenHeight * rows / cols
   Loop Parse, task_info, `,               ; task_info contains only windows to be drawn
   {
      StringSplit z, A_LoopField, |
      task_ids_%A_Index% := z1             ; for activation
      w%A_Index% := z2                     ; w
      h%A_Index% := z3                     ; h
      ratio_of_win := z2 / z3              ; w/h
      If ( scale_thumb_space )  {
         If (ratio_of_win < ratio_of_screen) { ; tall window
            thumb_h%A_Index% := thumb_h
            thumb_w%A_Index% := thumb_w * ratio_of_win / ratio_of_screen
         } Else {                              ; wide window
            thumb_w%A_Index% := thumb_w
            thumb_h%A_Index% := thumb_h / ratio_of_win * ratio_of_screen
         }
      } Else {
         thumb_w%A_Index% := z2 / cols
         thumb_h%A_Index% := z3 / cols     ; cols >= rows, keep aspect ratio of window
      }
   }
Return

draw_thumbnails:
   pos_x = 0
   pos_y = 0
   Loop %num_win%  {                       ; task_ids, dims have been set up in win_list
      pwin := DllCall("PrintWindow", UInt,task_ids_%A_Index%, UInt,hdc_buffer, UInt,0)
      DllCall("gdi32.dll\StretchBlt", UInt,hdc_frame
             , Int,pos_x + (thumb_w - thumb_w%A_Index% ) / 2
             , Int,pos_y + (thumb_h - thumb_h%A_Index% ) / 2
             , Int,thumb_w%A_Index%,  Int,thumb_h%A_Index%
             , UInt,hdc_buffer, Int,0, Int,0, Int,w%A_Index%, Int,h%A_Index% ,UInt,0xCC0020) ; SRCCOPY
      pos_x += thumb_w
      if (pos_x > A_ScreenWidth-9) {
         pos_x :=0
         pos_y += thumb_h
      }
   }
Return

is_excluded_win() {
   Global
   Return w < min_w or h < min_h or title ="»Expose«" or title =""
}

fade_in:                                   ; from translevel_start to translevel
   Loop %fade_steps%  {
      WinSet Transparent, % A_Index/fade_steps*(translevel-translevel_start) + translevel_start
      Sleep %fade_delay%
   }
Return

fade_out:                                  ; from translevel to 0
   Loop %fade_steps%  {
      WinSet Transparent, % translevel - A_Index / fade_steps * translevel
      Sleep %fade_delay%
   }
Return

create_gui:
   Gui +AlwaysOnTop -Caption +LastFound
   Gui Color, %BackGroundColor%
   WinSet Transparent, %translevel_start%
   Gui Show, w%A_ScreenWidth% h%A_ScreenHeight% x0 y0, »Expose«

   WinGet hw_frame, id, »Expose«
   hdc_frame := DllCall("GetDC", UInt,hw_frame)
   DllCall("gdi32.dll\SetStretchBltMode", UInt,hdc_frame, "int",4) ; Halftone better quality with stretch
   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)
Return

#IfWinExist »Expose«
LButton::
   MouseGetPos X, Y
   GoSub destroy_gui
   pos := 1 + X*cols//A_ScreenWidth + Y*rows//A_ScreenHeight * cols
   task_id := task_ids_%pos%
   If (pos <= num_win)
      WinActivate ahk_id %task_id%
Return

Esc::
destroy_gui:
   SetTimer draw_thumbnails, OFF
   Gosub fade_out
   Gui Destroy
   DllCall("gdi32.dll\DeleteObject", UInt,hbm_buffer)
   DllCall("gdi32.dll\DeleteDC", UInt,hdc_frame )
   DllCall("gdi32.dll\DeleteDC", UInt,hdc_buffer)
Return

handle_exit:
   Gosub destroy_gui
ExitApp

Edit 20061005:
- background color can be set in the settings
- fixed fade-in


Last edited by Laszlo on Thu Oct 05, 2006 5:22 pm; edited 1 time in total
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Wed Oct 04, 2006 6:20 pm    Post subject: Reply with quote

yes, that might be the problem.
Also, we can call InvalidateWindow after instead to minimize and restore the affected window, so really no problem with this...
Also, no problem with "expose" title (pointed by Sans), since gui hwnd will be used instead.

I think that shrinking after aranging all will lead to noticable speed improvement. I really don't know if windows can be screenshoted if they are out but I have positive experience with IE window. In my application HtmlToImage I succesifully converted html page to image, without restrictions on screen size... for instance, if page was 100 pages long, you would get 100MB "long bitmap"... The only problem is that I was using COM to get this. I was simply tellilng IE to give me desired rect of his DC without restrictions of any kind...

I beleive this is possible anyway...
_________________
Back to top
View user's profile Send private message MSN Messenger
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Thu Oct 05, 2006 10:51 am    Post subject: Reply with quote

@lazlo: i put your latest version into the first post, also the downloadable expose.ahk is the latest version.

@majkinetor: sounds good if bitblt / dc is not limited by screensize, this would give many new posibilites for new applications. hopefully this is only limited by the memory of your graphicscard. i guess dc is not stored in real memory by directly in gfx-card and hardware accellerated.

one way to "store" the images would be to paint them "offscreen" on the big dc and copy them to the visible area with bitblt or strechblt when needed. they could be stored in minimized version already so one can use bitblt instead of strechblit which is much faster.

also this would allow first experiments with animating the windows and slide them in and out. having the backbuffer in the invisible region of the dc.
animations should be possible as i manage to get 10 or more frames per second using my magnifier which constantly copyies the window with bitblt, so animatig the windows and sliding them with about 5 frames / sec would be possible even without directx. (is quite cpu intensive and directx would be faster i quess) as i have a shared memory card (intel-notebook) i cant decide between cpu und gfx-cpu (gpu) also memory -usage is shared. so if you have "real" grahics card like ati it might be different.
Back to top
View user's profile Send private message Visit poster's website
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Thu Oct 05, 2006 10:57 am    Post subject: Reply with quote

majkinetor wrote:
The only problem is that I was using COM to get this. I was simply tellilng IE to give me desired rect of his DC without restrictions of any kind...

is there a big difference beween com-object and dll ? can a com object called with a "DLLCALL ..." ? or could one compile a com into dll ? dont know much about this.
sounds this would be an easy way to take a screenshot of your whole page like some more advanced screenshot tools can do.
seems IE uses a backbuffer for rendering the page and only displays a part of it with bringing it to visible area with bitblt ? (only guessing)
could you share some lines of code about the com-call, so i get a better idea how to use it/understand it. eg. 10lines before and after your com-call of your c++ code ?
Back to top
View user's profile Send private message Visit poster's website
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Thu Oct 05, 2006 11:00 am    Post subject: Reply with quote

Looking at laszlos code

Code:

fade_delay           = 0    ; msec to wait for next animation frame
fade_steps           = 1


should we remove the fade_in / fade_out part ? as its not used.
and simply apply transparency once when needed ?
would also make the code shorter and perhaps easier to read.
(i think lazlo is happy if he can delete some lines of code Wink
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6 ... 15, 16, 17  Next
Page 5 of 17

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group