REDIM SHARED title$
, findbrowsertitle$
, numofspaces%
, inputindex
, inputcount
, word$
(1000), crow%
, ccol%
REDIM SHARED scindent%
, srindent%
, fw%
, fh%
, cwidth%
, rheight%
, num%
, p1%
, p2%
, p3%
, p4%
, fileextension$
REDIM SHARED maxwinheight%
, mintopindent%
, browsertab$
, hwnd%&
, ClassName
, WindowName$
, nVirtKey
, nCmdShow
FUNCTION GetForegroundWindow%&
'find currently focused process handle
title$ = "FireFox Session Manager" 'Title of program window
_TITLE title$
'Set program title findbrowsertitle$ = "Bing - mozilla firefox"
browsertab$ = "bing.com"
fileextension$ = ".ses"
numofspaces% = 60
scindent% = 10 ' To be centered to screen.
mintopindent% = 5 ' Minimum rows indented from the top needed to see clickable areas above.
maxwinheight% = 42
rheight% = 42 - 4 ' Last width that supports font size 16 height.
rheight% = maxwinheight% - 4 ' -4 is to keep window bottom above taskbar.
i = 0
i = i + 1
settings$(i) = a$ + "," + "(Undefined)"
i = 0
crow% = 9
ccol% = cwidth% \ 2 - w4 \ 2
w3 = 0
w4 = w4 + 2 ' margin buffer for menu box.
heading$ = "FireFox Session Menu"
LOCATE crow%
- 2, ccol%
+ (w4
- 2) \
2 - LEN(heading$
) \
2 w3 = w3 + 1
p1% = ccol%: p2% = ccol% + w4: p3% = crow%: p4% = crow% + w3 ' selection parameters
CASE 1 ' Firefox Full Screen CASE 2 ' Firefox minimized task$ = "load previous session" ' Load Previous Session.
CALL taskactions
(task$
, flag
) SHELL _HIDE "dir /b *." + fileextension$
+ ">tmp.tmp" w3
= 0:
REDIM session$
(100) IF INSTR(a$
, fileextension$
) <> 0 THEN ' Strip off file extension. w3 = w3 + 1
session$(w3) = a$
w4 = 0
IF w3
> 1 THEN ' More than one saved session in database. crow% = 10
ccol% = cwidth% \ 2 - w4 \ 2
p1% = ccol%: p2% = ccol% + w4: p3% = crow%: p4% = crow% + w3 ' selection parameters
w4 = w4 + 2 ' margin buffer for menu box.
heading$ = "Click to Load Session"
LOCATE crow%
- 3, ccol%
+ (w4
- 2) \
2 - LEN(heading$
) \
2 heading$ = "Back | Quit"
LOCATE crow%
- 2, ccol%
+ (w4
- 2) \
2 - LEN(heading$
) \
2
b$ = "1" ' Only one selection.
task$ = "session"
task$ = "close"
CALL taskactions
(task$
, flag
)
tasklist:
DATA FireFox Minimized
,Starting FireFox Minimized...
DATA FireFox Load Previous Session
,Starting Firefox Last Session...
DATA Load a Saved Session
,Loading Session Menu...
DATA Map a New Session
,Map a New Session...
DATA Settings
,Go
to Settings...
programcommands:
settingslist:
DATA Load Previous Session
SUB mouse
(x%
, y%
, mb%
, rb%
)
hwnd%&
= FindWindowA
(0, title$
+ CHR$(0)) 'find this program's process handleoldx% = -1: w = 0: v = 0: num% = 0
PRINT "Open all websites you want" PRINT "saved in this session." PRINT "Click the taskbar icon to" PRINT "record and save session..."
FGwin%& = GetForegroundWindow%&
CALL mouse
(x%
, y%
, mb%
, rb%
) IF FGwin%&
<> hwnd%&
THEN EXIT DO ' Exit when Firefox is clicked. 'Minimize here.
FGwin%& = GetForegroundWindow%&
IF FGwin%&
= hwnd%&
THEN EXIT DO ' Exit when program window is restored from task bar.
z& = SetForegroundWindow&(hwnd%&) 'set focus
PRINT "Left click the tabs you want saved in this session." PRINT "Right click anywhere when finished..." PRINT "Left click the [X] Close symbol in Firefox." CASE "load previous session" PRINT "Click: " + CHR$(34) + "Restore Previous Session" PRINT "Row ="; y%;
" ";
"Column ="; x%;
" ";
oldx% = x%: oldy% = y%
mb% = 0
'PRINT "Confirmed: Row ="; y%; " Column ="; x%,
num% = num% + 1
tabx(num%) = x%
taby(num%) = y%
CASE "load previous session" PRINT " Click " + CHR$(34) + "Restore Previous Session" + CHR$(34) CALL mouse
(x%
, y%
, mb%
, rb%
) num% = num% + 1
tabx(num%) = x%
taby(num%) = y%
PRINT "Name and Save this Session as: "; sdate$
+ ": ";
z& = SetForegroundWindow&(hwnd%&) 'Set focus for key input.
CALL keyinput
(word$
, b$
, flag
)
CALL savefile
(word$
, sdate$
, url$
())
putimage:
_SCREENMOVE 0, -25 ' Hides title bar above computer top screen margin. dispon% = -1
SUB keyinput
(word$
, b$
, flag
) startpos%
= POS(1) - LEN(word$
)endpos% = startpos% + numofspaces%
ii = ii + 1
ii = 0
inputindex = inputindex - 1: word$ = word$(inputindex)
word$ = word$(inputindex): inputindex = inputindex - 1
flag = -1
action:
word$
= MID$(word$
, 1, POS(1) - startpos%
) + key$
+ MID$(word$
, POS(1) - startpos%
+ 1) word$
= MID$(word$
, 1, POS(1) - startpos%
) + key$
+ MID$(word$
, POS(1) - startpos%
+ 2)
wash:
delete:
word$
= MID$(word$
, 1, POS(1) - startpos%
) + MID$(word$
, POS(1) - startpos%
+ 2)
SUB savefile
(word$
, sdate$
, url$
())
i = 0
i = i + 1
settings$
(i
) = LTRIM$(MID$(settings$
(i
), INSTR(settings$
(i
), ")") + 1)) ' Strip off any number.
b$ = ""
CALL mouse
(x%
, y%
, mb%
, rb%
) b$
= CHR$(49 + y%
- crow%
) IF VAL(b$
) = 0 THEN ' Check for program choices above menu items. IF LEN(cmd$
) <> 3 THEN cmd$
= "" ' Not in middle of a word." cmd$ = ""
FOR i
= x%
+ j
TO cwidth%
b$ = ""
SUB taskactions
(task$
, flag
) i = 0
i = i + 1
settings$(i) = a$ + "," + action$
flag = -1
flag = 0
flag = -1
a$
= MID$(settings$
(j
), INSTR(settings$
(j
), ",") + 1) PRINT "This feature requires making a" PRINT "setting before it can be used." PRINT "Opening the settings screen..." flag = 0
CASE "load previous session" ' Taskkill could be substituted here but may report an ff crash on next start up.
CALL startbrowser
' Ensures browser is running full screen before _SCREENCLICK. REM x&
= ShowWindow&
(hwnd%&
, 0) ' Closes Firefox but loses restore last session info. PRINT " ERROR: sessions-settings.dat file is missing." PRINT " Rerun program to re-install default data."
REDIM settings$
(100) ' Load the settings data again. i = 0: w4 = 0
i = i + 1
settings$
(i
) = LTRIM$(STR$(i
)) + ") " + a$
+ "," + action$
a$
= MID$(settings$
(i
), 1, INSTR(settings$
(i
), ",") - 1) ' Do not include actions in menu. w3 = i
w4 = w4 + 2
crow% = 10
ccol% = cwidth% \ 2 - w4 \ 2
p1% = ccol%: p2% = ccol% + w4: p3% = crow%: p4% = crow% + w3 ' selection parameters
heading$ = "Settings"
LOCATE crow%
- 3, ccol%
+ (w4
- 2) \
2 - LEN(heading$
) \
2 heading$ = "Back | Quit"
LOCATE crow%
- 2, ccol%
+ (w4
- 2) \
2 - LEN(heading$
) \
2
task$
= LTRIM$(MID$(task$
, INSTR(task$
, ")") + 1)) ' strip off number if present.
PRINT " ERROR: sessions-settings.dat file is missing." PRINT " Rerun program to re-install default data." task$ = "": a$ = "": b$ = ""
' Now that WIDTH has been set, the font heigh can be used to calculate window size.
hwnd%&
= FindWindowA
(0, findbrowsertitle$
+ CHR$(0))i = 0
DO ' Wait until title is registerd. i = i + 1
hwnd%&
= FindWindowA
(0, findbrowsertitle$
+ CHR$(0))
x& = ShowWindow&(hwnd%&, 3) ' Maximize window from FindWindowA.
z& = SetForegroundWindow&(hwnd%&)
x& = ShowWindow&(hwnd%&, 2) ' Minimize window from FindWindowA.
x& = ShowWindow&(hwnd%&, 1) ' Restore window from FindWindowA.
z& = SetForegroundWindow&(hwnd%&)
hwnd%&
= FindWindowA
(0, title$
+ CHR$(0))z& = SetForegroundWindow&(hwnd%&)