Post by Stefan Pendl on May 4, 2021 6:04:11 GMT -5
Below find a program I use to test LB5 alpha.
This is written with LB4.5.1, but should work in all LB4 releases.
The section with the folder and file names needs to be adjusted to meet your environment.
After an error has occurred, you are advised to not reuse the current LB5 session.
Have fun.
'LB5 test suite.bas
'Author: Stefan Pendl
'Date: 03.05.21
nomainwin
global hWndLB5, ReUseLb5
dim info$(1, 1)
' start - customize paths and names
Lb5InstallDir$ = "C:\VistaIncompatibel\lb5-352"
Lb5DataDir$ = Lb5InstallDir$; "\bas_files"
Lb5ExeFile$ = Lb5InstallDir$; "\lb5alpha64.exe"
Lb5CmdFile$ = Lb5InstallDir$; "\lb5alpha64_test.cmd"
' end - customize paths and names
files Lb5DataDir$, "*.bas", info$()
UpperLeftX = 1
UpperLeftY = 1
button #win.bt, "Next", [next], ul, 10, 10
checkbox #win.cb, "Reuse LB5 session", HandleCb, HandleCb, 100, 10, 150, 30
statictext #win.st, "", 10, 50, 290, 30
texteditor #win.te, 10, 80, 290, 100
open "LB5 alpha test" for window as #win
#win "trapclose [quit]"
[next]
i = i + 1
if i > val( info$(0, 0)) then i = 1
#win.st i; " ... "; info$(i, 0)
#win.te info$(0, 2); info$(0, 3); info$(i, 0)
#win.te "!selectall"
#win.te "!cut"
if i > 1 and ReUseLb5 = 0 then
dummy = BringWindowToTop(hWndLB5)
gosub [delay]
' sending Alt+F4
call keybdEvent _VK_MENU, 1
call keybdEvent _VK_F4, 1
call keybdEvent _VK_F4, 0
call keybdEvent _VK_MENU, 0
end if
if i = 1 or ReUseLb5 = 0 then
gosub [RestartLb5]
end if
dummy = BringWindowToTop(hWndLB5)
gosub [delay]
if i > 1 and ReUseLb5 = 1 then
' sending Ctrl+W
call keybdEvent _VK_CONTROL, 1
call keybdEvent asc("W"), 1
call keybdEvent asc("W"), 0
call keybdEvent _VK_CONTROL, 0
gosub [delay]
end if
' sending Ctrl+O
call keybdEvent _VK_CONTROL, 1
call keybdEvent asc("O"), 1
call keybdEvent asc("O"), 0
call keybdEvent _VK_CONTROL, 0
gosub [delay]
' sending Ctrl+V
call keybdEvent _VK_CONTROL, 1
call keybdEvent asc("V"), 1
call keybdEvent asc("V"), 0
call keybdEvent _VK_CONTROL, 0
gosub [delay]
' sending Return
call keybdEvent _VK_RETURN, 1
call keybdEvent _VK_RETURN, 0
gosub [delay]
if instr(lower$(info$(i, 0)), "fformj10_lb5_test") > 0 then
gosub [delay]
gosub [delay]
gosub [delay]
end if
' sending Shift+F5
call keybdEvent _VK_SHIFT, 1
call keybdEvent _VK_F5, 1
call keybdEvent _VK_F5, 0
call keybdEvent _VK_SHIFT, 0
wait
[quit]
close #win
end
[delay]
timer 1000, [continue]
wait
[continue]
timer 0
return
[RestartLb5]
open Lb5CmdFile$ for output as #cmd
#cmd "cd /d "; Lb5InstallDir$
#cmd chr$(34); Lb5ExeFile$; chr$(34)
close #cmd
run chr$(34); Lb5CmdFile$; chr$(34), HIDE
gosub [delay]
gosub [delay]
gosub [delay]
callback lpEnumFunc, EnumWindowsProc(ulong, ulong), long
calldll #user32, "EnumWindows", _
lpEnumFunc as ulong, _
lParam as ulong, _
result as long
return
function EnumWindowsProc(hwnd, lParam)
nMaxCount = 1024
lpString$ = space$(nMaxCount)
calldll #user32, "GetWindowTextA", _
hwnd as ulong, _
lpString$ as ptr, _
nMaxCount as ulong, _
result as ulong
if instr(lpString$, "BASIC v5") > 0 then
hWndLB5 = hwnd
end if
EnumWindowsProc = 1
end function
Function BringWindowToTop( hWnd )
CallDLL #user32, "BringWindowToTop", _
hWnd As ULong, _
BringWindowToTop As ULong
End Function
sub keybdEvent bVk, depressed
'bVk ......... Virtual Key Code of the key
'depressed ... 0 = released, 1 = depressed
if depressed = 0 then dwFlags = _KEYEVENTF_KEYUP
calldll #user32, "keybd_event",_
bVk as ushort,_
bScan as ushort,_
dwFlags as ulong,_
dwExtraInfo as ulong,_
result as void
end sub
sub HandleCb handle$
#handle$ "value? value$"
if value$ = "set" then
ReUseLb5 = 1
else
ReUseLb5 = 0
end if
end sub