Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Is it possible to add a hotkey that will open foobar2000 in fullscreen (Read 11199 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Hi.

Is it possible to add a hotkey that will open Foobar2000 in fullscreen ?

I mean get rid of the title & taskbar and get back to normal by the Esc key or by using the same key that put Foobar into fullscreen.

Any help would be greatly appreciated.

Thanks in advance,
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #1
As far as I know, the functionality you're talking about doesn't even exist.

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #2
As Zarggg said, this feature doesn't exist, so no hotkey can be mapped to it.

It's possible to do, but would require developing a custom UI component.

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #3
....... thanks for your replies.

Apparently it's possible with Autohotkey using an .ahk script but it's seems very difficult to me because I'm using Foobar2000 as a portable application.

Anyway, thanks again .......
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #4
It only need to know the window class, being portable or not.
You can use AU3 Spy, which comes with AutoHotkey.

I don't see any harm using it if you're using it for your own and don't blame someone else if it breaks anything.
Windows 10 Pro x64 // foobar2000 1.3.10

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #5
....... what could it break ???
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #6
....... what could it break ???


Probably not much, but software writers have an (unfortunate) tendency of relying on incorrect assumptions, so you never know if every component out there will work as it should.

Since I found our idea interesting I'll give it a shot myself in AutoIt (AutoHotKey's less handicapped sibling) and will post the script when I'm done.

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #7
Here is the script, run it using AutoIt 3.3.8.0 or later. You'll need the WinAPIEx library: I included it in the ZIP file but you can install it manually if you want. The script will stay running in the background, and will automatically detect the start and stop of foobar2000. Pressing Ctrl+Alt+Shift+G will toggle full screen mode. Close it through the system tray icon.

I didn't include a compiled executable so you can be sure the script does only what I told you it does. You can compile it yourself quite easily with the tools included with AutoIt.

http://www.mediafire.com/?hd3ecld8e9lrz97

PS: Meant 'your idea' on my post above, but I can't edit for some unknown reason.

 

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #8
Hi danielkza.
 
  Thanks a lot for this, you won't believe how much I do appreciate that.
  I installed AutoIt Portable and got your script working fine.
  Is it possible to run the script automatically when Foobar2000 starts and closes when exit Foobar2000 ?
  Also I would like to change the hotkey to just F12 for example which I tried but it didn't work.
  What I tried was changing this:
 
Code: [Select]
HotKeySet("^!+g","ToggleFullscreen")
to
Code: [Select]
HotKeySet("F12","ToggleFullscreen")

  It would be great if you could help me out with this.
  Here a "screenshot" of what I'm having now, thanks to you.

Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #9
http://www.autoitscript.com/autoit3/docs/f...s/HotKeySet.htm:

Quote
The following hotkeys cannot be set:
Ctrl+Alt+Delete    -- It is reserved by Windows
F12 -- It is also reserved by Windows, according to its API.
...


Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #10
i'd use F11. people should be used to that as it's what browsers use.

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #11
....... I got it now about the hotkey.

In AutoIt you can't just add F9 for example, instead it has to be {F9}

The script danielkza wrote had Ctrl+Alt+Shift+G as hotkey which has to be in AutoIt ^!+g

This leaves me only with how to start the AutoIt Portable script automatically when Foobar2000 Portable starts .......
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #12
use a batch file that runs both.

Code: [Select]
start blah.exe
start foobar2000.exe





Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #13
I can make it so the script itself runs foobar2000, waits for it to start and then closes itself when it foobar goes away. Give me a few minutes.

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #14
(Is there a time limit on editing posts? I wanted to add the script to my post above and fix my typo ('it foobar' should be 'it') but I don't see an Edit button anymore)

Here is an updated version of the script. Took me a bit longer than I expected because I accidentally found out a huge oversight of mine: the classname of the main window changes depending on the interface you are using. So I had to devise an alternate method to figure that out. I also did some other improvements: no more need for WinAPIEx, you can have the script start foobar2000 for you (it will properly pass on command line parameters, so replacing your shortcuts/file associations to the compiled script over foobar2000.exe should work) and close itself when it's gone, it should detect the main window more reliably, and it will not spawn repeated instances of itself (it will still properly run your foobar command line).

(sorry for the long code below, there are no attachments and I'd rather not use a hosting service now that it's all contained in a single file)

Code: [Select]
#include <WinAPI.au3>

#include <Misc.au3>

#include <Constants.au3>
#include <WindowsConstants.au3>

; ============================================================================;

; Changing this to True will make the script start foobar200 itself, and exit when it closes.
; Otherwise the script will stay running indefinitely, monitoring for foobar2000 whenever it starts.
Global Const $startFoobar2000 = True

Global $pidFoobar2000 = 0
Global $wndFoobar2000 = 0
Global $wndSavedPosition

Global Const $FullscreenRect[2] = [ _
_WinAPI_GetSystemMetrics($SM_CXSCREEN), _
_WinAPI_GetSystemMetrics($SM_CYSCREEN) _
]

Func ToggleFullscreen()
Global $wndFoobar2000, $wndSavedPosition
Local Const $stylesToRemove = BitOR($WS_CAPTION, $WS_BORDER, $WS_SIZEBOX)

If Not WinExists($wndFoobar2000) Then Return

Local $wndStyle = _WinAPI_GetWindowLong($wndFoobar2000, $GWL_STYLE)
If @error Then Return

If BitAND($wndStyle, $stylesToRemove) <> 0 Then
$wndSavedPosition = WinGetPos($wndFoobar2000)

$wndStyle = BitAND($wndStyle, BitNOT($stylesToRemove))
_WinAPI_SetWindowLong($wndFoobar2000, $GWL_STYLE, $wndStyle)

_WinAPI_SetWindowPos($wndFoobar2000, $HWND_TOPMOST, _
0, 0, _
0, 0, _
BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))

_WinAPI_SetWindowPos($wndFoobar2000, 0, _
0, 0, _
$FullscreenRect[0], $FullscreenRect[1], _
BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOZORDER))
Else
$wndStyle = BitOR($wndStyle, $stylesToRemove)
_WinAPI_SetWindowLong($wndFoobar2000, $GWL_STYLE, $wndStyle)

_WinAPI_SetWindowPos($wndFoobar2000, $HWND_NOTOPMOST, _
0, 0, _
0, 0, _
BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))

If UBound($wndSavedPosition, 1) >= 4 Then
_WinAPI_SetWindowPos($wndFoobar2000, 0, _
$wndSavedPosition[0], $wndSavedPosition[1], _
$wndSavedPosition[2], $wndSavedPosition[3], _
BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOZORDER))
EndIf
EndIf
EndFunc

Func GetFoobar2000Window()
Local $allWindows = _WinAPI_EnumWindowsTop()
If @error Then Return 0

Local $wndAlt = 0
For $i=1 To $allWindows[0][0]
Local $hwnd = $allWindows[$i][0], $pidWindow
If _WinAPI_GetWindowThreadProcessId($hWnd, $pidWindow) And $pidWindow == $pidFoobar2000 Then
  ; This is a hackish way to try and detect foobar2000's main window.
  ; It should have a maximize button, or at least the corresponding style!
If(BitAND(_WinAPI_GetWindowLong($hwnd, $GWL_STYLE), $WS_MAXIMIZEBOX)) Then
Return $hWnd
ElseIf Not $wndAlt And StringInStr(_WinAPI_GetWindowText($hWnd), "foobar2000") Then
$wndAlt = $hWnd
EndIf
EndIf
Next

  ; No window found with the semi-reliable method. Just return one with 'foobar2000' in the title.
Return $wndAlt
EndFunc

