Re: Hotkey Toolbar Quick Program Launcher - my first Euphoria prog=

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

Hi Dan and All

My last post came through OK. I suspect that it works OK when I use "send"=
=20
and not when I use "send later". I did the last one with "send" and will do=
=20
the same with this.

Anyway, I reformatted the program to lines all shorter than about 73, so=
=20
there should be no funny stuff in that regard.

It is incomplete but sort of works, though some bits are not done yet and=
=20
some are causing me problems. I am interested 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=20
(minimized) and it allows you to key F12 followed by a single letter to=20
launch any program you want. So that allows 26 programs. Just in case I=20
allowed the ten digits too. F12 Esc =3D quit program. F12 Space =3D Help. F=
12=20
Enter is not yet implemented. After F12 you can alternatively hover over a=
=20
button to see what it launches or press the button to launch.

At present I use ctrl-alt-LETTER to launch programs from the desktop but I=
=20
want to clear my desktop 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=20
program found the .ini file with just a "quick.ini" file name but after I=
=20
rebooted it couldn't find it and so I had to change to the full path which=
=20
is "C:\\EUPHORIA\\Ray\\quick.ini". I don't understand why a reboot did=20
this. You will need to change line 86 of the program to tell it where=20
quick.ini is on your computer.

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

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

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

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


----start quick.exw----
sequence qhelp
qhelp=3D"QUICK is a quick hotkey program launcher of your favourites\n" &
   "\n" &
   "START *quick* application which will be in minimized mode.\n" &
   "At any time press F12 to bring quick up for use,\n" &
   "then either click on a button or type a single key \n" &
   "a-z (or A-Z) or 0-9 to run the chosen application.\n" &
   "To remember easily, I use E for Explorer, I for Irfanview,\n" &
   "W for WordPad, Z for WinZip etc.\n" &
   "Press Enter to alter any of the 36 chosen applications.\n" &
   "The application's icon will show on the button it is set to.\n" &
   "Press Esc and the application will be disabled and closed.\n" &
   "Press any other key and help information will be brought 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,\n" &
   "Pete Lomax and others for help with Euphoria and Win32Lib.\n"

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

object bshow
bshow =3D "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" & {"Enter","Esc","?"}
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)
atom inifn, i
object linb, bsh, bhint
constant Window1=3Dcreate(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)
   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

-- serious execution starts here with quick.ini file
-- originally I just had "quick.ini" but rebooting req'd change ???
inifn=3Dopen( "C:\\EUPHORIA\\Ray\\quick.ini", "r")
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 ib<37 then bhint=3Dbsh&" unassigned"
   elsif ib=3D37 then bhint=3D"Enter sets code assignment of applications"
   elsif ib=3D38 then bhint=3D"Esc shuts down *quick*"
   elsif ib=3D39 then bhint=3D"? or space for Help and About quick"
   end if
   if length(assign[ib])>2 then bhint=3Dbsh&" launches "&assign[ib] end if
   if atom(bsh) then bsh=3D{bsh} end if
----- it seems that extractIcon is NOT compatible with PictureButton
--  if match(".exe",assign[ib]) then
--    i=3DextractIcon(assign[ib])
--    if i!=3D0 then button[ib]=3Dcreate(PictureButton,{bsh,bhint},
--      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]=3Dcreate(PushButton,{bsh,bhint},
       Window1,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 )
----end quick.exw----

----start quick.ini----
[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

----end quick.ini----

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

Search



Quick Links

User menu

Not signed in.

Misc Menu