Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it possible for QM to get the color of where the mouse clicked?
Copy      Help
int col=pixel(xm ym 0)
out "0x%X" col

or drag the preview icon in the Icon Editor and look at the title bar.
Import this little function. Once running it shows the color under the mouse all the time. It stops running if you hit the lower right corner of the screen.

Attached Files
.qml   MouseColor.qml (Size: 573 bytes / Downloads: 180)
Matt B

now that's nice!

good work there!
A new blog on QM coding and automation.

The Macro Hook
how do i use ColorToRGB ?
Copy      Help
int r g b
sys.ColorToRGB(color r g b)
out "%i %i %i" r g b
i like the idea, but i find that onscreen info is some kind of useless, because
you only see the color info.
my work in progress modification opens a small dialog with color info on
key [control end] (unusual key combination, but easy to reach.)

[Image: colordialog.jpg]

here is my current code:
function MouseColor
Copy      Help
str MouCol rgb
int mx my omx omy sy sx ocol r g b


,if(mx+100 > sx)
,if(my+30 > sy)
,;if((xm=sx-1 && ym=sy-1 ))
,ifk(CE) break
,sys.ColorToRGB(pixel(xm ym) r g b)
,MouCol.format("0x%X" pixel(xm ym))
,ocol=pixel(omx omy)
,OnScreenDisplay(MouCol 0.2 (omx) omy "" 8 ocol )
,OnScreenDisplay(MouCol 0.2 (omx+1) omy+1 "" 8 0x000001)

str controls = "3 6 8 10 11"
str _nullx hex red green blue
hex.format("#%X" pixel(xm ym))
if(!ShowDialog("MouseColorDialog" &MouseColorDialog &controls)) ret

function MouseColorDialog
Copy      Help
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("MouseColorDialog" &MouseColorDialog 0 0 0 0 0)) ret
;0 "" 0x90C80A44 0x100 0 0 121 46 "Colorpicker"
;9 Edit 0x54030080 0x200 4 50 10 8 "dummy"
;4 Static 0x54000000 0x0 6 4 10 10 "0x"
;5 Static 0x54000000 0x0 6 18 10 10 "#"
;7 Static 0x54000000 0x0 2 32 16 8 "RGB"
;3 Edit 0x54030080 0x200 22 2 96 14 "as 0x"
;6 Edit 0x54030080 0x200 22 16 96 14 "as hex"
;8 Edit 0x54030080 0x200 22 30 20 14 "red"
;10 Edit 0x54030080 0x200 44 30 20 14 "green"
;11 Edit 0x54030080 0x200 66 30 20 14 "blue"
;DIALOG EDITOR: "" 0x2010807 "" ""

if(message=WM_INITDIALOG) DT_Init(hDlg lParam)
;int param=DT_GetParam(hDlg)

sel message
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
sel wParam
,case EN_SETFOCUS<<16|3
,,out "0x"
,case EN_SETFOCUS<<16|6
,,out "hex"
,case EN_SETFOCUS<<16|8
,,out "rgb red"
,case EN_SETFOCUS<<16|10
,,out "rgb green"    
,case EN_SETFOCUS<<16|11
,,out "rgb blue"    
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1

feel free to optimize.
how do i use the dialog?
Mine is always empty when it opens.
A new blog on QM coding and automation.

The Macro Hook
Run MouseColor, move the mouse somewhere, press Ctrl+End, and the color will be in the dialog.
now ain't that won't accept the CE on my main keyboard (even though it moves to the bottom of the currently active window) but it will on my 2ndy keyboard...strange!
A new blog on QM coding and automation.

The Macro Hook

Forum Jump:

Users browsing this thread: 1 Guest(s)