If $startFoobar2000 Then
$pidFoobar2000 = Run(StringFormat('"%s/%s" %s', @ScriptDir, "foobar2000.exe", _Iif(@Compiled,$CmdLineRaw,"")))
If @error Then
MsgBox($MB_ICONHAND, "foobar2000 Full-screen", "Error: failed to start foobar2000.exe. Make sure this script is placed in foobar2000's folder.")
Exit 1
EndIf

If _Singleton("foobar2000_fullscreen", 1) == 0 Then
Exit 1
EndIf

Do
Sleep(500)

$wndFoobar2000 = GetFoobar2000Window()
If $wndFoobar2000 Then ExitLoop
Until Not ProcessExists($pidFoobar2000)

If Not $wndFoobar2000 Then
Exit 1
EndIf
ElseIf _Singleton("foobar2000_fullscreen", 1) == 0 Then
Exit 1
Else
$pidFoobar2000 = ProcessWait("foobar2000.exe")
EndIf

HotKeySet("^!+g","ToggleFullscreen")

While True
If Not WinExists($wndFoobar2000) Then
$wndFoobar2000 =  GetFoobar2000Window()
If Not $wndFoobar2000 Then
If $startFoobar2000 Then
Exit
Else
Sleep(1000)
EndIf
EndIf
EndIf

Sleep(200)
WEnd

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #15
....... thanks a lot for all your effort.

Quote
(it will properly pass on command line  parameters, so replacing your shortcuts/file associations to the  compiled script over foobar2000.exe should work)


I don't understand how to do this.

Could you please tell me in detail what to do ?

By the way, the script is closing on exit foobar2000 now which leaves me only with running it automatically .......
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #16
(Is there a time li mit on editing posts? I wanted to add the script to my post above and fix my typo ('it foobar' should be 'it') but I don't see an Edit button anymore)
Yes, there is.

Quote
(sorry for the long code below, there are no attachments and I'd rather not use a hosting service now that it's all contained in a single file)
Hydrogenaudio provides codebox tags for large items of text, to use in place of code tags; I have edited your post accordingly.
Hydrogenaudio has an Uploads subforum.

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #17
(Is there a time li mit on editing posts? I wanted to add the script to my post above and fix my typo ('it foobar' should be 'it') but I don't see an Edit button anymore)
Yes, there is.

Quote
(sorry for the long code below, there are no attachments and I'd rather not use a hosting service now that it's all contained in a single file)
Hydrogenaudio provides codebox tags for large items of text, to use in place of code tags; I have edited your post accordingly.
Hydrogenaudio has an Uploads subforum.

Thanks for the information and the correction.

....... thanks a lot for all your effort.

Quote
(it will properly pass on command line  parameters, so replacing your shortcuts/file associations to the  compiled script over foobar2000.exe should work)

I don't understand how to do this.

Could you please tell me in detail what to do ?

By the way, the script is closing on exit foobar2000 now which leaves me only with running it automatically .......

What I meant was that in any case you would run foobar2000.exe running foobar2000_fullscreen.exe should work, even if you're passing commands, like file names, /play, etc. But for that to happen, you actually have to get other programs to run foobar2000_fullscreen.exe over the original executable, which requires you to a) change your shortcuts b) change your file associations. The former is easy, the latter no so much: you'd have to go through the registry changing the right keys (either manually or with some automated tool) or the 'Open With...' dialog for every file type you want. And you'd need to redo that if you change any associations through foobar2000. My suggestion for you is just to use the 'background task' mode since it will use virtually no resources: the script sleep permanently while foobar2000 is not running, and once it finds the main window, it will also sleep until you press the hotkey. I updated the script a bit, and the latest version follows below.

Code: [Select]
#include <WinAPI.au3>

#include <Misc.au3>

#include <Constants.au3>
#include <WindowsConstants.au3>

; ============================================================================ ;

; Changing this to True will make the script start foobar200 itself, and exit when it closes.
; Otherwise the script will stay running indefinitely, monitoring for foobar2000 whenever it starts.
Global Const $startFoobar2000 = False

Global $pidFoobar2000 = 0
Global $wndFoobar2000 = 0
Global $wndSavedPosition

Global Const $FullscreenRect[2] = [ _
    _WinAPI_GetSystemMetrics($SM_CXSCREEN), _
    _WinAPI_GetSystemMetrics($SM_CYSCREEN) _
]

Func ToggleFullscreen()
    Global $wndFoobar2000, $wndSavedPosition
    Local Const $stylesToRemove = BitOR($WS_CAPTION, $WS_BORDER, $WS_SIZEBOX)

    If Not WinExists($wndFoobar2000) Then Return

    Local $wndStyle = _WinAPI_GetWindowLong($wndFoobar2000, $GWL_STYLE)
    If @error Then Return

    If BitAND($wndStyle, $stylesToRemove) <> 0 Then
        $wndSavedPosition = WinGetPos($wndFoobar2000)

        $wndStyle = BitAND($wndStyle, BitNOT($stylesToRemove))
        _WinAPI_SetWindowLong($wndFoobar2000, $GWL_STYLE, $wndStyle)

        _WinAPI_SetWindowPos($wndFoobar2000, $HWND_TOPMOST, _
                            0, 0, _
                            0, 0, _
                            BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))

        _WinAPI_SetWindowPos($wndFoobar2000, 0, _
                            0, 0, _
                            $FullscreenRect[0], $FullscreenRect[1], _
                            BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOZORDER))
    Else
        $wndStyle = BitOR($wndStyle, $stylesToRemove)
        _WinAPI_SetWindowLong($wndFoobar2000, $GWL_STYLE, $wndStyle)

        _WinAPI_SetWindowPos($wndFoobar2000, $HWND_NOTOPMOST, _
                            0, 0, _
                            0, 0, _
                            BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))

        If UBound($wndSavedPosition, 1) >= 4 Then
            _WinAPI_SetWindowPos($wndFoobar2000, 0, _
                                $wndSavedPosition[0], $wndSavedPosition[1], _
                                $wndSavedPosition[2], $wndSavedPosition[3], _
                                BitOR($SWP_NOCOPYBITS, $SWP_FRAMECHANGED, $SWP_NOZORDER))
        EndIf
    EndIf
