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
(01-22-2025, 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
#9
(01-22-2025, 03:53 PM)SMcNeill Wrote: Jeden z urządzeń minutowych, jaki jest stworzony od innego czasu, jest przeznaczony tylko dla systemu Windows:
Code: (Select All)
 Dim WinMse As POINTAPI 
Typ POINTAPI: As Long X_Pos, Y_Pos: End Type
Deklaracja biblioteki User32” Funkcja GetWindowLongA& ( ByVal hwnd As Long , ByVal nIndex As Long ) Funkcja SetWindowLongA& ( ByVal hwnd As Long , ByVal nIndex As Long , ByVal dwNewLong As Long ) Funkcja GetAsyncKeyState% ( ByVal vkey As Long ) Funkcja GetCursorPos (lpPoint As POINTAPI) Endacja Szerokość 12 , 1 ' znak towarowy, aby otrzymać wartość znaku w szesnastkowym GWL_STYLE = -16 ws_border = &H800000 WS_VISIBLE = &H10000000 _Title "Wybór koloru" hwnd& = _WindowHandle winstyle& = GetWindowLongA& (hwnd&, GWL_STYLE) _Delay .2 a& = SetWindowLongA& (hwnd&, GWL_STYLE, winstyle& i WS_VISIBLE) Kolor 15 Wykonaj _Limit 30     z = GetCursorPos (WinMse) _ScreenMove WinMse.X_Pos + 1 , WinMse.Y_Pos + 1     obraz tymczasowy = _ScreenImage Cls , 0 _źródło tempimage: Print Hex$ ( Point (WinMse.X_Pos, WinMse.Y_Pos));: _Źródło 0 _FreeImage tempimage _Wyświetl pętlę do momentu PobierzAsyncKeyState ( 1 ) Lub PobierzAsyncKeyState ( 2 ) Lub PobierzAsyncKeyState ( 27 ) System
Uruchomione. Poruszaj myszką po ekranie. Myślę, że łatwo i łatwo się bawię, co dla Ciebie robi.
   
   

Wygląda jak fajny mały program, który pobiera kolor piksela pod kursorem. Poruszasz myszką, a ona pokazuje kolor w formacie szesnastkowym. Działa w pętli, dopóki nie klikniesz myszą lub nie naciśniesz Escape. Proste, ale przydatne narzędzie




   

   

   
   
   
   

Reply
#10
What did he say? Smile

Welcome Adam!
b = b + ...
Reply




Users browsing this thread: 3 Guest(s)