Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIXEL COLOR AND MOUSE
#1
Is it possible for QM to get the color of where the mouse clicked?
#2
Code:
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.
#3
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
#4
HA!

now that's nice!

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

The Macro Hook
#5
how do i use ColorToRGB ?
pi
#6
Code:
Copy      Help
int r g b
sys.ColorToRGB(color r g b)
out "%i %i %i" r g b
#7
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
Code:
Copy      Help
str MouCol rgb
int mx my omx omy sy sx ocol r g b
sy=ScreenHeight
sx=ScreenWidth

rep
,mx=xm
,my=ym

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


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

function MouseColorDialog
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("MouseColorDialog" &MouseColorDialog 0 0 0 0 0)) ret
;BEGIN DIALOG
;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"
;END DIALOG
;DIALOG EDITOR: "" 0x2010807 "" ""


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

sel message
,case WM_INITDIALOG
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;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.
pi
#8
how do i use the dialog?
Mine is always empty when it opens.
A new blog on QM coding and automation.

The Macro Hook
#9
Run MouseColor, move the mouse somewhere, press Ctrl+End, and the color will be in the dialog.
#10
now ain't that something.....it 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)