EndFunc

Func GetFoobar2000Window()
    Local $allWindows = _WinAPI_EnumWindowsTop()
    If @error Then Return 0

    Local $wndAlt = 0
    For $i=1 To $allWindows[0][0]
        Local $hwnd = $allWindows[$i][0], $pidWindow
        If _WinAPI_GetWindowThreadProcessId($hWnd, $pidWindow) And $pidWindow == $pidFoobar2000 Then
            ; This is a hackish way to try and detect foobar2000's main window.
            ; It should have a maximize button, or at least the corresponding style!
            If(BitAND(_WinAPI_GetWindowLong($hwnd, $GWL_STYLE), $WS_MAXIMIZEBOX)) Then
                Return $hWnd
            ElseIf Not $wndAlt And StringInStr(_WinAPI_GetWindowText($hWnd), "foobar2000") Then
                $wndAlt = $hWnd
            EndIf
        EndIf
    Next

    ; No window found with the semi-reliable method. Just return one with 'foobar2000' in the title.
    Return $wndAlt
EndFunc

If $startFoobar2000 Then
    $pidFoobar2000 = Run(StringFormat('"%s/%s" %s', @ScriptDir, "foobar2000.exe", _Iif(@Compiled, $CmdLineRaw, "")))
    If @error Then
        MsgBox($MB_ICONHAND, "foobar2000 Full-screen", "Error: failed to start foobar2000.exe. Make sure this script is placed in foobar2000's folder.")
        Exit 1
    EndIf

    If _Singleton("foobar2000_fullscreen", 1) == 0 Then
        Exit 1
    EndIf
