Code: Alles auswählen
Procedure.i GetColorUnderMouse()
;aus dem PBForum, http://www.purebasic.fr/german/viewtopic.php?t=2887
Protected CursorPos.Point, hdc, color
GetCursorPos_(CursorPos.POINT )
hDC = GetDC_(0)
If hDC <> 0
Color = GetPixel_(hDC,CursorPos\x,CursorPos\y)
ReleaseDC_(0, hDC)
ProcedureReturn Color
EndIf
EndProcedure
OpenWindow(0, 0, 0, 600, 150, "Get Color with F5", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
AddKeyboardShortcut(0, #PB_Shortcut_F5, #PB_Shortcut_F5)
TextGadget(1, 10, 10, 222, 33, "Move Cursor and press F5 to get the Color")
Define event, color
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenu()
Case #PB_Shortcut_F5
color = GetColorUnderMouse()
Debug RSet(Hex(color), 6, "0")
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow