Jump to content



Photo

GUIGetBkColor() - Get the background color of the GUI.


  • Please log in to reply
7 replies to this topic

#1 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,235 posts

Posted 19 February 2011 - 10:38 PM

If you set the GUI background colour with GUISetBkColor() and happen to forget the colour you set it as, then why not try GUIGetBkColor()

Function:
AutoIt         
#include-once #include <WinAPIGdi.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUIGetBkColor ; Description ...: Retrieves the RGB value of the GUI background. ; Syntax ........: GUIGetBkColor($hWnd) ; Parameters ....: $hWnd                - A handle of the GUI. ; Return values .: Success - RGB value ;                  Failure - 0 ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func GUIGetBkColor($hWnd)     Local $iColor = 0     If IsHWnd($hWnd) Then         Local $hDC = _WinAPI_GetDC($hWnd)         $iColor = _WinAPI_GetBkColor($hDC)         _WinAPI_ReleaseDC($hWnd, $hDC)     EndIf     Return $iColor EndFunc   ;==>GUIGetBkColor
Example use of Function:

AutoIt         
#include <MsgBoxConstants.au3> #include 'GUIGetBkColor.au3' Example() Func Example()     Local $hGUI = GUICreate('GUIGetBkColor() Example', 500, 350)     GUISetState(@SW_SHOW, $hGUI)     Local $aColor = [0x0000FF, 0x8FFF9F, 0xEC4841, 0xB0E35D, 0x440BFD] ; Random colour array.     Local $iColor = 0     For $i = 0 To UBound($aColor) - 1         GUISetBkColor($aColor[$i])         Sleep(20)         $iColor = GUIGetBkColor($hGUI) ; Pass the GUI handle to the function.         MsgBox($MB_SYSTEMMODAL, '', 'Background Color: ' & _ConvertToHexFormat($aColor[$i]) & @CRLF & _                 'GUIGetBkColor() Hex Format: ' & _ConvertToHexFormat($iColor) & @CRLF & _                 'GUIGetBkColor() Returned: ' & $iColor, 0, $hGUI)     Next     GUIDelete($hGUI) EndFunc   ;==>Example Func _ConvertToHexFormat($iColor)     Return Hex($iColor, 6) EndFunc   ;==>_ConvertToHexFormat

Edited by guinness, 17 July 2014 - 10:29 PM.

  • Luigi likes this
UDF List:
Spoiler
Updated: 02/04/2015







#2 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,235 posts

Posted 20 February 2011 - 08:35 AM

Updated the Original Post with small changes.
UDF List:
Spoiler
Updated: 02/04/2015

#3 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,235 posts

Posted 17 October 2012 - 08:07 PM

I've updated the example and function syntax. See above for more details. Thanks.
UDF List:
Spoiler
Updated: 02/04/2015

#4 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,235 posts

Posted 17 July 2014 - 10:19 PM

Just under two years ago since I last updated this function, so now is a good time to tidy the syntax. I removed the 4096 MsgBox() value and went for the approach of a single exit point.
UDF List:
Spoiler
Updated: 02/04/2015

#5 JScript

JScript

    I'm back ... I miss, why not!

  • Active Members
  • PipPipPipPipPipPip
  • 1,232 posts

Posted 17 July 2014 - 11:04 PM

I removed the 4096 MsgBox() value and went for the approach of a single exit point.

Why you always try to get us to use your scripts in this way?
It would be much easier to have the number 4096 out instead to include a file with definitions.
The same happens with the ternary, noting that many people still using older versions of AutoIt simply by meeting the needs.

But okay, everyone writes the way you want, do not misunderstand me.
 
Would not it be preferable to have all the topics below in only one? Since all appear to be co-related
fKCUS5S.png

Thanks for the updates,

JS
http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler


dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!


#6 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,235 posts

Posted 17 July 2014 - 11:11 PM

The answer is because I enjoy writing clean and easy to understand code, plus I enjoy using the new features of AutoIt.

I am not worried about the users who use an old version of AutoIt, because you seriously believe people actually use the code I post? Come on JScript, be realistic buddy! 0_-

Edit: Post 16,666.

Edited by guinness, 17 July 2014 - 11:13 PM.

UDF List:
Spoiler
Updated: 02/04/2015

#7 JScript

JScript

    I'm back ... I miss, why not!

  • Active Members
  • PipPipPipPipPipPip
  • 1,232 posts

Posted 17 July 2014 - 11:28 PM

The answer is because I enjoy writing clean and easy to understand code, plus I enjoy using the new features of AutoIt.

Yes, thinking at it this way is even better!

I am not worried about the users who use an old version of AutoIt

Ok, but I think you should it matter. It's just a opnion...

because you seriously believe people actually use the code I post? Come on JScript, be realistic buddy! 0_-

Yes, why not? I use your scripts whenever I need, they are all well structured and quite helpful.

JS
http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler


dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!


#8 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 18,235 posts

Posted 17 July 2014 - 11:36 PM

I have taken your comments on board.
UDF List:
Spoiler
Updated: 02/04/2015




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users