It is currently April 16th, 2024, 12:23 pm

How to change the cursor position to x, y coordinates ... and ETC.

Discuss the use of Lua in Script measures.
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

How to change the cursor position to x, y coordinates ... and ETC.

Post by gkmaz9 »

Hello. See you in a long time.


I am practicing to transform the existing color picker.(Author = raiguard)

I'm designing and I want to convert sunrise images to color code. That's the job for it.

I want to know the color change every 5 seconds at the points X = 400 and Y = 400.

The current color picker has to press the eyedropper and then click on the cursor to see its value.



1. In the example Lua script, i want to know how to determine the x, y coordinates instead of the cursor position.

2. In the example Luascript, I want to know how to produce the result without the last click.

3. I want to know how to execute a command every 5 seconds instead of LeftMouseUpAction =.



I'm attaching a skin in practice.

I left only the essential parts of the skin.

I need your help.


ColorPickerPlus.lua

Code: Select all

-- setup data structure and some constants, set initial rgb value
function Initialize()

    colors = {}

end

function Update() end

function GetColor(key) return colors[key] or 0 end

function SetRGB(...)

    if arg.n == 1 then
        colors.cur_rgb = arg[1]
        colors.cur_r, colors.cur_g, colors.cur_b = string.match(colors.cur_rgb, '(%d+),(%d+),(%d+)')
    else
        colors['cur_' .. arg[1]] = arg[3] and arg[2] or Round(Clamp((SKIN:ParseFormula(arg[2]) * 255),0,255),0)
        colors.cur_rgb = string.format('%s,%s,%s', colors.cur_r, colors.cur_g, colors.cur_b)
    end

  
    SetScrubbers()
    SKIN:Bang('!Update')
    -- SKIN:Bang('!UpdateMeterGroup', 'ColorMeters')
    -- SKIN:Bang('!Redraw')

end


function SetHSB(...)

    if arg.n == 1 then
        colors.cur_hsb = arg[1]
        
    else
        colors['cur_' .. arg[1]] = Clamp(SKIN:ParseFormula(arg[2]),0,1)
        colors.cur_hsb = string.format('%s,%s,%s', colors.cur_hue, colors.cur_sat, colors.cur_bri)
    end

    colors.cur_rgb = string.format('%s,%s,%s', HSBtoRGB(colors.cur_hue, colors.cur_sat, colors.cur_bri))
    colors.cur_r, colors.cur_g, colors.cur_b = string.match(colors.cur_rgb, '(%d+),(%d+),(%d+)')
    colors.cur_hex = RGBtoHEX(colors.cur_r, colors.cur_g, colors.cur_b)

 
end

function ChangeRGB(key, delta)

    SetRGB(key, Clamp(colors['cur_' .. key] + delta, 0, 255), true)

end



ColorPickerPlus.ini

Code: Select all

 [Rainmeter]
Update=100
MiddleMouseUpAction=[!Refresh]
OnRefreshAction=[!ZPos 1]
AccurateText=1

[Metadata]

[Variables]



; ==================================================
; MEASURES

[MeasureScript]
Measure=Script
ScriptFile=Extra\Scripts\ColorPickerPlus.lua


[MeasureScreenshot]
Measure=Plugin
Plugin=RunCommand
Parameter=nircmd savescreenshotfull C:\Windows\Temp\colorpickerplus-capture.png
StartInFolder=#CURRENTPATH#Extra
FinishAction=[!ActivateConfig "[#CURRENTCONFIG]\Eyedropper"][!SetVariable parentConfig "[#CURRENTCONFIG]" "[#CURRENTCONFIG]\Eyedropper"][!UpdateMeter MeterOverlay "[#CURRENTCONFIG]\Eyedropper"]

; ==================================================

[MeterEyedropperButton]
Meter=Shape
LeftMouseUpAction=[!CommandMeasure MeasureScreenshot "Run"]
MeterStyle=StyleIcon | StyleIcon_Eyedropper

