Coloring the Excel Cell Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Datapoint
Posts: 300
Joined: 18 Mar 2018, 17:06

Re: Coloring the Excel Cell

Post by Datapoint » 15 May 2019, 19:51

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)
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Coloring the Excel Cell

Post by hasantr » 16 May 2019, 01:11

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. :)
Klarion
Posts: 176
Joined: 26 Mar 2019, 10:02

Re: Coloring the Excel Cell

Post by Klarion » 16 May 2019, 01:27

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.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Coloring the Excel Cell

Post by hasantr » 16 May 2019, 01:42

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?
Klarion
Posts: 176
Joined: 26 Mar 2019, 10:02

Re: Coloring the Excel Cell

Post by Klarion » 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
Klarion
Posts: 176
Joined: 26 Mar 2019, 10:02

Re: Coloring the Excel Cell

Post by Klarion » 16 May 2019, 04:52

Code: Select all

PixelGetColor, _, 0, 0
MsgBox % _
캡처.PNG
캡처.PNG (8.94 KiB) Viewed 1687 times
Klarion
Posts: 176
Joined: 26 Mar 2019, 10:02

Re: Coloring the Excel Cell

Post by Klarion » 16 May 2019, 04:54

that is not my Desktop value
because, my Desktop value is 0xC37E2B
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Coloring the Excel Cell

Post by hasantr » 16 May 2019, 06:00

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.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Coloring the Excel Cell

Post by hasantr » 16 May 2019, 06:02

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.
Post Reply

Return to “Ask for Help (v1)”