Search the Community
Showing results for tags 'color pixelgetcolor'.
-
I plan to write an Au3 script to automatically install a PPT plug-in. Because the button on the installation wizard of the PPT plug-in is not a standard control, I consider writing a while loop to constantly judge the color of a specific location on the installation wizard. When the plug-in is successfully installed, a blue "Start Software" button will appear at this location, so that I can let the script close the installation wizard window. But when I used the PixelGetColor function, the script did not get the color of the button on the installation wizard. On the contrary, it went through this foreground window and got the color of my desktop background! However, Au3's window information tool can correctly return the color of this position. The following is my script code (due to different configurations, some coordinates may need to be changed when testing on other devices): ;~ Run plug-in installation package #RequireAdmin run(@ScriptDir & "\FocoSlide.exe") ;~ In each installation, the number behind this class is different, so you need to use wildcards to match the window. $tittle = "[REGEXPCLASS:HwndWrapper*]" WinWait($tittle) ;~ Change the installation path WinActivate($tittle) Send("+{TAB}") Send("+{TAB}") Send("+{END}") Send("{DELETE}") ControlSend($tittle, "", "", "C:\Program Files (x86)\OfficePlugins\Foco") ;~ Switch focus to "Install" button and enter to confirm Send("+{TAB}") Send("{ENTER}") $wh = WinGetHandle($tittle) ;~ Wait for the "Start Software" button to appear (installation is complete) ;~ Activate the window before each color acquisition to avoid potential errors. WinActivate($tittle) $s = PixelGetColor(763, 533, $wh) ConsoleWrite("color is " & Hex($s, 6) & @CR) While Hex($s) <> "0267EC" Sleep(3000) $s = PixelGetColor(763, 533, $wh) ConsoleWrite("color is " & Hex($s, 6) & @CR) WinActivate($tittle) WEnd ;~ When the blue Start Software button is detected, the installation is completed and the installation wizard is closed. MouseClick("left", 1043, 350) Exit Au3 version: 3.3.16.1 Operating system: Win11
- 10 replies
-
I have been busy elsewhere and today I dusted off AutoIt and decided to try something. This script will identify a color under the mouse and reply in human terms. I set the values to return on a scale of 0 to 10 and then using my best judgement I named the color. It could use some tweaks but it works. While 1 $pos = MouseGetPos() $ax = $pos[0] $ay = $pos[1] $var = PixelGetColor( $ax , $ay ) $color = Hex($var,6) $Redcv = Int(Dec(StringLeft ($color,2))/25.5) $Blucv = Int(Dec(StringRight ($color,2))/25.5) $Grncv = Int(Dec(StringMid ($color,3,2))/25.5) $cvalue = Get_Color ($Redcv,$Grncv,$Blucv) ToolTip ($cvalue) Sleep (50) WEnd Func Get_Color ($rv,$gv,$bv) $gc = "unknown" If $rv = $gv and $bv = $gv Then $gc = "Gray" If $rv > 8 and $gv > 8 and $bv > 8 Then $gc = "White" If $rv < 2 and $gv < 2 and $bv < 2 Then $gc = "Black" If $rv > $bv And $rv > $gv Then $gc = "Red" If $bv < 2 Then If $gv > 3 Then $gc = "Brown" If $gv > 5 Then $gc = "Orange" If $gv > 7 Then $gc = "Yellow" EndIf If $gv < 2 Then If $bv > 3 Then $gc = "Rust" If $bv > 5 Then $gc = "Pink" If $bv > 7 Then $gc = "Hot Pink" EndIf EndIf If $gv > $bv And $gv > $rv Then $gc = "Green" If $bv < 2 Then If $rv > 3 Then $gc = "Lt. Green" If $rv > 5 Then $gc = "Lime" If $rv > 7 Then $gc = "Yellow" EndIf If $rv < 2 Then If $bv > 3 Then $gc = "Lt. Green" If $bv > 5 Then $gc = "Turquoise" If $bv > 7 Then $gc = "Cyan" EndIf EndIf If $bv > $rv And $bv > $gv Then $gc = "Blue" If $rv < 2 Then If $gv > 3 Then $gc = "Sea Blue" If $gv > 5 Then $gc = "Sky Blue" If $gv > 7 Then $gc = "Cyan" EndIf If $gv < 2 Then If $rv > 3 Then $gc = "Violet" If $rv > 5 Then $gc = "Purple" If $rv > 7 Then $gc = "Hot Pink" EndIf EndIf Return $gc EndFunc Please note: The last time I posted here was over 2 years ago because some moron got me ticked off. I write programs and scripts for a living and I am not some child sitting in mom's dungeon hacking interweb games. All I ask for is a little respect and I will return the same. Have a better one.