Type Mismatch with Hex Color

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rafters
Posts: 6
Joined: 15 Jul 2019, 12:53

Type Mismatch with Hex Color

15 Jul 2019, 13:02

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?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Type Mismatch with Hex Color

15 Jul 2019, 14:24

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 %
just me
Posts: 9532
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Type Mismatch with Hex Color

16 Jul 2019, 04:02

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.
hitman
Posts: 21
Joined: 10 Aug 2014, 06:47

Re: Type Mismatch with Hex Color

31 Dec 2021, 10:26

pp.ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB := color+0

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo, Google [Bot] and 245 guests