Jump to content

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

Thumbnail window switcher


  • Please log in to reply
12 replies to this topic
balabas
  • Members
  • 2 posts
  • Last active: Feb 07 2013 09:08 PM
  • Joined: 05 Jan 2013

This window switcher may be usefull if you need to switch between many windows using thumbnails with permanent position (unlike default window switcher by Alt+Tab)
 
This program creates thumbnail for each visible window, hides task bar (not system tray).Window activates by clicking thumbnail (or move mouse).
To show or hide thumbnails, touch bottom of screen (or press lmb taskbar and move along it, I use it on touchscreen), to hide - touch top of screen. Also, thumbnails can be dragged by LMB.
 
right click (or ctrl) on thumbnail to switch 'specfication window position' mode. After that, specify 1-st and 2-nd window corners, or press Esc or RMB
double click on thumbnail to hide thumbnails
press 'delete' on thumbnail - to try close window
press 'alt' on thumbnail - to switch activation mode. (activation on click or activation on mouse move)
 
Tested in win XP,win 7,win 8 CP
 
sorry for my English
download:
-script:

(required Gdip.ahk)
-compiled:
http://atc101.narod....winswithcer.rar
 
I'll be glad to any improvements
 
shot.JPG



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

looks cool, i like the screenshot 



vsub
  • Members
  • 1098 posts
  • Last active: Sep 28 2015 09:48 AM
  • Joined: 10 Nov 2011

Hi,it's a nice script but I have a little problem with it(WinXp SP3)

 

If the last active window was the desktop,clicking on any of the windows,when the script tries to recreate the preview for the desktop,everything or almost everything disappear(drawing problem).

Moving the mouse around or switching to another window will make some thing to be visible again but to completely fix it,i have to run anything in full screen(for example F11 in firefox).

 

I have another similar program called VisualTaskTips which behaves the same way but only in certain conditions.



Arcanist
  • Members
  • 27 posts
  • Last active: Jan 27 2018 08:46 AM
  • Joined: 10 Mar 2014

Wow. That must have taken a lot of work. I prefer my own way of switching windows though. I have Win + 1, Win + 2, Win + 3 and Win + 4 bound to the side of my Razer Naga (a mouse with 12 buttons on the side). Win + a number switches to a window in the task bar.

 

I like this because I don't have to click with the mouse to change windows. A limitation is that if I've got more than one of the same window open, I have to click with the mouse. I only use 4 of these because the rest of my buttons are taken up. More can be used



Skrell
  • Members
  • 384 posts
  • Last active: Jul 07 2016 05:03 PM
  • Joined: 23 Aug 2011

this looks VERY impressive!! Many many thanks!!!



scriptor
  • Members
  • 668 posts
  • Last active: Feb 15 2016 01:02 AM
  • Joined: 20 Jun 2013

bump this old thread... does anyone have this working?



gregster
  • Members
  • 283 posts
  • Last active: Nov 09 2015 03:08 AM
  • Joined: 19 Mar 2009

bump this old thread... does anyone have this working?

 

Couldn't find the proc.ahk to include. But after commenting that #include-line out, it seems to work (shows thumbnails, moving mouse to the borders hides and shows them). OP doesn't mention it, anyway. So it's probably not directly related to the functionality of this script. (Of course, gdip.ahk you'll still have to include).

 

But I just tested it for a minute, so far.

Tested with v1.1.22.03 64-bit Unicode on Win7 64bit.
 

EDIT: Correction. It messed up my tray. Now taskbar buttons are missing. So better be careful!! Have to see how I can reverse this...!

 

EDIT2: Everything OK. after ending the script, the buttons came back. ;-) These were the programs it shows as thumbnails, instead. Looks cool, so far. Could really be useful. Seems to work as advertized with all functions mentioned in the original post. Only the "sticky" quick launch buttons on the taskbar are missing, while the script is running. Not optimal, but might be fixable in the script. (I would prefer if it would leave the quick launch buttons alone...)



GEV
  • Members
  • 1364 posts
  • Last active:
  • Joined: 23 Oct 2013

This seems to work (I downloaded and modified it a little some time ago, I can't remember how).

#SingleInstance Force
#MaxThreads
#Persistent

setwindelay, -1
Process Priority,,R
SetBatchLines -1
cr_ACTIVE_MARKER()
pt:=object()
Menu, tray, NoStandard
Menu, tray, add, About, About
Menu, tray, add, exit, exit
Menu, tray, add, settings, sett_ini
messages:=object()
messages["rus","WSP2"]:="укажите 1-ый угол окна и нажмите CTRL, ЛКМ; или Esc"
messages["rus","WSP1"]:="укажите 2-ой угол окна  и нажмите CTRL, ЛКМ; или Esc"
messages["rus","SettDo_scredr2"]:="попытка убрать артефакты (если есть)"
messages["rus","SettAon"]:="активация при наведении (иначе при нажантии)"
messages["rus","SettSwitch_on_TB"]:="скрывать/показывать миниаюры при наведении мыши на панель задач в режиме активации при нажатии"
messages["rus","SettPause"]:="ожидание перед скрытием/показом"
messages["rus","About"]:="Эта программа предназначена для завата власти над миром агентами госдепа!!!"
messages["rus","ACTONCLICK"]:="активация окна при нажатии кнопки мыши"
messages["rus","ACTONMouseOn"]:="актиация окна при наведении мыши"
messages["eng","WSP2"]:="point 1-st corner of window by pressing CTRL, left mouse; or Esc"
messages["eng","WSP1"]:="point 2-nd corner of window by pressing CTRL, left mouse; or Esc"
messages["eng","SettDo_scredr2"]:="try to fix something"
messages["eng","SettAon"]:="activate window on cursor above thumbnail (else activate window on click thumbnail)"
messages["eng","SettSwitch_on_TB"]:="show/hide thubnails if cursor above taskbar in mode 'activate window on cursor above thumbnail'"
messages["eng","SettPause"]:="pause before show/hide thumbnails"
messages["eng","About"]:=":)"
messages["eng","ACTONCLICK"]:="activate window on click"
messages["eng","ACTONMouseOn"]:="activate window on cursor above thumbnail"
WINAFTERMINALLSTATE:=object()
WINGEOM:=object()
TVSt:=True
WINSETPOST:=0
RESTORABLE_WINDOWS:=object()
props:=file_to_arr("settings.ini")
if not (props.haskey("lang"))
{
props["lang"]:="eng"
gui, SeLL:new
Gui, SeLL:Add, text,, Select language:
Gui, SeLL:Add, ListBox, vListbox
GuiControl, SeLL:, Listbox, eng|rus
Gui, SeLL:show,,Lauguage selection
Gui, SeLL:+hwndhSell
GuiControl, SeLL:Choose, Listbox, 1
WinWaitclose ahk_id %hSell%
Gui, SeLL:Submit, NoHide
props["lang"]:=Listbox
gui, SeLL:destroy
msgbox to reset this choose delete file 'settings.ini'
}
UNWATCHED_USER_PROCESSES:=file_to_arr("UUP.list")
UNWATCHED_USER_CLASSES:=file_to_arr("UUC.list")
UNWATCHED_USER_CLASSES["AutoHotkeyGUI"]:=1
UNWATCHED_USER_CLASSES["tooltips_class32"]:=1
UNWATCHED_USER_PROCS:=object()
UNWATCHED_USER_PROCS["ccc.exe"]:=1
ACTWINTRANS:="OFF"
THUMBSIZES:=object()
wait_im_update:=object()
KeyST:=object()
ini_arr(cur_winds)
ini_arr(prev_winds)
ini_arr(THUMB_DATA)
dbl_click_timer_wait:=false
WS_EX_CONTROLPARENT =0x10000
WS_EX_DLGMODALFRAME =0x1
WS_CLIPCHILDREN =0x2000000
WS_EX_APPWINDOW =0x40000
WS_EX_TOOLWINDOW =0x80
WS_DISABLED =0x8000000
WS_VSCROLL =0x200000
WS_POPUP =0x80000000
WS_VISIBLE = 0x10000000
EMPTY_TITLE:=""
BORD:=10
UNWATCHED_TITLES:=object()
a=Меню "Пуск"
UNWATCHED_TITLES[a]:=1
a=Пуск
UNWATCHED_TITLES[a]:=1
UNWATCHED_PROCS:=object()
UNWATCHED_PROCS["ccc.exe"]:=1
UNWATCHED_CLASSES:=object()
UNWATCHED_CLASSES["Progman"]:=1
UNWATCHED_CLASSES["tooltips_class32"]:=1
UNWATCHED_CLASSES["Button"]:=1
UNWATCHED_CLASSES["Shell_TrayWnd"]:=1
UNWATCHED_CLASSES["DV2ControlHost"]:=1
UNWATCHED_CLASSES["BasicWindow"]:=1
UNWATCHED_CLASSES["SideBar_HTMLHostWindow"]:=1
UNWATCHED_CLASSES["#32770"]:=1
UNWATCHED_CLASSES["IPTip_AutoHide_Window"]:=1
UNWATCHED_CLASSES["SysShadow"]:=1
UNWATCHED_CLASSES["Static"]:=1
UNWATCHED_CLASSES["OnScreen Display Window"]:=1
UNWATCHED_CLASSES["Desktop User Picture"]:=1
UNWATCHED_CLASSES["UIHubMouseHiderWindowClass"]:=1
UNWATCHED_CLASSES["TaskSwitcherWnd"]:=1
HiddenthumbnailShow:=1
CATHCH_ALL_WIND:=1
default_val(props,"ACTIVATE_ON_MOUSE_ON",0)
default_val(props,"wait1",0)
props["THUMB_WIDTH"]:= round(A_ScreenWidth/10,0)
if A_OSVersion in WIN_XP
{
default_val(props,"do_scredr",true)
default_val(props,"do_scredr2",false)
}
else
{
default_val(props,"do_scredr",false)
default_val(props,"do_scredr2",false)
}
default_val(props,"switch_on_TB_if_ActOnCl",false)
CoordMode Mouse, Screen
SysGet MonitorLimit, Monitor
calc_THUMB_HEIGHT(props["THUMB_WIDTH"])
calc_act_bord()
pToken := Gdip_Startup()
onexit exit
WinExist("ahk_class Shell_TrayWnd")
Control, hide,, MSTaskListWClass1
Control, hide,, MSTaskSwWClass1
Control, hide,, TrayShowDesktopButtonWClass1
arr_wind:=get_all_winds()
for n,id in arr_wind
{
WinGetClass, Class, ahk_id %id%
If (Class="Progman")
{
arr_wind:=object()
arr_wind.insert(id)
if (TVSt_pr<>TVSt)
{
if (TVSt=true)
{
TVStCh:=1
}
else
{
TVStCh:=-1
}
}
else
{
TVStCh:=0
}
gosub first_wind
}
}
SetTimer , wacth_wind_appearance, 100
SetTimer , wacth_mouse, 1
settimer, upd_image_wait, 100
do_scredr2:=props["do_scredr"]
scredr()
sleep 3000
do_scredr2:=props["do_scredr2"]
return
-------------------------------------
default_val(arr,key,val)
{
if not (arr.haskey(key))
{
arr[key]:=val
}
}
------------------------------------------------------------------------------------------
dbl_click_timer:
dbl_click_timer_wait:=false
return
------------------------------------------------------------------------------------------
About:
Gui, About:New
Gui, About:Add, text,, % messages[props["lang"],"About"]
Gui About:Show
return
scredr()
{
global hredr,do_scredr2
if A_OSVersion in WIN_XP
{
if (do_scredr2=true)
{
Gui, Redra:New
Gui Redra:+ToolWindow +hwndHRedr
Gui Redra:Show ,x0 y0 w3000 h2000 NoActivate
Gui Redra:Hide
}
}
}
cr_ACTIVE_MARKER()
{
global ACTIVE_MARKER
Gui, AM:New
Gui AM:+ToolWindow +hwndACTIVE_MARKER +AlwaysOnTop -Caption +0x40000
COLOR:= 0x0000FF
Gui, AM: Color, % COLOR
Gui AM:Show ,x-100 y-100 w0 h0 NoActivate
WinSet, ExStyle, +0x00000020,ahk_id %ACTIVE_MARKER%
WinSet, Transparent, % 140,ahk_id %ACTIVE_MARKER%
}
------------------------------------------------------------------------------------------
sett_ini:
global props,SettDo_scredr2,SettAon,SettPause
Gui, Sett:New
Gui, Sett:+LabelSett_On
Gui, Sett:Add, Checkbox, vSettDo_scredr2, % messages[props["lang"],"SettDo_scredr2"]
Gui, Sett:Add, Checkbox, vSettAon, % messages[props["lang"],"SettAon"]
Gui, Sett:Add, Checkbox, vSettSwitch_on_TB, % messages[props["lang"],"SettSwitch_on_TB"]
Gui, Sett:Add, text,, % messages[props["lang"],"SettPause"]
Gui, Sett:Add, edit, w40 vSettPause, % props["wait1"]
GuiControl, Sett:,SettDo_scredr2, % do_scredr2
GuiControl, Sett:,SettAon, % props["ACTIVATE_ON_MOUSE_ON"]
GuiControl, Sett:,SettSwitch_on_TB, % props["switch_on_TB_if_ActOnCl"]
Gui, Sett:Submit, NoHide
Gui Sett:Show , ,Settings
return
------------------------------------------------------------------------------------------
Sett_OnClose:
Gui, Sett:Submit, NoHide
if (Settdo_scredr2=1)
do_scredr2:=true
else
do_scredr2:=false
props["do_scredr2"]:=do_scredr2
props["ACTIVATE_ON_MOUSE_ON"]:=SettAon
props["wait1"]:=SettPause
props["switch_on_TB_if_ActOnCl"]:=SettSwitch_on_TB
Gui Sett:hide
calc_act_bord()
return
------------------------------------------------------------------------------------------
wacth_mouse:
px:=x
py:=y
MouseGetPos x, y,wind,contr
updkeyst()
if (WINSETPOST=False)
{
if haskeykey(THUMB_DATA,"_" . wind,"Root")
{
root_win_:=THUMB_DATA["_" . wind,"Root"]
WinGetPos,tx,ty,tw,th,ahk_id %wind%
tooltip % gwt(root_win_)
if (MOVE_ST=False) and (RES_ST=False)
{
if (KeyST["lButton","Ch"]="D")
{
if (x<tx-bord) or (y<ty-bord) or (x>tx+tw-bord) or (y>ty+th-bord)
{
RES_ST:=True
}
else
{
if (props["ACTIVATE_ON_MOUSE_ON"]=0)
{
if !(dbl_click_timer_wait)
{
px:=x
py:=y
MOVE_ST:=True
MOVE_win:=wind
dbl_click_timer_wait:=true
SetTimer , dbl_click_timer, 300
}
else
{
if (MOVE_ST=False) and (RES_ST=False)
{
}
tvst:=false
}
}
else
{
tvst:=false
}
}
}
if (KeyST["MButton","Ch"]="D")
{
switch_AON()
}
}
if (KeyST["RCtrl","Ch"]="D" or KeyST["LCtrl","Ch"]="D" or KeyST["RButton","Ch"]="D")
{
WINSETPOST:=1
GEST_ST:=0
MOVE_ST:=False
RES_ST:=False
MOVE_win2:=THUMB_DATA["_" . root_win_,"thumbnailcreatable_win"]
tvst:=false
Gui, blank:New
Gui blank:+Toolwindow -Caption +hwndhBlank +AlwaysOnTop
COLOR:= 0x800000
Gui, blank: Color, % COLOR
Gui, blank:Show, x0 y0 w%A_Screenwidth% h%A_Screenheight%
WinSet, Transparent, % 50, ahk_id %hBlank%
}
if (KeyST["Delete","Ch"]="D")
{
WinClose ahk_id %root_win_%
}
if (props["ACTIVATE_ON_MOUSE_ON"]=1)
{
if (MOVE_ST=False) and (RES_ST=False)
{
window_activate(root_win_)
}
}
if (th<>thumb_height)
{
winmove,ahk_id %wind%,,,,,thumb_height
}
if (tw<>thumb_width)
{
winmove,ahk_id %wind%,,,,thumb_width
}
}
else
{
tooltip
if  (props["ACTIVATE_ON_MOUSE_ON"]=1) or ((props["ACTIVATE_ON_MOUSE_ON"]=0) and (props["switch_on_TB_if_ActOnCl"]=false))
{
if (MOVE_ST=False) and (RES_ST=False)
{
if (gwc(wind)="Shell_TrayWnd")
{
if (contr="ReBarWindow321")
{
if (GEST_ST=0)
{
if (KeyST["lButton","Ch"]="D")
{
GEST_ST:=1
gestart_x:=x
gestart_y:=y
}
}
}
}
}
if (GEST_ST=1)
{
if (TASK_BAR_WIDTH=A_ScreenWidth)
{
dist:=abs(gestart_x-x)
}
else
{
dist:=abs(gestart_y-y)
}
if (dist>15)
{
GEST_ST:=-1
gosub toggle_ShowHide
}
}
}
}
critical
if (KeyST["lButton","C"]="U")
{
if (KeyST["lButton","Ch"]="U")
{
upd_pos(MOVE_win)
mark_actwin(MOVE_win)
}
GEST_ST:=0
MOVE_ST:=False
RES_ST:=False
MOVE_win=
}
if (MOVE_ST)
{
dx:=x-px
dy:=y-py
if (dx<>0) or (dy<>0)
{
WinGetPos,wx,wy,,,ahk_id %MOVE_win%
winmove,ahk_id %MOVE_win%,,wx+dx,wy+dy
mark_actwin(MOVE_win)
}
}
}
else
{
WinGetPos,nx,ny,nw,nh,ahk_class Shell_TrayWnd
minmax_(nx,ny,nw,nh, nmin, nmax)
if (KeyST["Esc","Ch"]="D" or KeyST["RButton","Ch"]="D")
{
WINSETPOST:=0
window_activate2(MOVE_win2,true)
Gui, blank:hide
}
if (WINSETPOST=2)
{
tooltip % messages[props["lang"],"WSP1"]
p2x:=x
p2y:=y
pt[0]:=p2x
pt[1]:=p2y
if (is_inside_BB_2d_pt(nmin, nmax,pt))
{
cr_TB_pt(p2x,p2y)
}
if (p1x<p2x)
{
sp2x:=p2x
sp1x:=p1x
}
else
{
sp2x:=p1x
sp1x:=p2x
}
if (p1y<p2y)
{
sp2y:=p2y
sp1y:=p1y
}
else
{
sp2y:=p1y
sp1y:=p2y
}
winmove,ahk_id %MOVE_win2%,,sp1x,sp1y,sp2x-sp1x,sp2y-sp1y
if (KeyST["RCtrl","Ch"]="D" or KeyST["LCtrl","Ch"]="D" or KeyST["lButton","Ch"]="D")
{
WINSETPOST:=0
WinSet, AlwaysOnTop,Off, ahk_id %MOVE_win2%
window_activate2(MOVE_win2,true)
Gui, blank:hide
}
}
if (WINSETPOST=1)
{
tooltip % messages[props["lang"],"WSP2"]
if (KeyST["RCtrl","Ch"]="D" or KeyST["LCtrl","Ch"]="D" or KeyST["lButton","Ch"]="D")
{
p1x:=x
p1y:=y
WINSETPOST:=2
pt[0]:=p1x
pt[1]:=p1y
if (is_inside_BB_2d_pt(nmin, nmax,pt))
{
cr_TB_pt(p1x,p1y)
}
if (WinGetMinMaxState(MOVE_win2)=1)
{
WinRestore, ahk_id %MOVE_win2%
}
WinSet, AlwaysOnTop,On, ahk_id %MOVE_win2%
}
}
}
critical, off
if (WINSETPOST=0)
{
if (y>ACT_LIM_BOTT)
{
ON_BOTT_Act:=true
}
else
{
ON_BOTT_Act:=False
}
if 	(ON_BOTT_Act_pr<>ON_BOTT_Act)
{
if (ON_BOTT_Act=true)
{
SetTimer , wait_mouse_act, % props["wait1"]
}
ON_BOTT_Act_pr:=ON_BOTT_Act
}
if (y<ACT_LIM_TOP) and (x<A_screenwidth-60)
{
ON_TOP_Act:=true
}
else
{
ON_TOP_Act:=False
}
if 	(ON_TOP_Act_pr<>ON_TOP_Act)
{
if (ON_TOP_Act=true)
{
tvst:=false
}
ON_TOP_Act_pr:=ON_TOP_Act
}
}
WatchWindNThSw()
return
cr_TB_pt(byref p2x,byref p2y)
{
global TASK_BAR_HEIGHT,TASK_BAR_width,TBY
if (TASK_BAR_HEIGHT<>a_screenheight)
{
if (TBY<>0)
{
p2y:=a_screenheight-TASK_BAR_HEIGHT
}
else
{
p2y:=TASK_BAR_HEIGHT
}
}
else
{
if (TBX<>0)
{
p2x:=a_screenwidth-TASK_BAR_width
}
else
{
p2x:=TASK_BAR_width
}
}
}
updkeyst()
{
updkeystch("lButton")
updkeystch("MButton")
updkeystch("RButton")
updkeystch("Delete")
updkeystch("RCtrl")
updkeystch("LCtrl")
updkeystch("Esc")
}
switch_AON()
{
global props,messages
props["ACTIVATE_ON_MOUSE_ON"]:=rev_01(props["ACTIVATE_ON_MOUSE_ON"])
if (props["ACTIVATE_ON_MOUSE_ON"]=0)
{
aon:=messages[props["lang"],"ACTONCLICK"]
}
else
{
aon:=messages[props["lang"],"ACTONMouseOn"]
}
calc_act_bord()
msgbox %aon%
}
wait_mouse_act:
SetTimer , wait_mouse_act, off
if (ON_BOTT_Act=true)
gosub toggle_ShowHide
return
------------------------------------------------------------------------------------------
minmax_(mx,my,mw,mh,byref mmin,byref mmax)
{
mmin:=object()
mmax:=object()
mmin[0]:=mx
mmin[1]:=my
mmax[0]:=mx+mw
mmax[1]:=my+mh
}
------------------------------------------------------------------------------------------
upd_pos(thmb)
{
if (thmb="")
return
global THUMB_DATA,TASK_BAR_HEIGH2T,THUMB_HEIGHT,THUMB_WIDTH,THUMBSIZES
dy:=-round((((A_ScreenHeight-TASK_BAR_HEIGH2T)/(THUMB_HEIGHT+1)),0)*(THUMB_HEIGHT+1))+(A_ScreenHeight-TASK_BAR_HEIGH2T)+round((A_ScreenHeight-TASK_BAR_HEIGH2T)/(THUMB_HEIGHT+1),0)
root_wind:=THUMB_DATA["_" . thmb,"Root"]
agn:
WinGetPos,mx,my,mw,mh,ahk_id %thmb%
nx:=round((mx/(THUMB_WIDTH+1))-0.25,0)*(THUMB_WIDTH+1)+1
ny:=round(((my+dy)/(THUMB_HEIGHT+1))-0.25,0)*(THUMB_HEIGHT+1)+1-dy
if (nx<>mx) or (my<>ny)
{
winmove,ahk_id %thmb%,,nx,ny
mx:=nx
my:=ny
}
if (THUMBSIZES["_" . root_wind,"w"]<>mw) or (THUMBSIZES["_" . root_wind,"h"]<>mh)
{
mh:=round(mh,0)
mw:=round(mw,0)
winmove,ahk_id %thmb%,,mx,my,mw,mh
upd_image(THUMB_DATA["_" . root_wind,"Root"])
THUMBSIZES["_" . root_wind,"w"]:=mw
THUMBSIZES["_" . root_wind,"h"]:=mh
goto agn
}
minmax_(mx,my,mw,mh, mmin, mmax)
if (mmax[0]>A_ScreenWidth)
{
winmove,ahk_id %thmb%,,0,mmin[1]-mh-1
goto agn
}
if (mmin[0]<0)
{
winmove,ahk_id %thmb%,,1
goto agn
}
if (mmax[1]>A_ScreenHeight -TASK_BAR_HEIGH2T)
{
winmove,ahk_id %thmb%,,,A_ScreenHeight-TASK_BAR_HEIGH2T - mh -1
goto agn
}
for _win,val in THUMB_DATA
{
if haskeykey(THUMB_DATA,_win,"Root")
{
win:=striml(_win,1)
if (thmb<>win)
{
WinGetPos,nx,ny,nw,nh,ahk_id %win%
minmax_(nx,ny,nw,nh, nmin, nmax)
if (is_inside_BB_2d(mmin, mmax,nmin, nmax))
{
winmove,ahk_id %thmb%,,nmax[0]+1
goto agn
}
}
}
}
THUMBSIZES["_" . root_wind,"w"]:=mw
THUMBSIZES["_" . root_wind,"h"]:=mh
THUMBSIZES["_" . root_wind,"x"]:=mx
THUMBSIZES["_" . root_wind,"y"]:=my
}
------------------------------------------------------------------------------------------
window_activate(win,anyway:=false,passive:=false)
{
global props
if (props["ACTIVATE_ON_MOUSE_ON"]=1)
{
window_activate2(win,anyway)
}
}
------------------------------------------------------------------------------------------
window_activate2(win,anyway:=false,passive:=false)
{
global activated_window,THUMB_DATA,ACTWINTRANS,TVSt
THMBCR:=THUMB_DATA["_" . win,"thumbnailcreatable_win"]
WinGet, active_id, ID, A
if (THUMB_DATA["_" . win,"Root"]<>"")
{
win:=THUMB_DATA["_" . win,"Root"]
}
if (THUMB_DATA["_" . CreatedThumb,"Root"]<>"")
{
active_id:=THUMB_DATA["_" . THUMB_DATA["_" . active_id,"Root"],"thumbnailcreatable_win"]
}
ONE_TCR:=False
if (THUMB_DATA["_" . activated_window,"thumbnailcreatable_win"]<>active_id) and (activated_window<>active_id)
{
ONE_TCR:=True
}
if (activated_window<>win) or (ONE_TCR)
{
DetectHiddenWindows, On
if (TVSt=true)
{
WinSet, Transparent, off, % "ahk_id " . THUMB_DATA["_" . activated_window,"Thumb"]
WinSet, Transparent, %ACTWINTRANS%, % "ahk_id " . THUMB_DATA["_" . win,"Thumb"]
mark_actwin(THUMB_DATA["_" . win,"Thumb"])
}
if (THMBCR<>THUMB_DATA["_" . activated_window,"thumbnailcreatable_win"])
{
winact2(win)
WinGettitle, ttl, ahk_id %win%
WinGetClass, Class, ahk_id %win%
upd_image(activated_window)
}
else
{
upd_image_w(activated_window)
scredr2()
winact2(win)
}
DetectHiddenWindows, off
activated_window:=win
upd_title(activated_window)
}
}
------------------------------------------------------------------------------------------
mark_actwin(thumb)
{
global THUMB_DATA,ACTIVE_MARKER
WinSet, AlwaysOnTop,On, ahk_id %ACTIVE_MARKER%
wingetpos,nx,ny,nw,nh, % "ahk_id " . thumb
winmove,ahk_id %ACTIVE_MARKER%,,nx,ny,nw,nh
}
------------------------------------------------------------------------------------------
winact2(win)
{
global THUMB_DATA
if not(winexist("ahk_id " . win))
{
return
}
WinGettitle, ttl, ahk_id %win%
WinGetClass, Class, ahk_id %win%
If (Class="Progman")
{
critical
for _win,val in THUMB_DATA
{
if haskeykey(THUMB_DATA,_win,"Thumb")
{
win:=striml(_win,1)
if (gwc(win)<>"Progman")
wp_SetProp(win,"WINAFTERMINALLSTATE",1)
}
}
WinMinimizeAll
critical, off
}
else
{
if !(is_restorable(win))
{
DllCall("SwitchToThisWindow", "UInt", win, "UInt", 1)
}
wp_SetProp(win,"WINAFTERMINALLSTATE",0)
winactivate, ahk_id %win%
if (WinGetMinMaxState(win)=-1)
{
DllCall("SwitchToThisWindow", "UInt", win, "UInt", 1)
}
}
}
WatchWindNThSw()
{
global THUMB_DATA,activated_window,ACTWINTRANS,TVSt
WinGet, active_id2, ID, A
WWNroot:=get_root_win(active_id2)
WWNroot_prew:=get_root_win(activated_window)
if haskeykey(THUMB_DATA,"_" . active_id2,"Root")
{
if (THUMB_DATA["_" . active_id2,"Root"]<>activated_window) and (active_id2<>activated_window)
window_activate2(THUMB_DATA["_" . active_id2,"Root"])
return
}
if !(haskeykey(THUMB_DATA,"_" . WWNroot,"thumbnailcreatable_win"))
{
return
}
if (THUMB_DATA["_" . WWNroot_prew,"thumbnailcreatable_win"]<>THUMB_DATA["_" . WWNroot,"thumbnailcreatable_win"])
{
WinGetClass, Class, ahk_id %WWNroot_prew%
WinGetClass, Class2, ahk_id %WWNroot%
If !((Class="Progman") and ((wp_getProp(WWNroot,"WINAFTERMINALLSTATE")=1) and (WinGetMinMaxState(active_id2)=-1)))
{
Critical
if (TVSt=true)
{
WinSet, Transparent, off, % "ahk_id " . THUMB_DATA["_" . WWNroot_prew,"Thumb"]
WinSet, Transparent, %ACTWINTRANS%, % "ahk_id " . THUMB_DATA["_" . WWNroot,"Thumb"]
mark_actwin(THUMB_DATA["_" . WWNroot,"Thumb"])
}
activated_window:=WWNroot
Critical, off
}
else
{
if (Class2="Progman")
{
for _win,val in THUMB_DATA
{
if haskeykey(THUMB_DATA,_win,"Thumb")
{
win:=striml(_win,1)
if (gwc(win)<>"Progman")
wp_SetProp(win,"WINAFTERMINALLSTATE",1)
}
}
}
}
}
}
updkeystch(key)
{
global KeyST
KeyST[key,"P"]:=KeyST[key,"C"]
GetKeyState,st,%key%,P
if (st <> KeyST[key,"P"])
{
if (st="D")
{
KeyST[key,"Ch"]:="D"
}
else
{
KeyST[key,"Ch"]:="U"
}
}
else
{
KeyST[key,"Ch"]:=""
}
KeyST[key,"C"]:=st
}
------------------------------------------------------------------------------------------
rev_TrFl(var)
{
if (var=True)
var:=false
else
var:=true
return var
}
------------------------------------------------------------------------------------------
rev_01(var)
{
if (var=1)
var:=0
else
var:=1
return var
}
------------------------------------------------------------------------------------------
toggle_ShowHide:
TVST:=rev_TrFl(TVST)
return
------------------------------------------------------------------------------------------
----------------------------------------------------------
thumb_show(thumb)
{
global activated_window,THUMB_DATA,ACTWINTRANS
if (THUMB_DATA["_" . activated_window,"Thumb"]<>thumb)
{
WinSet, Transparent, OFF, ahk_id %thumb%
}
else
{
WinSet, Transparent, %ACTWINTRANS%, ahk_id %thumb%
mark_actwin(thumb)
}
WinSet, Region,, ahk_id %thumb%
}
----------------------------------------------------------
thumb_hide(thumb)
{
WinSet, Transparent, 0, ahk_id %thumb%
WinSet, Region, 0-0 W0 H0, ahk_id %thumb%
}
----------------------------------------------------------
wacth_wind_appearance:
if (TVSt_pr<>TVSt)
{
if (TVSt=true)
{
TVStCh:=1
}
else
{
TVStCh:=-1
}
}
else
{
TVStCh:=0
}
prev_winds:=cur_winds
cur_winds:=object()
arr_wind:=get_all_winds()
first_wind:
for n,id in arr_wind
{
if (is_TBBTN_win(id))
{
if (not_hidden_by_user_or_system(id))
{
wwaroot_wind:=get_root_win(id)
cur_winds["_" . wwaroot_wind]:=1
if not(haskeykey(THUMB_DATA,"_" . wwaroot_wind,"Thumb"))
{
critical
wwathumbnailcreatable_win:=find_thumbnailcreatable_win(wwaroot_wind)
wp_SetProp(wwaroot_wind,"WINAFTERMINALLSTATE",0)
create_thumbnail(wwaroot_wind,wwathumbnailcreatable_win)
}
else
{
wwathumbnailcreatable_win:=THUMB_DATA["_" . wwaroot_wind,"thumbnailcreatable_win"]
if (wp_getProp(wwaroot_wind,"WINAFTERMINALLSTATE")=0)
{
WinGetPos,,,wwa_wd,wwa_ht,ahk_id %wwathumbnailcreatable_win%
if (wwa_wd=0) or (wwa_ht=0) or (wwathumbnailcreatable_win="") or !(winexist("ahk_id " . wwathumbnailcreatable_win))
{
wwathumbnailcreatable_win2:=find_thumbnailcreatable_win(wwaroot_wind)
if (wwathumbnailcreatable_win2<>wwathumbnailcreatable_win)
{
if (wwathumbnailcreatable_win2<>"")
{
create_thumbnail(wwaroot_wind,wwathumbnailcreatable_win2)
}
}
}
}
}
}
}
if (TVStCh<>0)
{
if (haskeykey(THUMB_DATA,"_" . wwaroot_wind, "Thumb"))
{
thumb:=THUMB_DATA["_" . wwaroot_wind, "Thumb"]
if (TVStCh=1)
{
thumb_show(thumb)
Gui a%wwaroot_wind%: +AlwaysOnTop
}
else
{
thumb_hide(thumb)
}
}
}
if (CREATED_GUI<>"")
{
CREATED_GUI:=""
}
}
if (TVStCh<>0)
{
if (TVStCh=1)
{
WinSet, Region,, ahk_id %ACTIVE_MARKER%
WinSet, AlwaysOnTop,On, ahk_id %ACTIVE_MARKER%
}
else
{
WinSet, Region, 0-0 W0 H0, ahk_id %ACTIVE_MARKER%
}
}
for prev_wind,v in prev_winds
{
if not (cur_winds.haskey(prev_wind))
{
dstrw:=striml(prev_wind,1)
destroy_thumbnail(dstrw)
}
}
TVSt_pr:=TVSt
return
------------------------------------------------------------------------------------------
exit:
Gdip_Shutdown(pToken)
WinExist("ahk_class Shell_TrayWnd")
Control, Show,, MSTaskListWClass1
Control, Show,, MSTaskSwWClass1
Control, Show,, ReBarWindow321
Control, Show,, TrayShowDesktopButtonWClass1
arr_to_file(UNWATCHED_USER_PROCESSES,"UUP.list")
arr_to_file(UNWATCHED_USER_CLASSES,"UUC.list")
arr_to_file(props,"settings.ini")
exitapp
------------------------------------------------------------------------------------------
find_thumbnailcreatable_win(win)
{
WinGetPos,x,y,wd,ht,ahk_id %win%
if (wd=0) and (ht=0)
{
ini_arr(childs)
childs:=get_child_wins(win)
if  !(childs.maxindex())
{
WinGet, CPID, PID,  ahk_id %win%
ini_arr(wpid)
wpid:=get_winds_on_pid(CPID)
if  (wpid.maxindex()<>0)
{
for a,win_on_pid in wpid
{
if (win_on_pid<>win)
{
WinGetPos,x,y,wd,ht,ahk_id %win_on_pid%
if (wd>0) and (ht>0)
{
return win_on_pid
}
}
}
}
}
else
{
for a,child in childs
{
WinGetPos,x,y,wd,ht,ahk_id %child%
if (wd>0) and (ht>0)
{
return child
}
}
}
return ""
}
else
{
if not(is_restorable(win))
{
WinGet, CPID, PID,  ahk_id %win%
wpid:=object()
wpid:=get_winds_on_pid(CPID)
for a,win_on_pid in wpid
{
if (win_on_pid<>win)
{
if (is_restorable(win_on_pid))
{
return win_on_pid
}
}
}
return ""
}
return win
}
}
WinGetMinMaxState(win)
{
WinGet MinMaxState, MinMax, ahk_id %win%
RETURN MinMaxState
}
------------------------------------------------------------------------------------------
is_restorable(win)
{
global RESTORABLE_WINDOWS
if not(RESTORABLE_WINDOWS.haskey("_" . win))
{
RESTORABLE_WINDOWS["_" . win]:=1
WinGet MinMaxState, MinMax, ahk_id %win%
if (MinMaxState = -1)
{
WinRestore, ahk_id %win%
sleep, 100
WinGet MinMaxState, MinMax, ahk_id %win%
if (MinMaxState = -1)
{
DllCall("SwitchToThisWindow", "UInt", win, "UInt", 0)
WinGet MinMaxState, MinMax, ahk_id %win%
if (MinMaxState = -1)
{
RESTORABLE_WINDOWS["_" . win]:=-1
}
RESTORABLE_WINDOWS["_" . win]:=-1
}
}
}
if (RESTORABLE_WINDOWS["_" . win]=1)
{
return true
}
else
{
return false
}
}
------------------------------------------------------------------------------------------
striml(strng,c)
{
StringTrimLeft, a, strng, c
return a
}
------------------------------------------------------------------------------------------
is_TBBTN_win(wid)
{
ex1:=0
ex2:=0
global WS_EX_CONTROLPARENT, WS_EX_DLGMODALFRAME, WS_CLIPCHILDREN, WS_EX_APPWINDOW, WS_EX_TOOLWINDOW , WS_DISABLED , WS_VSCROLL, WS_POPUP, WS_VISIBLE
WinGetTitle, wid_Title, ahk_id %wid%
WinGet, Style, Style, ahk_id %wid%
WinGet, proc, ProcessName, ahk_id %wid%
WinGetClass, Class, ahk_id %wid%
If (Class="Progman")
{
return TRUE
}
If (!(wid_Title))
{
return FALSE
}
If (Style & WS_DISABLED)
{
return FALSE
}
WinGet, es, ExStyle, ahk_id %wid%
Parent := C10_16( DllCall( "GetParent", "uint", wid ) )
WinGet, Style_parent, Style, ahk_id %Parent%
Owner := C10_16( DllCall( "GetWindow", "uint", wid , "uint", "4" ) )
WinGet, Style_Owner, Style, ahk_id %Owner%
If (((es & WS_EX_TOOLWINDOW)  and !(Parent)  and (Style & WS_VISIBLE))
or ( !(es & WS_EX_APPWINDOW)
and (((Parent) and ((Style_parent & WS_DISABLED) =0))
or ((Owner) and ((Style_Owner & WS_DISABLED) =0)))))
{
return FALSE
}
return TRUE
}
------------------------------------------------------------------------------------------
wp_GetProp(hwnd, property_name, type="int")
{
return DllCall("GetProp", "uint", hwnd, "str", property_name, type)
}
------------------------------------------------------------------------------------------
wp_SetProp(hwnd, property_name, data, type="int")
{
return DllCall("SetProp", "uint", hwnd, "str", property_name, type, data)
}
------------------------------------------------------------------------------------------
create_thumbnail(root_wind,thumbnailcreatable_win)
{
critical
global THUMB_DATA,MAX_TOP,THUMB_WIDTH,THUMB_HEIGHT,CREATED_GUI,THUMBSIZES,TVST
Gui, a%root_wind%:New
Gui a%root_wind%: +ToolWindow +hwndCreatedThumb +AlwaysOnTop +0x40000 -0xC00000
Gui a%root_wind%:Show , NoActivate
if (TVST=FALSE)
{
thumb_hide(CreatedThumb)
}
Gui a%root_wind%:Add, Picture, x0 y-2 w100 h100 hwndCreatedThumbImage +0xE
Gui a%root_wind%:Add, Picture, x0 y0 w32 h32 BackgroundTrans hwndCreatedThumbIcon +0xE
if (THUMBSIZES.haskey("_" . root_wind))
{
winmove,ahk_id %CreatedThumb%,,THUMBSIZES["_" . root_wind,"x"],THUMBSIZES["_" . root_wind,"y"],THUMBSIZES["_" . root_wind,"w"],THUMBSIZES["_" . root_wind,"h"]
}
else
{
winmove,ahk_id %CreatedThumb%,,1,MAX_TOP-1,THUMB_WIDTH,THUMB_HEIGHT
}
THUMB_DATA["_" . root_wind,"thumbnailcreatable_win"]:=thumbnailcreatable_win
THUMB_DATA["_" . root_wind,"Thumb"]:=CreatedThumb
THUMB_DATA["_" . CreatedThumb,"ThumbImage"]:=CreatedThumbImage
THUMB_DATA["_" . CreatedThumb,"ThumbIcon"]:=CreatedThumbIcon
THUMB_DATA["_" . CreatedThumb,"Root"]:=root_wind
wp_SetProp(root_wind,"WINAFTERMINALLSTATE",0)
upd_image(root_wind)
upd_title(root_wind)
upd_pos(CreatedThumb)
CREATED_GUI:=a%root_wind%
critical, off
}
------------------------------------------------------------------------------------------
upd_title(root_wind)
{
global WinInfoShow,THUMB_DATA
Thumb:=THUMB_DATA["_" . root_wind,"Thumb"]
WinGetTitle, Title, ahk_id %root_wind%
prev_mb_title=%Title%
WinGetTitle, rTitle, ahk_id %Thumb%
if (rTitle<>prev_mb_title)
WinSetTitle,ahk_id %Thumb% ,,%prev_mb_title%
}
------------------------------------------------------------------------------------------
upd_image(root_wind)
{
global wait_im_update
wait_im_update["_" . root_wind]:=6
}
------------------------------------------------------------------------------------------
upd_image_wait:
cc:=0
for WW,w in wait_im_update
{
wait_im_update[WW]:=wait_im_update[WW]-1
if (wait_im_update[WW]=0)
{
cc:=1
upd_image_w(striml(WW,1))
wait_im_update.remove(ww)
}
}
if (cc=1)
{
scredr2()
}
return
------------------------------------------------------------------------------------------
upd_image_w(root_wind)
{
global THUMB_DATA
thumbnailcreatable_win:=THUMB_DATA["_" . root_wind,"thumbnailcreatable_win"]
WinGet MinMaxState, MinMax, ahk_id %thumbnailcreatable_win%
if (wp_getProp(root_wind,"WINAFTERMINALLSTATE")=0) and (thumbnailcreatable_win<>"")
{
if (MinMaxState <> -1)
{
Thumb:=THUMB_DATA["_" . root_wind,"Thumb"]
img:=THUMB_DATA["_" . Thumb,"ThumbImage"]
iimg:=THUMB_DATA["_" . Thumb,"ThumbIcon"]
copy_win_img_to_contr(thumbnailcreatable_win,Thumb,img,iimg)
}
}
}
scredr2()
{
global hredr,do_scredr2
if A_OSVersion in WIN_XP
{
if (do_scredr2=true)
{
Gui Redra: +AlwaysOnTop
Gui Redra:Show,  NoActivate
Gui Redra:Hide
}
}
}
------------------------------------------------------------------------------------------
copy_win_img_to_contr(SourceWin,TargetWin,TargetContol,TargIc)
{
global Bord
WinGetPos,,, DstWidth, DstHeight, ahk_id %TargetWin%
DstWidth:=DstWidth-Bord
DstHeight:=DstHeight-Bord
pBitmapI :=Gdip_CreateBitmapFromHICON(Get_Window_Icon(SourceWin))
hBitmapI := Gdip_CreateHBITMAPFromBitmap(pBitmapI)
pBitmap := 	Gdip_BitmapFromHWNDStretchToDst(SourceWin,DstWidth,DstHeight)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
if (pBitmap<>0)
SetImage(TargetContol, hBitmap)
if (pBitmapI<>0)
SetImage(TargIc, hBitmapI)
DeleteObject(hBitmap)
DeleteObject(hBitmapI)
Gdip_DisposeImage(pBitmap)
Gdip_DisposeImage(pBitmapI)
if pBitmap=0
return false
return true
}
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
destroy_thumbnail(root_wind)
{
global THUMB_DATA,ACTIVE_MARKER,activated_window
Gui a%root_wind%:Destroy
Thumb:=THUMB_DATA["_" . root_wind,"Thumb"]
if (root_wind=activated_window)
{
winmove,ahk_id %ACTIVE_MARKER%,,0,0,0,0
}
THUMB_DATA.remove("_" . root_wind)
THUMB_DATA.remove("_" . Thumb)
}
------------------------------------------------------------------------------------------
not_hidden_by_user_or_system(wind)
{
global EMPTY_TITLE,UNWATCHED_PROCS,UNWATCHED_TITLES,UNWATCHED_CLASSES,UNWATCHED_USER_PROCS,UNWATCHED_USER_CLASSES
WinGetClass, Class, ahk_id %wind%
WinGet, proc, ProcessName, ahk_id %wind%
if (UNWATCHED_USER_PROCS.haskey(proc)) or (UNWATCHED_USER_CLASSES.haskey(Class))
return false
return true
}
------------------------------------------------------------------------------------------
get_child_wins(wind)
{
winds_on_pid:=get_all_winds()
for n,wind_on_pid in winds_on_pid
{
pv:=get_Parent_Win(wind_on_pid)
if (pv=wind)
{
ini_arr(arr)
arr.insert(wind_on_pid)
}
}
return arr
}
------------------------------------------------------------------------------------------
get_winds_on_pid(CPID)
{
WinGet, same_pid_winds, List,  ahk_pid %CPID%
ini_arr(arr)
Loop %same_pid_winds%
{
arr.insert(same_pid_winds%A_index%)
}
return arr
}
------------------------------------------------------------------------------------------
gwt(win)
{
WinGetTitle, Title, ahk_id %win%
return Title
}
gwc(win)
{
WinGetClass, Title, ahk_id %win%
return Title
}
gwp(win)
{
WinGet, proc, ProcessName, ahk_id %win%
return proc
}
------------------------------------------------------------------------------------------
get_root_win(wind,byref not_zero_size_win:=" ")
{
not_zero_size_win:=" "
loop 1000
{
win_tmp:=get_Parent_Win(wind)
if (win_tmp="")
{
break
}
if not(winexist(c_winstr(win_tmp)))
{
break
}
wind:=win_tmp
}
win_tmp:=wind
cl:=gwc(wind)
pr:=gwp(wind)
return wind
}
---------------------------------------------
GetWinParamId(ParamType,WinId:=" ")
{
info:=GetWinParam(ParamType,c_winstr(WinId))
return info
}
---------------------------------------------
c_winstr(WinId)
{
if (WinId=" ")
{
WinIdstr = A
}
else
{
WinIdstr = ahk_id %WinId%
}
return WinIdstr
}
---------------------------------------------
c_win(wstr)
{
StringTrimLeft, win, wstr, 7
return win
}
---------------------------------------------
GetWinParam(ParamType,WinIdstr:="A")
{
WinGet, info, %ParamType%, %WinIdstr%
return info
}
---------------------------------------------
get_Parent_Win(wind)
{
ID :=DllCall("GetParent", UInt,wind)
if (ID<>0)
return C10_16(ID)
else
return ""
}
----------------------------------------------
C10_16(var)
{
SetFormat, integer, hex
var += 0
SetFormat, integer, d
return var
}
----------------------------------------------
------------------------------------------------------------------------------------------
get_all_winds(filtr:=" ")
{
if (filtr=" ")
{
WinGet, ids, list
}
else
{
WinGet, ids, list,filtr
}
ini_arr(arr)
Loop %ids%
{
arr.insert(ids%A_index%)
}
return arr
}
------------------------------------------------------------------------------------------
calc_THUMB_HEIGHT(THUMB_WIDTH_)
{
global
THUMB_WIDTH:=THUMB_WIDTH_-2
WinGetPos,TBX,TBY,TASK_BAR_WIDTH,TASK_BAR_HEIGH2T,ahk_class Shell_TrayWnd
TASK_BAR_HEIGHT:=TASK_BAR_HEIGH2T
if (TASK_BAR_HEIGH2T=a_screenheight) or (TBY=0)
{
TASK_BAR_HEIGH2T:=3
}
THUMB_HEIGHT:=round(THUMB_WIDTH/(A_ScreenWidth/(A_ScreenHeight-TASK_BAR_HEIGH2T)),0)
MAX_TOP:=round(A_ScreenHeight - THUMB_HEIGHT-TASK_BAR_HEIGH2T,0)
}
calc_act_bord()
{
global
ACT_LIM_RIG:=MonitorLimitRight - 3
ACT_LIM_LEFT:=MonitorLimitLeft + 3
ACT_LIM_TOP:=MonitorLimitTop + 3
ACT_LIM_BOTT:=MonitorLimitBottom - 3
if (props["ACTIVATE_ON_MOUSE_ON"]=0) and (props["switch_on_TB_if_ActOnCl"]=true)
{
if (TASK_BAR_HEIGHT<>a_screenheight) and (TBY<>0)
ACT_LIM_BOTT:=MonitorLimitBottom - TASK_BAR_HEIGHT
}
}
------------------------------------------------------------------------------------------
Get_Window_Icon(wid, Use_Large_Icons_Current=1)
{
h_icon:=0
Responding := DllCall("SendMessageTimeout", "UInt", wid, "UInt", 0x0, "Int", 0, "Int", 0, "UInt", 0x2, "UInt", 150, "UInt *", NR_temp)
If (Responding)
{
If Use_Large_Icons_Current =1
{
SendMessage, 0x7F, 1, 0,, ahk_id %wid%
h_icon := ErrorLevel
}
If ( ! h_icon )
{
SendMessage, 0x7F, 2, 0,, ahk_id %wid%
h_icon := ErrorLevel
If ( ! h_icon )
{
SendMessage, 0x7F, 0, 0,, ahk_id %wid%
h_icon := ErrorLevel
If ( ! h_icon )
{
If Use_Large_Icons_Current =1
h_icon := DllCall( "GetClassLong", "uint", wid, "int", -14 )
If ( ! h_icon )
{
h_icon := DllCall( "GetClassLong", "uint", wid, "int", -34 )
}
}
}
}
}
return h_icon
}
------------------------------------------------------------------------------------------
Gdip_BitmapFromHWNDStretchToDst(SrcHwnd,DstWidth,DstHeight,Bord:=0)
{
WinGetPos,,, Width, Height, ahk_id %SrcHwnd%
if (Width=0) or (Height=0)
{
return 0
}
if (A_OSVersion in WIN_XP)
{
pBitmap := Gdip_BitmapFromHWND(SrcHwnd)
}
else
{
if (SrcHwnd="")
{
SrcHwnd:=0
}
hdc2 := DllCall("GetDC", UInt, SrcHwnd)
hdc := DllCall("CreateCompatibleDC", "uint", hdc2)
hbm := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc2 , Int,Width, Int,Height)
obm := DllCall( "gdi32.dll\SelectObject", UInt,hdc, UInt,hbm)
PrintWindow(SrcHwnd, hdc)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
sel_obj := SelectObject(hdc, obm)
DeleteObject(obm),
DeleteObject(hbm),
DeleteDC(hdc),
DeleteDC(hdc2),
DeleteObject(sel_obj)
}
pBitmap := Gdip_ResizepBitmap(pBitmap, Width, Height, DstWidth, DstHeight,Bord)
return pBitmap
}







UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
{
if ((x != "") && (y != ""))
VarSetCapacity(pt, 8), NumPut(x, pt, 0), NumPut(y, pt, 4)
if (w = "") ||(h = "")
WinGetPos,,, w, h, ahk_id %hwnd%
return DllCall("UpdateLayeredWindow", "uint", hwnd, "uint", 0, "uint", ((x = "") && (y = "")) ? 0 : &pt
, "int64*", w|h<<32, "uint", hdc, "int64*", 0, "uint", 0, "uint*", Alpha<<16|1<<24, "uint", 2)
}
BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
{
return DllCall("gdi32\BitBlt", "uint", dDC, "int", dx, "int", dy, "int", dw, "int", dh
, "uint", sDC, "int", sx, "int", sy, "uint", Raster ? Raster : 0x00CC0020)
}
StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
{
return DllCall("gdi32\StretchBlt", "uint", ddc, "int", dx, "int", dy, "int", dw, "int", dh
, "uint", sdc, "int", sx, "int", sy, "int", sw, "int", sh, "uint", Raster ? Raster : 0x00CC0020)
}
SetStretchBltMode(hdc, iStretchMode=4)
{
return DllCall("gdi32\SetStretchBltMode", "uint", hdc, "int", iStretchMode)
}
SetImage(hwnd, hBitmap)
{
SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
E := ErrorLevel
DeleteObject(E)
return E
}
SetSysColorToControl(hwnd, SysColor=15)
{
WinGetPos,,, w, h, ahk_id %hwnd%
bc := DllCall("GetSysColor", "Int", SysColor)
pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
SetImage(hwnd, hBitmap)
Gdip_DeleteBrush(pBrushClear)
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
return 0
}
Gdip_BitmapFromScreen(Screen=0, Raster="")
{
if (Screen = 0)
{
Sysget, x, 76
Sysget, y, 77
Sysget, w, 78
Sysget, h, 79
}
else if (SubStr(Screen, 1, 5) = "hwnd:")
{
Screen := SubStr(Screen, 6)
if !WinExist( "ahk_id " Screen)
return -2
WinGetPos,,, w, h, ahk_id %Screen%
x := y := 0
hhdc := GetDCEx(Screen, 3)
}
else if (Screen&1 != "")
{
Sysget, M, Monitor, %Screen%
x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
}
else
{
StringSplit, S, Screen, |
x := S1, y := S2, w := S3, h := S4
}
if (x = "") || (y = "") || (w = "") || (h = "")
return -1
chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
ReleaseDC(hhdc)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
return pBitmap
}
Gdip_BitmapFromHWND(hwnd)
{
WinGetPos,,, Width, Height, ahk_id %hwnd%
hdc2 := DllCall("GetDC", UInt, hwnd)
hdc := DllCall("CreateCompatibleDC", "uint", hdc2)
hbm := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc2 , Int,Width, Int,Height)
obm := DllCall( "gdi32.dll\SelectObject", UInt,hdc, UInt,hbm)
PrintWindow(hwnd, hdc)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm,460)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc),
SelectObject(hdc2, obm), DeleteObject(hbm), DeleteDC(hdc2),
DeleteObject(obm)
return pBitmap
}
Gdip_ResizepBitmap(pBitmap,SrcW,SrcH,DstW,DstH,Bord:=0)
{
nwpBitmap := Gdip_CreateBitmap(DstW,DstH)
nwpGraphics := Gdip_GraphicsFromImage(nwpBitmap)
Gdip_DrawImage(nwpGraphics, pBitmap, 0, 0, DstW, DstH, Bord, Bord, SrcW, SrcH)
Gdip_DeleteGraphics(nwpGraphics)
Gdip_DisposeImage(pBitmap)
return nwpBitmap
}
Gdip_copyStretchDC_ret_dst(SourceID,DestID)
{
dst_frame := DllCall("GetDC", UInt, DestID)
src_frame := DllCall("GetDC", UInt, SourceID)
WinGetPos,src_x,src_y,src_w,src_h, ahk_id %SourceID%
WinGetPos,dst_x,dst_y,dst_w,dst_h, ahk_id %DestID%
StretchBlt(dst_frame, 0, 0, dst_w, dst_h, src_frame, 0, 0,src_w,src_h)
return dst_frame
}
Gdip_BitmapFromWIDn(src_id,dst_id)
{
WinGetPos,,, src_w,src_h, ahk_id %src_id%
hdc := DllCall( "GetDC", UInt, src_id )
hdestdc := DllCall( "GetDC", UInt, dst_id )
WinGetPos,dst_x,dst_y,dst_w,dst_h, ahk_id %dst_id%
StretchBlt(dst_frame, 0, 0, dst_w, dst_h, src_frame, 0, 0,src_w,src_h)
hbm := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc , Int,Width, Int,Height)
obm := DllCall( "gdi32.dll\SelectObject", UInt,hdc, UInt,hbm)
DllCall("PrintWindow", UInt,src_id, UInt,hdc, UInt,0)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
msgbox pBitmap %pBitmap%
SelectObject(hdc, obm),
DeleteObject(hbm),
DeleteDC(hdc)
return pBitmap
}
Gdip_BitmapFromsrc_id(src_id)
{
WinGetPos,,, Width, Height, ahk_id %src_id%
hdc := DllCall( "GetDC", UInt, src_id )
hbm := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt,hdc , Int,Width, Int,Height)
obm := DllCall( "gdi32.dll\SelectObject", UInt,hdc, UInt,hbm)
DllCall("PrintWindow", UInt,src_id, UInt,hdc, UInt,0)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
msgbox pBitmap %pBitmap%
SelectObject(hdc, obm),
DeleteObject(hbm),
DeleteDC(hdc)
return pBitmap
}
CreateRectF(ByRef RectF, x, y, w, h)
{
VarSetCapacity(RectF, 16)
NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float")
}
CreateRect(ByRef Rect, x, y, w, h)
{
VarSetCapacity(Rect, 16)
NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
}
CreateSizeF(ByRef SizeF, w, h)
{
VarSetCapacity(SizeF, 8)
NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
}
CreatePointF(ByRef PointF, x, y)
{
VarSetCapacity(PointF, 8)
NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
}
CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0)
{
hdc2 := hdc ? hdc : GetDC()
VarSetCapacity(bi, 40, 0)
NumPut(w, bi, 4), NumPut(h, bi, 8), NumPut(40, bi, 0), NumPut(1, bi, 12, "ushort"), NumPut(0, bi, 16), NumPut(bpp, bi, 14, "ushort")
hbm := DllCall("CreateDIBSection", "uint" , hdc2, "uint" , &bi, "uint" , 0, "uint*", ppvBits, "uint" , 0, "uint" , 0)
if !hdc
ReleaseDC(hdc2)
return hbm
}
PrintWindow(hwnd, hdc, Flags=0)
{
return DllCall("PrintWindow", "uint", hwnd, "uint", hdc, "uint", Flags)
}
DestroyIcon(hIcon)
{
return DllCall("DestroyIcon", "uint", hIcon)
}
PaintDesktop(hdc)
{
return DllCall("PaintDesktop", "uint", hdc)
}
CreateCompatibleBitmap(hdc, w, h)
{
return DllCall("gdi32\CreateCompatibleBitmap", "uint", hdc, "int", w, "int", h)
}
CreateCompatibleDC(hdc=0)
{
return DllCall("CreateCompatibleDC", "uint", hdc)
}
SelectObject(hdc, hgdiobj)
{
return DllCall("SelectObject", "uint", hdc, "uint", hgdiobj)
}
DeleteObject(hObject)
{
return DllCall("DeleteObject", "uint", hObject)
}
GetDC(hwnd=0)
{
return DllCall("GetDC", "uint", hwnd)
}
GetDCEx(hwnd, flags=0, hrgnClip=0)
{
return DllCall("GetDCEx", "uint", hwnd, "uint", hrgnClip, "int", flags)
}
ReleaseDC(hdc, hwnd=0)
{
return DllCall("ReleaseDC", "uint", hwnd, "uint", hdc)
}
DeleteDC(hdc)
{
return DllCall("DeleteDC", "uint", hdc)
}
Gdip_LibraryVersion()
{
return 1.45
}
Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
{
if !BRAFromMemIn
return -1
Loop, Parse, BRAFromMemIn, `n
{
if (A_Index = 1)
{
StringSplit, Header, A_LoopField, |
if (Header0 != 4 || Header2 != "BRA!")
return -2
}
else if (A_Index = 2)
{
StringSplit, Info, A_LoopField, |
if (Info0 != 3)
return -3
}
else
break
}
if !Alternate
StringReplace, File, File, \, \\, All
RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
if !FileInfo
return -4
hData := DllCall("GlobalAlloc", "uint", 2, "uint", FileInfo2)
pData := DllCall("GlobalLock", "uint", hData)
DllCall("RtlMoveMemory", "uint", pData, "uint", &BRAFromMemIn+Info2+FileInfo1, "uint", FileInfo2)
DllCall("GlobalUnlock", "uint", hData)
DllCall("ole32\CreateStreamOnHGlobal", "uint", hData, "int", 1, "uint*", pStream)
DllCall("gdiplus\GdipCreateBitmapFromStream", "uint", pStream, "uint*", pBitmap)
DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
return pBitmap
}
Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
{
return DllCall("gdiplus\GdipDrawRectangle", "uint", pGraphics, "uint", pPen, "float", x, "float", y, "float", w, "float", h)
}
Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r)
{
Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
Gdip_ResetClip(pGraphics)
Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
Gdip_DrawEllipse(pGraphics, pPen, x, y, 2*r, 2*r)
Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y, 2*r, 2*r)
Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r)
Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
Gdip_ResetClip(pGraphics)
return E
}
Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h)
{
return DllCall("gdiplus\GdipDrawEllipse", "uint", pGraphics, "uint", pPen, "float", x, "float", y, "float", w, "float", h)
}
Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
{
return DllCall("gdiplus\GdipDrawBezier", "uint", pgraphics, "uint", pPen
, "float", x1, "float", y1, "float", x2, "float", y2
, "float", x3, "float", y3, "float", x4, "float", y4)
}
Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
{
return DllCall("gdiplus\GdipDrawArc", "uint", pGraphics, "uint", pPen, "float", x
, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
}
Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
{
return DllCall("gdiplus\GdipDrawPie", "uint", pGraphics, "uint", pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
}
Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
{
return DllCall("gdiplus\GdipDrawLine", "uint", pGraphics, "uint", pPen
, "float", x1, "float", y1, "float", x2, "float", y2)
}
Gdip_DrawLines(pGraphics, pPen, Points)
{
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
}
return DllCall("gdiplus\GdipDrawLines", "uint", pGraphics, "uint", pPen, "uint", &PointF, "int", Points0)
}
Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
{
return DllCall("gdiplus\GdipFillRectangle", "uint", pGraphics, "int", pBrush
, "float", x, "float", y, "float", w, "float", h)
}
Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r)
{
Region := Gdip_GetClipRegion(pGraphics)
Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r)
Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
Gdip_SetClipRegion(pGraphics, Region, 0)
Gdip_DeleteRegion(Region)
return E
}
Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0)
{
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
}
return DllCall("gdiplus\GdipFillPolygon", "uint", pGraphics, "uint", pBrush, "uint", &PointF, "int", Points0, "int", FillMode)
}
Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
{
return DllCall("gdiplus\GdipFillPie", "uint", pGraphics, "uint", pBrush
, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
}
Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h)
{
return DllCall("gdiplus\GdipFillEllipse", "uint", pGraphics, "uint", pBrush, "float", x, "float", y, "float", w, "float", h)
}
Gdip_FillRegion(pGraphics, pBrush, Region)
{
return DllCall("gdiplus\GdipFillRegion", "uint", pGraphics, "uint", pBrush, "uint", Region)
}
Gdip_FillPath(pGraphics, pBrush, Path)
{
return DllCall("gdiplus\GdipFillPath", "uint", pGraphics, "uint", pBrush, "uint", Path)
}
Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
{
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
}
if (Matrix&1 = "")
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
if (sx = "" && sy = "" && sw = "" && sh = "")
{
sx := 0, sy := 0
sw := Gdip_GetImageWidth(pBitmap)
sh := Gdip_GetImageHeight(pBitmap)
}
E := DllCall("gdiplus\GdipDrawImagePointsRect", "uint", pGraphics, "uint", pBitmap
, "uint", &PointF, "int", Points0, "float", sx, "float", sy, "float", sw, "float", sh
, "int", 2, "uint", ImageAttr, "uint", 0, "uint", 0)
if ImageAttr
Gdip_DisposeImageAttributes(ImageAttr)
return E
}
Gdip_DrawImage(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1)
{
if (Matrix&1 = "")
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
if (sx = "" && sy = "" && sw = "" && sh = "")
{
if (dx = "" && dy = "" && dw = "" && dh = "")
{
sx := dx := 0, sy := dy := 0
sw := dw := Gdip_GetImageWidth(pBitmap)
sh := dh := Gdip_GetImageHeight(pBitmap)
}
else
{
sx := sy := 0
sw := Gdip_GetImageWidth(pBitmap)
sh := Gdip_GetImageHeight(pBitmap)
}
}
E := DllCall("gdiplus\GdipDrawImageRectRect", "uint", pGraphics, "uint", pBitmap
, "float", dx, "float", dy, "float", dw, "float", dh
, "float", sx, "float", sy, "float", sw, "float", sh
, "int", 2, "uint", ImageAttr, "uint", 0, "uint", 0)
if ImageAttr
Gdip_DisposeImageAttributes(ImageAttr)
return E
}
Gdip_SetImageAttributesColorMatrix(Matrix)
{
VarSetCapacity(ColourMatrix, 100, 0)
Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", "", 1), "[^\d-\.]+", "|")
StringSplit, Matrix, Matrix, |
Loop, 25
{
Matrix := (Matrix%A_Index% != "") ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1
NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "float")
}
DllCall("gdiplus\GdipCreateImageAttributes", "uint*", ImageAttr)
DllCall("gdiplus\GdipSetImageAttributesColorMatrix", "uint", ImageAttr, "int", 1, "int", 1, "uint", &ColourMatrix, "int", 0, "int", 0)
return ImageAttr
}
Gdip_GraphicsFromImage(pBitmap)
{
DllCall("gdiplus\GdipGetImageGraphicsContext", "uint", pBitmap, "uint*", pGraphics)
return pGraphics
}
Gdip_GraphicsFromHDC(hdc)
{
DllCall("gdiplus\GdipCreateFromHDC", "uint", hdc, "uint*", pGraphics)
return pGraphics
}
Gdip_GetDC(pGraphics)
{
DllCall("gdiplus\GdipGetDC", "uint", pGraphics, "uint*", hdc)
return hdc
}
Gdip_ReleaseDC(pGraphics, hdc)
{
return DllCall("gdiplus\GdipReleaseDC", "uint", pGraphics, "uint", hdc)
}
Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
{
return DllCall("gdiplus\GdipGraphicsClear", "uint", pGraphics, "int", ARGB)
}
Gdip_BlurBitmap(pBitmap, Blur)
{
if (Blur > 100) || (Blur < 1)
return -1
sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
dWidth := sWidth//Blur, dHeight := sHeight//Blur
pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
G1 := Gdip_GraphicsFromImage(pBitmap1)
Gdip_SetInterpolationMode(G1, 7)
Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
Gdip_DeleteGraphics(G1)
pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
G2 := Gdip_GraphicsFromImage(pBitmap2)
Gdip_SetInterpolationMode(G2, 7)
Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
Gdip_DeleteGraphics(G2)
Gdip_DisposeImage(pBitmap1)
return pBitmap2
}
Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
{
SplitPath, sOutput,,, Extension
if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
return -1
Extension := "." Extension
DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
VarSetCapacity(ci, nSize)
DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, "uint", &ci)
if !(nCount && nSize)
return -2
Loop, %nCount%
{
Location := NumGet(ci, 76*(A_Index-1)+44)
if !A_IsUnicode
{
nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int",  0, "uint", 0, "uint", 0)
VarSetCapacity(sString, nSize)
DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
if !InStr(sString, "*" Extension)
continue
}
else
{
nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int",  0, "uint", 0, "uint", 0)
sString := ""
Loop, %nSize%
sString .= Chr(NumGet(Location+0, 2*(A_Index-1), "char"))
if !InStr(sString, "*" Extension)
continue
}
pCodec := &ci+76*(A_Index-1)
break
}
if !pCodec
return -3
if (Quality != 75)
{
Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality
if Extension in .JPG,.JPEG,.JPE,.JFIF
{
DllCall("gdiplus\GdipGetEncoderParameterListSize", "uint", pBitmap, "uint", pCodec, "uint*", nSize)
VarSetCapacity(EncoderParameters, nSize, 0)
DllCall("gdiplus\GdipGetEncoderParameterList", "uint", pBitmap, "uint", pCodec, "uint", nSize, "uint", &EncoderParameters)
Loop, % NumGet(EncoderParameters)
{
if (NumGet(EncoderParameters, (28*(A_Index-1))+20) = 1) && (NumGet(EncoderParameters, (28*(A_Index-1))+24) = 6)
{
p := (28*(A_Index-1))+&EncoderParameters
NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20)))
break
}
}
}
}
if !A_IsUnicode
{
nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sOutput, "int", -1, "uint", 0, "int", 0)
VarSetCapacity(wOutput, nSize*2)
DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sOutput, "int", -1, "uint", &wOutput, "int", nSize)
VarSetCapacity(wOutput, -1)
if !VarSetCapacity(wOutput)
return -4
E := DllCall("gdiplus\GdipSaveImageToFile", "uint", pBitmap, "uint", &wOutput, "uint", pCodec, "uint", p ? p : 0)
}
else
E := DllCall("gdiplus\GdipSaveImageToFile", "uint", pBitmap, "uint", &sOutput, "uint", pCodec, "uint", p ? p : 0)
return E ? -5 : 0
}
Gdip_GetPixel(pBitmap, x, y)
{
DllCall("gdiplus\GdipBitmapGetPixel", "uint", pBitmap, "int", x, "int", y, "uint*", ARGB)
return ARGB
}
Gdip_SetPixel(pBitmap, x, y, ARGB)
{
return DllCall("gdiplus\GdipBitmapSetPixel", "uint", pBitmap, "int", x, "int", y, "int", ARGB)
}
Gdip_GetImageWidth(pBitmap)
{
DllCall("gdiplus\GdipGetImageWidth", "uint", pBitmap, "uint*", Width)
return Width
}
Gdip_GetImageHeight(pBitmap)
{
DllCall("gdiplus\GdipGetImageHeight", "uint", pBitmap, "uint*", Height)
return Height
}
Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
{
DllCall("gdiplus\GdipGetImageWidth", "uint", pBitmap, "uint*", Width)
DllCall("gdiplus\GdipGetImageHeight", "uint", pBitmap, "uint*", Height)
}
Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
{
Gdip_GetImageDimensions(pBitmap, Width, Height)
}
Gdip_GetImagePixelFormat(pBitmap)
{
DllCall("gdiplus\GdipGetImagePixelFormat", "uint", pBitmap, "uint*", Format)
return Format
}
Gdip_GetDpiX(pGraphics)
{
DllCall("gdiplus\GdipGetDpiX", "uint", pGraphics, "float*", dpix)
return Round(dpix)
}
Gdip_GetDpiY(pGraphics)
{
DllCall("gdiplus\GdipGetDpiY", "uint", pGraphics, "float*", dpiy)
return Round(dpiy)
}
Gdip_GetImageHorizontalResolution(pBitmap)
{
DllCall("gdiplus\GdipGetImageHorizontalResolution", "uint", pBitmap, "float*", dpix)
return Round(dpix)
}
Gdip_GetImageVerticalResolution(pBitmap)
{
DllCall("gdiplus\GdipGetImageVerticalResolution", "uint", pBitmap, "float*", dpiy)
return Round(dpiy)
}
Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
{
return DllCall("gdiplus\GdipBitmapSetResolution", "uint", pBitmap, "float", dpix, "float", dpiy)
}
Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
{
SplitPath, sFile,,, ext
if ext in exe,dll
{
Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
VarSetCapacity(buf, 40)
Loop, Parse, Sizes, |
{
DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, "uint*", hIcon, "uint*", 0, "uint", 1, "uint", 0)
if !hIcon
continue
if !DllCall("GetIconInfo", "uint", hIcon, "uint", &buf)
{
DestroyIcon(hIcon)
continue
}
hbmColor := NumGet(buf, 16)
hbmMask  := NumGet(buf, 12)
if !(hbmColor && DllCall("GetObject", "uint", hbmColor, "int", 24, "uint", &buf))
{
DestroyIcon(hIcon)
continue
}
break
}
if !hIcon
return -1
Width := NumGet(buf, 4, "int"),  Height := NumGet(buf, 8, "int")
hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
if !DllCall("DrawIconEx", "uint", hdc, "int", 0, "int", 0, "uint", hIcon, "uint", Width, "uint", Height, "uint", 0, "uint", 0, "uint", 3)
{
DestroyIcon(hIcon)
return -2
}
VarSetCapacity(dib, 84)
DllCall("GetObject", "uint", hbm, "int", 84, "uint", &dib)
Stride := NumGet(dib, 12), Bits := NumGet(dib, 20)
DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, "uint", Bits, "uint*", pBitmapOld)
pBitmap := Gdip_CreateBitmap(Width, Height), G := Gdip_GraphicsFromImage(pBitmap)
Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
DestroyIcon(hIcon)
}
else
{
if !A_IsUnicode
{
VarSetCapacity(wFile, 1023)
DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sFile, "int", -1, "uint", &wFile, "int", 512)
DllCall("gdiplus\GdipCreateBitmapFromFile", "uint", &wFile, "uint*", pBitmap)
}
else
DllCall("gdiplus\GdipCreateBitmapFromFile", "uint", &sFile, "uint*", pBitmap)
}
return pBitmap
}
Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
{
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "uint", hBitmap, "uint", Palette, "uint*", pBitmap)
return pBitmap
}
Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
{
DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "uint", pBitmap, "uint*", hbm, "int", Background)
return hbm
}
Gdip_CreateBitmapFromHICON(hIcon)
{
DllCall("gdiplus\GdipCreateBitmapFromHICON", "uint", hIcon, "uint*", pBitmap)
return pBitmap
}
Gdip_CreateHICONFromBitmap(pBitmap)
{
DllCall("gdiplus\GdipCreateHICONFromBitmap", "uint", pBitmap, "uint*", hIcon)
return hIcon
}
Gdip_CreateBitmap(Width, Height, Format=0x26200A)
{
DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", 0, "int", Format, "uint", 0, "uint*", pBitmap)
Return pBitmap
}
Gdip_CreateBitmapFromClipboard()
{
if !DllCall("OpenClipboard", "uint", 0)
return -1
if !DllCall("IsClipboardFormatAvailable", "uint", 8)
return -2
if !hBitmap := DllCall("GetClipboardData", "uint", 2)
return -3
if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
return -4
if !DllCall("CloseClipboard")
return -5
DeleteObject(hBitmap)
return pBitmap
}
Gdip_SetBitmapToClipboard(pBitmap)
{
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
DllCall("GetObject", "uint", hBitmap, "int", VarSetCapacity(oi, 84, 0), "uint", &oi)
hdib := DllCall("GlobalAlloc", "uint", 2, "uint", 40+NumGet(oi, 44))
pdib := DllCall("GlobalLock", "uint", hdib)
DllCall("RtlMoveMemory", "uint", pdib, "uint", &oi+24, "uint", 40)
DllCall("RtlMoveMemory", "Uint", pdib+40, "Uint", NumGet(oi, 20), "uint", NumGet(oi, 44))
DllCall("GlobalUnlock", "uint", hdib)
DllCall("DeleteObject", "uint", hBitmap)
DllCall("OpenClipboard", "uint", 0)
DllCall("EmptyClipboard")
DllCall("SetClipboardData", "uint", 8, "uint", hdib)
DllCall("CloseClipboard")
}
Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
{
DllCall("gdiplus\GdipCloneBitmapArea", "float", x, "float", y, "float", w, "float", h
, "int", Format, "uint", pBitmap, "uint*", pBitmapDest)
return pBitmapDest
}
Gdip_CreatePen(ARGB, w)
{
DllCall("gdiplus\GdipCreatePen1", "int", ARGB, "float", w, "int", 2, "uint*", pPen)
return pPen
}
Gdip_CreatePenFromBrush(pBrush, w)
{
DllCall("gdiplus\GdipCreatePen2", "uint", pBrush, "float", w, "int", 2, "uint*", pPen)
return pPen
}
Gdip_BrushCreateSolid(ARGB=0xff000000)
{
DllCall("gdiplus\GdipCreateSolidFill", "int", ARGB, "uint*", pBrush)
return pBrush
}
Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
{
DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "int", ARGBfront, "int", ARGBback, "uint*", pBrush)
return pBrush
}
Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
{
if !(w && h)
DllCall("gdiplus\GdipCreateTexture", "uint", pBitmap, "int", WrapMode, "uint*", pBrush)
else
DllCall("gdiplus\GdipCreateTexture2", "uint", pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, "uint*", pBrush)
return pBrush
}
Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
{
CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
DllCall("gdiplus\GdipCreateLineBrush", "uint", &PointF1, "uint", &PointF2, "int", ARGB1, "int", ARGB2, "int", WrapMode, "uint*", LGpBrush)
return LGpBrush
}
Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1)
{
CreateRectF(RectF, x, y, w, h)
DllCall("gdiplus\GdipCreateLineBrushFromRect", "uint", &RectF, "int", ARGB1, "int", ARGB2, "int", LinearGradientMode, "int", WrapMode, "uint*", LGpBrush)
return LGpBrush
}
Gdip_CloneBrush(pBrush)
{
DllCall("gdiplus\GdipCloneBrush", "uint", pBrush, "uint*", pBrushClone)
return pBrushClone
}
Gdip_DeletePen(pPen)
{
return DllCall("gdiplus\GdipDeletePen", "uint", pPen)
}
Gdip_DeleteBrush(pBrush)
{
return DllCall("gdiplus\GdipDeleteBrush", "uint", pBrush)
}
Gdip_DisposeImage(pBitmap)
{
return DllCall("gdiplus\GdipDisposeImage", "uint", pBitmap)
}
Gdip_DeleteGraphics(pGraphics)
{
return DllCall("gdiplus\GdipDeleteGraphics", "uint", pGraphics)
}
Gdip_DisposeImageAttributes(ImageAttr)
{
return DllCall("gdiplus\GdipDisposeImageAttributes", "uint", ImageAttr)
}
Gdip_DeleteFont(hFont)
{
return DllCall("gdiplus\GdipDeleteFont", "uint", hFont)
}
Gdip_DeleteStringFormat(hFormat)
{
return DllCall("gdiplus\GdipDeleteStringFormat", "uint", hFormat)
}
Gdip_DeleteFontFamily(hFamily)
{
return DllCall("gdiplus\GdipDeleteFontFamily", "uint", hFamily)
}
Gdip_DeleteMatrix(Matrix)
{
return DllCall("gdiplus\GdipDeleteMatrix", "uint", Matrix)
}
Gdip_TextToGraphics(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0)
{
IWidth := Width, IHeight:= Height
RegExMatch(Options, "i)X([\-\d\.]+)(p*)", xpos)
RegExMatch(Options, "i)Y([\-\d\.]+)(p*)", ypos)
RegExMatch(Options, "i)W([\-\d\.]+)(p*)", Width)
RegExMatch(Options, "i)H([\-\d\.]+)(p*)", Height)
RegExMatch(Options, "i)C(?!(entre|enter))([a-f\d]+)", Colour)
RegExMatch(Options, "i)Top|Up|Bottom|Down|vCentre|vCenter", vPos)
RegExMatch(Options, "i)NoWrap", NoWrap)
RegExMatch(Options, "i)R(\d)", Rendering)
RegExMatch(Options, "i)S(\d+)(p*)", Size)
if !Gdip_DeleteBrush(Gdip_CloneBrush(Colour2))
PassBrush := 1, pBrush := Colour2
if !(IWidth && IHeight) && (xpos2 || ypos2 || Width2 || Height2 || Size2)
return -1
Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout"
Loop, Parse, Styles, |
{
if RegExMatch(Options, "\b" A_loopField)
Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8
}
Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right"
Loop, Parse, Alignments, |
{
if RegExMatch(Options, "\b" A_loopField)
Align |= A_Index//2.1
}
xpos := (xpos1 != "") ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0
ypos := (ypos1 != "") ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0
Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth
Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight
if !PassBrush
Colour := "0x" (Colour2 ? Colour2 : "ff000000")
Rendering := ((Rendering1 >= 0) && (Rendering1 <= 5)) ? Rendering1 : 4
Size := (Size1 > 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12
hFamily := Gdip_FontFamilyCreate(Font)
hFont := Gdip_FontCreate(hFamily, Size, Style)
FormatStyle := NoWrap ? 0x4000 | 0x1000 : 0x4000
hFormat := Gdip_StringFormatCreate(FormatStyle)
pBrush := PassBrush ? pBrush : Gdip_BrushCreateSolid(Colour)
if !(hFamily && hFont && hFormat && pBrush && pGraphics)
return !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0
CreateRectF(RC, xpos, ypos, Width, Height)
Gdip_SetStringFormatAlign(hFormat, Align)
Gdip_SetTextRenderingHint(pGraphics, Rendering)
ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
if vPos
{
StringSplit, ReturnRC, ReturnRC, |
if (vPos = "vCentre") || (vPos = "vCenter")
ypos += (Height-ReturnRC4)//2
else if (vPos = "Top") || (vPos = "Up")
ypos := 0
else if (vPos = "Bottom") || (vPos = "Down")
ypos := Height-ReturnRC4
CreateRectF(RC, xpos, ypos, Width, ReturnRC4)
ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
}
if !Measure
E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC)
if !PassBrush
Gdip_DeleteBrush(pBrush)
Gdip_DeleteStringFormat(hFormat)
Gdip_DeleteFont(hFont)
Gdip_DeleteFontFamily(hFamily)
return E ? E : ReturnRC
}
Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF)
{
if !A_IsUnicode
{
nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", 0, "int", 0)
VarSetCapacity(wString, nSize*2)
DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", &wString, "int", nSize)
return DllCall("gdiplus\GdipDrawString", "uint", pGraphics
, "uint", &wString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", pBrush)
}
else
{
return DllCall("gdiplus\GdipDrawString", "uint", pGraphics
, "uint", &sString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", pBrush)
}
}
Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF)
{
VarSetCapacity(RC, 16)
if !A_IsUnicode
{
nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", 0, "int", 0)
VarSetCapacity(wString, nSize*2)
DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &sString, "int", -1, "uint", &wString, "int", nSize)
DllCall("gdiplus\GdipMeasureString", "uint", pGraphics
, "uint", &wString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", &RC, "uint*", Chars, "uint*", Lines)
}
else
{
DllCall("gdiplus\GdipMeasureString", "uint", pGraphics
, "uint", &sString, "int", -1, "uint", hFont, "uint", &RectF, "uint", hFormat, "uint", &RC, "uint*", Chars, "uint*", Lines)
}
return &RC ? NumGet(RC, 0, "float") "|" NumGet(RC, 4, "float") "|" NumGet(RC, 8, "float") "|" NumGet(RC, 12, "float") "|" Chars "|" Lines : 0
}
Gdip_SetStringFormatAlign(hFormat, Align)
{
return DllCall("gdiplus\GdipSetStringFormatAlign", "uint", hFormat, "int", Align)
}
Gdip_StringFormatCreate(Format=0, Lang=0)
{
DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, "uint*", hFormat)
return hFormat
}
Gdip_FontCreate(hFamily, Size, Style=0)
{
DllCall("gdiplus\GdipCreateFont", "uint", hFamily, "float", Size, "int", Style, "int", 0, "uint*", hFont)
return hFont
}
Gdip_FontFamilyCreate(Font)
{
if !A_IsUnicode
{
nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &Font, "int", -1, "uint", 0, "int", 0)
VarSetCapacity(wFont, nSize*2)
DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, "uint", &Font, "int", -1, "uint", &wFont, "int", nSize)
DllCall("gdiplus\GdipCreateFontFamilyFromName", "uint", &wFont, "uint", 0, "uint*", hFamily)
}
else
DllCall("gdiplus\GdipCreateFontFamilyFromName", "uint", &Font, "uint", 0, "uint*", hFamily)
return hFamily
}
Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
{
DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, "uint*", Matrix)
return Matrix
}
Gdip_CreateMatrix()
{
DllCall("gdiplus\GdipCreateMatrix", "uint*", Matrix)
return Matrix
}
Gdip_CreatePath(BrushMode=0)
{
DllCall("gdiplus\GdipCreatePath", "int", BrushMode, "uint*", Path)
return Path
}
Gdip_AddPathEllipse(Path, x, y, w, h)
{
return DllCall("gdiplus\GdipAddPathEllipse", "uint", Path, "float", x, "float", y, "float", w, "float", h)
}
Gdip_AddPathPolygon(Path, Points)
{
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
}
return DllCall("gdiplus\GdipAddPathPolygon", "uint", Path, "uint", &PointF, "int", Points0)
}
Gdip_DeletePath(Path)
{
return DllCall("gdiplus\GdipDeletePath", "uint", Path)
}
Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
{
return DllCall("gdiplus\GdipSetTextRenderingHint", "uint", pGraphics, "int", RenderingHint)
}
Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
{
return DllCall("gdiplus\GdipSetInterpolationMode", "uint", pGraphics, "int", InterpolationMode)
}
Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
{
return DllCall("gdiplus\GdipSetSmoothingMode", "uint", pGraphics, "int", SmoothingMode)
}
Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
{
return DllCall("gdiplus\GdipSetCompositingMode", "uint", pGraphics, "int", CompositingMode)
}
Gdip_Startup()
{
if !DllCall("GetModuleHandle", "str", "gdiplus")
DllCall("LoadLibrary", "str", "gdiplus")
VarSetCapacity(si, 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", "uint*", pToken, "uint", &si, "uint", 0)
return pToken
}
Gdip_Shutdown(pToken)
{
DllCall("gdiplus\GdiplusShutdown", "uint", pToken)
if hModule := DllCall("GetModuleHandle", "str", "gdiplus")
DllCall("FreeLibrary", "uint", hModule)
return 0
}
Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
{
return DllCall("gdiplus\GdipRotateWorldTransform", "uint", pGraphics, "float", Angle, "int", MatrixOrder)
}
Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
{
return DllCall("gdiplus\GdipScaleWorldTransform", "uint", pGraphics, "float", x, "float", y, "int", MatrixOrder)
}
Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
{
return DllCall("gdiplus\GdipTranslateWorldTransform", "uint", pGraphics, "float", x, "float", y, "int", MatrixOrder)
}
Gdip_ResetWorldTransform(pGraphics)
{
return DllCall("gdiplus\GdipResetWorldTransform", "uint", pGraphics)
}
Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
{
pi := 3.14159, TAngle := Angle*(pi/180)
Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
if ((Bound >= 0) && (Bound <= 90))
xTranslation := Height*Sin(TAngle), yTranslation := 0
else if ((Bound > 90) && (Bound <= 180))
xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
else if ((Bound > 180) && (Bound <= 270))
xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
else if ((Bound > 270) && (Bound <= 360))
xTranslation := 0, yTranslation := -Width*Sin(TAngle)
}
Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
{
pi := 3.14159, TAngle := Angle*(pi/180)
if !(Width && Height)
return -1
RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
}
Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
{
return DllCall("gdiplus\GdipImageRotateFlip", "uint", pBitmap, "int", RotateFlipType)
}
Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0)
{
return DllCall("gdiplus\GdipSetClipRect", "uint", pGraphics, "float", x, "float", y, "float", w, "float", h, "int", CombineMode)
}
Gdip_SetClipPath(pGraphics, Path, CombineMode=0)
{
return DllCall("gdiplus\GdipSetClipPath", "uint", pGraphics, "uint", Path, "int", CombineMode)
}
Gdip_ResetClip(pGraphics)
{
return DllCall("gdiplus\GdipResetClip", "uint", pGraphics)
}
Gdip_GetClipRegion(pGraphics)
{
Region := Gdip_CreateRegion()
DllCall("gdiplus\GdipGetClip", "uint" pGraphics, "uint*", Region)
return Region
}
Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
{
return DllCall("gdiplus\GdipSetClipRegion", "uint", pGraphics, "uint", Region, "int", CombineMode)
}
Gdip_CreateRegion()
{
DllCall("gdiplus\GdipCreateRegion", "uint*", Region)
return Region
}
Gdip_DeleteRegion(Region)
{
return DllCall("gdiplus\GdipDeleteRegion", "uint", Region)
}
Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
{
CreateRect(Rect, x, y, w, h)
VarSetCapacity(BitmapData, 21, 0)
E := DllCall("Gdiplus\GdipBitmapLockBits", "uint", pBitmap, "uint", &Rect, "uint", LockMode, "int", PixelFormat, "uint", &BitmapData)
Stride := NumGet(BitmapData, 8)
Scan0 := NumGet(BitmapData, 16)
return E
}
Gdip_UnlockBits(pBitmap, ByRef BitmapData)
{
return DllCall("Gdiplus\GdipBitmapUnlockBits", "uint", pBitmap, "uint", &BitmapData)
}
Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
{
Numput(ARGB, Scan0+0, (x*4)+(y*Stride))
}
Gdip_GetLockBitPixel(Scan0, x, y, Stride)
{
return NumGet(Scan0+0, (x*4)+(y*Stride))
}
Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
{
static PixelateBitmap
if !PixelateBitmap
{
MCode_PixelateBitmap := "83EC388B4424485355568B74245C99F7FE8B5C244C8B6C2448578BF88BCA894C241C897C243485FF0F8E2E0300008B44245"
. "499F7FE897C24448944242833C089542418894424308944242CEB038D490033FF397C2428897C24380F8E750100008BCE0FAFCE894C24408DA4240000"
. "000033C03BF08944241089442460894424580F8E8A0000008B5C242C8D4D028BD52BD183C203895424208D3CBB0FAFFE8BD52BD142895424248BD52BD"
. "103F9897C24148974243C8BCF8BFE8DA424000000008B5C24200FB61C0B03C30FB619015C24588B5C24240FB61C0B015C24600FB61C11015C241083C1"
. "0483EF0175D38B7C2414037C245C836C243C01897C241475B58B7C24388B6C244C8B5C24508B4C244099F7F9894424148B44245899F7F9894424588B4"
. "4246099F7F9894424608B44241099F7F98944241085F60F8E820000008D4B028BC32BC18D68038B44242C8D04B80FAFC68BD32BD142895424248BD32B"
. "D103C18944243C89742420EB038D49008BC88BFE0FB64424148B5C24248804290FB644245888010FB644246088040B0FB644241088040A83C10483EF0"
. "175D58B44243C0344245C836C2420018944243C75BE8B4C24408B5C24508B6C244C8B7C2438473B7C2428897C24380F8C9FFEFFFF8B4C241C33D23954"
. "24180F846401000033C03BF2895424108954246089542458895424148944243C0F8E82000000EB0233D2395424187E6F8B4C243003C80FAF4C245C8B4"
. "424280FAFC68D550203CA8D0C818BC52BC283C003894424208BC52BC2408BFD2BFA8B54241889442424895424408B4424200FB614080FB60101542414"
. "8B542424014424580FB6040A0FB61439014424600154241083C104836C24400175CF8B44243C403BC68944243C7C808B4C24188B4424140FAFCE99F7F"
. "9894424148B44245899F7F9894424588B44246099F7F9894424608B44241099F7F98944241033C08944243C85F60F8E7F000000837C2418007E6F8B4C"
. "243003C80FAF4C245C8B4424280FAFC68D530203CA8D0C818BC32BC283C003894424208BC32BC2408BFB2BFA8B54241889442424895424400FB644241"
. "48B5424208804110FB64424580FB654246088018B4424248814010FB654241088143983C104836C24400175CF8B44243C403BC68944243C7C818B4C24"
. "1C8B44245C0144242C01742430836C2444010F85F4FCFFFF8B44245499F7FE895424188944242885C00F8E890100008BF90FAFFE33D2897C243C89542"
. "45489442438EB0233D233C03BCA89542410895424608954245889542414894424400F8E840000003BF27E738B4C24340FAFCE03C80FAF4C245C034C24"
. "548D55028BC52BC283C003894424208BC52BC2408BFD03CA894424242BFA89742444908B5424200FB6040A0FB611014424148B442424015424580FB61"
. "4080FB6040F015424600144241083C104836C24440175CF8B4424408B7C243C8B4C241C33D2403BC1894424400F8C7CFFFFFF8B44241499F7FF894424"
. "148B44245899F7FF894424588B44246099F7FF894424608B44241099F7FF8944241033C08944244085C90F8E8000000085F67E738B4C24340FAFCE03C"
. "80FAF4C245C034C24548D53028BC32BC283C003894424208BC32BC2408BFB03CA894424242BFA897424448D49000FB65424148B4424208814010FB654"
. "24580FB644246088118B5424248804110FB644241088043983C104836C24440175CF8B4424408B7C243C8B4C241C403BC1894424407C808D04B500000"
. "00001442454836C2438010F858CFEFFFF33D233C03BCA89542410895424608954245889542414894424440F8E9A000000EB048BFF33D2395424180F8E"
. "7D0000008B4C24340FAFCE03C80FAF4C245C8B4424280FAFC68D550203CA8D0C818BC52BC283C003894424208BC52BC240894424248BC52BC28B54241"
. "8895424548DA424000000008B5424200FB6140A015424140FB611015424588B5424240FB6140A015424600FB614010154241083C104836C24540175CF"
. "8B4424448B4C241C403BC1894424440F8C6AFFFFFF0FAF4C24188B44241499F7F9894424148B44245899F7F9894424588B44246099F7F9894424608B4"
. "4241099F7F98944241033C03944241C894424540F8E7B0000008B7C241885FF7E688B4C24340FAFCE03C80FAF4C245C8B4424280FAFC68D530203CA8D"
. "0C818BC32BC283C003894424208BC32BC2408BEB894424242BEA0FB65424148B4424208814010FB65424580FB644246088118B5424248804110FB6442"
. "41088042983C10483EF0175D18B442454403B44241C894424547C855F5E5D33C05B83C438C3"
VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
Loop % StrLen(MCode_PixelateBitmap)//2
NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "char")
}
Gdip_GetImageDimensions(pBitmap, Width, Height)
if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
return -1
if (BlockSize > Width || BlockSize > Height)
return -2
E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
if (E1 || E2)
return -3
E := DllCall(&PixelateBitmap, "uint", Scan01, "uint", Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
return 0
}
Gdip_ToARGB(A, R, G, B)
{
return (A << 24) | (R << 16) | (G << 8) | B
}
Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
{
A := (0xff000000 & ARGB) >> 24
R := (0x00ff0000 & ARGB) >> 16
G := (0x0000ff00 & ARGB) >> 8
B := 0x000000ff & ARGB
}
Gdip_AFromARGB(ARGB)
{
return (0xff000000 & ARGB) >> 24
}
Gdip_RFromARGB(ARGB)
{
return (0x00ff0000 & ARGB) >> 16
}
Gdip_GFromARGB(ARGB)
{
return (0x0000ff00 & ARGB) >> 8
}
Gdip_BFromARGB(ARGB)
{
return 0x000000ff & ARGB
}
search_in_file(file_nm,str)
{
IfExist, %file_nm%
{
Loop, read, %file_nm%
{
if str = %A_LoopReadLine%
{
return 1
}
}
}
return 0
}
search_in_file_left(file_nm,str)
{
IfExist, %file_nm%
{
Loop, read, %file_nm%
{
if str = %A_LoopReadLine%
{
return 1
}
}
}
return 0
}
arr_p1(arr,p1)
{
ini_arr(arr)
arr.Insert(p1)
return arr
}
ini_arr(byref arr)
{
if not (isobject(arr))
arr:= Object()
}
arr_p1u(arr,p1)
{
ini_arr(arr)
if search_in_arr(arr,p1) := 0
{
arr.Insert(p1)
}
return arr
}
arr_m1(arr,p1)
{
arr.Remove(search_in_arr(arr,p1))
return arr
}
file_p1u(file,str)
{
if search_in_file(file,str) := 0
{
file_p1(file,str)
}
}
file_p1ul(file,str,unk_lefk)
{
if search_in_file(file,str) := 0
{
file_p1(file,str)
}
}
file_p1(file,str)
{
file := FileOpen(file, "a")
str = %str%`r
File.WriteLine(str)
file.Close()
}
hasKeyKey(arr,key1,key2)
{
if (arr[key1,key2]=0)
return True
dd:=arr[key1,key2]
dd=%dd%-
if (dd="-")
return False
return True
}
search_in_arr(arr,val)
{
for i, el in arr
{
if (val := el)
{
return index
}
}
return -1
}
arr_to_str(arr)
{
for i, el in arr
{
ttmp_out  = %ttmp_out%%el%`n
}
return ttmp_out
}
arr_to_file(arr,file)
{
file := FileOpen(file, "w")
for i, el in arr
{
i =%i%`r
File.WriteLine(i)
el=%el%`r
File.WriteLine(el)
}
file.Close()
}
file_to_arr(file)
{
c:=0
arr:= Object()
IfExist, %file%
{
Loop, read, %file%
{
if (c=0)
{
c:=1
}
else
{
c:=0
}
if (c=1)
{
key=%A_LoopReadLine%
}
else
{
arr[key]:=(A_LoopReadLine)
}
}
}
return arr
}
list_to_arr2(same_pid_winds)
{
msgbox --- %same_pid_winds%
loop %same_pid_winds%
{
fdg:=same_pid_winds[A_index]
msgbox %e% %fdg%
}
}
list_to_arr(list2)
{
ini_arr(arr)
Loop %list2%
{
fff:=A_index
ttt:=list2%A_index%
msgbox %fff% %ttt%
arr.insert(list2%A_index%)
}
return arr
}
is_inside_BB_2d(main_obj_min, main_obj_max, ins_obj_min, ins_obj_max)
{
If ins_obj_min[0] <= main_obj_max[0] And main_obj_min[0] <= ins_obj_max[0] And ins_obj_min[1] <= main_obj_max[1] And main_obj_min[1] <= ins_obj_max[1]
{
return  True
}
return FALSE
}
is_inside_BB_2d_pt(main_obj_min, main_obj_max, ins_pt)
{
If ins_pt[0] <= main_obj_max[0] And main_obj_min[0] <= ins_pt[0] And ins_pt[1] <= main_obj_max[1] And main_obj_min[1] <= ins_pt[1]
{
return  True
}
return FALSE
}
keys(arr)
{
ini_arr(res_arr)
for i, in arr
{
res_arr.insert(i)
}
return res_arr
}
keysVal(arr,val)
{
ini_arr(res_arr)
for i, el in arr
{
if (el=val)
{
res_arr.insert(i)
}
}
return res_arr
}
Process_GetCurrentProcessID()
{
Return DllCall("GetCurrentProcessId")
}
Process_GetCurrentParentProcessID()
{
Return Process_GetParentProcessID(Process_GetCurrentProcessID())
}
Process_GetProcessName(ProcessID)
{
Return Process_GetProcessInformation(ProcessID, "Str", 260, 36)
}
Process_GetParentProcessID(ProcessID)
{
Return Process_GetProcessInformation(ProcessID, "UInt *", 4, 24)
}
Process_GetProcessThreadCount(ProcessID)
{  Return Process_GetProcessInformation(ProcessID, "UInt *", 4, 20)
}
Process_GetProcessInformation(ProcessID, CallVariableType, VariableCapacity, DataOffset)
{
hSnapshot := DLLCall("CreateToolhelp32Snapshot", "UInt", 2, "UInt", 0)
if (hSnapshot >= 0)
{
VarSetCapacity(PE32, 304, 0)
DllCall("ntdll.dll\RtlFillMemoryUlong", "UInt", &PE32, "UInt", 4, "UInt", 304)
if (DllCall("Process32First", "UInt", hSnapshot, "UInt", &PE32))
Loop
{
DllCall("RtlMoveMemory", "UInt *", th32ProcessID, "UInt", &PE32 + 8, "UInt", 4)
if (ProcessID = th32ProcessID)
{
VarSetCapacity(th32DataEntry, VariableCapacity, 0)
DllCall("RtlMoveMemory", CallVariableType, th32DataEntry, "UInt", &PE32 + DataOffset, "UInt", VariableCapacity)
DllCall("CloseHandle", "UInt", hSnapshot)
Return th32DataEntry
}
if not DllCall("Process32Next", "UInt", hSnapshot, "UInt", &PE32)
Break
}
DllCall("CloseHandle", "UInt", hSnapshot)
}
Return
}
Process_GetModuleFileNameEx(ProcessID)
{
if A_OSVersion in WIN_95, WIN_98, WIN_ME
Return Process_GetProcessName(ProcessID)
hProcess := DllCall( "OpenProcess", "UInt", 0x10|0x400, "Int", False, "UInt", ProcessID)
if (ErrorLevel or hProcess = 0)
Return
FileNameSize := 260
VarSetCapacity(ModuleFileName, FileNameSize, 0)
CallResult := DllCall("Psapi.dll\GetModuleFileNameExA", "UInt", hProcess, "UInt", 0, "Str", ModuleFileName, "UInt", FileNameSize)
DllCall("CloseHandle", hProcess)
Return ModuleFileName
}







gregster
  • Members
  • 283 posts
  • Last active: Nov 09 2015 03:08 AM
  • Joined: 19 Mar 2009

Thanks, GEV. It seems you added all used Gdip functions in the script so that there are no more external dependencies. Scriptor, does that work for you?

 

Not sure, if you changed something apart from that. It still seems to hide the quick launch buttons on my taskbar. Will have to take a deeper look into it in the next days.



Skrell
  • Members
  • 384 posts
  • Last active: Jul 07 2016 05:03 PM
  • Joined: 23 Aug 2011

Thanks, GEV. It seems you added all used Gdip functions in the script so that there are no more external dependencies. Scriptor, does that work for you?

 

Not sure, if you changed something apart from that. It still seems to hide the quick launch buttons on my taskbar. Will have to take a deeper look into it in the next days.

gregster , anything you find of benefit please repost as I'd be interested too!  :)



scriptor
  • Members
  • 668 posts
  • Last active: Feb 15 2016 01:02 AM
  • Joined: 20 Jun 2013

sorry guys, I'm just catching up with this topic now - this one skipped my mind the last week.

 

Gregster - no, it's not working - when I run the script I get stuck on the first GUI which says choose language (eng/rus) - but I can't click on anything or get past it - am I missing something simple here?



gregster
  • Members
  • 283 posts
  • Last active: Nov 09 2015 03:08 AM
  • Joined: 19 Mar 2009

Gregster - no, it's not working - when I run the script I get stuck on the first GUI which says choose language (eng/rus) - but I can't click on anything or get past it - am I missing something simple here?

 

You can't choose a language or you don't find a button to confirm? To confirm and get past, just close the gui with the x-button (a bit unusual, but it works here) after you chose your language.

 

This and other settings will be saved when you close the script in a file named settings.ini (in the script dir). That contains in my case (should be default):

ACTIVATE_ON_MOUSE_ON
0
do_scredr
0
do_scredr2
0
lang
eng
switch_on_TB_if_ActOnCl
0
THUMB_WIDTH
168
wait1
0

So, if the dialogue is really not working, you could create the settings.ini in a text editor by yourself in order to skip it...

 

 

Apart from that, my problem with the missing quick launch icons was easily fixed by commenting out these lines:

;Control, hide,, MSTaskListWClass1
;Control, hide,, MSTaskSwWClass1
;Control, hide,, ReBarWindow321
;Control, hide,, TrayShowDesktopButtonWClass1                             ; would hide the 'show desktop' button

(somewhere around line 160). My taskbar is auto-hiding anyway, so I prefer having it unaltered. Like this, it works now well for the last days. Only thing I still want to change is the default placement of the thumbnails (perhaps I will add a toggle to stack them on the side rather than at the bottom). But I didn't look into that, so far.

 

Anyway, it should work with the right gdip.ahk library for your system...(If I remember correctly, GEV gdi-included-version also worked for me)

I hope you get it working!



scriptor
  • Members
  • 668 posts
  • Last active: Feb 15 2016 01:02 AM
  • Joined: 20 Jun 2013

ahh, thanks - it works now. I just pressed the "x" to get out of it, and then the thumbnails showed up. Seems to work! Although it seems a little buggy, but I haven't spent too much time with it. I'll keep it running to see how things go - looks like a useful script! 

 

I'm wondering if I need an Aero theme installed in Win7. Because right now it's pretty buggy - all the thumbnail windows keep changing and showing bits and peices of the .exe's icons. I prefer not to use the Aero Theme if possible, though. It interferes with some software I'm running.