Comment ================================================ HotMax TaskMax HotKey Control Program Copyright 1992 by Marc Perkel * All Rights Reserved This menu requires DR-DOS 6.0 and TaskMax to run. ================================================ EndComment Var Tasks DeviceSeg DeviceOfs DeviceID TaskName TaskNum HotKey Commands CommandLines KeyVals KeyNames Help HelpName DeviceID = 'HOTMAX$' CommandLines[1] = CmdLine ParseLine if Commands[1] = '' ShowHelp endif StandardIO Writeln if not TMaxInstalled Error ('TaskMax must be installed to run this program!') endif repeat FirstCommand ParseLine until Commands[1] = '' TMaxDirectSwitching Off ;=========================================== Procedure ParseLine var P Cmd ; Writeln '> ' CommandLines[1] CommandLines[1] = UpperCase(CommandLines[1]) dispose(Commands) while CommandLines[1] > '' if left(CommandLines[1],1) = '"' delete(CommandLines[1],1,1) P = pos('"',CommandLines[1]) else P = pos(' ',CommandLines[1]) endif if P = 0 then P = succ(length(CommandLines[1])) Cmd = left(CommandLines[1],pred(P)) delete(CommandLines[1],1,P) trim(Cmd) trim(CommandLines[1]) AppendArray(Commands,Cmd) endwhile delete(CommandLines,1,1) EndProc Procedure NextCommand var Cmd Cmd = Commands[1] delete(Commands,1,1) return Cmd EndProc Procedure PatchHotKey if NumberOfElements Commands = 0 then return FindDevice GetHotKey MemW(DeviceSeg,DeviceOfs + $16 + (TaskNum * 2)) = HotKey EndProc Procedure ClearKeys FindDevice loop 25 MemW(DeviceSeg,DeviceOfs + $14 + (LoopIndex * 2)) = $FFFF endloop EndProc Procedure GetHotKey var Hot Hot = Commands[1] if Hot = '' then Error('Hot Key not Specified!') if left(Hot,1) = '$' HotKey = Value(Hot) else KeyByName endif EndProc Procedure FirstCommand var T X HotKey KeyString Old New TaskName = NextCommand if left(TaskName,1) = '@' delete(TaskName,1,1) ReadTextFile(TaskName,T) loop T X = pos(';',LoopVal) if X > 0 then LoopVal = left(LoopVal,pred(X)) if LoopVal > '' AppendArray(CommandLines,LoopVal) endif endloop elseif TaskName = 'CLEARKEYS' ClearKeys Writeln 'HotKeys Reset.' elseif TaskName = 'CLEARKEY' FindDevice New = NextCommand FindTaskID(New) MemW(DeviceSeg,DeviceOfs + $16 + (TaskNum * 2)) = $FFFF Writeln 'Clearing HotKey for task ' TaskNum '.' elseif TaskName = 'SWITCHTOTASK' New = NextCommand FindTaskID(New) TMaxSwitchTasks(TaskNum) elseif TaskName = 'KILLTASK' New = NextCommand FindTaskID(New) TMaxDeleteTask(TaskNum) Writeln 'Task ' New ' deleted.' elseif (TaskName = 'STARTTASK') or (pos('.',TaskName) > 0) TMaxReturnCount = 75 if pos('.',TaskName) > 0 New = TaskName else New = NextCommand endif TMaxCreateTask(New) TaskNum = TmaxResult if left(Commands[1],1) = '[' T = NextCommand delete(T,1,1) length(T) = length(T) - 1 trim(T) TMaxNameTask(TaskNum,T) endif PatchHotKey Writeln 'Task ' TaskNum ' created.' elseif TaskName = 'NAMETASK' Old = NextCommand FindTaskID(Old) New = NextCommand Writeln 'Renaming ' Old ' to ' New '.' TMaxNameTask(TaskNum,New) elseif TaskName = 'LISTTASKS' FindDevice TMaxReadTaskInfo(Tasks) Writeln 'Task: ID: Key:' Writeln '---------------------' loop Tasks HotKey = MemW(DeviceSeg,DeviceOfs + $16 + (LoopVal[2] * 2)) if HotKey <> $FFFF KeyString = '$' + HexString(HotKey,4) else KeyString = 'None' endif if LoopVal[2] = TMaxThisTask Write '* ' else Write ' ' endif Write PadRight(LoopVal[1],10) Writeln PadLeft(Str(LoopVal[2]),2) ' ' KeyString endloop else FindTaskID(TaskName) PatchHotKey Writeln 'Assigning HotKey to task ' TaskName '.' endif EndProc Procedure FindTaskID (Name) var T Ch if Name = 'THISTASK' TaskNum = TMaxThisTask return endif if Name = 'LASTTASK' TaskNum = 24 return endif if Name = 'SECURITY' TaskNum = 23 return endif Ch = left(Name,1) if (Ch >= '0') and (Ch <= '9') TaskNum = Value(Name) return endif TMaxReadTaskInfo(Tasks) MatrixInvert(Tasks) T = PosInList(Name,Tasks[1]) if T = 0 then Error('Task ' + Name + ' not found!') TaskNum = Tasks[2,T] EndProc Procedure FindDevice var Regs DeviceName X if DeviceSeg > 0 then return Regs.AX = $5200 MsDos(Regs) DeviceOfs = MemW(Regs.ES,Regs.BX + $22) DeviceSeg = MemW(Regs.ES,Regs.BX + $24) while (DeviceName <> 'HOTMAX$') and (DeviceSeg <> $FFFF) DeviceName = '' loop 8 DeviceName = DeviceName + char(Mem(DeviceSeg,DeviceOfs + 9 + LoopIndex)) endloop Trim(DeviceName) if DeviceName <> 'HOTMAX$' X = MemW(DeviceSeg,DeviceOfs) DeviceSeg = MemW(DeviceSeg,DeviceOfs + 2) DeviceOfs = X endif endwhile if DeviceName <> 'HOTMAX$' DeviceDoc ExitMenu endif EndProc Procedure Error (St) Writeln St ExitMenu EndProc Procedure DeviceDoc Writeln Writeln 'To use this program you must have HOTMAX.SYS loaded as a device' Writeln 'driver in your CONFIG.SYS file as follows:' Writeln Writeln 'DEVICE=HOTMAX.SYS or' Writeln 'DEVICEHIGH=HOTMAX.SYS' EndProc Procedure KeyByName var P St BuildTable repeat St = NextCommand if St > '' P = PosInList(St,KeyNames) if P > 0 HotKey = HotKey + KeyVals[P] endif endif until St = '' EndProc Procedure BuildTable loop 26 AppendArray(KeyNames,char(LoopIndex + 64)) endloop AppendArray(KeyNames,'ALT') AppendArray(KeyNames,'CTRL') AppendArray(KeyNames,'LSHIFT') AppendArray(KeyNames,'RSHIFT') loop 12 AppendArray(KeyNames,'F' + Str(LoopIndex)) endloop KeyVals[1] = $1E KeyVals[2] = $30 KeyVals[3] = $2E KeyVals[4] = $20 KeyVals[5] = $12 KeyVals[6] = $21 KeyVals[7] = $22 KeyVals[8] = $23 KeyVals[9] = $17 KeyVals[10] = $24 KeyVals[11] = $25 KeyVals[12] = $26 KeyVals[13] = $32 KeyVals[14] = $31 KeyVals[15] = $18 KeyVals[16] = $19 KeyVals[17] = $10 KeyVals[18] = $13 KeyVals[19] = $1F KeyVals[20] = $14 KeyVals[21] = $16 KeyVals[22] = $2F KeyVals[23] = $11 KeyVals[24] = $2D KeyVals[25] = $15 KeyVals[26] = $2C KeyVals[27] = $0800 KeyVals[28] = $0400 KeyVals[29] = $0200 KeyVals[30] = $0100 KeyVals[31] = $3B KeyVals[32] = $3C KeyVals[33] = $3D KeyVals[34] = $3E KeyVals[35] = $3F KeyVals[36] = $40 KeyVals[37] = $41 KeyVals[38] = $42 KeyVals[39] = $43 KeyVals[40] = $44 KeyVals[41] = $57 KeyVals[42] = $58 EndProc Procedure ShowHelp HelpName = ExistOnPath 'HOTMAX.DOC' if HelpName = '' StandardIO Writeln Error('HOTMAX.DOC not found!') endif ClearScreen BlankTime = 0 Explode Off BoxBorderColor Green Blue BoxInsideColor Grey Blue BoxHeaderColor Yellow Mag BoxHeader = ' Viewing HOTMAX.DOC ' BoxFooterRight = ' Press ESC to Exit ' Shadow Off DrawBox 1 1 ScreenWidth ScreenHeight ReadTextFile (HelpName,Help) ViewArray Help ExitMenu EndProc