Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
; date : June 3 2003 ; author : Delgove jean-jacques ; purpose : Create a systray menu from an inifile ; version : 1.0 ; this program reads tray.ini for making a menu in systray. ; we take PopupMenu fonction and main idea from TechnicalDatabase ;Magic. Real Magic. Don't ask. Thanx to Guido for making it work the first time. ; vraiment magique. Merci Guido ;The PopupMenu UDF takes a | delimted list of menu items. and presents them to the user #DefineFunction PopupMenu(choices) user32=StrCat(DirWindows(1),"User32.DLL") MF_STRING = 0 TPM_RETURNCMD = 256 TPM_LEFTBUTTON = 0 hwnd=DllHwnd("") ;create menu hmenu = DllCall(user32,long:"CreatePopupMenu") choicecount=ItemCount(choices,"|") For xx=1 To choicecount thischoice=ItemExtract(xx,choices,"|") DllCall(user32,long:"AppendMenuA",long:hmenu, long:MF_STRING, long:xx, lpstr:thischoice) Next DllCall(user32,long:"SetForegroundWindow",long:hwnd) mc = MouseInfo(3) mcx=ItemExtract(1,mc," ") mcy=ItemExtract(2,mc," ") wFlags=TPM_RETURNCMD|TPM_LEFTBUTTON s=DllCall(user32,long:"TrackPopupMenu",long:hmenu, long:wFlags, long:mcx, long:mcy, long:0, long:hwnd, lpnull) ;Destroy Menu DllCall(user32,long:"DestroyMenu",long:hmenu) Return(s) #EndFunction ;This is a system tray icon example. Left clicking it runs code in case 1 ;Right clicking the icon pops up a menu ;BoxOpen("","") ;WinZoom("") IntControl(12,1+4,0,0,0) ; maybe 1+8 after debugged IntControl(1007, 1, 1, "Click me!", "shell32.dll|39") tray_ini=FileLocate("tray.ini") chemin=FilePath(tray_ini) if( tray_ini == "") then message("ERROR",strcat( "Ini file tray.ini not found ")) exit endif While 1 fichier=tray_ini gosub exploite gosub tray EndWhile exit :exploite ;debug(1) all_section=IniItemizePvt("",fichier) nb_section = ItemCount(all_section, @TAB) liste_prog="" last=0 for j=1 to nb_section p = ItemExtract(j, all_section, @TAB) c=IniReadPvt(p, "prog", "", fichier) if( c != "") then liste_prog=strcat(liste_prog,p,"|") last=last+1 run%last%=c endif next liste_prog=strcat(liste_prog,"exit") last=last+1 return :tray button=IntControl(1007, 3,0, "", "") :tray1 choice=PopupMenu(liste_prog) p = ItemExtract(choice, all_section, @TAB) c=IniReadPvt(p, "prog", "", fichier) if ( FileExist(c)) then fichier=strcat(chemin,"\",c) gosub exploite goto tray1 endif if ( choice == last) then IntControl(1007, 2,0, "", "") exit endif if( choice >= 1) then c=run%choice% %c% endif return
[calculator] prog=Run("calc.exe","") [notepad] prog=Run("notepad.exe","") [winbatch BBS] prog=ShellExecute("http://forum.winbatch.com","","",@NORMAL,"")
Article ID: W16724
File Created: 2013:06:19:13:50:52
Last Updated: 2013:06:19:13:50:52