--- In [email protected], "quantiworks" <quanticwo...@...> wrote:
>
> forxtra wrote:
>
> > How about use foo_comserver2.dll(COM Automation Server) and com plugin?
>
> Thanks for the suggestion, I already knew about that one too but never wanted
> to follow that route.
>
> Based on your two scripts, I made one that works with default user interface
> and columns_ui with or without the buttons* (see comments in script below)
> However, since I'm not a coder, I need help improving it.
> First, I want to ask, if is there a need to remove/destroy(?) maps in the
> whole script after a condition is met since I'm using three maps in there.
AFAIK, if variable using services of the map is declared as Local variable,
explicit Map.Destroy() is not mandatory. It automatically be released when
local goes out of scope.
> Second, check the comments for the other question.
>
We could also use the parent class name of the ToolbarWindow32:
- with CUI (Columns UI)
C={D75D4E2D-603B-4699-9C49-64DDFFE56A16}
- with DUI (Default User Interface)
C={FA3C10FD-A629-4e97-8731-EF51338807FD}
; -------------------------------------------------------------------Function
ControlFoobar(sParam)
Local hWnd = Win.Handle("+Foobar2000")
;; with CUI (Columns UI)
Local sCUI = "C={D75D4E2D-603B-4699-9C49-64DDFFE56A16}"
;; with DUI (Default User Interface)
Local sDUI = "C={FA3C10FD-A629-4e97-8731-EF51338807FD}"
Local hToolBar = Win.ChildHandleList(hWnd, sCUI)
If (hToolBar) Do
ControlFoobarWithCUI(hToolBar, sParam)
Else
hToolBar = Win.ChildHandleList(hWnd, sDUI)
If (hToolBar) Do
ControlFoobarWithDUI(hToolBar, sParam)
Else
ControlFoobarByCMD(sParam)
EndIf
EndIf
Quit
; -----------------------------------------
; with CUI (Columns UI)
Function ControlFoobarWithCUI(hToolBar, sParam)
Local m = Map.Create(6)
m["Stop"] = 0
m["Pause"] = 1
m["Play"] = 2
m["Prev"] = 3
m["Next"] = 4
m["Random"] = 5
m["Open"] = 7
Local WM_COMMAND = 0x111
Win.PostMessage(hToolBar, WM_COMMAND, m[sParam], 0x20614)
Quit
; -----------------------------------------
; with DUI (Default User Interface)
Function ControlFoobarWithDUI(hToolBar, sParam)
Local m = Map.Create(6)
m["Stop"] = 1
m["Play"] = 2
m["Pause"] = 3
m["Prev"] = 4
m["Next"] = 5
m["Random"] = 6
Local WM_COMMAND = 0x111
Win.PostMessage(hToolBar, WM_COMMAND, m[sParam], 0)
Quit
; -----------------------------------------
; using command-line switches
Function ControlFoobarByCMD(sParam)
Local m = Map.Create(6)
m["Stop"] = "/stop"
m["Pause"] = "/pause"
m["Play"] = "/play"
m["Prev"] = "/prev"
m["Next"] = "/next"
m["Random"] = "/rand"
Local Foobar2000 = ?"C:\Program Files\foobar2000\foobar2000.exe"
Do (Foobar2000, m[sParam])
Quit
; -------------------------------------------------------------------