From c70acc73f6716c2865064e6008d7feb64528cb82 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Wed, 13 Jan 2016 12:16:37 +0100 Subject: [PATCH 01/15] [*] #45 - Windy: property next[] - gets the windy object below the current object in the Z order. Initial implementation --- YUnit_Windy.ahk | 24 +++++++++++++++++++----- lib/Windy/Const_WinUser.ahk | 14 +++++++++++++- lib/Windy/Windy.ahk | 27 ++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 0fa4f3c..8805324 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -10,7 +10,7 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "0.9.0" +ReferenceVersion := "0.9.1" debug := 1 ;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) @@ -25,12 +25,14 @@ class TempTestSuite { this.obj := new Windy(0, debug) } - scale() { + next() { Global debug OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - this.obj.maximized := true - this.obj.scale(2) + newObj := new Windy(0, debug) + x := newObj.next + Yunit.assert(this.obj.hwnd == x.hwnd) + newObj.kill() OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" } @@ -801,7 +803,19 @@ class MiscTestSuite { own:= this.obj.owner Yunit.assert(own == 0) OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" - } + } + + next() { + Global debug + + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + newObj := new Windy(0, debug) + x := newObj.next + Yunit.assert(this.obj.hwnd == x.hwnd) + newObj.kill() + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + End() { this.obj.kill() diff --git a/lib/Windy/Const_WinUser.ahk b/lib/Windy/Const_WinUser.ahk index fcb8210..7117ccc 100644 --- a/lib/Windy/Const_WinUser.ahk +++ b/lib/Windy/Const_WinUser.ahk @@ -2,7 +2,19 @@ ; Function: Several Constants from Windows_API (winuser.h) ; AHK version: 1.1.05+ ; Language: English -; Version: 1.0.00.00/2014-09-19/hoppfrosch +; Version: 1.0.01.00/2016-01-13/hoppfrosch + +; Window field offsets for GetWindow() === (winuser.h) ============================================================= +class GW { + ; https://msdn.microsoft.com/en-us/library/ms633515%28VS.85%29.aspx + static HWNDFIRST := 0 + static HWNDLAST := 1 + static HWNDNEXT := 2 + static HWNDPREV := 3 + static HWNDOWNER := 4 + static CHILD := 5 + static ENABLEDPOPUP := 6 +} ; Window field offsets for GetWindowLong() === (winuser.h) ============================================================= class GWL { diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index fd7b08c..3f838ff 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -23,7 +23,7 @@ class Windy { About: License This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See for more details. */ - _version := "0.9.0" + _version := "0.9.1" _debug := 0 _hWnd := 0 @@ -521,6 +521,31 @@ class Windy { return monID } } + next[] { + /* --------------------------------------------------------------------------------------- + Property: next [get] + gets the object below the current object in the Z order. + + Returns: + new -object + + Remarks: + * There is no setter available, since this is a constant window property + */ + get { + hwndnext := DllCall("GetWindow", "uint", this.hwnd, "uint", GW.HWNDNEXT) + while (!this.__isWindow(hwndnext)) { + hwndnext := DllCall("GetWindow", "uint", hwndnext, "uint", GW.HWNDNEXT) + } + ret := "" + if (this.__isWindow(hwndnext)) { + ret := new Windy(hwndNext) + } + if (this._debug) ; _DBG_ + OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> (" hwndnext ")]" ; _DBG_ + return ret + } + } owner[] { /* --------------------------------------------------------------------------------------- Property: owner [get/set] From f6ff01d3c794e961e7145ed536e26dda01f72cfe Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Thu, 14 Jan 2016 09:01:28 +0100 Subject: [PATCH 02/15] [*] #46 - Windy: property activated[] - Set/Unset the current window as active window or get the current state *ERRONEOUS* Initial implementation --- YUnit_Windy.ahk | 21 +++++++++++++++------ lib/Windy/Windy.ahk | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 0fa4f3c..dabcf9f 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -10,11 +10,11 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "0.9.0" +ReferenceVersion := "0.9.1" debug := 1 -;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) -Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) +Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) +;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) Return @@ -25,12 +25,21 @@ class TempTestSuite { this.obj := new Windy(0, debug) } - scale() { + activated() { Global debug OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - this.obj.maximized := true - this.obj.scale(2) + this.obj.activated := true + sleep 1000 + val := (this.obj.activated == true) + Yunit.assert(val == true) + this.obj.activated := false + Yunit.assert(this.obj.activated == false) + this.obj.activated := true + newObj := new Windy(0, debug) + Yunit.assert(this.obj.activated == false) + newObj.kill() + Yunit.assert(this.obj.activated == true) OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" } diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index fd7b08c..4aaad21 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -23,7 +23,7 @@ class Windy { About: License This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See for more details. */ - _version := "0.9.0" + _version := "0.9.1" _debug := 0 _hWnd := 0 @@ -37,6 +37,39 @@ class Windy { _posStack := 0 ; ##################### Start of Properties (AHK >1.1.16.x) ############################################################ + activated[] { + /* --------------------------------------------------------------------------------------- + Property: activated [get/set] + Set/Unset the current window as active window or get the current state + + Value: + flag - *true* or *false* (activates/deactivates *activated*-Property) + + Remarks: + * To toogle, simply use + >obj.activated := !obj.activated + */ + get { + hwnd := this.hwnd + val := WinActive("ahk_id hwnd") + ret := (val) > 0 ? 1 : 0 + if (this._debug) ; _DBG_ + OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret " (" val ")" ; _DBG_ + return ret + } + set { + hwnd := this.hwnd + if (value == true) + WinActivate, ahk_id hwnd + else if (value == false) + WinActivate, ahk_class Shell_TrayWnd ; see: https://autohotkey.com/board/topic/29314-windeactivate/ + + if (this._debug) ; _DBG_ + OutputDebug % "[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.activated ; _DBG_ + + return this.alwaysOnTop + } + } alwaysOnTop[] { /* --------------------------------------------------------------------------------------- Property: alwaysOnTop [get/set] @@ -1148,7 +1181,7 @@ class Windy { } ; ##################### End of Properties (AHK >1.1.16.x) ############################################################## - ; ######################## Methods to be called directly ########################################################### + ; ######################## Methods to be called directly ########################################################### /* --------------------------------------------------------------------------------------- Method: border2percent translates a border string to monitor percents. From dfe2be839ad00e5b9612e302f17a9ac2ea5699cb Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Mon, 8 Feb 2016 09:21:48 +0100 Subject: [PATCH 03/15] #48 - Definition of WS_EX_CLICKTHROUGH constant --- lib/Windy/Const_WinUser.ahk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Windy/Const_WinUser.ahk b/lib/Windy/Const_WinUser.ahk index fcb8210..7d3b74f 100644 --- a/lib/Windy/Const_WinUser.ahk +++ b/lib/Windy/Const_WinUser.ahk @@ -2,7 +2,7 @@ ; Function: Several Constants from Windows_API (winuser.h) ; AHK version: 1.1.05+ ; Language: English -; Version: 1.0.00.00/2014-09-19/hoppfrosch +; Version: 1.0.01.00/2016-02-08/hoppfrosch ; Window field offsets for GetWindowLong() === (winuser.h) ============================================================= class GWL { @@ -342,6 +342,7 @@ class WS { static TOOLWINDOW := 0x00000080 static TOPMOST := 0x00000008 static TRANSPARENT := 0x00000020 + static CLICKTHROUGH := 0x00000020 ; http://stackoverflow.com/questions/1524035/topmost-form-clicking-through-possible static WINDOWEDGE := 0x00000100 static OVERLAPPEDWINDOW := 0x00000300 ; WS_EX_WINDOWEDGE|EX_CLIENTEDGE static PALETTEWINDOW := 0x00000188 ; WS_EX_WINDOWEDGE|EX_TOOLWINDOW|EX_TOPMOST From 697f436ed654c1479136f86bdae64870a2853076 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Thu, 28 Apr 2016 07:33:16 +0200 Subject: [PATCH 04/15] #48 - Windy: property clickThrough() Implementation --- Examples/Windy/clickthrough.ahk | 17 +++++++++++++ YUnit_Windy.ahk | 2 +- lib/Windy/Windy.ahk | 42 ++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 Examples/Windy/clickthrough.ahk diff --git a/Examples/Windy/clickthrough.ahk b/Examples/Windy/clickthrough.ahk new file mode 100644 index 0000000..49f683e --- /dev/null +++ b/Examples/Windy/clickthrough.ahk @@ -0,0 +1,17 @@ +#include %A_ScriptDir%\..\..\lib\Windy +#include Windy.ahk + +obj := new Windy(0,0) + +ToolTip, ClickThrough:= 1`nAlwaysOnTop:=1, 100, 150 +obj.alwaysontop := 1 +obj.clickthrough := 1 +sleep 10000 +ToolTip, ClickThrough:= 0`nAlwaysOnTop:=0, 100, 150 +obj.clickthrough := 0 +obj.alwaysontop := 0 +sleep 10000 +ToolTip +obj.kill() + +ExitApp \ No newline at end of file diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 0fa4f3c..bc7ecb0 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -10,7 +10,7 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "0.9.0" +ReferenceVersion := "0.10.0" debug := 1 ;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index fd7b08c..b0661ae 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -23,7 +23,7 @@ class Windy { About: License This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See for more details. */ - _version := "0.9.0" + _version := "0.10.0" _debug := 0 _hWnd := 0 @@ -155,6 +155,46 @@ class Windy { return __classname } } + clickThrough[transparency := 128, alwaysOnTop := 0] { + /* --------------------------------------------------------------------------------------- + Property: clickThrough [get/set] + Set/Unset clickThrough flag of the current window or get the current state + + When a Window is set to clickthrough, its recommended to set the *alwaysontop*-Property as well + + Parameters: + transparency - transparency to be set on clickthrough. If clickthrough is disabled transparency will be switched off + + Value: + flag - *true* or *false* (activates/deactivates *clickThrough*-Property) + + Remarks: + * To toogle, simply use + >obj.clickThrough := !obj.clickThrough + */ + get { + ret := (this.styleEx & WS.EX.CLICKTHROUGH) > 0 ? 1 : 0 + if (this._debug) ; _DBG_ + OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + return ret + } + set { + hwnd := this.hwnd + if (value == true) { + value := "+" WS.EX.CLICKTHROUGH + tp := transparency + } else if (value == false) { + value := "-" WS.EX.CLICKTHROUGH + tp := "OFF" + } + this.transparency(100) := tp + WinSet, ExStyle, %value%, ahk_id %hwnd% + if (this._debug) ; _DBG_ + OutputDebug % "[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.clickThrough ; _DBG_ + + return this.clickThrough + } + } debug[] { /* ------------------------------------------------------------------------------- Property: debug [get/set] From 51f3d64519e90480f769d14db9c9a196248d762a Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Thu, 28 Apr 2016 09:39:53 +0200 Subject: [PATCH 05/15] #46 - Windy - property activated[] --- YUnit_Windy.ahk | 28 +++++++++++++++++++--------- lib/Windy/Windy.ahk | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 63754c6..535cc99 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -10,15 +10,11 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -<<<<<<< HEAD -ReferenceVersion := "0.9.1" -======= ReferenceVersion := "0.10.0" ->>>>>>> develop debug := 1 -Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) -;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) +;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) +Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) Return @@ -42,8 +38,6 @@ class TempTestSuite { this.obj.activated := true newObj := new Windy(0, debug) Yunit.assert(this.obj.activated == false) - newObj.kill() - Yunit.assert(this.obj.activated == true) OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" } @@ -614,7 +608,23 @@ class MiscTestSuite { _hWnd := WinExist("ahk_class Notepad") this.obj := new Windy(_hWnd, debug) } - + + activated() { + Global debug + + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + this.obj.activated := true + sleep 1000 + val := (this.obj.activated == true) + Yunit.assert(val == true) + this.obj.activated := false + Yunit.assert(this.obj.activated == false) + this.obj.activated := true + newObj := new Windy(0, debug) + Yunit.assert(this.obj.activated == false) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + Caption() { OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" OutputDebug % "....[" A_ThisFunc "] > 1" diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index 14c3aa9..0a30d22 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -51,7 +51,7 @@ class Windy { */ get { hwnd := this.hwnd - val := WinActive("ahk_id hwnd") + val := WinActive("ahk_id " hwnd) ret := (val) > 0 ? 1 : 0 if (this._debug) ; _DBG_ OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret " (" val ")" ; _DBG_ From 748033ad714cd1a4c176c36f88b389de4a1d442d Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Thu, 28 Apr 2016 11:24:47 +0200 Subject: [PATCH 06/15] #51 - MultiMony - proprties idPrimary[] and idTaskbar[] --- YUnit_MultiMony.ahk | 25 ++++++++++++++++++------- lib/Windy/MultiMony.ahk | 29 ++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/YUnit_MultiMony.ahk b/YUnit_MultiMony.ahk index fa31304..1fa597d 100644 --- a/YUnit_MultiMony.ahk +++ b/YUnit_MultiMony.ahk @@ -12,12 +12,12 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "1.0.1" +ReferenceVersion := "1.0.2" debug := 1 ;Yunit.use(YunitStdOut, YunitWindow).Test(ExpMultiMonyTestSuite) Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MultiMonyTestSuite) -ExitApp +Return class ExpMultiMonyTestSuite { Begin() { @@ -26,7 +26,7 @@ class ExpMultiMonyTestSuite { this.monCount := 2 this.mon1Width := 1920 this.mon1Height := 1080 - this.mon2Width := 1600 + this.mon2Width := 1920 this.mon2Height := 1200 this.monvirtWidth := this.mon1Width + this.mon2Width @@ -56,15 +56,26 @@ class MultiMonyTestSuite Global debug this.obj := new MultiMony(debug) this.monCount := 2 - this.mon1Width := 1920 - this.mon1Height := 1080 - this.mon2Width := 1600 - this.mon2Height := 1200 + this.mon2Width := 1920 + this.mon2Height := 1080 + this.mon1Width := 1900 + this.mon1Height := 1200 this.monvirtWidth := this.mon1Width + this.mon2Width this.monvirtHeight := this.mon2Height } + idPrimary() { + Global debug + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + prim := this.obj.idPrimary + Yunit.assert(prim == 2) + tb := this.obj.idTaskbar + Yunit.assert(tb == prim) + Yunit.assert(tb == 2) + OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + } + coordDisplayToVirtualScreen() { Global debug OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" diff --git a/lib/Windy/MultiMony.ahk b/lib/Windy/MultiMony.ahk index 62eebc9..9eeda2b 100644 --- a/lib/Windy/MultiMony.ahk +++ b/lib/Windy/MultiMony.ahk @@ -19,7 +19,7 @@ */ class MultiMony { _debug := 0 - _version := "1.0.1" + _version := "1.0.2" ; ===== Properties ============================================================== debug[] { @@ -39,6 +39,33 @@ class MultiMony { return this._debug } } + idPrimary[] { + /* --------------------------------------------------------------------------------------- + Property: idPrimary [get] + Get the ID of the primary monitor + + Remarks: + * There is no setter available, since this is a constant system property + */ + get { + SysGet, ret, MonitorPrimary + if (this._debug) ; _DBG_ + OutputDebug % "|[" A_ThisFunc "([" this.id "]) -> (" ret ")]" ; _DBG_ + return ret + } + } + idTaskbar[] { + /* --------------------------------------------------------------------------------------- + Property: idTaskbar [get] + Get the ID of the monitor where the taskbar is on (aka. primary monitor) + + Remarks: + * There is no setter available, since this is a constant system property + */ + get { + return this.idPrimary + } + } monitorsCount[] { /* --------------------------------------------------------------------------------------- Property: monitorsCount [get] From bf946e497334ad828313a41ac4a2c19cdc18ff47 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Fri, 29 Apr 2016 11:34:25 +0200 Subject: [PATCH 07/15] #45 - Windy: property previous[]/next[] - gets the windy object above/below the current object in the Z order. --- YUnit_Windy.ahk | 25 ++++++++------------ lib/Windy/Const_WinUser.ahk | 13 ++++++++++ lib/Windy/Windy.ahk | 47 +++++++++++++++++++++++++++++++------ 3 files changed, 63 insertions(+), 22 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 535cc99..f9c79eb 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -13,8 +13,8 @@ ReferenceVersion := "0.10.0" debug := 1 -;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) -Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) +Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) +;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) Return @@ -24,20 +24,14 @@ class TempTestSuite { Global debug this.obj := new Windy(0, debug) } - - activated() { - Global debug - + previous() { OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - this.obj.activated := true - sleep 1000 - val := (this.obj.activated == true) - Yunit.assert(val == true) - this.obj.activated := false - Yunit.assert(this.obj.activated == false) - this.obj.activated := true - newObj := new Windy(0, debug) - Yunit.assert(this.obj.activated == false) + hwndnext := this.obj.next + newObj := new Windy(hwndnext, 1) + hwndprev := newObj.previous + Yunit.assert(this.obj.hwnd == hwndprev) + Yunit.assert(newObj.hwnd == hwndnext) + newObj.kill() OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" } @@ -620,6 +614,7 @@ class MiscTestSuite { this.obj.activated := false Yunit.assert(this.obj.activated == false) this.obj.activated := true + val := (this.obj.activated == true) newObj := new Windy(0, debug) Yunit.assert(this.obj.activated == false) OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" diff --git a/lib/Windy/Const_WinUser.ahk b/lib/Windy/Const_WinUser.ahk index 7d3b74f..391ae35 100644 --- a/lib/Windy/Const_WinUser.ahk +++ b/lib/Windy/Const_WinUser.ahk @@ -4,6 +4,19 @@ ; Language: English ; Version: 1.0.01.00/2016-02-08/hoppfrosch + +; GetWindow() constants ====================== (winuser.h) ============================================================= +class GW { + ; hhttps://msdn.microsoft.com/de-de/library/windows/desktop/ms633515%28v=vs.85%29.aspx + static HWNDFIRST := 0 + static HWNDLAST := 1 + static HWNDNEXT := 2 + static HWNDPREV := 3 + static OWNER := 4 + static CHILD := 5 + static ENABLEDPOPUP := 6 + static MAX := 6 +} ; Window field offsets for GetWindowLong() === (winuser.h) ============================================================= class GWL { ; http://msdn.microsoft.com/en-us/library/windows/desktop/ms633584%28v=vs.85%29.aspx diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index 7ed8d1c..a2eee79 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -606,17 +606,21 @@ class Windy { * There is no setter available, since this is a constant window property */ get { - hwndnext := DllCall("GetWindow", "uint", this.hwnd, "uint", GW.HWNDNEXT) - while (!this.__isWindow(hwndnext)) { + ; http://autohotkey.com/board/topic/32171-how-to-get-the-id-of-the-next-or-previous-window-in-z-order/?p=205384 + hwndnext := this.hwnd + Loop { hwndnext := DllCall("GetWindow", "uint", hwndnext, "uint", GW.HWNDNEXT) - } - ret := "" - if (this.__isWindow(hwndnext)) { - ret := new Windy(hwndNext) + ; GetWindow() returns a decimal value, so we have to convert it to hex + SetFormat,integer,hex + hwndnext += 0 + SetFormat,integer,d + ; GetWindow() processes even hidden windows, so we move down the z oder until the next visible window is found + if (DllCall("IsWindowVisible","uint",hwndnext) = 1) + break } if (this._debug) ; _DBG_ OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> (" hwndnext ")]" ; _DBG_ - return ret + return hwndnext } } owner[] { @@ -746,6 +750,35 @@ class Windy { return newPos } } + previous[] { + /* --------------------------------------------------------------------------------------- + Property: previous [get] + gets the object above the current object in the Z order. + + Returns: + new -object + + Remarks: + * There is no setter available, since this is a constant window property + */ + get { + ; http://autohotkey.com/board/topic/32171-how-to-get-the-id-of-the-next-or-previous-window-in-z-order/?p=205384 + hwndprev := this.hwnd + Loop { + hwndprev := DllCall("GetWindow", "uint", hwndprev, "uint", GW.HWNDPREV) + ; GetWindow() returns a decimal value, so we have to convert it to hex + SetFormat,integer,hex + hwndprev += 0 + SetFormat,integer,d + ; GetWindow() processes even hidden windows, so we move down the z oder until the next visible window is found + if (DllCall("IsWindowVisible","uint",hwndprev) = 1) + break + } + if (this._debug) ; _DBG_ + OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> (" hwndprev ")]" ; _DBG_ + return hwndprev + } + } processID[] { /*--------------------------------------------------------------------------------------- Property: processID [get] From 9306f26aaa7f368d27ee46f7f1aa91b927008a69 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Mon, 2 May 2016 08:16:20 +0200 Subject: [PATCH 08/15] Updated Unittest-Framework YUnit --- YUnit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YUnit b/YUnit index 1d24d41..d5f8953 160000 --- a/YUnit +++ b/YUnit @@ -1 +1 @@ -Subproject commit 1d24d414dd9621bd28be50ea699d9fabf6418e7b +Subproject commit d5f895390d52bce98e2974bc6234d4fb58895a0c From 25fb2e38a1b821dc396bf2a559ef79006d953fc9 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Tue, 3 May 2016 08:34:11 +0200 Subject: [PATCH 09/15] #52 Windy: Property geometry.captionheight[] --- YUnit_Windy.ahk | 40 ++++++++++++++++++++++++++++------------ lib/Windy/Windy.ahk | 26 +++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 535cc99..1a44193 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -10,11 +10,11 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "0.10.0" +ReferenceVersion := "0.10.1" debug := 1 ;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) -Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) +Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, GeometryTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) Return @@ -25,19 +25,12 @@ class TempTestSuite { this.obj := new Windy(0, debug) } - activated() { + captionheight() { Global debug OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - this.obj.activated := true - sleep 1000 - val := (this.obj.activated == true) - Yunit.assert(val == true) - this.obj.activated := false - Yunit.assert(this.obj.activated == false) - this.obj.activated := true - newObj := new Windy(0, debug) - Yunit.assert(this.obj.activated == false) + x := this.obj.geometry.captionheight + Yunit.assert(x == 22) OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" } @@ -48,6 +41,7 @@ class TempTestSuite { } } +; ################################################################### class _BaseTestSuite { Begin() { Global debug @@ -68,6 +62,28 @@ class _BaseTestSuite { } } +; ################################################################### +class GeometryTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + captionheight() { + Global debug + + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + x := this.obj.geometry.captionheight + Yunit.assert(x == 22) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} ; ################################################################### class TileTestSuite { diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index 0a30d22..98d3a39 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -23,7 +23,7 @@ class Windy { About: License This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See for more details. */ - _version := "0.10.0" + _version := "0.10.1" _debug := 0 _hWnd := 0 @@ -36,6 +36,30 @@ class Windy { _posStack := 0 + class geometry { +; ****************************************************************************************************************************************** +/* + Class: Windy.Geometry + Geometry of the window + + Authors: + : Original +*/ + captionHeight[] { + /* --------------------------------------------------------------------------------------- + Property: captionHeight [get] + Height of the caption bar + + Remarks: + * There is no setter available, since this is a constant window property + */ + get { + SysGet, val, 4 + return val + } + } + } + ; ##################### Start of Properties (AHK >1.1.16.x) ############################################################ activated[] { /* --------------------------------------------------------------------------------------- From 5165785e6391941fc4094999d0137022b42da2db Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Wed, 4 May 2016 11:17:23 +0200 Subject: [PATCH 10/15] #53 - Moved metgod captionHeight() from subclass geometry to parent class windy subclass geometry does not make much sense, since a lot of functions to be moved there need to call methods from parent class. This is not easy to handle in AHK --- YUnit_Windy.ahk | 105 +++----------------------------------------- lib/Windy/Windy.ahk | 39 ++++++---------- 2 files changed, 19 insertions(+), 125 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 1a44193..f743886 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -10,7 +10,7 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "0.10.1" +ReferenceVersion := "0.10.2" debug := 1 ;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) @@ -73,7 +73,7 @@ class GeometryTestSuite { Global debug OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - x := this.obj.geometry.captionheight + x := this.obj.captionheight Yunit.assert(x == 22) OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" } @@ -805,7 +805,7 @@ class MiscTestSuite { OutputDebug % "**** " A_ThisFunc " 1 ****" this.obj.Move(2,2,300,300) monID := this.obj.monitorID - Yunit.assert(monId == 1) + Yunit.assert(monId == 2) OutputDebug % "**** " A_ThisFunc " 2 - via Move ****" obj := new Mony(2, debug) rect2 := obj.boundary @@ -813,9 +813,9 @@ class MiscTestSuite { monID := this.obj.monitorID Yunit.assert(monId == 2) OutputDebug % "**** " A_ThisFunc " 3 - via MonitorID ****" - this.obj.monitorID := 1 + this.obj.monitorID := 2 monID := this.obj.monitorID - Yunit.assert(monId == 1) + Yunit.assert(monId == 2) OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" } @@ -874,98 +874,3 @@ class ExistTestSuite { this.obj := } } - - -/* -; ################################################################### -class MoveResizeTestSuite -{ - Begin() - { - Global debug - this.obj := new Windy(0, debug) - sleep 1000 - } - - MoveViaWinMove() - { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "Initial Position: " this.obj._lastPos.Dump() " - Restore: " this.obj._restorePos.Dump() - hwnd := this.obj.hwnd - xold := this.obj._lastPos.x - yold := this.obj._lastPos.y - xnew := xold+10 - ynew := yold+10 - - OutputDebug % "BEFORE - Moving from x,y(" xold "," yold ") to (" xnew "," ynew ")" - WinMove % "ahk_id" this.obj.hwnd, ,xnew, ynew - OutputDebug % "AFTER - Moving from x,y(" xold "," yold ") to (" xnew "," ynew ")" - Yunit.assert(this.obj.isMoved()==1) - Yunit.assert(this.obj.isResized()==0) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" - } - - MoveResizeViaWinMove() - { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "Initial Position: " this.obj._lastPos.Dump() " - Restore: " this.obj._restorePos.Dump() - hwnd := this.obj.hwnd - xold := this.obj._lastPos.x - yold := this.obj._lastPos.y - wold := this.obj._lastPos.w - hold := this.obj._lastPos.h - xnew := xold+10 - ynew := yold+20 - wnew := wold+10 - hnew := hold+20 - OutputDebug % "BEFORE- Moving/Resizing from x,y,w,h(" xold "," yold "," wold "," hold ") to (" xnew "," ynew "," wnew "," hnew ")" - WinMove % "ahk_id" this.obj.hwnd, , xnew, ynew, wnew, hnew - OutputDebug % "AFTER - Moving/Resizing from x,y,w,h(" xold "," yold "," wold "," hold ") to (" xnew "," ynew "," wnew "," hnew ")" - Yunit.assert(this.obj.isMoved()==1) - Yunit.assert(this.obj.isResized()==1) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" - } - - ResizeViaWinMove() - { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "Initial Position: " this.obj._lastPos.Dump() " - Restore: " this.obj._restorePos.Dump() - hwnd := this.obj.hwnd - hwnd := this.obj.hwnd - xold := this.obj._lastPos.x - yold := this.obj._lastPos.y - wold := this.obj._lastPos.w - hold := this.obj._lastPos.h - wnew := wold+10 - hnew := hold+20 - OutputDebug % "BEFORE- Resizing from w,h(" wold "," hold ") to (" wnew "," hnew ")" - WinMove % "ahk_id" this.obj.hwnd, , xold, yold, wnew, hnew - OutputDebug % "AFTER- Resizing from w,h(" wold "," hold ") to (" wnew "," hnew ")" - Yunit.assert(this.obj.isMoved()==0) - Yunit.assert(this.obj.isResized()==1) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" - } - - NoMoveResize() { - Global debug - success := 1 - l := new Windy(0, debug) - WinMove % "ahk_id" l._hWnd, , l._lastPos.x, l._lastPos.y, l._lastPos.w, l._lastPos.h - isMoved := l.isMoved() - isResized := l.isResized() - success := success && !(isMoved) && !(isResized) - l.kill() - if !success - throw " - } - - End() - { - sleep,2000 - this.obj.kill() - this.remove("obj") - this.obj := - } -} - -*/ \ No newline at end of file diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index 98d3a39..f2f41e3 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -23,7 +23,7 @@ class Windy { About: License This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See for more details. */ - _version := "0.10.1" + _version := "0.10.2" _debug := 0 _hWnd := 0 @@ -36,30 +36,6 @@ class Windy { _posStack := 0 - class geometry { -; ****************************************************************************************************************************************** -/* - Class: Windy.Geometry - Geometry of the window - - Authors: - : Original -*/ - captionHeight[] { - /* --------------------------------------------------------------------------------------- - Property: captionHeight [get] - Height of the caption bar - - Remarks: - * There is no setter available, since this is a constant window property - */ - get { - SysGet, val, 4 - return val - } - } - } - ; ##################### Start of Properties (AHK >1.1.16.x) ############################################################ activated[] { /* --------------------------------------------------------------------------------------- @@ -160,6 +136,19 @@ class Windy { return value } } + captionHeight[] { + /* --------------------------------------------------------------------------------------- + Property: captionHeight [get] + Height of the caption bar + + Remarks: + * There is no setter available, since this is a constant window property + */ + get { + SysGet, val, 4 + return val + } + } centercoords[] { /* --------------------------------------------------------------------------------------- Property: centercoords [get/set] From 4df2b07e141a2613caf6d69692a43732163817bc Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Mon, 19 Dec 2016 10:23:51 +0100 Subject: [PATCH 11/15] Usage of own function DbgOut in several modules --- Examples/WindLy/Windly_Demo01_Basic.ahk | 3 + .../WindLy/Windly_Demo02_Intersection.ahk | 5 +- YUnit | 2 +- YUnit_Windy_Fade.ahk | 949 ++++++++++++++++++ lib/DbgOut.ahk | 43 + lib/Windy/Recty.ahk | 14 +- lib/Windy/WindLy.ahk | 34 +- lib/Windy/Windy.ahk | 274 ++--- 8 files changed, 1120 insertions(+), 204 deletions(-) create mode 100644 YUnit_Windy_Fade.ahk create mode 100644 lib/DbgOut.ahk diff --git a/Examples/WindLy/Windly_Demo01_Basic.ahk b/Examples/WindLy/Windly_Demo01_Basic.ahk index f80be83..e3003f3 100644 --- a/Examples/WindLy/Windly_Demo01_Basic.ahk +++ b/Examples/WindLy/Windly_Demo01_Basic.ahk @@ -1,5 +1,8 @@ #include %A_ScriptDir%\..\..\lib\Windy\WindLy.ahk #include %A_ScriptDir%\..\..\lib\Windy\Const_WinUser.ahk +#include %A_ScriptDir%\..\..\lib\DbgOut.ahk + +OutputDebug DBGVIEWCLEAR OutputDebug % "******** All Windows **************************************************************************" x := new WindLy() diff --git a/Examples/WindLy/Windly_Demo02_Intersection.ahk b/Examples/WindLy/Windly_Demo02_Intersection.ahk index 7aa1326..8f53c8f 100644 --- a/Examples/WindLy/Windly_Demo02_Intersection.ahk +++ b/Examples/WindLy/Windly_Demo02_Intersection.ahk @@ -1,9 +1,12 @@ #include %A_ScriptDir%\..\..\lib\Windy #include WindLy.ahk #include Windy.ahk +#include ..\DbgOut.ahk + +OutputDebug DBGVIEWCLEAR OutputDebug % "******** Start Situation: All windows of monitor 1 *******************" -x := new WindLy() +x := new WindLy(0) x.byMonitorId(1) for key, data in x.list { OutputDebug % " " key ": " data.hwnd ": " data.title " (" key ")" diff --git a/YUnit b/YUnit index d5f8953..c7060c6 160000 --- a/YUnit +++ b/YUnit @@ -1 +1 @@ -Subproject commit d5f895390d52bce98e2974bc6234d4fb58895a0c +Subproject commit c7060c62f64e5b809c6da0c891ff02308496c12f diff --git a/YUnit_Windy_Fade.ahk b/YUnit_Windy_Fade.ahk new file mode 100644 index 0000000..f40c97d --- /dev/null +++ b/YUnit_Windy_Fade.ahk @@ -0,0 +1,949 @@ +;#NoEnv +#Warn + +#Include %A_ScriptDir%\Yunit\Yunit.ahk +#Include %A_ScriptDir%\Yunit\Window.ahk +#Include %A_ScriptDir%\Yunit\StdOut.ahk +#include +#include %A_ScriptDir%\lib\\DbgOut.ahk + +; #Warn All +;#Warn LocalSameAsGlobal, Off +#SingleInstance force + +ReferenceVersion := "0.10.2" +debug := 1 + +OutputDebug DBGVIEWCLEAR + +Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TransparencyTestSuite) +;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) +Return + + +; ################################################################### +class TempTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + activated() { + Global debug + + dbgOut(">[" A_ThisFunc "]") + this.obj.activated := true + sleep 1000 + val := (this.obj.activated == true) + Yunit.assert(val == true) + this.obj.activated := false + Yunit.assert(this.obj.activated == false) + this.obj.activated := true + newObj := new Windy(0, debug) + Yunit.assert(this.obj.activated == false) + dbgOut("<[" A_ThisFunc "]") + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + +class _BaseTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + Version() { + dbgOut(">[" A_ThisFunc "]") + Global ReferenceVersion + Yunit.assert(this.obj._version == ReferenceVersion) + dbgOut("<[" A_ThisFunc "]") + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + + +; ################################################################### +class TileTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + movePercental() { + Global debug + + dbgOut(">[" A_ThisFunc "]") + this.obj.movePercental(25, 25, 50, 50) + MsgBox % A_ThisFunc " - To be done ..." + dbgOut("<[" A_ThisFunc "]") + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + +; ################################################################### +class TransparencyTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + Transparency() { + dbgOut(">[" A_ThisFunc "]") +; OutputDebug % "**** " A_ThisFunc " 1 ****" +; t := this.obj.transparency +; Yunit.assert(t == 255) +; OutputDebug % "**** " A_ThisFunc " 3 ****" +; this.obj.transparency(1,5) := 100 +; t := this.obj.transparency +; Yunit.assert(t == 100) +; OutputDebug % "**** " A_ThisFunc " 3 ****" +; this.obj.transparency(1,5) := "OFF" +; t := this.obj.transparency +; Yunit.assert(t == 255) + step := 20 + delay := 3 + this.obj.transparency(step,delay) := 100 + this.obj.transparency(step,delay) := "OFF" + this.obj.transparency(step,delay) := 100 + this.obj.transparency(step,delay) := "OFF" + + dbgOut("<[" A_ThisFunc "]") + } + + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + +; ################################################################### +class RollupTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + RollupToggle() { + Global debug + + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "**** " A_ThisFunc " 1 ****" + val := this.obj.rolledUp + Yunit.assert(val == false) + + OutputDebug % "**** " A_ThisFunc " 2 ****" + this.obj.rolledUp := false + val := this.obj.rolledUp + Yunit.assert(val == false) + + OutputDebug % "**** " A_ThisFunc " 3 ****" + this.obj.rolledUp := true + val := this.obj.rolledUp + Yunit.assert(val == true) + + OutputDebug % "**** " A_ThisFunc " 4 ****" + this.obj.rolledUp := false + val := this.obj.rolledUp + Yunit.assert(val == false) + + OutputDebug % "**** " A_ThisFunc " 5 ****" + this.obj.rolledUp := !this.obj.rolledUp ; as the window wasn't rolled up, it should be rolled up now + val := this.obj.rolledUp + Yunit.assert(val == true) + + OutputDebug % "**** " A_ThisFunc " 6 ****" + this.obj.rolledUp := !this.obj.rolledUp ; as the window was rolled up, it shouldn't be rolled up now + val := this.obj.rolledUp + Yunit.assert(val == false) + + OutputDebug % "**** " A_ThisFunc " 7 ****" + this.End() + val := this.obj.rolledUp + Yunit.assert(val == ) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + +; ################################################################### +class MoveResizeTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + Maximize() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == false) + this.obj.maximized := true + Yunit.assert(this.obj.maximized == true) + Yunit.assert(this.obj.minimized == false) + this.obj.maximized := false + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == false) + this.obj.maximized := !this.obj.maximized + Yunit.assert(this.obj.maximized == true) + Yunit.assert(this.obj.minimized == false) + this.obj.maximized := !this.obj.maximized + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == false) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + + } + + Minimize() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == false) + this.obj.minimized := true + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == true) + this.obj.minimized := false + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == false) + this.obj.minimized := !this.obj.minimized + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == true) + this.obj.minimized := !this.obj.minimized + Yunit.assert(this.obj.maximized == false) + Yunit.assert(this.obj.minimized == false) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + + } + + MoveViaWinMove() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + xnew := oldPos.x+200 + ynew := oldPos.y+200 + + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" + WinMove % "ahk_id" this.obj.hwnd, ,xnew, ynew + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == xnew) + Yunit.assert(newPos.y == ynew) + Yunit.assert(newPos.w == oldPos.w) + Yunit.assert(newPos.h == oldPos.h) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MoveViaMoveMethod() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + xnew := oldPos.x+200 + ynew := oldPos.y+200 + + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" + this.obj.move(xnew, ynew, oldPos.w, oldPos.h) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == xnew) + Yunit.assert(newPos.y == ynew) + Yunit.assert(newPos.w == oldPos.w) + Yunit.assert(newPos.h == oldPos.h) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MoveViaPosSizeProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + xnew := oldPos.x+200 + ynew := oldPos.y+200 + + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" + this.obj.posSize := new Recty(xnew,ynew,oldPos.w,oldPos.h) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == xnew) + Yunit.assert(newPos.y == ynew) + Yunit.assert(newPos.w == oldPos.w) + Yunit.assert(newPos.h == oldPos.h) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MoveViaPosProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.pos + OutputDebug % "Initial Position: " oldPos.Dump() + + xnew := oldPos.x+200 + ynew := oldPos.y+200 + + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew ")" + this.obj.pos := new Pointy(xnew,ynew) + newPos := this.obj.pos + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == xnew) + Yunit.assert(newPos.y == ynew) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MoveResizeViaWinMove() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + xnew := oldPos.x+10 + ynew := oldPos.y+20 + wnew := oldPos.w+10 + hnew := oldPos.h+20 + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" + WinMove % "ahk_id" this.obj.hwnd, , xnew, ynew, wnew, hnew + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == xnew) + Yunit.assert(newPos.y == ynew) + Yunit.assert(newPos.w == wnew) + Yunit.assert(newPos.h == hnew) + + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MoveResizeViaMoveMehod() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + xnew := oldPos.x+10 + ynew := oldPos.y+20 + wnew := oldPos.w+10 + hnew := oldPos.h+20 + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" + this.obj.move(xnew, ynew, wnew, hnew) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == xnew) + Yunit.assert(newPos.y == ynew) + Yunit.assert(newPos.w == wnew) + Yunit.assert(newPos.h == hnew) + + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MoveResizeViaPosSizeProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + xnew := oldPos.x+10 + ynew := oldPos.y+20 + wnew := oldPos.w+10 + hnew := oldPos.h+20 + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" + this.obj.posSize := new Recty(xnew, ynew, wnew, hnew) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == xnew) + Yunit.assert(newPos.y == ynew) + Yunit.assert(newPos.w == wnew) + Yunit.assert(newPos.h == hnew) + + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + ResizeViaWinMove() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + wnew := oldPos.w+100 + hnew := oldPos.h+200 + + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" + WinMove % "ahk_id" this.obj.hwnd, , oldPos.x, oldPos.y, wnew, hnew + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == oldPos.x) + Yunit.assert(newPos.y == oldPos.y) + Yunit.assert(newPos.w == wnew) + Yunit.assert(newPos.h == hnew) + + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + ResizeViaMoveMethod() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + wnew := oldPos.w+100 + hnew := oldPos.h+200 + + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" + this.obj.move(oldPos.x, oldPos.y, wnew, hnew) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == oldPos.x) + Yunit.assert(newPos.y == oldPos.y) + Yunit.assert(newPos.w == wnew) + Yunit.assert(newPos.h == hnew) + + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + ResizeViaPosSizeProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + + wnew := oldPos.w+100 + hnew := oldPos.h+200 + + OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" + this.obj.posSize := new Recty(oldPos.x, oldPos.y, wnew, hnew) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == oldPos.x) + Yunit.assert(newPos.y == oldPos.y) + Yunit.assert(newPos.w == wnew) + Yunit.assert(newPos.h == hnew) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + ResizeViaSizeProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldSize:= this.obj.size + OutputDebug % "Initial Size: " oldSize.Dump() + + wnew := oldSize.x+100 + hnew := oldSize.y+200 + + OutputDebug % "BEFORE - Resizing from " oldSize.Dump() " to (" wnew "," hnew ")" + this.obj.size := new Pointy(wnew, hnew) + newSize := this.obj.size + OutputDebug % "AFTER - Resizing from " oldSize.Dump() " to " newSize.Dump() + Yunit.assert(newSize.x == wnew) + Yunit.assert(newSize.y == hnew) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + NoMoveResizeViaWinMove() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + WinMove % "ahk_id" this.obj.hwnd, , oldPos.x, oldPos.y, oldPos.w, oldPos.h + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == oldPos.x) + Yunit.assert(newPos.y == oldPos.y) + Yunit.assert(newPos.w == oldPos.w) + Yunit.assert(newPos.h == oldPos.h) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + NoMoveResizeViaMoveMehod() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + this.obj.move(oldPos.x, oldPos.y, oldPos.w, oldPos.h) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == oldPos.x) + Yunit.assert(newPos.y == oldPos.y) + Yunit.assert(newPos.w == oldPos.w) + Yunit.assert(newPos.h == oldPos.h) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + NoMoveResizeViaPosSizeProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.posSize + OutputDebug % "Initial Position: " oldPos.Dump() + this.obj.posSize := new Recty(oldPos.x, oldPos.y, oldPos.w, oldPos.h) + newPos := this.obj.posSize + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == oldPos.x) + Yunit.assert(newPos.y == oldPos.y) + Yunit.assert(newPos.w == oldPos.w) + Yunit.assert(newPos.h == oldPos.h) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + NoMoveViaPosProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldPos := this.obj.pos + OutputDebug % "Initial Position: " oldPos.Dump() + this.obj.pos := new Pointy(oldPos.x, oldPos.y) + newPos := this.obj.pos + OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + Yunit.assert(newPos.x == oldPos.x) + Yunit.assert(newPos.y == oldPos.y) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + NoResizeViaSizeProperty() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + oldSize := this.obj.size + OutputDebug % "Initial Size: " oldSize.Dump() + this.obj.size := new Pointy(oldSize.x, oldSize.y) + newSize := this.obj.size + OutputDebug % "AFTER - Resizing from " oldSize.Dump() " to " newSize.Dump() + Yunit.assert(newSize.x == oldSize.x) + Yunit.assert(newSize.y == oldSize.y) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + scale() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + this.obj.maximized := true + this.obj.scale(2) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + +; ################################################################### +class HideShowTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + HideShowToggle() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.hidden == false) + this.obj.hidden := false + Yunit.assert(this.obj.hidden == false) + this.obj.hidden := true + Yunit.assert(this.obj.hidden == true) + this.obj.hidden := false + Yunit.assert(this.obj.hidden == false) + this.obj.hidden := true + Yunit.assert(this.obj.hidden == true) + this.obj.hidden := !this.obj.hidden ; as the window was hidden, it shouldn't be hidden now + Yunit.assert(this.obj.hidden == false) + this.obj.hidden := !this.obj.hidden ; as the window wasn't hidden, it should be hidden now + Yunit.assert(this.obj.hidden == true) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + HiddenFalse() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.hidden==false) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + HiddenTrue() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + this.obj.hidden := true + Yunit.assert(this.obj.hidden == true) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + HiddenDoesNotExist() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + this.obj.kill() + Yunit.assert(this.obj.hidden==-1) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + +; ################################################################### +class NotRealWindowTestSuite { + Test() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Global debug + HDesktop := DllCall("User32.dll\GetDesktopWindow", "UPtr") + this.obj := new Windy(HDesktop, debug) + Yunit.assert(this.obj==) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } +} + +; ################################################################### +class MiscTestSuite { + Begin() { + Global debug + ; Create a Testwindow ... + Run, notepad.exe + WinWait, ahk_class Notepad, , 2 + WinMove, ahk_class Notepad,, 10, 10, 300, 300 + _hWnd := WinExist("ahk_class Notepad") + this.obj := new Windy(_hWnd, debug) + } + + activated() { + Global debug + + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + this.obj.activated := true + sleep 1000 + val := (this.obj.activated == true) + Yunit.assert(val == true) + this.obj.activated := false + Yunit.assert(this.obj.activated == false) + this.obj.activated := true + newObj := new Windy(0, debug) + Yunit.assert(this.obj.activated == false) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + Caption() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "....[" A_ThisFunc "] > 1" + Yunit.assert(this.obj.caption == 1) + OutputDebug % "....[" A_ThisFunc "] > 0" + this.obj.caption := 0 + Yunit.assert(this.obj.caption == 0) + OutputDebug % "....[" A_ThisFunc "] > 1" + this.obj.caption := 1 + Yunit.assert(this.obj.caption == 1) + OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + } + + Center() { + Global debug + + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + hwnd := this.obj.hwnd + WinGetPos x, y, w, h, ahk_id %hwnd% + centerx := round(x+(w)/2) + centery := round(y+(h)/2) + OutputDebug % "**** " A_ThisFunc " 1 ****" + center := this.obj.centercoords + Yunit.assert(center.x == centerx) + Yunit.assert(center.y == centery) + + OutputDebug % "**** " A_ThisFunc " 2 ****" + newCenter := new Pointy(205,205,debug) + this.obj.centercoords := newCenter + center := this.obj.centercoords + Yunit.assert(center.x == 205) + Yunit.assert(center.y == 205) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + Classname() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.classname =="Notepad") + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + hscrollable() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "....[" A_ThisFunc "] > Initial" + Yunit.assert(this.obj.hscrollable == 0) + OutputDebug % "....[" A_ThisFunc "] > 1" + this.obj.hscrollable := 1 + Yunit.assert(this.obj.hscrollable == 1) + OutputDebug % "....[" A_ThisFunc "] > 0" + this.obj.hscrollable := 0 + Yunit.assert(this.obj.hscrollable == 0) + OutputDebug % "....[" A_ThisFunc "] > 1" + this.obj.hscrollable := !this.obj.hscrollable + Yunit.assert(this.obj.hscrollable == 1) + OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + } + + maximizebox() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "....[" A_ThisFunc "] > Initial" + Yunit.assert(this.obj.maximizebox == 1) + OutputDebug % "....[" A_ThisFunc "] > 0" + this.obj.maximizebox := 0 + Yunit.assert(this.obj.maximizebox == 0) + OutputDebug % "....[" A_ThisFunc "] > 1" + this.obj.maximizebox := !this.obj.maximizebox + Yunit.assert(this.obj.caption == 1) + OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + } + + minimizebox() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "....[" A_ThisFunc "] > Initial" + Yunit.assert(this.obj.minimizebox == 1) + OutputDebug % "....[" A_ThisFunc "] > 0" + this.obj.minimizebox := 0 + Yunit.assert(this.obj.minimizebox == 0) + OutputDebug % "....[" A_ThisFunc "] > 1" + this.obj.minimizebox := !this.obj.minimizebox + Yunit.assert(this.obj.caption == 1) + OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + } + + Title() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.title =="Unbenannt - Editor") + this.obj.title := "Halllloo" + Yunit.assert(this.obj.title =="Halllloo") + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + Parent() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + parent := this.parent + Yunit.assert(parent == ) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + Processname() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + val := this.obj.processname + Yunit.assert( val == "notepad.exe") + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + ProcessID() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + val := this.obj.processID + Yunit.assert( val > 0) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + Resizable() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "...[" A_ThisFunc "]> 1" + Yunit.assert( this.obj.resizable == 1) + OutputDebug % "...[" A_ThisFunc "]> 0" + this.obj.resizable := 0 + Yunit.assert( this.obj.resizable == 0) + OutputDebug % "...[" A_ThisFunc "]> toggle" + this.obj.resizable := !this.obj.resizable + Yunit.assert( this.obj.resizable == 1) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + sleep, 500 + } + + vscrollable() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "....[" A_ThisFunc "] > Initial" + Yunit.assert(this.obj.vscrollable == 0) + OutputDebug % "....[" A_ThisFunc "] > 1" + this.obj.vscrollable := 1 + Yunit.assert(this.obj.vscrollable == 1) + OutputDebug % "....[" A_ThisFunc "] > 0" + this.obj.vscrollable := 0 + Yunit.assert(this.obj.vscrollable == 0) + OutputDebug % "....[" A_ThisFunc "] > 1" + this.obj.vscrollable := !this.obj.vscrollable + Yunit.assert(this.obj.vscrollable == 1) + OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + } + + AlwaysOnTop() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.alwaysontop == false) + this.obj.alwaysOnTop := true + Yunit.assert(this.obj.alwaysontop == true) + this.obj.alwaysOnTop := false + Yunit.assert(this.obj.alwaysontop == false) + this.obj.alwaysOnTop := false + Yunit.assert(this.obj.alwaysontop == false) + this.obj.alwaysOnTop := !this.obj.alwaysOnTop + Yunit.assert(this.obj.alwaysontop == true) + this.obj.alwaysOnTop := !this.obj.alwaysOnTop + Yunit.assert(this.obj.alwaysontop == false) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MonitorID() { + Global debug + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "**** " A_ThisFunc " 1 ****" + this.obj.Move(2,2,300,300) + monID := this.obj.monitorID + Yunit.assert(monId == 1) + OutputDebug % "**** " A_ThisFunc " 2 - via Move ****" + obj := new Mony(2, debug) + rect2 := obj.boundary + this.obj.Move(rect2.x+10,rect2.y+10,300,300) + monID := this.obj.monitorID + Yunit.assert(monId == 2) + OutputDebug % "**** " A_ThisFunc " 3 - via MonitorID ****" + this.obj.monitorID := 1 + monID := this.obj.monitorID + Yunit.assert(monId == 1) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + Hangs() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + val := this.obj.hangs + Yunit.assert(val == false) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + + } + + Getter() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + hwnd := this.obj.hwnd + WinGetPos x, y, w, h, ahk_id %hwnd% + Yunit.assert(1 == ((this.obj.posSize.x == x) && (this.obj.posSize.y == y) && (this.obj.posSize.w == w) && (this.obj.posSize.h == h))) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + owner() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + own:= this.obj.owner + Yunit.assert(own == 0) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } + +} + +; ################################################################### +class ExistTestSuite { + Begin() { + Global debug + this.obj := new Windy(0, debug) + } + + ExistNonExistingWindow() { + this.obj.kill() + Yunit.assert(this.obj.exist == false) + } + + ExistExistingWindow() { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + Yunit.assert(this.obj.exist ==true) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + End() { + this.obj.kill() + this.remove("obj") + this.obj := + } +} + + +/* +; ################################################################### +class MoveResizeTestSuite +{ + Begin() + { + Global debug + this.obj := new Windy(0, debug) + sleep 1000 + } + + MoveViaWinMove() + { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "Initial Position: " this.obj._lastPos.Dump() " - Restore: " this.obj._restorePos.Dump() + hwnd := this.obj.hwnd + xold := this.obj._lastPos.x + yold := this.obj._lastPos.y + xnew := xold+10 + ynew := yold+10 + + OutputDebug % "BEFORE - Moving from x,y(" xold "," yold ") to (" xnew "," ynew ")" + WinMove % "ahk_id" this.obj.hwnd, ,xnew, ynew + OutputDebug % "AFTER - Moving from x,y(" xold "," yold ") to (" xnew "," ynew ")" + Yunit.assert(this.obj.isMoved()==1) + Yunit.assert(this.obj.isResized()==0) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + MoveResizeViaWinMove() + { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "Initial Position: " this.obj._lastPos.Dump() " - Restore: " this.obj._restorePos.Dump() + hwnd := this.obj.hwnd + xold := this.obj._lastPos.x + yold := this.obj._lastPos.y + wold := this.obj._lastPos.w + hold := this.obj._lastPos.h + xnew := xold+10 + ynew := yold+20 + wnew := wold+10 + hnew := hold+20 + OutputDebug % "BEFORE- Moving/Resizing from x,y,w,h(" xold "," yold "," wold "," hold ") to (" xnew "," ynew "," wnew "," hnew ")" + WinMove % "ahk_id" this.obj.hwnd, , xnew, ynew, wnew, hnew + OutputDebug % "AFTER - Moving/Resizing from x,y,w,h(" xold "," yold "," wold "," hold ") to (" xnew "," ynew "," wnew "," hnew ")" + Yunit.assert(this.obj.isMoved()==1) + Yunit.assert(this.obj.isResized()==1) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + ResizeViaWinMove() + { + OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + OutputDebug % "Initial Position: " this.obj._lastPos.Dump() " - Restore: " this.obj._restorePos.Dump() + hwnd := this.obj.hwnd + hwnd := this.obj.hwnd + xold := this.obj._lastPos.x + yold := this.obj._lastPos.y + wold := this.obj._lastPos.w + hold := this.obj._lastPos.h + wnew := wold+10 + hnew := hold+20 + OutputDebug % "BEFORE- Resizing from w,h(" wold "," hold ") to (" wnew "," hnew ")" + WinMove % "ahk_id" this.obj.hwnd, , xold, yold, wnew, hnew + OutputDebug % "AFTER- Resizing from w,h(" wold "," hold ") to (" wnew "," hnew ")" + Yunit.assert(this.obj.isMoved()==0) + Yunit.assert(this.obj.isResized()==1) + OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + } + + NoMoveResize() { + Global debug + success := 1 + l := new Windy(0, debug) + WinMove % "ahk_id" l._hWnd, , l._lastPos.x, l._lastPos.y, l._lastPos.w, l._lastPos.h + isMoved := l.isMoved() + isResized := l.isResized() + success := success && !(isMoved) && !(isResized) + l.kill() + if !success + throw " + } + + End() + { + sleep,2000 + this.obj.kill() + this.remove("obj") + this.obj := + } +} + +*/ \ No newline at end of file diff --git a/lib/DbgOut.ahk b/lib/DbgOut.ahk new file mode 100644 index 0000000..600f8cd --- /dev/null +++ b/lib/DbgOut.ahk @@ -0,0 +1,43 @@ +/* +Name: dbgOut - Prints given String via OutputDebug and indents string according to a given prefix +Version 0.1 (20161130) +Created: 20161130 +Author: hoppfrosch +Description: + Prints the given Debug-String via command OutputDebug. + The string is indented according to a given prefix in the Debug-String. + This allows a better tracing of stack depth with deep function calls. + + Supported prefixes are currently: + * ">" - This should be used when a funtion is entered. On each usage of this Prefix the indentation level is increased + Example: dbgOut(">[" A_ThisFunc "()]") + * "<" - This should be used when a funtion is exited. On each usage of this Prefix the indentation level is decreased + Example: dbgOut("<[" A_ThisFunc "()]") + * "|" - This should be used for temporary indentation +*/ +dbgOut(str, debug := 1) { + static indentLvl := 0 + x1 := SubStr(str, 1, 1) + if (x1 = "<") { + indentLvl := indentLvl - 1 + } + ;if (x1 = "|") { + ; indentLvl := indentLvl + 1 + ;} + + if (debug) { + i := 0 + indent := "" + while (i < indentLvl) { + indent := indent "++" + i := i + 1 + } + OutputDebug % indent str + } + if (x1 = ">") { + indentLvl := indentLvl + 1 + } + ;if (x1 = "|") { + ; indentLvl := indentLvl - 1 + ;} +} diff --git a/lib/Windy/Recty.ahk b/lib/Windy/Recty.ahk index c8244db..ed863ac 100644 --- a/lib/Windy/Recty.ahk +++ b/lib/Windy/Recty.ahk @@ -1,4 +1,7 @@ -; ****** HINT: Documentation can be extracted to HTML using NaturalDocs (http://www.naturaldocs.org/) ************** +#include %A_LineFile%\.. +#include ..\DbgOut.ahk + +; ****** HINT: Documentation can be extracted to HTML using NaturalDocs (http://www.naturaldocs.org/) ************** class Recty { ; ****************************************************************************************************************************************** @@ -219,8 +222,7 @@ class Recty { this.y := y this.w := w this.h := h - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" hwnd "])] -> x,y,w,h: (" x "," y "," w "," h ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" hwnd "])] -> x,y,w,h: (" x "," y "," w "," h ")", this.debug) } /* --------------------------------------------------------------------------------------- Method: fromRectangle(new) @@ -234,8 +236,7 @@ class Recty { this.y := new.y this.w := new.w this.h := new.h - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "] -> x,y,w,h: " this.Dump() ; _DBG_ + dbgOut("=[" A_ThisFunc "] -> x,y,w,h: " this.Dump(), this.debug) } /* --------------------------------------------------------------------------------------- Method: __New @@ -247,8 +248,7 @@ class Recty { */ __New(x=0, y=0, w=0, h=0, debug=false) { this._debug := debug ; _DBG_ - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "(x=" x ", y=" y ", w=" w ", h=" h ", _debug=" debug ")] (version: " this._version ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "(x=" x ", y=" y ", w=" w ", h=" h ", _debug=" debug ")] (version: " this._version ")", this._debug) this.x := x this.y := y this.w := w diff --git a/lib/Windy/WindLy.ahk b/lib/Windy/WindLy.ahk index 3a00dac..08f21b6 100644 --- a/lib/Windy/WindLy.ahk +++ b/lib/Windy/WindLy.ahk @@ -4,6 +4,7 @@ #include %A_LineFile%\.. #include Windy.ahk #include Const_WinUser.ahk +#include ..\DbgOut.ahk /* ****************************************************************************************************************************************** @@ -137,7 +138,7 @@ class WindLy { oWindy - Object to be inserted */ intersection(oWindLy) { - result := new WindLy() + result := new WindLy(this.debug) for _currhwnd, _data in oWindLy.list { if (this._wl[_data.hwnd]) { result.insert(_data) @@ -154,18 +155,18 @@ class WindLy { do currently exist. Non existing windows are removed from the list. */ removeNonExisting() { - OutputDebug % ">>>>>>>> Windly.removeNonExisting()" - u := new WindLy() + dbgOut(">[" A_ThisFunc "([" this.hwnd "])]", this.debug) + u := new WindLy(this.debug) u.list := this.list.Clone() for key, data in u.list { OutputDebug % " CURRENT:" key ": " data.hwnd ": " data.title " (" key ")" if !data.exist { - OutputDebug % " REMOVE SINCE NON EXISTANT:" key ": " data.hwnd + dbgOut("|[" A_ThisFunc "([" this.hwnd "])] - REMOVE SINCE NON EXISTANT:" key ": " data.hwnd, this.debug) u.delete(data) } } this.list := u.list.Clone() - OutputDebug % "<<<<<<<< Windly.removeNonExisting()" + dbgOut("<[" A_ThisFunc "([" this.hwnd "])]", this.debug) return this.list } /* ------------------------------------------------------------------------------- @@ -176,8 +177,10 @@ class WindLy { List of Objects. */ snapshot() { + dbgOut(">[" A_ThisFunc "()]", this.debug) this.__reset() this._wl := this.__all() + dbgOut("<[" A_ThisFunc "()]", this.debug) return this._wl } /* ------------------------------------------------------------------------------- @@ -191,9 +194,9 @@ class WindLy { oWindy - Object to operate with */ symmetricDifference(oWindLy) { - result := new WindLy() - u := new WindLy() - i := new WindLy() + result := new WindLy(this.debug) + u := new WindLy(this.debug) + i := new WindLy(this.debug) ; The symmetric difference is the union without the intersection: u.list := this.list.Clone() @@ -238,16 +241,17 @@ class WindLy { List of Objects */ __all() { + dbgOut(">[" A_ThisFunc "()]", this.debug) hwnds := this.__hwnds(true) ret := {} Loop % hwnds.MaxIndex() { h_Wnd := hwnds[A_Index] h_WndHex := this.__hexStr(h_Wnd) - _w := new Windy(h_Wnd) + _w := new Windy(h_Wnd, this.debug) ret[h_WndHex] := _w } - + dbgOut("<[" A_ThisFunc "()]", this.debug) return ret } /*! --------------------------------------------------------------------------------------- @@ -296,6 +300,7 @@ class WindLy { __isRealWindow(h_Wnd) { WinGet, s, Style, ahk_id %h_Wnd% ret := s & WS.CAPTION ? (s & WS.POPUP ? 0 : 1) : 0 + dbgOut("=[" A_ThisFunc "([hWnd=" h_wnd "])] -> " ret, this.debug) return ret } /*! ------------------------------------------------------------------------------- @@ -303,6 +308,7 @@ class WindLy { Initializes all the data (*INTERNAL*) */ __reset() { + dbgOut("=[" A_ThisFunc "()]", this.debug) this._wl := {} } /* --------------------------------------------------------------------------------------- @@ -314,8 +320,7 @@ class WindLy { */ __New(_debug=0) { this._debug := _debug - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "()] (version: " this._version ")" ; _DBG_ + dbgOut(">[" A_ThisFunc "()] (version: " this._version ")", _debug) if % (A_AhkVersion < "1.1.20.02" || A_AhkVersion >= "2.0") { MsgBox 16, Error, %A_ThisFunc% :`n This class only needs AHK later than 1.1.20.01 (and before 2.0)`nAborting... @@ -323,10 +328,7 @@ class WindLy { OutputDebug % "<[" A_ThisFunc "(...) -> ()]: *ERROR* : This class needs AHK later than 1.1.20.01 (and before 2.0). Aborting..." ; _DBG_ return } - - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "()]" ; _DBG_ - + dbgOut("<[" A_ThisFunc "()]", _debug) return this } /*! --------------------------------------------------------------------------------------- diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index f2f41e3..7706de8 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -10,6 +10,7 @@ #include Const_WinUser.ahk #include _WindowHandlerEvent.ahk #include ..\SerDes.ahk +#include ..\DbgOut.ahk class Windy { ; ****************************************************************************************************************************************** @@ -53,8 +54,7 @@ class Windy { hwnd := this.hwnd val := WinActive("ahk_id " hwnd) ret := (val) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret " (" val ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret " (" val ")", this.debug) return ret } set { @@ -63,9 +63,7 @@ class Windy { WinActivate, ahk_id hwnd else if (value == false) WinActivate, ahk_class Shell_TrayWnd ; see: https://autohotkey.com/board/topic/29314-windeactivate/ - - if (this._debug) ; _DBG_ - OutputDebug % "[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.activated ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.activated, this.debug) return this.alwaysOnTop } @@ -84,8 +82,7 @@ class Windy { */ get { ret := (this.styleEx & WS.EX.TOPMOST) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } set { @@ -95,9 +92,7 @@ class Windy { else if (value == false) value := "off" WinSet, AlwaysOnTop, %value%, ahk_id %hwnd% - if (this._debug) ; _DBG_ - OutputDebug % "[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.alwaysontop ; _DBG_ - + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.alwaysontop, this.debug) return this.alwaysOnTop } } @@ -115,8 +110,7 @@ class Windy { */ get { ret := (this.style & WS.CAPTION) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -131,8 +125,7 @@ class Windy { this.style := style this.redraw() DetectHiddenWindows, %prevState% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.caption ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.caption, this.debug) return value } } @@ -146,6 +139,7 @@ class Windy { */ get { SysGet, val, 4 + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " val, this.debug) return val } } @@ -163,8 +157,7 @@ class Windy { x := Round((pos.w)/2 + pos.x) y := Round((pos.h)/2 + pos.y) centerPos := new Pointy(x,y,this._debug) - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "(pos="pos.dump() " [" this.hwnd "])] -> " centerPos.dump() ; _DBG_ + dbgOut("=[" A_ThisFunc "(pos="pos.dump() " [" this.hwnd "])] -> " centerPos.dump(), this.debug) return centerPos } @@ -180,8 +173,7 @@ class Windy { this.move(x,y,99999,99999) centerPos := this.centercoords - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "(pos=" value.dump() " [" this.hwnd "])] -> " centerPos.dump() ; _DBG_ + dbgOut("=[" A_ThisFunc "(pos=" value.dump() " [" this.hwnd "])] -> " centerPos.dump(), this.debug) return centerPos } } @@ -196,8 +188,7 @@ class Windy { get { val := this.hwnd WinGetClass, __classname, ahk_id %val% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> (" __classname ")]" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "]) -> (" __classname ")]", this.debug) return __classname } } @@ -220,8 +211,7 @@ class Windy { */ get { ret := (this.styleEx & WS.EX.CLICKTHROUGH) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } set { @@ -235,9 +225,7 @@ class Windy { } this.transparency(100) := tp WinSet, ExStyle, %value%, ahk_id %hwnd% - if (this._debug) ; _DBG_ - OutputDebug % "[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.clickThrough ; _DBG_ - + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.clickThrough, this.debug) return this.clickThrough } } @@ -275,8 +263,7 @@ class Windy { ret := true if (_hWnd = 0) ret := false - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } } @@ -313,16 +300,12 @@ class Windy { } DetectHiddenWindows, %prevState% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } set{ mode := value - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> Current Value:" this.hidden ; _DBG_ - val := this.hwnd ret := 0 if (mode == true) { @@ -335,8 +318,7 @@ class Windy { } isHidden := this.hidden - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isHidden ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isHidden, this.debug) return isHidden } @@ -364,8 +346,7 @@ class Windy { */ get { ret := DllCall("user32\IsHungAppWindow", "Ptr", this.hwnd) - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } } @@ -383,8 +364,7 @@ class Windy { */ get { ret := (this.style & WS.HSCROLL) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -398,8 +378,7 @@ class Windy { this.style := style this.redraw() DetectHiddenWindows, %prevState% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.hscrollable ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.hscrollable, this.debug) return value } } @@ -417,8 +396,7 @@ class Windy { */ get { ret := (this.style & WS.MAXIMIZEBOX) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -432,8 +410,7 @@ class Windy { this.style := style this.redraw() DetectHiddenWindows, %prevState% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.maximizebox ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.maximizebox, this.debug) return value } } @@ -455,6 +432,7 @@ class Windy { ret := 0 if (s == 1) ret := 1 + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -474,8 +452,7 @@ class Windy { DetectHiddenWindows, %prevState% isMax := this.maximized - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isMax ; _DBG_ + dbgOut("=[[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isMax, this.debug) return isMax } @@ -494,8 +471,7 @@ class Windy { */ get { ret := (this.style & WS.MINIMIZEBOX) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -509,8 +485,7 @@ class Windy { this.style := style this.redraw() DetectHiddenWindows, %prevState% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.minimizebox ; _DBG_ + dbgOut("=[[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.minimizebox, this.debug) return value } } @@ -531,7 +506,8 @@ class Windy { WinGet, s, MinMax, ahk_id %val% ret := 0 if (s == -1) - ret := 1 + ret := 1 + dbgOut("=[[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -551,8 +527,7 @@ class Windy { DetectHiddenWindows, %prevState% isMin := this.minimized - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isMin ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isMin, this.debug) return isMin } @@ -573,8 +548,7 @@ class Windy { c := this.centercoords md := new MultiMony(this._debug) mon := md.idFromCoord(c.x,c.y,mon) - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " mon ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " mon, this.debug) return mon } @@ -601,8 +575,7 @@ class Windy { } monID := this.monitorID - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], ID=" value ")] -> New Value:" monID " (from: " oldID ")" ; _DBG_ + dbgOut("=[[" A_ThisFunc "([" this.hwnd "], ID=" value ")] -> New Value:" monID " (from: " oldID ")", this.debug) return monID } @@ -623,8 +596,7 @@ class Windy { */ get { hwndOwner := DllCall("GetWindowLong", "uint", this.hwnd, "int", GWL.HWNDPARENT, "UInt") - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " hwndOwner ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " hwndOwner, this.debug) return hwndOwner } @@ -633,8 +605,7 @@ class Windy { ret := DllCall("SetWindowLong", "uint", this.hwnd, "int", GWL.HWNDPARENT, "uint", hwndOwner) if ret == 0 hwndOwner := 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], hwndOwner= " hwndOwner ")] -> hwndOwner:" hwndOwner ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], hwndOwner= " hwndOwner ")] -> hwndOwner:" hwndOwner ")", this.debug) return hwndOwner } } @@ -657,8 +628,7 @@ class Windy { */ get { hwndPar := DllCall("GetParent", "uint", hwndPar, "UInt") - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " hwndPar ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " hwndPar, this.debug) return hwndPar } @@ -680,8 +650,7 @@ class Windy { else SendMessage, WM.CHANGEUISTATE, UIS.NITIALIZE,,,ahk_id %hwndPar% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], hwndPar= " hwndPar ", bfixStyle=" bFixStyle ")] -> hwnd:" hwndPar ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], hwndPar= " hwndPar ", bfixStyle=" bFixStyle ")] -> hwnd:" hwndPar ")", this.debug) return hwndPar } } @@ -698,6 +667,7 @@ class Windy { pt := new Pointy() pt.x := ps.x pt.y := ps.y + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> (" pt.dump() ")", this.debug) return pt } set { @@ -706,6 +676,7 @@ class Windy { ps.x := pt.x ps.y := pt.y this.posSize := ps + dbgOut("=[" A_ThisFunc "([" this.hwnd "], pt=" pt.Dump()")] -> New Value:" pt.Dump(), this.debug) return pt } } @@ -720,8 +691,7 @@ class Windy { get { info := this.windowinfo currPos := new Recty(info.window.xul,info.window.yul,info.window.xlr-info.window.xul,info.window.ylr-info.window.yul,this._debug) - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> (" currPos.dump() ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> (" currPos.dump() ")", this.debug) return currPos } @@ -729,8 +699,7 @@ class Windy { rect := value this.move(rect.x, rect.y, rect.w, rect.h) newPos := this.posSize - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], pos=" newPos.Dump()")] -> New Value:" newPos.Dump() ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], pos=" newPos.Dump()")] -> New Value:" newPos.Dump(), this.debug) return newPos } } @@ -748,8 +717,7 @@ class Windy { WinGet, PID, PID, % "ahk_id " this.hwnd ret := PID } - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } } @@ -767,8 +735,7 @@ class Windy { WinGet, PName, ProcessName, % "ahk_id " this.hwnd ret := PName } - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } } @@ -818,8 +785,7 @@ class Windy { ret := 1 } } - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -854,8 +820,7 @@ class Windy { } isRolled := this.rolledUp - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isRolled ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], mode=" mode ")] -> New Value:" isRolled, this.debug) return isRolled } @@ -870,6 +835,7 @@ class Windy { */ get { SysGet, ret, 29 + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -906,8 +872,7 @@ class Windy { hdest := currPos.h * scaleY rt := new Recty(xdest, ydest, wdest, hdest, this._debug) - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.id "],monDest:= " monIdDest "] (" currPos.dump() ") -> (" rt.dump() ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.id "],monDest:= " monIdDest "] (" currPos.dump() ") -> (" rt.dump() ")", this.debug) return rt } } @@ -924,6 +889,7 @@ class Windy { pt := new Pointy() pt.x := ps.w pt.y := ps.h + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> (" pt.dump() ")", this.debug) return pt } set { @@ -932,6 +898,7 @@ class Windy { ps.w := pt.x ps.h := pt.y this.posSize := ps + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value.Dump()")] -> New Value:" pt.Dump(), this.debug) return pt } } @@ -950,8 +917,7 @@ class Windy { */ get { ret := (this.style & WS.SIZEBOX) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -965,8 +931,7 @@ class Windy { this.style := style this.redraw() DetectHiddenWindows, %prevState% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.sizebox ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.sizebox, this.debug) return value } } @@ -978,8 +943,7 @@ class Windy { get { hWnd := this._hwnd WinGet, currStyle, Style, ahk_id %hwnd% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this._hwnd "])] -> (" this.__hexStr(currStyle) ")" + dbgOut("=[" A_ThisFunc "([" this._hwnd "])] -> (" this.__hexStr(currStyle) ")", this.debug) return currStyle } set { @@ -987,8 +951,7 @@ class Windy { WinSet, Style, %value%, ahk_id %hwnd% this.redraw() WinGet, currStyle, Style, ahk_id %hwnd% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], style=" this.__hexStr(value) ")] -> (" this.__hexStr(value) "/" this.__hexStr(currStyle) ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], style=" this.__hexStr(value) ")] -> (" this.__hexStr(value) "/" this.__hexStr(currStyle) ")", this.debug) return value } } @@ -1001,8 +964,7 @@ class Windy { get { hWnd := this._hwnd WinGet, currStyle, ExStyle, ahk_id %hwnd% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this._hwnd "])] -> (" this.__hexStr(currStyle) ")" + dbgOut("=[" A_ThisFunc "([" this._hwnd "])] -> (" this.__hexStr(currStyle) ")", this.debug) return currStyle } set { @@ -1010,8 +972,7 @@ class Windy { WinSet, ExStyle, %value%, ahk_id %hwnd% this.redraw() WinGet, currStyle, ExStyle, ahk_id %hwnd% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], styleEx=" this.__hexStr(value) ")] -> (" this.__hexStr(value) "/" this.__hexStr(currStyle) ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], styleEx=" this.__hexStr(value) ")] -> (" this.__hexStr(value) "/" this.__hexStr(currStyle) ")", this.debug) return value } } @@ -1026,8 +987,7 @@ class Windy { get { val := this.hwnd WinGetTitle, title, ahk_id %val% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> (" title ")]" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "]) -> (" title ")]", this.debug) return title } @@ -1039,8 +999,7 @@ class Windy { WinSetTitle, ahk_id %val%,, %title% DetectHiddenWindows, %prevState% newTitle := this.title - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], title=" title ")] -> " newTitle ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], title=" title ")] -> " newTitle, this.debug) return newTitle } } @@ -1068,8 +1027,7 @@ class Windy { ret := 255 if (s != "") ret := s - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -1117,8 +1075,7 @@ class Windy { } transEnd := this.transparency - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "], transparency=" transOrig "(" transStart "), increment=" increment ", delay=" delay ")] -> New Value:" transEnd ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], transparency=" transOrig "(" transStart "), increment=" increment ", delay=" delay ")] -> New Value:" transEnd, this.debug) return transEnd } } @@ -1136,8 +1093,7 @@ class Windy { */ get { ret := (this.style & WS.VSCROLL) > 0 ? 1 : 0 - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> " ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) return ret } @@ -1151,8 +1107,7 @@ class Windy { this.style := style this.redraw() DetectHiddenWindows, %prevState% - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.vscrollable ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.vscrollable, this.debug) return value } } @@ -1192,14 +1147,14 @@ class Windy { } If !DllCall("User32.dll\IsWindow", "Ptr", this.hwnd) { ErrorLevel := 1 - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> false (is not a window)]" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "]) -> false (is not a window)]", this.debug) Return False } struct_WI := "" NumPut(VarSetCapacity(struct_WI, WI_Size, 0), struct_WI, 0, "UInt") If !(DllCall("User32.dll\GetWindowInfo", "Ptr", this.hwnd, "Ptr", &struct_WI)) { ErrorLevel := 2 - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> false]" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "]) -> false]", this.debug) Return False } obj_WI := {} @@ -1227,9 +1182,8 @@ class Windy { obj_WI[Key] := NumGet(struct_WI, Offset, Value[4]) } } - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] => (" SerDes(Obj_WI) ")" ; _DBG_ - Return obj_WI + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] => (" SerDes(Obj_WI) ")", this.debug) + Return obj_WI } } ; ##################### End of Properties (AHK >1.1.16.x) ############################################################## @@ -1295,17 +1249,15 @@ class Windy { destPos := new Recty(x, y, currPos.w, currPos.h) ret := mon.rectToPercent(destPos) - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], border=""" border """)] pos (" this.posSize.Dump()") on Mon " this.monitorId " -> percent (" ret.Dump() ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], border=""" border """)] pos (" this.posSize.Dump()") on Mon " this.monitorId " -> percent (" ret.Dump() ")", this.debug) return ret - } + } - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], border=""" border """)] *** ERROR: Invalid border string <" border ">" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], border=""" border """)] *** ERROR: Invalid border string <" border ">", this.debug) - return - } + return + } /* --------------------------------------------------------------------------------------- Method: kill Kills the Window (Forces the window to close) @@ -1316,9 +1268,7 @@ class Windy { */ kill() { - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])]" ; _DBG_ - + dbgOut("=[" A_ThisFunc "([" this.hwnd "])]", this.debug) prevState := A_DetectHiddenWindows DetectHiddenWindows, On WinKill % "ahk_id" this.hwnd @@ -1344,8 +1294,7 @@ class Windy { , */ move(X,Y,W="99999",H="99999") { - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "([" this.hwnd "])(X=" X " ,Y=" Y " ,W=" W " ,H=" H ")]" ; _DBG_ + dbgOut(">[" A_ThisFunc "([" this.hwnd "])(X=" X " ,Y=" Y " ,W=" W " ,H=" H ")]") if (X = 99999 || Y = 99999 || W = 99999 || H = 9999) currPos := this.posSize @@ -1361,8 +1310,7 @@ class Windy { if (H = 99999) H := currPos.H - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "])(X=" X " ,Y=" Y " ,W=" W " ,H=" H ")]" ; _DBG_ + dbgOut("<[" A_ThisFunc "([" this.hwnd "])(X=" X " ,Y=" Y " ,W=" W " ,H=" H ")]", this.debug) WinMove % "ahk_id" this.hwnd, , X, Y, W, H } /* --------------------------------------------------------------------------------------- @@ -1391,8 +1339,7 @@ class Windy { - The range of the method parameters is *NOT* checked, so be carefull using any values *<0* or *>100* */ movePercental(xFactor=0, yFactor=0, wFactor=100, hFactor=100) { - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "([" this.hwnd "], xFactor=" xFactor ", yFactor=" yFactor ", wFactor=" wFactor ", hFactor=" hFactor ")]" ; _DBG_ + dbgOut(">[" A_ThisFunc "([" this.hwnd "], xFactor=" xFactor ", yFactor=" yFactor ", wFactor=" wFactor ", hFactor=" hFactor ")]", this.debug) mon := new Mony(this.monitorID, this._debug) monWorkArea := mon.workingArea @@ -1407,8 +1354,7 @@ class Windy { this.move(x,y,w,h) - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "], xFactor=" xFactor ", yFactor=" yFactor ", wFactor=" wFactor ", hFactor=" hFactor ")] -> padded to (" this.posSize.Dump() ") on Monitor (" this.monitorID ")" ; _DBG_ + dbgOut("<[" A_ThisFunc "([" this.hwnd "], xFactor=" xFactor ", yFactor=" yFactor ", wFactor=" wFactor ", hFactor=" hFactor ")] -> padded to (" this.posSize.Dump() ") on Monitor (" this.monitorID ")", this.debug) } /* --------------------------------------------------------------------------------------- Method: moveBorder @@ -1432,16 +1378,12 @@ class Windy { , */ moveBorder(border="") { - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "([" this.hwnd "], border=""" border """)] -> started from (" this.posSize.Dump() ") on Monitor (" this.monitorID ")" ; _DBG_ - + dbgOut(">[" A_ThisFunc "([" this.hwnd "], border=""" border """)] -> started from (" this.posSize.Dump() ") on Monitor (" this.monitorID ")", this.debug) factor := this.border2percent(border) if (factor) { this.movePercental(factor.x, factor.y, factor.w, factor.h) } - - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "([" this.hwnd "], border=""" border """)] -> moved to (" this.posSize.Dump() ") on Monitor (" this.monitorID ")" ; _DBG_ + dbgOut(">[" A_ThisFunc "([" this.hwnd "], border=""" border """)] -> moved to (" this.posSize.Dump() ") on Monitor (" this.monitorID ")", this.debug) } /* --------------------------------------------------------------------------------------- Method: posSize2percent @@ -1456,10 +1398,7 @@ class Windy { currPos := this.posSize mon := new Mony(this.monitorID, this._debug) ret := mon.rectToPercent(currPos) - - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] pos (" this.posSize.Dump()") on Mon " this.monitorId " -> percent (" ret.Dump() ")" ; _DBG_ - + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] pos (" this.posSize.Dump()") on Mon " this.monitorId " -> percent (" ret.Dump() ")", this.debug) return ret } /* --------------------------------------------------------------------------------------- @@ -1490,8 +1429,7 @@ class Windy { ifEqual, bEnable, 0, return } ret := DllCall("RedrawWindow", "uint", hwnd, "uint", 0, "uint", 0, "uint" ,RDW.INVALIDATE | RDW.ERASE | RDW.FRAME | RDW.ERASENOW | RDW.UPDATENOW | RDW.ALLCHILDREN) - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "], Option=" Option ")] -> ret=" ret ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "], Option=" Option ")] -> ret=" ret, this.debug) return ret } ; ######################## Internal Methods - not to be called directly ############################################ @@ -1510,11 +1448,8 @@ class Windy { */ __isWindow(hWnd) { WinGet, s, Style, ahk_id %hWnd% - ret := s & WS.CAPTION ? (s & WS.POPUP ? 0 : 1) : 0 ;WS_CAPTION AND !WS_POPUP(for tooltips etc) - - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" hWnd "])] -> " ret ; _DBG_ - + ret := s & WS.CAPTION ? (s & WS.POPUP ? 0 : 1) : 0 ;WS_CAPTION AND !WS_POPUP(for tooltips etc) + dbgOut("=[" A_ThisFunc "([" hWnd "])] -> " ret, this.debug) return ret } /* --------------------------------------------------------------------------------------- @@ -1535,7 +1470,7 @@ class Windy { __posPush() { this._posStack.Insert(1, this.posSize) if (this._debug) { ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])] -> (" this._posStack[1].dump() ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> (" this._posStack[1].dump() ")", this.debug) this.__posStackDump() ; _DBG_ } } @@ -1545,7 +1480,7 @@ class Windy { */ __posStackDump() { For key,value in this._posStack ; loops through all elements in Stack - OutputDebug % "|[" A_ThisFunc "()] -> (" key "): (" Value.dump() ")" ; _DBG_ + dbgOut("=[" A_ThisFunc "()] -> (" key "): (" Value.dump() ")", this.debug) return } /* --------------------------------------------------------------------------------------- @@ -1556,8 +1491,7 @@ class Windy { index - Index of position to restore (*Optional*, Default = 2) (1 is the current position) */ __posRestore(index="2") { - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "([" this.hwnd "], index=" index ")]" ; _DBG_ + dbgOut(">[" A_ThisFunc "([" this.hwnd "], index=" index ")]", this.debug) restorePos := this._posStack[index] currPos := this.posSize @@ -1565,7 +1499,7 @@ class Windy { this.move(restorePos.x, restorePos.y, restorePos.w, restorePos.h) if (this._debug) { ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "])] LastPos: " currPos.Dump() " - RestoredPos: " restorePos.Dump() ; _DBG_ + dbgOut("<[" A_ThisFunc "([" this.hwnd "])] LastPos: " currPos.Dump() " - RestoredPos: " restorePos.Dump(), this.debug) this.__posStackDump() ; _DBG_ } } @@ -1580,9 +1514,7 @@ class Windy { true or false, depending on result of dllcall */ __SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags) { - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])(eventMin=" eventMin ", eventMax=" eventMax ", hmodWinEventProc=" hmodWinEventProc ", lpfnWinEventProc=" lpfnWinEventProc ", idProcess=" idProcess ", idThread=" idThread ", dwFlags=" dwFlags ")" ; _DBG_ - + dbgOut("[" A_ThisFunc "([" this.hwnd "])(eventMin=" eventMin ", eventMax=" eventMax ", hmodWinEventProc=" hmodWinEventProc ", lpfnWinEventProc=" lpfnWinEventProc ", idProcess=" idProcess ", idThread=" idThread ", dwFlags=" dwFlags ")", this.debug) ret := DllCall("ole32\CoInitialize", Uint, 0) ; This is a WinEventProc (siehe ) - this determines parameters which can be handled by "HookProc" ret := DllCall("user32\SetWinEventHook" @@ -1602,27 +1534,24 @@ class Windy { * Store windows size/pos on each change */ __onLocationChange() { - if this.hwnd = 0 + if this.hwnd = 0 return - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "([" this.hwnd "])" ; _DBG_ + dbgOut(">[" A_ThisFunc "([" this.hwnd "])") currPos := this.posSize lastPos := this._posStack[1] ; current size/position is identical with previous Size/position if (currPos.equal(lastPos)) { - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "])] Position has NOT changed!" ; _DBG_ + dbgOut("<[" A_ThisFunc "([" this.hwnd "])] Position has NOT changed!)", this.debug) return } ; size/position has been changed -> store it! this.__posPush() - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "([" this.hwnd "])] LastPos: " lastPos.Dump() " - NewPos: " currPos.Dump() ; _DBG_ + dbgOut("<[" A_ThisFunc "([" this.hwnd "])] LastPos: " lastPos.Dump() " - NewPos: " currPos.Dump(), this.debug) return } /* --------------------------------------------------------------------------------------- @@ -1633,9 +1562,7 @@ class Windy { if (this.hwnd <= 0) { return } - - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])" ; _DBG_ + dbgOut("=[" A_ThisFunc "([" this.hwnd "])", this.debug) if (this.__useEventHook == 1) { if (this.__hWinEventHook1) @@ -1645,9 +1572,6 @@ class Windy { if (this._HookProcAdr) DllCall( "kernel32\GlobalFree", UInt,&this._HookProcAdr ) ; free up allocated memory for RegisterCallback } - - if (this._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" this.hwnd "])" ; _DBG_ ; Reset all "dangerous" settings (all windows should be left in a user accessable state) if (this.alwaysontop == true) { @@ -1674,13 +1598,11 @@ class Windy { */ __New(_hWnd=-1, _debug=0, _test=0) { this._debug := _debug - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "(hWnd=(" _hWnd "))] (version: " this._version ")" ; _DBG_ + dbgOut(">[" A_ThisFunc "(hWnd=(" _hWnd "))] (version: " this._version ")", _debug) if % (A_AhkVersion < "1.1.08.00" || A_AhkVersion >= "2.0") { MsgBox 16, Error, %A_ThisFunc% :`n This class is only tested with AHK_L later than 1.1.08.00 (and before 2.0)`nAborting... - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "(...) -> ()]: *ERROR* : This class is only tested with AHK_L later than 1.1.08.00 (and before 2.0). Aborting..." ; _DBG_ + dbgOut("<[" A_ThisFunc "(...) -> ()]: *ERROR* : This class is only tested with AHK_L later than 1.1.08.00 (and before 2.0). Aborting...", _debug) return } @@ -1693,23 +1615,20 @@ class Windy { } else if % (_hWnd = -1) { ; hWnd is missing MsgBox 16, Error, %A_ThisFunc% :`n Required parameter is missing`nAborting... - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "(...) -> ()] *ERROR*: Required parameter is missing. Aborting..." ; _DBG_ + dbgOut("<[" A_ThisFunc "(...) -> ()] *ERROR*: Required parameter is missing. Aborting...", _debug) this.hwnd := -1 return } if (!this.__isWindow(_hWnd)) { - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "(hWnd=(" _hWnd "))] is NOT a true window. Aborting..." ; _DBG_ + dbgOut("<[" A_ThisFunc "(hWnd=(" _hWnd "))] is NOT a true window. Aborting...", _debug) this.hwnd := -1 return } _hWnd := this.__hexstr(_hWnd) this._hWnd := _hWnd - if (this._debug) ; _DBG_ - OutputDebug % ">[" A_ThisFunc "(hWnd=(" _hWnd "))] (WinTitle: " this.title ")" ; _DBG_ + dbgOut("|[" A_ThisFunc "(hWnd=(" _hWnd "))] (WinTitle: " this.title ")", _debug) this._posStack := Object() ; creates initially empty stack @@ -1725,9 +1644,7 @@ class Windy { this._hWinEventHook2 := this.__SetWinEventHook( CONST_EVENT.OBJECT.SHOW, CONST_EVENT.OBJECT.CONTENTSCROLLED, 0, this._HookProcAdr, 0, 0, 0 ) } - if (this._debug) ; _DBG_ - OutputDebug % "<[" A_ThisFunc "(hWnd=(" _hWnd "))]" ; _DBG_ - + dbgOut("<[" A_ThisFunc "(hWnd=(" _hWnd "))]", _debug) return this } @@ -1755,8 +1672,7 @@ ClassWindy_EventHook(hWinEventHook, Event, hWnd, idObject, idChild, dwEventThrea return self := Object(A_EventInfo) - if (Object(A_EventInfo)._debug) ; _DBG_ - OutputDebug % "|[" A_ThisFunc "([" Object(A_EventInfo)._hWnd "])(hWinEventHook=" hWinEventHook ", Event=" Event2Str(Event) ", hWnd=" hWnd ", idObject=" idObject ", idChild=" idChild ", dwEventThread=" dwEventThread ", dwmsEventTime=" dwmsEventTime ") -> A_EventInfo: " A_EventInfo ; _DBG_ + dbgOut("=[" A_ThisFunc "([" Object(A_EventInfo)._hWnd "])(hWinEventHook=" hWinEventHook ", Event=" Event2Str(Event) ", hWnd=" hWnd ", idObject=" idObject ", idChild=" idChild ", dwEventThread=" dwEventThread ", dwmsEventTime=" dwmsEventTime ") -> A_EventInfo: " A_EventInfo, Object(A_EventInfo)._debug) ; ########## START: Handling window movement ################################################## ; We want to detect when the window movement has finished finally, as onLocationChanged() has only to be called at the END of the movement From f8d8868e9406cf49d48d50b1399595e30ce4ac68 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Tue, 7 Mar 2017 08:41:41 +0100 Subject: [PATCH 12/15] [*] #45 - Windy: Finalized next()/previous() --- YUnit_Windy.ahk | 405 ++++++++++++++++++++++++-------------------- lib/Windy/Windy.ahk | 24 ++- 2 files changed, 233 insertions(+), 196 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index f743886..5c832c6 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -5,14 +5,17 @@ #Include %A_ScriptDir%\Yunit\Window.ahk #Include %A_ScriptDir%\Yunit\StdOut.ahk #include +#include ; #Warn All ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "0.10.2" +ReferenceVersion := "0.10.3" debug := 1 +OutputDebug DBGVIEWCLEAR + ;Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, TempTestSuite) Yunit.Use(YunitStdOut, YunitWindow).Test(_BaseTestSuite, GeometryTestSuite, MiscTestSuite, NotRealWindowTestSuite, HideShowTestSuite, ExistTestSuite, RollupTestSuite, MoveResizeTestSuite, TransparencyTestSuite) Return @@ -25,15 +28,23 @@ class TempTestSuite { this.obj := new Windy(0, debug) } - captionheight() { - Global debug + nextprevious() { + Global debug + + dbgOut(">[" A_ThisFunc "]") + hwndNext := this.obj.next + nextObj := new Windy(hwndNext, 0) + OutputDebug % "[IMPORTANT] NEXT OF [" this.obj.hwnd "-<" this.obj.title ">]: [" hwndNext "-<" nextObj.title ">]" + hwndPrev := this.obj.previous + prevObj := new Windy(hwndPrev, 0) + OutputDebug % "[IMPORTANT] PREVIOUS OF [" this.obj.hwnd "-<" this.obj.title ">]: [" hwndPrev "-" prevObj.title "]" + + Yunit.assert(this.obj.hwnd == prevObj.next) + Yunit.assert(this.obj.hwnd == nextObj.previous) + + dbgOut("<[" A_ThisFunc "]") + } - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - x := this.obj.geometry.captionheight - Yunit.assert(x == 22) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" - } - End() { this.obj.kill() this.remove("obj") @@ -49,10 +60,10 @@ class _BaseTestSuite { } Version() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Global ReferenceVersion Yunit.assert(this.obj._version == ReferenceVersion) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -72,10 +83,10 @@ class GeometryTestSuite { captionheight() { Global debug - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") x := this.obj.captionheight Yunit.assert(x == 22) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -95,10 +106,10 @@ class TileTestSuite { movePercental() { Global debug - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") this.obj.movePercental(25, 25, 50, 50) MsgBox % A_ThisFunc " - To be done ..." - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -116,36 +127,36 @@ class TransparencyTestSuite { } Transparency() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "**** " A_ThisFunc " 1 ****" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 1 ****" t := this.obj.transparency Yunit.assert(t == 255) - OutputDebug % "**** " A_ThisFunc " 3 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 3 ****" this.obj.transparency(10) := 100 t := this.obj.transparency Yunit.assert(t == 100) - OutputDebug % "**** " A_ThisFunc " 3 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 3 ****" this.obj.transparency(1) := "OFF" t := this.obj.transparency Yunit.assert(t == 255) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } TransparencyNoCaption() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") this.obj.caption := false - OutputDebug % "**** " A_ThisFunc " 1 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 1 ****" t := this.obj.transparency Yunit.assert(t == 255) - OutputDebug % "**** " A_ThisFunc " 3 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 3 ****" this.obj.transparency(10) := 100 t := this.obj.transparency Yunit.assert(t == 100) - OutputDebug % "**** " A_ThisFunc " 3 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 3 ****" this.obj.transparency(1) := "OFF" t := this.obj.transparency Yunit.assert(t == 255) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -165,41 +176,41 @@ class RollupTestSuite { RollupToggle() { Global debug - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "**** " A_ThisFunc " 1 ****" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 1 ****" val := this.obj.rolledUp Yunit.assert(val == false) - OutputDebug % "**** " A_ThisFunc " 2 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 2 ****" this.obj.rolledUp := false val := this.obj.rolledUp Yunit.assert(val == false) - OutputDebug % "**** " A_ThisFunc " 3 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 3 ****" this.obj.rolledUp := true val := this.obj.rolledUp Yunit.assert(val == true) - OutputDebug % "**** " A_ThisFunc " 4 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 4 ****" this.obj.rolledUp := false val := this.obj.rolledUp Yunit.assert(val == false) - OutputDebug % "**** " A_ThisFunc " 5 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 5 ****" this.obj.rolledUp := !this.obj.rolledUp ; as the window wasn't rolled up, it should be rolled up now val := this.obj.rolledUp Yunit.assert(val == true) - OutputDebug % "**** " A_ThisFunc " 6 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 6 ****" this.obj.rolledUp := !this.obj.rolledUp ; as the window was rolled up, it shouldn't be rolled up now val := this.obj.rolledUp Yunit.assert(val == false) - OutputDebug % "**** " A_ThisFunc " 7 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 7 ****" this.End() val := this.obj.rolledUp Yunit.assert(val == ) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -217,7 +228,7 @@ class MoveResizeTestSuite { } Maximize() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.maximized == false) Yunit.assert(this.obj.minimized == false) this.obj.maximized := true @@ -232,12 +243,12 @@ class MoveResizeTestSuite { this.obj.maximized := !this.obj.maximized Yunit.assert(this.obj.maximized == false) Yunit.assert(this.obj.minimized == false) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Minimize() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.maximized == false) Yunit.assert(this.obj.minimized == false) this.obj.minimized := true @@ -252,294 +263,294 @@ class MoveResizeTestSuite { this.obj.minimized := !this.obj.minimized Yunit.assert(this.obj.maximized == false) Yunit.assert(this.obj.minimized == false) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MoveViaWinMove() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() xnew := oldPos.x+200 ynew := oldPos.y+200 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" WinMove % "ahk_id" this.obj.hwnd, ,xnew, ynew newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == xnew) Yunit.assert(newPos.y == ynew) Yunit.assert(newPos.w == oldPos.w) Yunit.assert(newPos.h == oldPos.h) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MoveViaMoveMethod() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() xnew := oldPos.x+200 ynew := oldPos.y+200 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" this.obj.move(xnew, ynew, oldPos.w, oldPos.h) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == xnew) Yunit.assert(newPos.y == ynew) Yunit.assert(newPos.w == oldPos.w) Yunit.assert(newPos.h == oldPos.h) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MoveViaPosSizeProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() xnew := oldPos.x+200 ynew := oldPos.y+200 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," oldPos.w "," oldPos.h ")" this.obj.posSize := new Recty(xnew,ynew,oldPos.w,oldPos.h) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == xnew) Yunit.assert(newPos.y == ynew) Yunit.assert(newPos.w == oldPos.w) Yunit.assert(newPos.h == oldPos.h) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MoveViaPosProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.pos - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() xnew := oldPos.x+200 ynew := oldPos.y+200 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew ")" this.obj.pos := new Pointy(xnew,ynew) newPos := this.obj.pos - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == xnew) Yunit.assert(newPos.y == ynew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MoveResizeViaWinMove() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() xnew := oldPos.x+10 ynew := oldPos.y+20 wnew := oldPos.w+10 hnew := oldPos.h+20 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" WinMove % "ahk_id" this.obj.hwnd, , xnew, ynew, wnew, hnew newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == xnew) Yunit.assert(newPos.y == ynew) Yunit.assert(newPos.w == wnew) Yunit.assert(newPos.h == hnew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MoveResizeViaMoveMehod() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() xnew := oldPos.x+10 ynew := oldPos.y+20 wnew := oldPos.w+10 hnew := oldPos.h+20 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" this.obj.move(xnew, ynew, wnew, hnew) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == xnew) Yunit.assert(newPos.y == ynew) Yunit.assert(newPos.w == wnew) Yunit.assert(newPos.h == hnew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MoveResizeViaPosSizeProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() xnew := oldPos.x+10 ynew := oldPos.y+20 wnew := oldPos.w+10 hnew := oldPos.h+20 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" xnew "," ynew "," wnew "," hnew ")" this.obj.posSize := new Recty(xnew, ynew, wnew, hnew) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == xnew) Yunit.assert(newPos.y == ynew) Yunit.assert(newPos.w == wnew) Yunit.assert(newPos.h == hnew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } ResizeViaWinMove() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() wnew := oldPos.w+100 hnew := oldPos.h+200 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" WinMove % "ahk_id" this.obj.hwnd, , oldPos.x, oldPos.y, wnew, hnew newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == oldPos.x) Yunit.assert(newPos.y == oldPos.y) Yunit.assert(newPos.w == wnew) Yunit.assert(newPos.h == hnew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } ResizeViaMoveMethod() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() wnew := oldPos.w+100 hnew := oldPos.h+200 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" this.obj.move(oldPos.x, oldPos.y, wnew, hnew) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == oldPos.x) Yunit.assert(newPos.y == oldPos.y) Yunit.assert(newPos.w == wnew) Yunit.assert(newPos.h == hnew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } ResizeViaPosSizeProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() wnew := oldPos.w+100 hnew := oldPos.h+200 - OutputDebug % "BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" + OutputDebug % "[IMPORTANT]BEFORE - Moving from " oldPos.Dump() " to (" oldPos.x "," oldPos.y "," wnew "," hnew ")" this.obj.posSize := new Recty(oldPos.x, oldPos.y, wnew, hnew) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == oldPos.x) Yunit.assert(newPos.y == oldPos.y) Yunit.assert(newPos.w == wnew) Yunit.assert(newPos.h == hnew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } ResizeViaSizeProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldSize:= this.obj.size - OutputDebug % "Initial Size: " oldSize.Dump() + OutputDebug % "[IMPORTANT]Initial Size: " oldSize.Dump() wnew := oldSize.x+100 hnew := oldSize.y+200 - OutputDebug % "BEFORE - Resizing from " oldSize.Dump() " to (" wnew "," hnew ")" + OutputDebug % "[IMPORTANT]BEFORE - Resizing from " oldSize.Dump() " to (" wnew "," hnew ")" this.obj.size := new Pointy(wnew, hnew) newSize := this.obj.size - OutputDebug % "AFTER - Resizing from " oldSize.Dump() " to " newSize.Dump() + OutputDebug % "[IMPORTANT]AFTER - Resizing from " oldSize.Dump() " to " newSize.Dump() Yunit.assert(newSize.x == wnew) Yunit.assert(newSize.y == hnew) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } NoMoveResizeViaWinMove() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() WinMove % "ahk_id" this.obj.hwnd, , oldPos.x, oldPos.y, oldPos.w, oldPos.h newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == oldPos.x) Yunit.assert(newPos.y == oldPos.y) Yunit.assert(newPos.w == oldPos.w) Yunit.assert(newPos.h == oldPos.h) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } NoMoveResizeViaMoveMehod() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() this.obj.move(oldPos.x, oldPos.y, oldPos.w, oldPos.h) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == oldPos.x) Yunit.assert(newPos.y == oldPos.y) Yunit.assert(newPos.w == oldPos.w) Yunit.assert(newPos.h == oldPos.h) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } NoMoveResizeViaPosSizeProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.posSize - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() this.obj.posSize := new Recty(oldPos.x, oldPos.y, oldPos.w, oldPos.h) newPos := this.obj.posSize - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == oldPos.x) Yunit.assert(newPos.y == oldPos.y) Yunit.assert(newPos.w == oldPos.w) Yunit.assert(newPos.h == oldPos.h) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } NoMoveViaPosProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldPos := this.obj.pos - OutputDebug % "Initial Position: " oldPos.Dump() + OutputDebug % "[IMPORTANT]Initial Position: " oldPos.Dump() this.obj.pos := new Pointy(oldPos.x, oldPos.y) newPos := this.obj.pos - OutputDebug % "AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() + OutputDebug % "[IMPORTANT]AFTER - Moving from " oldPos.Dump() " to " newPos.Dump() Yunit.assert(newPos.x == oldPos.x) Yunit.assert(newPos.y == oldPos.y) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } NoResizeViaSizeProperty() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") oldSize := this.obj.size - OutputDebug % "Initial Size: " oldSize.Dump() + OutputDebug % "[IMPORTANT]Initial Size: " oldSize.Dump() this.obj.size := new Pointy(oldSize.x, oldSize.y) newSize := this.obj.size - OutputDebug % "AFTER - Resizing from " oldSize.Dump() " to " newSize.Dump() + OutputDebug % "[IMPORTANT]AFTER - Resizing from " oldSize.Dump() " to " newSize.Dump() Yunit.assert(newSize.x == oldSize.x) Yunit.assert(newSize.y == oldSize.y) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } scale() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") this.obj.maximized := true this.obj.scale(2) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -557,7 +568,7 @@ class HideShowTestSuite { } HideShowToggle() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.hidden == false) this.obj.hidden := false Yunit.assert(this.obj.hidden == false) @@ -571,27 +582,27 @@ class HideShowTestSuite { Yunit.assert(this.obj.hidden == false) this.obj.hidden := !this.obj.hidden ; as the window wasn't hidden, it should be hidden now Yunit.assert(this.obj.hidden == true) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } HiddenFalse() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.hidden==false) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } HiddenTrue() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") this.obj.hidden := true Yunit.assert(this.obj.hidden == true) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } HiddenDoesNotExist() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") this.obj.kill() Yunit.assert(this.obj.hidden==-1) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -604,12 +615,12 @@ class HideShowTestSuite { ; ################################################################### class NotRealWindowTestSuite { Test() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Global debug HDesktop := DllCall("User32.dll\GetDesktopWindow", "UPtr") this.obj := new Windy(HDesktop, debug) Yunit.assert(this.obj==) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } } @@ -628,7 +639,7 @@ class MiscTestSuite { activated() { Global debug - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") this.obj.activated := true sleep 1000 val := (this.obj.activated == true) @@ -638,153 +649,171 @@ class MiscTestSuite { this.obj.activated := true newObj := new Windy(0, debug) Yunit.assert(this.obj.activated == false) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Caption() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "....[" A_ThisFunc "] > 1" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" Yunit.assert(this.obj.caption == 1) - OutputDebug % "....[" A_ThisFunc "] > 0" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 0" this.obj.caption := 0 Yunit.assert(this.obj.caption == 0) - OutputDebug % "....[" A_ThisFunc "] > 1" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" this.obj.caption := 1 Yunit.assert(this.obj.caption == 1) - OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Center() { Global debug - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") hwnd := this.obj.hwnd WinGetPos x, y, w, h, ahk_id %hwnd% centerx := round(x+(w)/2) centery := round(y+(h)/2) - OutputDebug % "**** " A_ThisFunc " 1 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 1 ****" center := this.obj.centercoords Yunit.assert(center.x == centerx) Yunit.assert(center.y == centery) - OutputDebug % "**** " A_ThisFunc " 2 ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 2 ****" newCenter := new Pointy(205,205,debug) this.obj.centercoords := newCenter center := this.obj.centercoords Yunit.assert(center.x == 205) Yunit.assert(center.y == 205) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Classname() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.classname =="Notepad") - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } hscrollable() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "....[" A_ThisFunc "] > Initial" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > Initial" Yunit.assert(this.obj.hscrollable == 0) - OutputDebug % "....[" A_ThisFunc "] > 1" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" this.obj.hscrollable := 1 Yunit.assert(this.obj.hscrollable == 1) - OutputDebug % "....[" A_ThisFunc "] > 0" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 0" this.obj.hscrollable := 0 Yunit.assert(this.obj.hscrollable == 0) - OutputDebug % "....[" A_ThisFunc "] > 1" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" this.obj.hscrollable := !this.obj.hscrollable Yunit.assert(this.obj.hscrollable == 1) - OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } maximizebox() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "....[" A_ThisFunc "] > Initial" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > Initial" Yunit.assert(this.obj.maximizebox == 1) - OutputDebug % "....[" A_ThisFunc "] > 0" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 0" this.obj.maximizebox := 0 Yunit.assert(this.obj.maximizebox == 0) - OutputDebug % "....[" A_ThisFunc "] > 1" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" this.obj.maximizebox := !this.obj.maximizebox Yunit.assert(this.obj.caption == 1) - OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } minimizebox() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "....[" A_ThisFunc "] > Initial" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > Initial" Yunit.assert(this.obj.minimizebox == 1) - OutputDebug % "....[" A_ThisFunc "] > 0" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 0" this.obj.minimizebox := 0 Yunit.assert(this.obj.minimizebox == 0) - OutputDebug % "....[" A_ThisFunc "] > 1" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" this.obj.minimizebox := !this.obj.minimizebox Yunit.assert(this.obj.caption == 1) - OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") + } + + nextprevious() { + Global debug + + dbgOut(">[" A_ThisFunc "]") + hwndNext := this.obj.next + nextObj := new Windy(hwndNext, 0) + OutputDebug % "[IMPORTANT] NEXT OF [" this.obj.hwnd "-<" this.obj.title ">]: [" hwndNext "-<" nextObj.title ">]" + hwndPrev := this.obj.previous + prevObj := new Windy(hwndPrev, 0) + OutputDebug % "[IMPORTANT] PREVIOUS OF [" this.obj.hwnd "-<" this.obj.title ">]: [" hwndPrev "-" prevObj.title "]" + + Yunit.assert(this.obj.hwnd == prevObj.next) + Yunit.assert(this.obj.hwnd == nextObj.previous) + + dbgOut("<[" A_ThisFunc "]") + } Title() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.title =="Unbenannt - Editor") this.obj.title := "Halllloo" Yunit.assert(this.obj.title =="Halllloo") - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Parent() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") parent := this.parent Yunit.assert(parent == ) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Processname() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") val := this.obj.processname Yunit.assert( val == "notepad.exe") - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } ProcessID() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") val := this.obj.processID Yunit.assert( val > 0) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Resizable() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "...[" A_ThisFunc "]> 1" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]...[" A_ThisFunc "]> 1" Yunit.assert( this.obj.resizable == 1) - OutputDebug % "...[" A_ThisFunc "]> 0" + OutputDebug % "[IMPORTANT]...[" A_ThisFunc "]> 0" this.obj.resizable := 0 Yunit.assert( this.obj.resizable == 0) - OutputDebug % "...[" A_ThisFunc "]> toggle" + OutputDebug % "[IMPORTANT]...[" A_ThisFunc "]> toggle" this.obj.resizable := !this.obj.resizable Yunit.assert( this.obj.resizable == 1) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") sleep, 500 } vscrollable() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "....[" A_ThisFunc "] > Initial" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > Initial" Yunit.assert(this.obj.vscrollable == 0) - OutputDebug % "....[" A_ThisFunc "] > 1" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" this.obj.vscrollable := 1 Yunit.assert(this.obj.vscrollable == 1) - OutputDebug % "....[" A_ThisFunc "] > 0" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 0" this.obj.vscrollable := 0 Yunit.assert(this.obj.vscrollable == 0) - OutputDebug % "....[" A_ThisFunc "] > 1" + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" this.obj.vscrollable := !this.obj.vscrollable Yunit.assert(this.obj.vscrollable == 1) - OutputDebug % "<<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } AlwaysOnTop() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.alwaysontop == false) this.obj.alwaysOnTop := true Yunit.assert(this.obj.alwaysontop == true) @@ -796,50 +825,50 @@ class MiscTestSuite { Yunit.assert(this.obj.alwaysontop == true) this.obj.alwaysOnTop := !this.obj.alwaysOnTop Yunit.assert(this.obj.alwaysontop == false) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } MonitorID() { Global debug - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" - OutputDebug % "**** " A_ThisFunc " 1 ****" + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 1 ****" this.obj.Move(2,2,300,300) monID := this.obj.monitorID Yunit.assert(monId == 2) - OutputDebug % "**** " A_ThisFunc " 2 - via Move ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 2 - via Move ****" obj := new Mony(2, debug) rect2 := obj.boundary this.obj.Move(rect2.x+10,rect2.y+10,300,300) monID := this.obj.monitorID Yunit.assert(monId == 2) - OutputDebug % "**** " A_ThisFunc " 3 - via MonitorID ****" + OutputDebug % "[IMPORTANT]**** " A_ThisFunc " 3 - via MonitorID ****" this.obj.monitorID := 2 monID := this.obj.monitorID Yunit.assert(monId == 2) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Hangs() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") val := this.obj.hangs Yunit.assert(val == false) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } Getter() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") hwnd := this.obj.hwnd WinGetPos x, y, w, h, ahk_id %hwnd% Yunit.assert(1 == ((this.obj.posSize.x == x) && (this.obj.posSize.y == y) && (this.obj.posSize.w == w) && (this.obj.posSize.h == h))) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } owner() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") own:= this.obj.owner Yunit.assert(own == 0) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { @@ -863,9 +892,9 @@ class ExistTestSuite { } ExistExistingWindow() { - OutputDebug % ">>>>>[" A_ThisFunc "]>>>>>" + dbgOut(">[" A_ThisFunc "]") Yunit.assert(this.obj.exist ==true) - OutputDebug % "<<<<[" A_ThisFunc "]<<<<<" + dbgOut("<[" A_ThisFunc "]") } End() { diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index f523cd8..eb9941f 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -24,7 +24,7 @@ class Windy { About: License This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See for more details. */ - _version := "0.10.2" + _version := "0.10.3" _debug := 0 _hWnd := 0 @@ -65,7 +65,7 @@ class Windy { WinActivate, ahk_class Shell_TrayWnd ; see: https://autohotkey.com/board/topic/29314-windeactivate/ dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> New Value:" this.activated, this.debug) - return this.alwaysOnTop + return this.activated } } alwaysOnTop[] { @@ -600,9 +600,13 @@ class Windy { SetFormat,integer,hex hwndnext += 0 SetFormat,integer,d - ; GetWindow() processes even hidden windows, so we move down the z oder until the next visible window is found - if (DllCall("IsWindowVisible","uint",hwndnext) = 1) - break + if (hwndnext = 0) + break + if (this.__isWindow(hwndnext)) { + ; GetWindow() processes even hidden windows, so we move down the z oder until the next visible window is found + if (DllCall("IsWindowVisible","uint",hwndnext) = 1) + break + } } if (this._debug) ; _DBG_ OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> (" hwndnext ")]" ; _DBG_ @@ -752,9 +756,13 @@ class Windy { SetFormat,integer,hex hwndprev += 0 SetFormat,integer,d - ; GetWindow() processes even hidden windows, so we move down the z oder until the next visible window is found - if (DllCall("IsWindowVisible","uint",hwndprev) = 1) - break + if (hwndprev =0) + break + if (this.__isWindow(hwndprev)) { + ; GetWindow() processes even hidden windows, so we move down the z oder until the next visible window is found + if (DllCall("IsWindowVisible","uint",hwndprev) = 1) + break + } } if (this._debug) ; _DBG_ OutputDebug % "|[" A_ThisFunc "([" this.hwnd "]) -> (" hwndprev ")]" ; _DBG_ From ec150b84b03ba51410c9676457c30a3c24a664f9 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Tue, 7 Mar 2017 09:17:49 +0100 Subject: [PATCH 13/15] [V] Windy 0.15.4 Closes #45 - Windy: Get Previous/Next Window within Z-Order Closes #46 - Windy: Activate the window Closes #48 - Windy: property clickthrough Closes #52 - Windy: Property CaptionHeight[] Closes #53 - INTERNAL: Windy: Move existing properties to geometry subclass --- lib/Windy.ahk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Windy.ahk b/lib/Windy.ahk index 33a9180..9c5da70 100644 --- a/lib/Windy.ahk +++ b/lib/Windy.ahk @@ -1,5 +1,5 @@ /* - Title: Windy, v0.15.3 + Title: Windy, v0.15.4 Windy provides a collection of classes, which allow a class based approach of handling windows, monitors, etc. @@ -31,4 +31,4 @@ #include Windy.ahk -Version := "0.15.3" \ No newline at end of file +Version := "0.15.4" \ No newline at end of file From dbc8673e4f3c4b64ec9f6f894b8f777b0cdea384 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Mon, 13 Mar 2017 08:22:52 +0100 Subject: [PATCH 14/15] [+] #54: Windy: Property border[] --- YUnit_Windy.ahk | 42 ++++++++++++++++++++++++------------- lib/Windy/Const_WinUser.ahk | 1 + lib/Windy/Windy.ahk | 34 +++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/YUnit_Windy.ahk b/YUnit_Windy.ahk index 5c832c6..429df66 100644 --- a/YUnit_Windy.ahk +++ b/YUnit_Windy.ahk @@ -11,7 +11,7 @@ ;#Warn LocalSameAsGlobal, Off #SingleInstance force -ReferenceVersion := "0.10.3" +ReferenceVersion := "0.10.4" debug := 1 OutputDebug DBGVIEWCLEAR @@ -28,21 +28,19 @@ class TempTestSuite { this.obj := new Windy(0, debug) } - nextprevious() { + border() { Global debug dbgOut(">[" A_ThisFunc "]") - hwndNext := this.obj.next - nextObj := new Windy(hwndNext, 0) - OutputDebug % "[IMPORTANT] NEXT OF [" this.obj.hwnd "-<" this.obj.title ">]: [" hwndNext "-<" nextObj.title ">]" - hwndPrev := this.obj.previous - prevObj := new Windy(hwndPrev, 0) - OutputDebug % "[IMPORTANT] PREVIOUS OF [" this.obj.hwnd "-<" this.obj.title ">]: [" hwndPrev "-" prevObj.title "]" - - Yunit.assert(this.obj.hwnd == prevObj.next) - Yunit.assert(this.obj.hwnd == nextObj.previous) - - dbgOut("<[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" + Yunit.assert(this.obj.border == 1) + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 0" + this.obj.border := 0 + Yunit.assert(this.obj.border == 0) + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" + this.obj.border := 1 + Yunit.assert(this.obj.border == 1) + dbgOut("<[" A_ThisFunc "]") } End() { @@ -652,6 +650,22 @@ class MiscTestSuite { dbgOut("<[" A_ThisFunc "]") } + border() { + Global debug + + dbgOut(">[" A_ThisFunc "]") + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" + Yunit.assert(this.obj.border == 1) + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 0" + this.obj.border := 0 + Yunit.assert(this.obj.border == 0) + OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" + this.obj.border := 1 + Yunit.assert(this.obj.border == 1) + dbgOut("<[" A_ThisFunc "]") + } + + Caption() { dbgOut(">[" A_ThisFunc "]") OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > 1" @@ -693,7 +707,7 @@ class MiscTestSuite { dbgOut("<[" A_ThisFunc "]") } - hscrollable() { + hscrollable() { dbgOut(">[" A_ThisFunc "]") OutputDebug % "[IMPORTANT]....[" A_ThisFunc "] > Initial" Yunit.assert(this.obj.hscrollable == 0) diff --git a/lib/Windy/Const_WinUser.ahk b/lib/Windy/Const_WinUser.ahk index 391ae35..7aec6d6 100644 --- a/lib/Windy/Const_WinUser.ahk +++ b/lib/Windy/Const_WinUser.ahk @@ -329,6 +329,7 @@ class WS { static OVERLAPPEDWINDOW := 0x00CF0000 ; WS_OVERLAPPED|CAPTION|SYSMENU|THICKFRAME|MINIMIZEBOX|MAXIMIZEBOX static POPUPWINDOW := 0x80880000 ; WS_POPUP|BORDER|SYSMENU static TILEDWINDOW := 0x00CF0000 ; WS_OVERLAPPEDWINDOW + static BORDER := 0x00C40000 ; WS_BORDER|WS_DLGFRAME|WS_SIZEBOX class EX { ; ExStyles ============================================================================================================= diff --git a/lib/Windy/Windy.ahk b/lib/Windy/Windy.ahk index eb9941f..a18d6aa 100644 --- a/lib/Windy/Windy.ahk +++ b/lib/Windy/Windy.ahk @@ -24,7 +24,7 @@ class Windy { About: License This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See for more details. */ - _version := "0.10.3" + _version := "0.10.4" _debug := 0 _hWnd := 0 @@ -96,6 +96,38 @@ class Windy { return this.alwaysOnTop } } + border[] { + /* --------------------------------------------------------------------------------------- + Property: border [get/set] + Set/Unset visibility of the windows border (caption, sizebox) + + Value: + flag - *true* or *false* (activates/deactivates *border*-Property) + + Remarks: + * To toogle, simply use + > obj.border := !obj.border + */ + get { + ret := (this.style & WS.BORDERLESS) > 0 ? 1 : 0 + dbgOut("=[" A_ThisFunc "([" this.hwnd "])] -> " ret, this.debug) + return ret + } + + set { + style := "-" this.__hexStr(WS.BORDERLESS) + if (value) { + style := "+" this.__hexStr(WS.BORDERLESS) + } + prevState := A_DetectHiddenWindows + DetectHiddenWindows, on + this.style := style + this.redraw() + DetectHiddenWindows, %prevState% + dbgOut("=[" A_ThisFunc "([" this.hwnd "], value=" value ")] -> " this.caption, this.debug) + return value + } + } caption[] { /* --------------------------------------------------------------------------------------- Property: caption [get/set] From 52b35e38be9a431236b092d16fe0d3eca4429390 Mon Sep 17 00:00:00 2001 From: hoppfrosch Date: Mon, 13 Mar 2017 09:14:26 +0100 Subject: [PATCH 15/15] [+] #54: Windy: Property border[] - Fixed Typo --- lib/Windy/Const_WinUser.ahk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Windy/Const_WinUser.ahk b/lib/Windy/Const_WinUser.ahk index 7aec6d6..426a815 100644 --- a/lib/Windy/Const_WinUser.ahk +++ b/lib/Windy/Const_WinUser.ahk @@ -329,7 +329,7 @@ class WS { static OVERLAPPEDWINDOW := 0x00CF0000 ; WS_OVERLAPPED|CAPTION|SYSMENU|THICKFRAME|MINIMIZEBOX|MAXIMIZEBOX static POPUPWINDOW := 0x80880000 ; WS_POPUP|BORDER|SYSMENU static TILEDWINDOW := 0x00CF0000 ; WS_OVERLAPPEDWINDOW - static BORDER := 0x00C40000 ; WS_BORDER|WS_DLGFRAME|WS_SIZEBOX + static BORDERLESS := 0x00C40000 ; WS_BORDER|WS_DLGFRAME|WS_SIZEBOX class EX { ; ExStyles =============================================================================================================