Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color Picker
#1
One of my most useful little ten minute programs that I've came up with for a while, though this is for Windows Only:

Code: (Select All)
Dim WinMse As POINTAPI
Type POINTAPI: As Long X_Pos, Y_Pos: End Type

Declare Dynamic Library "User32"
Function GetWindowLongA& (ByVal hwnd As Long, ByVal nIndex As Long)
Function SetWindowLongA& (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Function GetAsyncKeyState% (ByVal vkey As Long)
Function GetCursorPos (lpPoint As POINTAPI)
End Declare
Width 12, 1 'large enough to hold our color value in hex
GWL_STYLE = -16
ws_border = &H800000
WS_VISIBLE = &H10000000
_Title "Color Picker"
hwnd& = _WindowHandle
winstyle& = GetWindowLongA&(hwnd&, GWL_STYLE)
_Delay .2
a& = SetWindowLongA&(hwnd&, GWL_STYLE, winstyle& And WS_VISIBLE)

Color 15
Do
_Limit 30
z = GetCursorPos(WinMse)
_ScreenMove WinMse.X_Pos + 1, WinMse.Y_Pos + 1
tempimage = _ScreenImage
Cls , 0
_Source tempimage: Print Hex$(Point(WinMse.X_Pos, WinMse.Y_Pos));: _Source 0
_FreeImage tempimage
_Display
Loop Until GetAsyncKeyState(1) Or GetAsyncKeyState(2) Or GetAsyncKeyState(27)
System

Run it. Move the mouse around your screen. I think you can tell fairly quickly and easily what it does for you.
Reply
#2
I'm having trouble running it full screen. Big Grin Big Grin Big Grin

I made a few similar Win32 API utilities, but I never thought of a color-picker, nice!

+1

Pete
Reply
#3
color picker or color reporter?

It is interesting. Could be handy.


Attached Files Image(s)
   
b = b + ...
Reply
#4
Nice color picker @SMcNeill!
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#5
What would be nice is if I could minimize it to the icon tray on the lower right corner and then configure it to pop-up/close with a set of hotkeys.  I don't want it minimized and stuck on the task bar, but as an icon in the tray, it'd be a nice TSR tool to make use of whenever I wanted to know the color code for whatever was on the screen. 

Anyone have a clue how to register and minimize to the system tray?  And perhaps a working demo?  I'd love to see it sometime if so.
Reply
#6
@SMcNeill

Step 1) Right click the exe file. In the menu, click: Pin to Taskbar.

Step 2) Move it in your Task Bar so it is no more than 10 icons from the left. Let's say it is #8.

Step 3) Hold the Windows key and press the number 8.

That will open it. Unfortunately, I do not believe repeating the Win + 8 will toggle it closed. Sorry.

Pete
Shoot first and shoot people who ask questions, later.
Reply
#7
(Yesterday, 11:58 PM)Pete Wrote: @SMcNeill

Step 1) Right click the exe file. In the menu, click: Pin to Taskbar.

Step 2) Move it in your Task Bar so it is no more than 10 icons from the left. Let's say it is #8.

Step 3) Hold the Windows key and press the number 8.

That will open it. Unfortunately, I do not believe repeating the Win + 8 will toggle it closed. Sorry.

Pete

I'm not talking about the taskbar itself, but the icon tray in the lower corner:


[Image: image.png]

(Click the image above to expand it.  You can see the icons down in the little pop-up area in the corner.)  <-- That's the functionality I'm talking about.

I'm thinking it'd have to be done via https://learn.microsoft.com/en-us/window...otifyicona

I'm just not certain how to do it without an example to go by that I can build off of.  Tongue
Reply
#8
Oh, the system tray. In my Win 10, I need to click the ^ symbol to pull that up...

[Image: maxresdefault.jpg]

You might need third party software to set that up. Here's an article I found:

https://umatechnology.org/how-to-minimiz...h-hotkeys/

Might be worth a look if no one comes along with a native way to do it.

Pete
Reply




Users browsing this thread: 4 Guest(s)