The Runner
Posted: Sun Apr 30, 2006 7:48 pm
Here's a small tool (nice for USB-Sticks) which can be assigned to a shortcut (e.g. <windows>-x), it executes selected (and self configured) programs by typing some significant letters...
What you have to do before running it:
1) take a nice 16x16 icon and colorize it, so you will have 4 different icons in red, orange, green and white (I made a small arrow for me)
2) enter commonly used directories in the first DataSection (as I use 'The Runner' on my USB stick, the program checks, if it has been started from my USB-Stick, please adapt it's name - the drive letter will replace all "*" in the directories you entered above)
3) enter your programs, starting with some chars, a program description, the exe name, parameters and it's starting directory (see the examples in the second DataSection)
4) Compile it and start it...
You will see a small input field, where you can enter the program names, if you test it with the example code, just enter:
* 'p?' - you will see all entries starting with 'p'
* delete the '?' and complete to...
* ...'pur' - you will see "Pure Basic" and if you wait for a second, Purebasic is started (if you have it in the same directory I have)
* ...'pure' - this would have opened the source directory of Purebasic
Michael
What you have to do before running it:
1) take a nice 16x16 icon and colorize it, so you will have 4 different icons in red, orange, green and white (I made a small arrow for me)
2) enter commonly used directories in the first DataSection (as I use 'The Runner' on my USB stick, the program checks, if it has been started from my USB-Stick, please adapt it's name - the drive letter will replace all "*" in the directories you entered above)
3) enter your programs, starting with some chars, a program description, the exe name, parameters and it's starting directory (see the examples in the second DataSection)
4) Compile it and start it...
You will see a small input field, where you can enter the program names, if you test it with the example code, just enter:
* 'p?' - you will see all entries starting with 'p'
* delete the '?' and complete to...
* ...'pur' - you will see "Pure Basic" and if you wait for a second, Purebasic is started (if you have it in the same directory I have)
* ...'pure' - this would have opened the source directory of Purebasic
Michael
Code: Select all
; Define
Declare.c FirstChar(string.s)
; EndDefine
Procedure Init()
USBDrive=FirstChar(PeekS(GetCommandLine_())); ...Runner vom USB-Stick gestartet?
If USBDrive='C'; ...wohl nicht, also "händisch" prüfen...
USBDrive='H'; ...von "H" beginnend ("G", "F", "E",...) wird's wohl reichen...
VolumeLabel.s=Space(64)
Repeat
If GetVolumeInformation_(Chr(USBDrive)+":\",@VolumeLabel,64,#Null,#Null,#Null,#Null,#Null)
If LCase(volumelabel)="usb-stick name" ;### Configure that ###
Break
EndIf
EndIf
USBDrive-1
Until USBDrive='C'
EndIf
#MaxShortcuts=20; ... maximale Zahl von Kürzeln
#MaxPrograms=100; ... maximale Zahl von Programmeinträgen
#WinH=36
#WinW=142
Global Dim Shortcut.s(#MaxShortcuts,1)
Global Dim Program.s(#MaxPrograms,4)
Global i
Global Shortcuts=0; ... Kürzel einlesen...
Repeat
Shortcuts+1
Read Shortcut(Shortcuts,0)
Read Shortcut(Shortcuts,1)
Shortcut(Shortcuts,1)=ReplaceString(Shortcut(Shortcuts,1),"*",Chr(USBDrive))
;Debug Shortcut(Shortcuts,1)
Until Shortcut(Shortcuts,0)="*"
Global Programs=0; ... Programme einlesen...
Repeat
Programs+1
Read Program(Programs,0)
Read Program(Programs,1)
Read Program(Programs,2)
Read Program(Programs,3)
Read Program(Programs,4)
i=Shortcuts; ... Kürzel expandieren...
Repeat
i-1
Program(Programs,2)=ReplaceString(Program(Programs,2),Shortcut(i,0),Shortcut(i,1))
Program(Programs,3)=ReplaceString(Program(Programs,3),Shortcut(i,0),Shortcut(i,1))
Program(Programs,4)=ReplaceString(Program(Programs,4),Shortcut(i,0),Shortcut(i,1))
Until i=1
If Len(Program(Programs,4)) And Right(Program(Programs,4),1)<>"\"
Program(Programs,4)+"\"
EndIf
;Debug Program(Programs,2)
;Debug Program(Programs,4)
Until Program(Programs,0)="*"
DataSection;### Configure that ###
; Shortcut, Expandierter Text
Data.s "<U>","*:"
Data.s "<T>","*:\Programs\Tools\"
Data.s "<V>","*:\Programs\"
Data.s "<D>","C:\Dokumente und Einstellungen\vo\Eigene Dateien"
Data.s "<O>","C:\Dos\Win\"
Data.s "<I>","C:\Daten\Infos\"
Data.s "<P>","C:\Programme\"
Data.s "<W>","C:\Win\"
Data.s "<Z>","C:\Programme\Zubehör\"
Data.s "*","*"
EndDataSection
DataSection;### Configure that ###
; Kürzel, Name, Programm,Parameter, Pfad
Data.s "fox","Foxit Reader","<V>Tools\Viewer\Foxit Reader.exe","",""
Data.s "fs","FastStone Viewer","<V>Tools\Viewer\FSViewer.exe","",""
Data.s "neo","NeoMem","<V>NeoMem\NeoMem.exe <V>NeoMem\Getronics.neo","",""
Data.s "tom","TomeRaider","<V>TomeRaider\TomeRaider.exe","",""
Data.s "max","Maxthon Browser","<V>Tools\Internet\Maxthon.exe","",""
Data.s "vv","Ultra VNC Viewer","<V>Tools\Internet\VNC Viewer.exe","",""
Data.s "vs","Ultra VNC Server","<V>Tools\Internet\VNC Server.exe","",""
Data.s "xy","XYplorer","<V>Tools\XYplorer\XYplorer.exe","",""
Data.s "mem","Memory","<V>Games\Memory.Exe","",""
Data.s "quiz","Quiz","Quiz.Exe","","<V>Games"
Data.s "su","Sudoku","<V>Games\Sudoku.Exe","",""
Data.s "take","Take1","Take1.Exe","","<V>Games"
Data.s "pur","Pure Basic","PureBasic.exe","","<Z>PureBasic"
Data.s "pure","Pure Basic Sources","Examples","","<Z>PureBasic"
Data.s "c","Console Calculator","<V>Math\Calc\Ccalc.exe","",""
Data.s "hp","Free42","<V>Math\Calc\Free42.exe","",""
Data.s "pl","Process Mate","<V>Tools\System\ProcessMate.exe","",""
Data.s "sl","Safarp","<V>Tools\System\Safarp.exe","",""
Data.s "snif","Smart Sniffer","<V>Tools\System\SmSniff.exe","",""
Data.s "tree","TreeSize","<V>Tools\System\Treesize.exe <U>\","",""
Data.s "lex","Brockhaus","PCBib_Bi.Exe","","<I>Langenscheidt"
Data.s "wiki","Wikipedia","TomeRaider.exe","Books\Wikipedia.tr3 TomeRaider","<I>Tomeraider"
Data.s "ping","VPing Utility","VPing.exe","*","<T>Cool Tools"
Data.s "xon","TrueCrypt on","TrueCrypt.exe","/q /e /l x /a /v TrueCrypt.dev","<V>Tools\TrueCrypt"
Data.s "xoff","TrueCrypt off","<V>Tools\TrueCrypt\TrueCrypt.exe","/q /d",""
Data.s "*","","","","",""
EndDataSection
DataSection
Icon0: IncludeBinary "red.ico"
Icon1: IncludeBinary "orange.ico"
Icon2: IncludeBinary "green.ico"
Icon3: IncludeBinary "white.ico"
EndDataSection
Global Dim Icon(3)
Icon(0)=CatchImage(0,?Icon0)
Icon(1)=CatchImage(1,?Icon1)
Icon(2)=CatchImage(2,?Icon2)
Icon(3)=CatchImage(3,?Icon3)
EndProcedure
Procedure.c FirstChar(string.s)
Protected char
char=PeekB(@string)
If char=34 : char=PeekB(@string+1) : EndIf
ProcedureReturn char
EndProcedure
Procedure.l FirstProgram(string.s)
Protected i=Programs
Repeat
i-1
If string=Program(i,0)
ProcedureReturn i
EndIf
Until i=1
ProcedureReturn 0
EndProcedure
Procedure Main()
Protected quit=0; Schleife
Protected oldstart=-1; gemerkte Programmwahl
Protected start; aktuelle gewähltes Programm
Protected timer; Wartezähler
Protected icon=0; Bildnummer
Protected oldicon=-1; gemerkte Bildnummer
Protected list1.s,list2.s; Programmlisten
Protected input.s; aktuelle Eingabe
Protected oldinput.s; letzte Eingabe mit "?"
Protected l,r; Hilfsvariablen
Init()
Protected Font=LoadFont(0,"Tahoma",7)
win=OpenWindow(1,0,0,#WinW,#WinH+150,"Runner...",#PB_Window_BorderLess|#PB_Window_Invisible|#WS_THICKFRAME|#PB_Window_ScreenCentered)
SmartWindowRefresh(1,#True)
SetWindowLong_(win,#GWL_EXSTYLE,GetWindowLong_(hide,#GWL_EXSTYLE)|#WS_EX_TOOLWINDOW); Fenster nicht in Taskleiste anzeigen
SetWindowPos_(win,#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_FRAMECHANGED|#SWP_NOZORDER); Fenster zurechtrücken (Update)
CreateGadgetList(win)
StringGadget(1,22,0,120,20,"")
SetGadgetFont(#PB_Default,Font)
TextGadget(2,24,23,120,16,"")
TextGadget(3,24,40,120,999,"")
TextGadget(4,50,40,120,999,"")
SetActiveGadget(1)
;kann keine transparenten Flächen...
;ImageGadget(9,0,0,20,20,Icon(0));,#PB_Image_Border)
;SetGadgetState(9,Icon(0))
ResizeWindow(1,#PB_Ignore,#PB_Ignore,#PB_Ignore,#WinH)
SetTimer_(win,1,100,0)
StickyWindow(1,1)
HideWindow(1,0)
Repeat
If icon<>oldicon
oldicon=icon
DCwin=StartDrawing(WindowOutput(1))
DrawIconEx_(DCwin,2,2,Icon(icon),0,0,0,#Null,#DI_NORMAL|#DI_COMPAT)
StopDrawing()
EndIf
Select WaitWindowEvent()
Case #WM_TIMER
input=LCase(GetGadgetText(1))
oldstart=start
start=FirstProgram(input)
If start
ResizeWindow(1,#PB_Ignore,#PB_Ignore,#PB_Ignore,#WinH)
If start<>oldstart
SetGadgetText(2,Program(start,1))
SetGadgetText(3,"")
SetGadgetText(4,"")
timer=0
icon=0
Else
timer+1
Select timer
Case 4
icon=1
Case 8
icon=2
Case 10
quit=999
EndSelect
EndIf
ElseIf Right(input,1)="?"
If input<>oldinput
oldinput=input
SetGadgetText(2,"Display Programs...")
l=Len(input)-1
input=Left(input,l)
list1=""
list2=""
i=1
r=0
While i<Programs
If Left(Program(i,0),l)=input
r+1
list1+Program(i,0)+#CRLF$
list2+Program(i,1)+#CRLF$
EndIf
i+1
Wend
ResizeWindow(1,#PB_Ignore,#PB_Ignore,#PB_Ignore,#WinH+r*11+10)
SetGadgetText(3,list1)
SetGadgetText(4,list2)
EndIf
Else
ResizeWindow(1,#PB_Ignore,#PB_Ignore,#PB_Ignore,#WinH)
SetGadgetText(2,"Programmkürzel eingeben")
SetGadgetText(3,"")
SetGadgetText(4,"")
timer=0
icon=0
oldinput=""
EndIf
Case #WM_CHAR
Select EventwParam()
Case 27
quit=#True
Case 13
input=LCase(GetGadgetText(1))
If Right(input,1)="?"
input=Left(input,Len(input)-1)
EndIf
oldstart=start
start=FirstProgram(input)
quit=1000
EndSelect
EndSelect
If quit>666
If start>0
;SetErrorMode_(#SEM_NOOPENFILEERRORBOX)
If RunProgram(Program(start,4)+Program(start,2),Program(start,3),Program(start,4))
quit=#True
ElseIf quit=1000; bei Enter immer Aussteigen...
quit=#True
Else
SetGadgetText(2,"Fehler beim Starten...")
quit=0
icon=3
EndIf
ElseIf quit=1000; bei Enter immer Aussteigen...
quit=#True
EndIf
EndIf
Until quit=#True
EndProcedure
Main()