[StyleIcon]
X=0
Y=0
W=20
H=20
Antialias=1
MouseOverAction=[!SetOption #CURRENTSECTION# Fill "Fill Color [#colorHover_[#CURRENTSECTION]]"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# Fill ""][!UpdateMeter #CURRENTSECTION#][!Redraw]
DynamicVariables=1
Fill=Fill Color #colorMain#

[StyleHeaderIcon]
W=30
@includeIcons=#CURRENTPATH#Extra\Icons.inc

; ==================================================

[Measure_RGB1]
Measure=String
String=[&MeasureScript:GetColor('cur_rgb')]
IfMatch=135.100.184
IfMatchAction=!Execute[!SetOption MeterForCheck2 Text "Ture"][!Redraw]
IfNotMatchAction=!Execute[!SetOption MeterForCheck2 Text "False"][!Redraw]
IfMatchMode=1
RegExpSubstitute=1
DynamicVariables=1

[MeterForCheck]
meter=String
MeasureName=Measure_RGB1
Text=%1
SolidColor=255,255,255,50
AntiAlias=1
ClipString=2
UpdateDivider = 1
DynamicVariables = 1
X=30
Y=0
W=100

[MeterForCheck2]
meter=String
MeasureName=Measure_RGB1
Text=%1
SolidColor=255,255,255,50
AntiAlias=1
ClipString=2
UpdateDivider = 1
DynamicVariables = 1
X=30
Y=20
W=100
You do not have the required permissions to view the files attached to this post.
User avatar
Jeff
Posts: 327
Joined: September 3rd, 2018, 11:18 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by Jeff »

I remember trying to do something similar as well but I gave up because of the nircmd savescreenshotfull part which just captures the entire screen, not desktop image, so if you have something in front of that specific pixel you're screwed.
Also you're missing other stuff from your stuff, more specifically all the eyedropper files.
Also can't you use something like Chameleon for this?
Last edited by Jeff on February 10th, 2020, 10:24 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by jsmorley »

Yes, I think I would use Chameleon.
User avatar
Jeff
Posts: 327
Joined: September 3rd, 2018, 11:18 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by Jeff »

Only problem with Chameleon is if the wallpaper is animated with Wallpaper Engine or free alternatives like weebp or lively in which case....... no f*ing clue
Last time I tested the plugin it only copied the colors from a hardcoded path to the dekstop image (notice that I'm saying image) and meters.
User avatar
Jeff
Posts: 327
Joined: September 3rd, 2018, 11:18 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by Jeff »

I just realized I'm wrong, raiguard's skin uses CursorColor plugin to get the color, not the eyedropper or anything else.
You're still not able to capture a certain position because the x and y are tied to the cursor's x and y, however, if you ever change the GetCursorPos function to retrieve certain coordinates, you'll run into the same problem as the one I described earlier with nircmd, if you have anything in front it will capture the color for that window.

Also to make it update every 5 seconds you add OnUpdateAction (and it's bangs) and Update=5000 to [Rainmeter] :P
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by gkmaz9 »

Jeff wrote: February 10th, 2020, 11:12 pm I just realized I'm wrong, raiguard's skin uses CursorColor plugin to get the color, not the eyedropper or anything else.
You're still not able to capture a certain position because the x and y are tied to the cursor's x and y, however, if you ever change the GetCursorPos function to retrieve certain coordinates, you'll run into the same problem as the one I described earlier with nircmd, if you have anything in front it will capture the color for that window.

Also to make it update every 5 seconds you add OnUpdateAction (and it's bangs) and Update=5000 to [Rainmeter] :P
I don't know English well. I don't know if I understand your explanation correctly.
Here is what I understand.
1. I can create 'delay' with 'OnUpdateAction'.
2. It uses the GetCursorFos function in the CursorColor plug-in.
3. There must be nothing in front of the part you want to do (including the eyedropper).



My skin doesn't have a square aim box in front of the cursor. I erased this window and all.
I want to change the GetCursorPos function, but I want to know where it is and how to change it.
Chameleon is a really good option. But it doesn't work on video. Is there a way to make it work?

Thanks for letting me know how to make the ''time delay(=OnUpdateAction)'.
User avatar
Jeff
Posts: 327
Joined: September 3rd, 2018, 11:18 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by Jeff »

https://streamable.com/ca9d9
I'm just trying to say the idea is worthless with the stuff you have, you will run into this problem
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by gkmaz9 »

Jeff wrote: February 11th, 2020, 5:25 pm https://streamable.com/ca9d9
I'm just trying to say the idea is worthless with the stuff you have, you will run into this problem
That's what I want.
Is it chameleon? I tried but failed.
I don't care what lies ahead. That skin is perfect for me.
Can you upload its skin file?
I really really, really need it.
please
User avatar
Jeff
Posts: 327
Joined: September 3rd, 2018, 11:18 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by Jeff »

I made it in Sony Vegas to show my point, but you can do it by compiling CursorColor's code and replacing GetPixel(hDC, p.x, p.y); in the code to GetPixel(hDC, 400, 400);
gkmaz9
Posts: 67
Joined: August 26th, 2019, 10:42 am

Re: How to change the cursor position to x, y coordinates ... and ETC.

Post by gkmaz9 »

Jeff wrote: February 12th, 2020, 10:03 pm I made it in Sony Vegas to show my point, but you can do it by compiling CursorColor's code and replacing GetPixel(hDC, p.x, p.y); in the code to GetPixel(hDC, 400, 400);
I didn't know Jsmorley's plug-in(CursorColor) was the key. I did it in the wrong place.
I tried to open the plug-in, but it seems to be encrypted.

I'm not familiar with the programming industry.
i think...It might be rude of the producer to ask how to decode and decompile.
With Mr. Jsmorley's permission, it might be appropriate to hear about the decompile method. :-(
Last edited by gkmaz9 on February 13th, 2020, 1:49 am, edited 2 times in total.