Hotkey Toolbar Quick Program Launcher - my first Euphoria program

new topic     » topic index » view thread      » older message » newer message

Hi All

I hope that this post isn't too big with my program in. It is incomplete bu=
t sort of works, though=20
some bits are not done yet and some are causing me problems. I am intereste=
d in comments about the=20
program, the code and the problems. Please feel free to make any criticisms=
.

What does QUICK do? Simply, you start it up and leave it running (minimized=
) and it allows you to=20
key F12 followed by a single letter to launch any program you want. So that=
 allows 26 programs. Just=20
in case I allowed the ten digits too. F12 Esc =3D quit program. F12 Space =
=3D Help. F12 Enter is not yet=20
implemented. After F12 you can alternatively hover over a button to see wha=
t it launches or press=20
the button to launch.

At present I use ctrl-alt-LETTER to launch programs from the desktop but I =
want to clear my desktop=20
so this seems like a good way.

The problems are these:

1. Originally I had quick.exw and quick.ini in the same folder and the prog=
ram found the .ini file=20
with just a "quick.ini" file name but after I rebooted it couldn't find it =
and so I had to change to=20
the full path which is "C:\\EUPHORIA\\Ray\\quick.ini". I don't understand w=
hy a reboot did this.

2. I want to put Icons on the buttons for the selected programs of type .ex=
e so that they are easy=20
to recognise.  However as someone said, the 	extractIcon( function does not=
 appear to be compatible=20
with the  create(PictureButton or the setIcon( function so I haven't manage=
d to get any icons on the=20
buttons. I have commented out the part that doesn't work near the bottom. D=
on't worry about the=20
complex looking floor((ib-1)/13)*40, remainder(ib-1,13)*40 parameters as th=
ey work fine and just use=20
the same code to set up all 39 buttons.

3. I haven't yet done the Enter key part which is to allow the reassignment=
 of the keys by the user.=20
So at present you have to edit the .ini file (carefully) to set up the prog=
rams you want to have a=20
quick launch of.

4. I am not sure whether my program has a memory leak but something does. H=
ow do I tell?

What follows are the program which I call quick.exw and a possible starting=
 quick.ini file.
You can edit quick.ini to have your own favourites - the format should be o=
bvious.

Dam - this is possibly going to butcher some long lines! I cut the indents =
down to try and help.

Ray Tomes

  =3D=3D=3D=3D=3Dquick.exw start=3D=3D=3D=3D=3D=3D=3D=3D
sequence qhelp
qhelp=3D"QUICK is a quick hotkey program launcher of your favourite program=
s\n" &
   "\n" &
   "TO USE, start the quick application which will be in minimized mode.\n"=
 &
   "At any time press F12 (or click *quick* on the task bar) to bring quick=
 up for use,\n" &
   "then either click on a button or type a single key a-z (or A-Z)\n" &
   "or 0-9 to run the chosen application. To remember easily,\n" &
   "I use E for Explorer, I for Irfanview, W for WordPad, Z for WinZip etc.=
\n" &
   "Press Enter and any of the 36 chosen applications can be set or altered=
.\n" &
   "When an application is selected for a button then its icon will show on=
 that button.\n" &
   "Press Esc and the application will be disabled and closed.\n" &
   "Press any other key (e.g. space) and the help information will be broug=
ht up.\n" &
   "Be Happy!\n" &
   "\n" &
   "=A9 Copyright 2003 Ray Tomes -- rtomes at ihug.co.nz\n" &
   "No warranty of any kind is given by the author\n" &
   "as it is my first Euphoria program, but I did test it lots  blink\n" &
   "May be freely used.  Please advise suggested changes to me.\n" &
   "Written in Euphoria language, see http://www.RapidEuphoria.com\n" &
   "and uses Win32Lib by David Cuny and friends and hotkey by Ting.\n" &
   "Thanks to Dan Moyer, Derek Parnell, C.K.Lester, aku saya, Pete Lomax\n"=
 &
   "and others for helping me to learn Euphoria and Win32Lib.\n"

without warning
include Win32lib.ew
include hotkey.e
include msgbox.e

atom bnum -- button number pressed or key typed: a-z=3D>1-26, 0-9=3D>27-36,=
 Enter=3D>37, Esc=3D>38, other=3D>39
sequence assign, button
assign =3D repeat("",39)
button =3D repeat(0,39)
object bshow
bshow =3D "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" & {"Enter","Esc","?"}
atom inifn, i
object linb, bsh
constant Window1 =3D create( Window, "Quick", 0, Center, Center, 128, 547, =
0 )

atom Window2

procedure gethelp()
   i =3D message_box(qhelp, "Quick HELP", MB_OK)
end procedure

procedure reassign()
   -- to be done yet
end procedure

procedure launch(integer butno)
   if butno=3D37 then reassign()
   elsif butno=3D38 then closeApp()
   elsif butno=3D39 then gethelp()
   else shellExecute("open", assign[butno], SW_SHOWNORMAL)
   end if
   openWindow(Window1, Minimize)
end procedure

procedure AnyKey(integer self, integer event, sequence params) -- KEYstroke=

   integer keycode, shift
   keycode=3Dparams[1]
   shift=3Dparams[2]
   if keycode>=3D'a' and keycode<=3D'z' then bnum=3Dkeycode-96
   elsif keycode>=3D'A' and keycode<=3D'Z' then bnum=3Dkeycode-64
   elsif keycode>=3D'0' and keycode<=3D'9' then bnum=3Dkeycode-48+27
   elsif keycode=3D13 then bnum=3D37
   elsif keycode=3D27 then bnum=3D38
   else bnum=3D39 -- undefined keys also gives help
   end if
   launch(bnum)
end procedure

procedure WinHotKey(atom id) -- HotKey pressed =3D> show window
   openWindow( Window1, Normal)
end procedure

procedure ClickBut(integer id, integer event, sequence parms)
   for ib=3D1 to 39 do
     if id=3Dbutton[ib] then launch(ib) end if
   end for
end procedure

inifn=3Dopen( "C:\\EUPHORIA\\Ray\\quick.ini", "r") -- execution starts here=
 with quick.ini file
if inifn =3D -1 then
   i =3D message_box("quick.ini file not found", "Quick", MB_OKCANCEL)
else
   linb =3D gets(inifn)
   if equal(linb,"[buttons]\n") then
     for bn=3D1 to 36 do
       linb =3D gets(inifn)
       if atom(linb) then exit end if
       assign[bn]=3Dlinb[3..length(linb)-1]
     end for
   end if
end if
close(inifn)

for ib=3D1 to 39 do
   i=3D0
   bsh=3Dbshow[ib]
   if atom(bsh) then bsh=3D{bsh} end if
--  if match(".exe",assign[ib]) then
--    i=3DextractIcon(assign[ib]) -- seems that extractIcon is NOT compatib=
le with PictureButton
--    if i !=3D 0 then button[ib] =3D create( PictureButton, {bsh,"Launches=
 " & assign[ib]}, Window1,
--      floor((ib-1)/13)*40, remainder(ib-1,13)*40, 40, 40, 0)
--      setIcon ( button[ib], {i} )
--    else
--    end if
--  end if
   if i=3D0 then
     button[ib] =3D create( PushButton, {bsh,"Launches " & assign[ib]}, Win=
dow1,
       floor((ib-1)/13)*40, remainder(ib-1,13)*40, 40, 40, 0)
   end if
   setHandler( button[ib], w32HClick, routine_id("ClickBut"))
end for

onHotKey =3D routine_id("WinHotKey")
setHotKey( Window1, 2, 0, VK_F12)
setHandler( Window1, w32HKeyPress, routine_id("AnyKey"))
WinMain( Window1, Minimize )
  =3D=3D=3D=3D=3D=3Dquick.exw end=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

  =3D=3D=3D=3D=3D=3Dquick.ini start=3D=3D=3D=3D=3D=3D=3D=3D=3D
[buttons]
A=3D
B=3D
C=3D
D=3D
E=3DC:\WINDOWS\EXPLORER.EXE
F=3D
G=3D
H=3D
I=3D"C:\Program Files\IrfanView\i_view32.exe"
J=3D
K=3D
L=3D"C:\Program Files\NoteTab Light\NoteTab.exe"
M=3D
N=3D"C:\Program Files\Netscape\Netscape\Netscp.exe"
O=3D
P=3D
Q=3D
R=3D
S=3D
T=3D
U=3D
V=3D
W=3D"C:\Program Files\Accessories\WORDPAD.EXE"
X=3D
Y=3D
Z=3D"C:\Program Files\WinZip\WINZIP32.EXE"
0=3D
1=3D
2=3D
3=3D
4=3D
5=3D
6=3D
7=3D
8=3D
9=3D

  =3D=3D=3D=3D=3D=3D=3D=3Dquick.ini ends=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu