Page 2 of 2

Re: Coloring the Excel Cell

Posted: 15 May 2019, 19:51
by Datapoint
hasantr wrote:So it worked great. Thank you all. :)
Cool script. Glad to hear it works.
BTW the PixelGetColor default is BGR.

Code: Select all

PixelGetColor, OutputVar1, 500, 500, RGB
PixelGetColor, OutputVar2, 500, 500
MsgBox % Format("0x{:x}", OutputVar1) "`n" Format("0x{:x}", OutputVar2)

Re: Coloring the Excel Cell

Posted: 16 May 2019, 01:11
by hasantr
awel20 wrote:
15 May 2019, 09:58
I can see some things that I would change. I added some comments.
hasantr wrote:
15 May 2019, 03:11

Code: Select all

XL := ""
XL.Quit ; The XL variable is blank, so this will never do anything
If !IsObject(XL)
	XL := ComObjCreate("Excel.Application") ; Creates a new instance of excel
XL.visible := true
; The next line gets an already running instance of Excel... possibly a different one than was created with XL := ComObjCreate("Excel.Application")
XL := ComObjActive("Excel.Application")

Code: Select all

If !IsObject(XL := ComObjActive("Excel.Application")) ; If Excel is not running
{
	XL := ComObjCreate("Excel.Application") ; Creates a new instance of excel
	XL.visible := true
}
Maybe something like this. But ComObjActive will only work well if you have just one instance of Excel.
Thank you so much. I did something wrong here. I can go on better now. :)

Re: Coloring the Excel Cell

Posted: 16 May 2019, 01:27
by Klarion
you do not need Format function
PixelGetColor function emits perfect hex format
and

that is not the point here
the point is unexpected return value of it
that is not documented at Help file though, I guess, it is some different representation of Color - I do not care.

Re: Coloring the Excel Cell

Posted: 16 May 2019, 01:42
by hasantr
Klarion wrote:
15 May 2019, 10:46
Just tested

What the heck is color value 0xFFFFFFFF ??

Code: Select all

_ := ComObjActive("Excel.Application")
Loop, 35 {
	c ++
	r := 0
	Loop, 30 {
		r ++
		PixelGetColor, cVal, % c, % r
		If(cVal != 0xFFFFFFFF)
			_.ActiveWorkbook.ActiveSheet.Cells(r, c).Interior.Color := cVal
	}}

캡처.PNG
How exactly did you do? Can you share all the codes?

Re: Coloring the Excel Cell

Posted: 16 May 2019, 04:20
by Klarion
That is all, no more codes to post and you do not need no more codes
-You know all the detail procedures and goals

The strange color code is emitted from very top of the Excel screen (I mean top of the top - Desktop itself or boundary line I guess)

Regards

Re: Coloring the Excel Cell

Posted: 16 May 2019, 04:52
by Klarion

Code: Select all

PixelGetColor, _, 0, 0
MsgBox % _
캡처.PNG
캡처.PNG (8.94 KiB) Viewed 1707 times

Re: Coloring the Excel Cell

Posted: 16 May 2019, 04:54
by Klarion
that is not my Desktop value
because, my Desktop value is 0xC37E2B

Re: Coloring the Excel Cell

Posted: 16 May 2019, 06:00
by hasantr
awel20 wrote:
15 May 2019, 09:58
I can see some things that I would change. I added some comments.
hasantr wrote:
15 May 2019, 03:11

Code: Select all

XL := ""
XL.Quit ; The XL variable is blank, so this will never do anything
If !IsObject(XL)
	XL := ComObjCreate("Excel.Application") ; Creates a new instance of excel
XL.visible := true
; The next line gets an already running instance of Excel... possibly a different one than was created with XL := ComObjCreate("Excel.Application")
XL := ComObjActive("Excel.Application")

Code: Select all

If !IsObject(XL := ComObjActive("Excel.Application")) ; If Excel is not running
{
	XL := ComObjCreate("Excel.Application") ; Creates a new instance of excel
	XL.visible := true
}
Maybe something like this. But ComObjActive will only work well if you have just one instance of Excel.

Thanks. That's good.

Re: Coloring the Excel Cell

Posted: 16 May 2019, 06:02
by hasantr
Klarion wrote:
16 May 2019, 04:20
That is all, no more codes to post and you do not need no more codes
-You know all the detail procedures and goals

The strange color code is emitted from very top of the Excel screen (I mean top of the top - Desktop itself or boundary line I guess)

Regards
I understand. Good work.