Page 1 of 1

Type Mismatch with Hex Color

Posted: 15 Jul 2019, 13:02
by rafters
The goal of this script is a simple color picker for PowerPoint: When the hotkey is pressed, the selected object's fill color will update to the color under the cursor position.

Code: Select all

pp := ComObjActive("Powerpoint.Application")
F12::
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
pp.ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB := %color%
return
I'm receiving a "Type Mismatch" error for this line:

Code: Select all

pp.ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB := %color%
But such a line does work:

Code: Select all

pp.ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB := 0xFFFFFF
I suspect it's because %color% is acting like a string "0xFFFFFF" instead of a hex number 0xFFFFFF

Any ideas how to fix this type mismatch?

Re: Type Mismatch with Hex Color

Posted: 15 Jul 2019, 14:24
by swagfag
its not being treated as a string
rather the value of color is being treated as a variable, since ure dereferencing color inside an expression
in other words, 0xFFFFFF is being treated as a variable and since this variable isnt defined in ur script, the result is, ure trying to assign blank to the comobject, hence the type mismatch

drop the %

Re: Type Mismatch with Hex Color

Posted: 16 Jul 2019, 04:02
by just me
Also:

Code: Select all

pp.ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB := color
seems to expect a RGB color value.
PixelGetColor:
OutputVar
The name of the variable in which to store the color ID in hexadecimal blue-green-red (BGR) format.

Re: Type Mismatch with Hex Color

Posted: 31 Dec 2021, 10:26
by hitman
pp.ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB := color+0