找回密码
 加入
搜索
查看: 3820|回复: 10

如何调出WINDOWS自带的颜色选择窗口

  [复制链接]
发表于 2009-2-4 08:34:28 | 显示全部楼层 |阅读模式
我要调出WINDOWS自带的颜色选择窗口
选择一个颜色以后,返回这个颜色的代码
要怎么调出这个颜色选择窗口,我记得哪里看到过

高手们帮帮忙,做程序卡住了

[ 本帖最后由 superflq 于 2009-2-4 19:35 编辑 ]
发表于 2009-2-4 12:31:56 | 显示全部楼层
#Include <Misc.au3>
$Form1 = GUICreate("颜色", 123, 58, -1, -1)
$Input1 = GUICtrlCreateInput("", 32, 8, 57, 21)
$Button1 = GUICtrlCreateButton("选择", 32, 32, 57, 17, 0x01)
GUISetState(@SW_SHOW)
While 1
        Switch GUIGetMsg()
                Case - 3
                        Exit
                Case $Button1
                        $APIColor = _ChooseColor(2, 0, 2, $Form1)
                        If $APIColor <> -1 Then
                                GUISetBkColor($APIColor, $Form1)
                                $APIColorMsg = StringRight($APIColor, 6)
                                GUICtrlSetData($Input1, $APIColorMsg)
                        EndIf
        EndSwitch
WEnd
 楼主| 发表于 2009-2-4 15:17:17 | 显示全部楼层
谢谢大哥~~~
发表于 2009-6-1 02:04:37 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Timers.au3>

Opt("GUIResizeMode", $GUI_DOCKALL)

filewrite("points and colors.txt", @CRLF & "Start session: " & @MON & " / " & @MDAY & " / " & @HOUR & ":" & @MIN & ", " & @SEC & " sec" & @CRLF & @CRLF)

Global $starttime = _Timer_Init()
Global $msg

  $gui = GUICreate("pos and color get", 221, 60, 0, -21, -1)
  GUISetBkColor(0x000000)

  $pos = MouseGetPos()                      
  $color = PixelGetColor($pos[0], $pos[1])  
  $cursorID = MouseGetCursor()
  $check2 = false  

  $button_1 = GUICtrlCreateButton("copy (F2)", 3, 18, 61, 21, 0)
  $button_2 = GUICtrlCreateButton("copy (F3)", 80, 18, 61, 21, 0)
  $button_3 = GUICtrlCreateButton("copy (F4)", 157, 18, 61, 21, 0)

  $pos_XY = GUICtrlCreateLabel("Coord: " & $pos[0] & ", " & $pos[1], 0, 0, 91,15)
  GUICtrlSetColor(-1,0x00ffff)
  $color_Hex = GUICtrlCreateLabel("Color: " & Hex($color,6), 81, 0, 141,15) 
  GUICtrlSetColor(-1,0x00ffff)       
  $cursID = GUICtrlCreateLabel("Cursor: " & $CursorID, 167, 0, 61,15)
  GUICtrlSetColor(-1,0x00ffff)
  
  $Slider11 = GUICtrlCreateSlider(3, 98, 215, 31)
  GUICtrlSetLimit(-1, 255 , 55)
  GUICtrlSetData(-1,250)
  GUICtrlSetBkColor(-1,0x000000)
  $Slider1value = GUICtrlRead($slider11)
  
  $check = GUICtrlCreateCheckbox("", 16, 62, 15)
  GUICtrlCreateLabel("include sleep() times between gets", 30,60)
  GUICtrlSetColor(-1, 0x00FFff)
  
  
  $Expand_Button = GUICtrlCreateButton("Options", 3, 40, 215, 15)

  GUISetState()
  
  HotKeySet("{F2}","copy1")
  HotKeySet("{F3}","copy2")
  HotKeySet("{F4}","copy3")
  
main();this runs main function.
  
func copy1()
        if $check2 = true then
                $time = round(_Timer_Diff($starttime),0)
                filewrite("points and colors.txt","sleep(" & $time & ")" & @CRLF)
                $starttime = _Timer_Init()
                filewrite("points and colors.txt",$pos[0] & ", " & $pos[1]& @CRLF)
        Else
        filewrite("points and colors.txt",$pos[0] & ", " & $pos[1]& @CRLF)
        EndIf
endfunc

func copy2()
                if $check2 = true then
                $time = round(_Timer_Diff($starttime),0)
                filewrite("points and colors.txt","sleep(" & $time & ")" & @CRLF)
                $starttime = _Timer_Init()
        filewrite("points and colors.txt","0x" &Hex($color,6) & @CRLF)
        Else
        filewrite("points and colors.txt","0x" &Hex($color,6) & @CRLF)
        EndIf
endfunc

func copy3()
                if $check2 = true then
                $time = round(_Timer_Diff($starttime),0)
                filewrite("points and colors.txt","sleep(" & $time & ")" & @CRLF)
                $starttime = _Timer_Init()
        filewrite("points and colors.txt","cursor " &$cursorID & @CRLF) 
        Else
        filewrite("points and colors.txt","cursor " &$cursorID & @CRLF) 
        EndIf
endfunc

func main()
  Do
    $msg = GUIGetMsg()
        
    get_data()
        
    Switch $msg
        Case $button_1
            ClipPut($pos[0] & ", " & $pos[1]) 
                  
        Case $button_2
            ClipPut(Hex($color,6))
                  
        Case $button_3
            ClipPut($cursorID)
                        
                case $check
                        if $check2 = True then
                                $check2 = false
                        Else
                                $check2 = true
                        EndIf
                        
                Case $Expand_Button
                        Local $Height, $ButtonText
                        $GuiPos = WinGetPos($Gui)
                        If $GuiPos[3] < 88 + 81 Then
                                $Height = 88 + 81
                                $ButtonText = "Close"
                        Else
                                $Height = 88
                                $ButtonText = "Options"
                        EndIf
                        GUICtrlSetData($Expand_Button, $ButtonText)
                        WinMove($Gui, "", $GuiPos[0], $GuiPos[1], $GuiPos[2], $Height)
                        
                Case $Slider11
                        $Slider1value = GUICtrlRead($slider11)
                        WinSetTrans("pos and color get","",$slider1value)
      EndSwitch
    
    sleep(10)
    WinSetOnTop($gui, 0, 1)
    Until $msg = $GUI_EVENT_CLOSE
    GUIDelete()
filewrite("points and colors.txt", @CRLF & "End session: " & @MON & " / " & @MDAY & " / " & @HOUR & ":" & @MIN & ", " & @SEC & " sec" & @CRLF)
endfunc

;a function to update the data if the new data is different.
Func get_data() 
    $pos2 = MouseGetPos()
    $color2 = PixelGetColor($pos2[0], $pos2[1])
    $cursorID2 = MouseGetCursor()
    
    If($pos[0] <> $pos2[0] or $pos[1] <> $pos2[1]) Then
      $pos = $pos2    
      GUICtrlSetData($pos_XY, "Coord: " & $pos[0] & ", " & $pos[1])
    EndIf
    
    If($color <> $color2) Then
                $color = $color2    
                GUICtrlSetData($color_Hex, "Color: " & Hex($color,6))
                if $color = 0x000000 Then
                        $color2 = 0xffffff
                Else
                        $color2 = $color
                endif
          GUICtrlSetBkColor($button_1, $color2)
          GUICtrlSetBkColor($button_2, $color2)
          GUICtrlSetBkColor($button_3, $color2)
          GUICtrlSetBkColor($Expand_Button, $color2)
    EndIf
  
    If($cursorID <> $cursorID2) Then
      $cursorID = $cursorID2        
      GUICtrlSetData($cursID, "Cursor: " & $cursorID)
    EndIf

EndFunc 
发表于 2009-6-1 16:27:39 | 显示全部楼层
看不懂的说
发表于 2009-11-11 13:03:59 | 显示全部楼层
谢谢

收下啦
发表于 2009-12-24 14:12:26 | 显示全部楼层
谢谢分享了,收藏
发表于 2009-12-28 04:01:13 | 显示全部楼层
不错的,收藏/
发表于 2009-12-28 04:01:45 | 显示全部楼层
晕,论坛程序是不是有BUG哦,怎么不给钱呢~~
发表于 2014-2-25 23:19:29 | 显示全部楼层
2楼就是我想要的功能,谢谢分享!
发表于 2014-3-29 19:51:38 | 显示全部楼层
用来做个性化的取色器非常不错。谢谢分享。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 07:26 , Processed in 0.071598 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表