ElseIf _Singleton("foobar2000_fullscreen", 1) == 0 Then
    Exit 1
EndIf

HotKeySet("^!+g","ToggleFullscreen")

While True
    If Not ProcessExists($pidFoobar2000) Then
        If Not $startFoobar2000 Then
            $pidFoobar2000 = ProcessWait("foobar2000.exe")
        Else
            Exit
        EndIf
    EndIf

    If Not WinExists($wndFoobar2000) Then
        $wndFoobar2000 = GetFoobar2000Window()
        If Not $wndFoobar2000 Then
            Sleep(1000)
            ContinueLoop
        EndIf
    EndIf

    Sleep(200)
WEnd

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #18
....... I finaly got it working as I wanted.

Not sure if it's the right way to do it but at least it works for me.

What I did was creating a very simple batch (.bat) file using a relative file path because I'm using foobar2000 as portable application.

Code: [Select]
@echo off
start  "" "AutoIt Portable\App\AutoIt3_x64.exe" foobar2000_fullscreen.au3


Then I did set the foobar2000_fullscreen.au3 to open with AutoIt by default (AutoIt3_x64.exe), this probably won't work on a x86 system but I'll create another batch file for that later on.

At last I converted the batch file to an .exe and added a foobar icon and that's it, now I only have to click the converted .exe file and foobar2000 opens with the hotkey script running automatically and closes on exit.

Couldn't have done that without the help of danielkza - Thanks a lot !

Thanks to ojdo as well for providing the HTPC Fullscreen Panels

By the way, I'm using the previous script from danielkza because it's working fine .......
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #19
The new version I posted has a small bugfix related to the foobar2000 window and process not going away at the same time, but that's all I changed, if you modify the '$startFoobar2000' line to True it will work as you want without the possible bug. And you don't need to run the script with AutoIt, you can compile it and it will be a fully self-contained executable. Editing the script with the SciTE editor bundled with AutoIt should give you a Compile option (which IIRC defaults to x86, which would allow it to work on both 32-bit and 64-bit Windows).

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #20
The new version I posted has a small bugfix related to the foobar2000 window and process not going away at the same time, but that's all I changed, if you modify the '$startFoobar2000' line to True it will work as you want without the possible bug. And you don't need to run the script with AutoIt, you can compile it and it will be a fully self-contained executable. Editing the script with the SciTE editor bundled with AutoIt should give you a Compile option (which IIRC defaults to x86, which would allow it to work on both 32-bit and 64-bit Windows).


....... ok I got it now, the new script is working fine.

I probably did something wrong on my 1st try with it.

Just compiled the script by your instructions and the self-contained executable that came out of it works like a charm.

It looks like I finally got it right.

Thanks again for all your help, I really do appreciate it .......
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #21
Hi danielkza.

It appears that there is a little problem with the script and I tried to figure it out on my own but I can't.

When I toggle the fullscreen mode the background image doesn't resize like it should and it also changes the perspective.

After  going back from fullscreen to normal view the progress bar is hidden  under the taskbar because it won't resize the background image and I  think it should go back to like it was before fullscreen mode.
 
  Not sure if this is because of the AutoIt script or the HTPC Fullscreen Panels II.

Here are 3 screenshots to show you what I mean:

Before fullscreen:

Fullscreen:

After fullscreen:

 
  It would be great if could have a look and tell what to change in the script.
 
  Thnks a lot in advance,
Tommy

Is it possible to add a hotkey that will open foobar2000 in fullscreen

Reply #22
I noticed the same problem here with my relatively simple Columns UI configuration, so it seems it's not related to your skin at all, and probably something to do with foobar2000 not 'liking' being resized and/or the script not sending one of the needed messages. I'll try fixing it later and I'll definitely post an updated version when/if I do correct it. Right now the 'fix' is to restore and maximize/resize the window manually after you 'un-fullscreen' it.