Hotkey Toolbar Quick Program Launcher AGAIN!
- Posted by Ray Tomes <rtomes at ihug.co.nz> Jun 19, 2003
- 500 views
Hello All They say third time lucky (or is this the fourth?) My recent posts had no weird characters so I think I have solved that=20 problems. If not I will have to hide under a rock for a while. :( If you want to try this, then read the help for quick at the beginning of= =20 the listing below. You can change quick.ini to have programs/documents what you want to=20 launch, and quick.exw will need to have the correct location of quick.ini= in it (at present c:\euphoria\bin\). Please let me know what you think and if you have any answers to my questions in the previous post. 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 whic= h=20 is "C:\\EUPHORIA\\BIN\\quick.ini". I don't understand why a reboot did th= is. 2. I want to put Icons on the buttons for the selected programs of type=20 =2Eexe so that they are easy to recognise. However as someone said, the = 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)*4= 0,=20 remainder(ib-1,13)*40 parameters as they work fine and just use the same = code to set up all 39 buttons. 3. I haven't yet done the Enter key part which is to allow the reassignme= nt=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? Thanks Ray ----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 \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-3= 6, -- 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\\BIN\\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 i= f 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=3DC:\EUPHORIA\DOC\database.doc E=3DC:\WINDOWS\EXPLORER.EXE F=3D G=3D H=3DC:\EUPHORIA\DOC\ENCYEU.HLP 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=3DC:\EUPHORIA\DOC\REFMAN.DOC 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=3DC:\EUPHORIA\DL\IDE\IDE.exw 3=3DC:\EUPHORIA\DL\Win32Lib\Docs\index.htm 4=3D 5=3D 6=3D 7=3D 8=3D 9=3D ----end quick.ini----