Hey.
I've been wondering:
When the CHAIN command is used to launch another program, and then the program closes, when a fullscreen mode is used at least for the original program, the program won't do anything until the user switches it back to active again, such as by clicking it in the taskbar.
Is there a simple way to resume program execution after a called program quits, with no user interaction?
Thank you.
(Windows) Launch/Close Programs With Fullscreen
Re: (Windows) Launch/Close Programs With Fullscreen
Workaround on Windows:
fxm wrote: ↑Aug 20, 2014 21:06 The only and best solution I've found to force a window to the foreground with the focus, whatever the starting configuration, is to run the 5 following commands in this order:
- Hide (not absolutely necessary, just to reduce a little the window flashing)
- Minimize
- Restore
- Foreground
- Focus
Test program:Code: Select all
#INCLUDE "windows.bi" #INCLUDE "fbgfx.bi" DIM HandleWindow AS HWND SCREEN 12 PRINT PRINT " You have 5 seconds:" PRINT " - to put the graphic window in the background," PRINT " - or to minimize the graphic window." SLEEP 5000 SCREENCONTROL(FB.GET_WINDOW_HANDLE, CAST(INTEGER, HandleWindow)) ShowWindow(HandleWindow, SW_HIDE) 'Hide ShowWindow(HandleWindow, SW_MINIMIZE) 'Minimize ShowWindow(HandleWindow, SW_RESTORE) 'Restore SetForegroundWindow(HandleWindow) 'Foreground SetFocus(HandleWindow) 'Focus PRINT PRINT " The window is back in the foreground with the focus." SLEEP
Re: (Windows) Launch/Close Programs With Fullscreen
Thank you!fxm wrote: ↑Jul 15, 2022 4:49 Workaround on Windows:fxm wrote: ↑Aug 20, 2014 21:06 The only and best solution I've found to force a window to the foreground with the focus, whatever the starting configuration, is to run the 5 following commands in this order:
- Hide (not absolutely necessary, just to reduce a little the window flashing)
- Minimize
- Restore
- Foreground
- Focus
Test program:Code: Select all
#INCLUDE "windows.bi" #INCLUDE "fbgfx.bi" DIM HandleWindow AS HWND SCREEN 12 PRINT PRINT " You have 5 seconds:" PRINT " - to put the graphic window in the background," PRINT " - or to minimize the graphic window." SLEEP 5000 SCREENCONTROL(FB.GET_WINDOW_HANDLE, CAST(INTEGER, HandleWindow)) ShowWindow(HandleWindow, SW_HIDE) 'Hide ShowWindow(HandleWindow, SW_MINIMIZE) 'Minimize ShowWindow(HandleWindow, SW_RESTORE) 'Restore SetForegroundWindow(HandleWindow) 'Foreground SetFocus(HandleWindow) 'Focus PRINT PRINT " The window is back in the foreground with the focus." SLEEP
I will try that (at some point I'll get around to it).
Re: (Windows) Launch/Close Programs With Fullscreen
I only use 2 of fxm's commands in the loop.
Tested 32/64 bits win 11.
Also checked resource monitor.
All OK.
Please note I kill the file key.dat, maybe you don't want to (line 36)
Code: Select all
'
' tabstop=4
'
' This is taken directly from the FreeBasic CHM file and just modified to work here.
'
' include fbgfx.bi for some useful definitions
'
#include "windows.bi"
#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
Using fb ' constants and structures are stored in the FB namespace in lang fb
#endif
ScreenRes 200, 50',,,GFX_ALWAYS_ON_TOP or GFX_HIGH_PRIORITY 'not needed
dim as any ptr win
Screencontrol(GET_WINDOW_HANDLE ,Cast(Integer, win))
Dim e As Event
#macro focus
SetForegroundWindow(win)
SetFocus(win)
#endmacro
Do
focus
If (ScreenEvent(@e)) Then
Select Case e.type
Case EVENT_KEY_PRESS
If (e.scancode = SC_ESCAPE) Then
shell "notepad key.dat"
kill "key.dat"
End
End If
If (e.ascii > 0) Then
open "key.dat" for append as #1
Print #1, chr( e.ascii );
close #1
End If
Case EVENT_KEY_RELEASE
Case EVENT_KEY_REPEAT
If (e.ascii > 0) Then
open "key.dat" for append as #1
Print #1, chr( e.ascii );
close #1
End If
Case EVENT_MOUSE_MOVE
Case EVENT_MOUSE_BUTTON_PRESS
Case EVENT_MOUSE_BUTTON_RELEASE
Case EVENT_MOUSE_DOUBLE_CLICK
Case EVENT_MOUSE_WHEEL
Case EVENT_MOUSE_ENTER
Case EVENT_MOUSE_EXIT
Case EVENT_WINDOW_GOT_FOCUS
Case EVENT_WINDOW_LOST_FOCUS
Case EVENT_WINDOW_CLOSE
End
Case EVENT_MOUSE_HWHEEL
End Select
End If
Sleep 1
Loop
Also checked resource monitor.
All OK.
Please note I kill the file key.dat, maybe you don't want to (line 36)