J'ai fait ce petit soft y'a un moment. Pas testé en PB 6
Code : Tout sélectionner
;Ar-S - PB 5.70 x64
;Ar-S - PB 5.21 LTS x86
; Version modifié par dobro
Enumeration
#Win
#Tim
EndEnumeration
Enumeration
#im_capslock_on
#im_capslock_off
#im_num_on
#im_num_off
EndEnumeration
Enumeration
#SysTrayIcone_capslock
#SysTrayIcone_numlock
EndEnumeration
Enumeration
#POPMENU
#Menu_info
#Menu_quitter
EndEnumeration
#Fonte=1
LoadFont(#fonte,"Arial",20,#PB_Font_Bold)
Global.b Quite
Quite = 0
Global State$,State2$,CapsInfo$ = "Majuscule désactivée", VerInfo$ = "VerrNum activé"
Declare test_key()
; CAPS LOCK
CreateImage(#im_capslock_on,32,32)
StartDrawing(ImageOutput(#im_capslock_on))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0,0,32,32,RGB(0,255,0))
DrawingFont(FontID(#fonte))
DrawText(7,4,"M",$0)
DrawText(6,2,"M",$FFFFFF)
StopDrawing()
CreateImage(#im_capslock_off,32,32)
StartDrawing(ImageOutput(#im_capslock_off))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0,0,32,32,RGB(255,0,0))
DrawingFont(FontID(#fonte))
DrawText(4,2,"m",$0)
DrawText(3,0,"m",$FFFFFF)
StopDrawing()
; VERR NUM
CreateImage(#im_num_on,32,32)
StartDrawing(ImageOutput(#im_num_on))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0,0,32,32,RGB(0,255,0))
DrawingFont(FontID(#fonte))
DrawText(7,4,"N",$0)
DrawText(6,2,"N",$FFFFFF)
StopDrawing()
CreateImage(#im_num_off,32,32)
StartDrawing(ImageOutput(#im_num_off))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0,0,32,32,RGB(255,0,0))
DrawingFont(FontID(#fonte))
DrawText(8,2,"n",$0)
DrawText(7,0,"n",$FFFFFF)
StopDrawing()
OpenWindow(#win,#PB_Ignore, #PB_Ignore,350,0,"Verr Maj "+ State$,#PB_Window_Invisible)
AddWindowTimer(#Win, #Tim, 500)
AddSysTrayIcon(#SysTrayIcone_capslock, WindowID(#win), ImageID(#im_capslock_off))
AddSysTrayIcon(#SysTrayIcone_numlock, WindowID(#win), ImageID(#im_num_off))
SysTrayIconToolTip(#SysTrayIcone_capslock, CapsInfo$)
SysTrayIconToolTip(#SysTrayIcone_numlock, VerInfo$)
;POPUP MENU
If CreatePopupMenu(#POPMENU)
MenuItem(#Menu_Info, "Info")
MenuItem(#Menu_Quitter, "Quitter")
EndIf
Repeat
Event = WaitWindowEvent(2)
EvT = EventTimer()
Select Evt
Case #Tim
test_key()
EndSelect
Select Event
Case #PB_Event_Menu
Select EventMenu()
Case #Menu_info
MessageRequester("Info",Help$,#PB_MessageRequester_Ok)
Case #Menu_Quitter
Quite = 1
EndSelect
Case #PB_Event_SysTray
Select EventType()
Case #PB_EventType_RightClick
DisplayPopupMenu(#POPMENU,WindowID(#win))
EndSelect
Case #WM_KEYDOWN
test_key()
Case #Win
test_key()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Win
Quite = 1
Break
EndSelect
EndSelect
Until Quite = 1 Or WaitWindowEvent() = #PB_Event_CloseWindow
Procedure test_key()
If GetKeyState_(#VK_CAPITAL) = 0
ChangeSysTrayIcon(#SysTrayIcone_capslock, ImageID(#im_capslock_off))
CapsInfo$ = "Majuscule désactivée"
Else
ChangeSysTrayIcon(#SysTrayIcone_capslock,ImageID(#im_capslock_on))
CapsInfo$ = "Majuscule activée"
EndIf
SysTrayIconToolTip(#SysTrayIcone_capslock, CapsInfo$)
If GetKeyState_(#VK_NUMLOCK) = 0
ChangeSysTrayIcon(#SysTrayIcone_numlock, ImageID(#im_num_off))
VerInfo$ = "VerrNum désactivé"
Else
ChangeSysTrayIcon(#SysTrayIcone_numlock, ImageID(#im_num_on))
VerInfo$ = "VerrNum activé"
EndIf
SysTrayIconToolTip(#SysTrayIcone_numlock, VerInfo$)
EndProcedure