Rand eies GUI

  • man kann die gui ja dann nicht mehr verschieben...da der rand ja weg ist

    welchen befehl braucht man da noch, um die gui frei auf dem desktop verschieben zu können?

    mfg team2way

  • das ist schon mal nice aber geht das auch ohne rand also mit popup so das man jede stelle des programms zum verschieben nutzen kann?

  • Hallo,
    ich habe ein Programm, um Farbtöne mit Pipette vom Bildschirm zu ermitteln, schon länger aus dem Forum hier auf meinem PC. Daher kann ich die Quelle leider nicht angeben. Aufgrund der Dokumentation im Programm ist der Autor jedoch ersichtlich: Patric Pendelin.

    Der Rand an diesem GUI musste weg, damit die Farbtöne direkt am Rand besser überprüfbar waren. Durch diesen Beitrag habe ich das auch hin bekommen, jedoch war damit auch die Verschiebe-Möglichkeit genommen (siehe oben).... Ich habe es gelöst, indem das Fenster mit den Pfeiltasten zu verschieben ist (_IsPressed).

    Es ist keine elegante Lösung, da sich das Fenster auch verschiebt, wenn in einem anderen Programm die Pfeiltasten gedrückt werden. (Könnte man noch verbessern, indem man mit winAktiv das aktuelle Fenster abfragt und nur dann verschiebt). Für mich ist das Programm von Patric mit meinen Änderungen so jedoch super verwendbar.

    Dies nur als mögliche Lösung zum verschieben, welche in diesem Beitrag nicht weiter verfolgt wurde.

    Und wie gesagt, das Autoit-Programm ist NICHT von mir.

    Viele Grüße
    Carsten

    autoit.de/wcf/attachment/6649/


    Spoiler anzeigen


    ; Author(s): Patric Pendelin <patric.pendelin@gmx.de>
    ; Kleine Änderungen (Rand weg, Verschieben mit Pfeiltasten) von Carsten, Nov-2009
    ; QUELLE des Original-Programms leider nicht mehr nachvollziehbar

    ;
    ;===============================================================================
    ; Includes
    ;===============================================================================
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    ;
    ;===============================================================================
    ; AutoItSetOption
    ;===============================================================================
    Opt('MustDeclareVars', 1)
    Opt("GUIOnEventMode", 1)
    ;
    ;===============================================================================
    ; Declaring Variables
    ;===============================================================================
    Global Const $S_OPTION_INI_DIR = @ScriptDir & "\options.ini"
    ; GUI:
    Global $h_Whndl
    Global $h_ColorExample_Graph
    Global $h_ColorCode_Input
    Global $h_OK_Button
    Global $h_Choose_Button
    Global $h_Pipette_Button
    Global $h_Clip_CheckBox
    Global $h_ContextMenu
    Global $H_InfoItem_CM
    ; Options:
    Global $ai_Ini
    Global $ai_WinPos[2]
    Global $s_CBS
    ;
    ;===============================================================================
    ; Start Program
    ;===============================================================================
    _main()
    ;
    ;===============================================================================
    ; Functions
    ;===============================================================================
    Func _main()
    Local $h_Dll
    Local $pos[5]

    $ai_Ini = _setIni(@ScriptDir & "\options.ini")

    _buildMainGUI()
    HotKeySet($ai_Ini[0][1], "_setPippeteOnHotkey")
    $h_Dll = DllOpen("user32.dll")
    While 1
    $ai_WinPos = WinGetPos($h_Whndl)
    $s_CBS = GUICtrlRead($h_Clip_CheckBox)
    If _IsPressed("27", $h_Dll) Then; 27 = rechts-taste
    $pos = WinGetPos("Color-Generator","")
    WinMove("Color-Generator","",$pos[0]+5,$pos[1])
    EndIf
    If _IsPressed("25", $h_Dll) Then; 25 = links-taste
    $pos = WinGetPos("Color-Generator","")
    WinMove("Color-Generator","",$pos[0]-5,$pos[1])
    EndIf
    If _IsPressed("26", $h_Dll) Then; 26 = hoch-taste
    $pos = WinGetPos("Color-Generator","")
    WinMove("Color-Generator","",$pos[0],$pos[1]-5)
    EndIf
    If _IsPressed("28", $h_Dll) Then; 28 = runter-taste
    $pos = WinGetPos("Color-Generator","")
    WinMove("Color-Generator","",$pos[0],$pos[1]+5)
    EndIf
    Sleep(50)
    WEnd
    EndFunc ;==>_main
    ;
    Func OnAutoItStart()
    _checkIfProgAllreadyExist('pcp Color-Generator - xghjz', 'An instance of pcp Color-Generator is allready running!'); Prüft, ob das Programm schon läuft
    EndFunc ;==>OnAutoItStart
    ;
    ;===============================================================================
    ; Function Name: _setColor
    ; Description: Setzt den zurückgegebenen Farbwert in die GUI
    ;
    ; Syntax: _setColor($i_ColorCode)
    ;
    ; Parameter: $i_ColorCode - Der zu übergebene Farb-Code
    ;
    ;
    ; Author(s): Patric Pendelin <patric.pendelin@gmx.de>
    ;===============================================================================
    Func _setColor($i_ColorCode)
    GUICtrlSetData($h_ColorCode_Input, $i_ColorCode)
    GUICtrlSetBkColor($h_ColorExample_Graph, $i_ColorCode)
    If GUICtrlRead($h_Clip_CheckBox) = 1 Then ClipPut($i_ColorCode)
    EndFunc ;==>_setColor
    ;
    ;===============================================================================
    ; Function Name: _getChooseColor
    ; Description: Setzt die "_ChooseColor" Funktion und übergibt den "RGB hex" Code in die "$h_ColorCode_Input"
    ;
    ; Syntax: _getChooseColor()
    ;
    ;
    ; Return Value(s): On Success - Return 1
    ; On Failure - @error
    ;
    ; Author(s): Patric Pendelin <patric.pendelin@gmx.de>
    ;===============================================================================
    Func _getChooseColor()
    Local $i_ColorCode
    ;
    $i_ColorCode = _ChooseColor(2, 255, 2, $h_Whndl)
    If Not @error Then
    _setColor($i_ColorCode)
    Return 1
    EndIf
    EndFunc ;==>_getChooseColor
    ;
    ;===============================================================================
    ; Function Name: _setPipette
    ; Description: Überprüft den Farb-Code, auf den der Maus-Cursor zeigt und übergibt den "RGB hex" Code in die "$h_ColorCode_Input"
    ;
    ; Syntax: _setPipette()
    ;
    ;
    ; Author(s): Patric Pendelin <patric.pendelin@gmx.de>
    ;===============================================================================
    Func _setPipette()
    Sleep(200)
    Local $i_ColorCode
    Local $h_Dll
    Local $ai_MousePos
    ;
    $h_Dll = DllOpen("user32.dll")
    While 1
    $ai_MousePos = MouseGetPos()
    $i_ColorCode = '0x' & Hex(PixelGetColor($ai_MousePos[0], $ai_MousePos[1]), 6)
    _setColor($i_ColorCode)
    ;
    ; Mouse Pressed Check
    If _IsPressed("01", $h_Dll) Then
    HotKeySet($ai_Ini[0][1], "_setPippeteOnHotkey")
    ExitLoop
    EndIf
    If _IsPressed("72", $h_Dll) Then; 72 = F3
    HotKeySet($ai_Ini[0][1], "_setPippeteOnHotkey")
    ExitLoop
    EndIf
    Sleep(40)
    WEnd
    DllClose($h_Dll)
    EndFunc ;==>_setPipette
    ;
    Func _setPippeteOnHotkey()
    HotKeySet($ai_Ini[0][1], "blankFunc")
    _setPipette()
    EndFunc ;==>_setPippeteOnHotkey
    ;
    Func blankFunc()
    Return 1
    EndFunc ;==>blankFunc
    ;
    ;===============================================================================
    ; Function Name: _checkIfProgAllreadyExist
    ; Description: Prüft ob das Programm bereits läuft indem der Titel des AutoIt-Fensters verglichen wird.
    ; Bei einer übereinstimmung gibt es eine MessageBox aus und schließt das Programm.
    ;
    ; Syntax: _checkIfProgAllreadyExist($s_Au3WinTitle, $s_Text)
    ;
    ; Parameter: $s_Au3WinTitle - Der Titel des AutoIt-Fensters
    ; $s_Text - Der Text der MessageBox
    ;
    ;
    ; Author(s): Markus Egert
    ; Patric Pendelin <patric.pendelin@gmx.de>
    ;===============================================================================
    Func _checkIfProgAllreadyExist($s_Au3WinTitle, $s_Text)
    If WinExists($s_Au3WinTitle) Then
    MsgBox(262144 + 48, 'Error', $s_Text)
    Exit
    EndIf
    AutoItWinSetTitle($s_Au3WinTitle)
    EndFunc ;==>_checkIfProgAllreadyExist
    ;===============================================================================
    ; Function Name: _getIni
    ; Description:
    ;
    ; Syntax: _getIni($s_Path)
    ;
    ; Parameter: $s_Path - Der Pfad zur INI-Datei
    ;
    ; Return Value(s): On Success -
    ; On Failure - @error = 1
    ;
    ;
    ; Author(s): Patric Pendelin <patric.pendelin@gmx.de>
    ;===============================================================================
    Func _getIni($s_Path)
    Local $ai_Ini[4][2]
    ;
    If Not FileExists($s_Path) Then Return 1
    ;
    $ai_Ini[0][0] = "hotkey"
    $ai_Ini[0][1] = IniRead($s_Path, "option", "hotkey", "")
    $ai_Ini[1][0] = "toclipboard"
    $ai_Ini[1][1] = IniRead($s_Path, "option", "toclipboard", "")
    $ai_Ini[2][0] = "y"
    $ai_Ini[2][1] = IniRead($s_Path, "coord", "y", "")
    $ai_Ini[3][0] = "x"
    $ai_Ini[3][1] = IniRead($s_Path, "coord", "x", "")

    ;
    Return $ai_Ini
    EndFunc ;==>_getIni
    Func _setIni($s_Path)
    Local $ai_Ini = _getIni($s_Path)
    If Not IsArray($ai_Ini) Then
    FileWrite($s_Path, "")
    IniWrite($s_Path, "option", "hotkey", "{F3}")
    IniWrite($s_Path, "option", "toclipboard", 1)
    IniWrite($s_Path, "coord", "x", "150")
    IniWrite($s_Path, "coord", "y", "200")
    $ai_Ini = _getIni($s_Path)
    Return $ai_Ini
    Else
    Return $ai_Ini
    EndIf

    EndFunc ;==>_setIni
    ;
    ; OnAutoItEnd:
    Func OnAutoItExit()
    IniWrite($S_OPTION_INI_DIR, "coord", "x", $ai_WinPos[0])
    IniWrite($S_OPTION_INI_DIR, "coord", "y", $ai_WinPos[1])
    IniWrite($S_OPTION_INI_DIR, "option", "toclipboard", $s_CBS)
    EndFunc ;==>OnAutoItExit
    ;===============================================================================
    ; GUI
    ;===============================================================================
    Func _buildMainGUI()
    $h_Whndl = GUICreate("Color-Generator", 240, 250, $ai_Ini[3][1], $ai_Ini[2][1],$WS_POPUP) ;$WS_CAPTION
    ;GUISetBkColor(0xFFFFFF)
    ;
    ; Layout Header;
    GUICtrlCreateGraphic(0, 0, 240, 40)
    GUICtrlSetBkColor(-1, 0xF4F4F4)
    ; Border 1
    GUICtrlCreateGraphic(0, 41, 240, 1)
    GUICtrlSetColor(-1, 0xB4B4B4)
    ; Border 2
    GUICtrlCreateGraphic(0, 42, 240, 1)
    GUICtrlSetColor(-1, 0xE1E1E1)
    ;
    ; Überschrift:
    GUICtrlCreateLabel("Color-Generator", 0, 7, 240, 26, $SS_CENTER)
    GUICtrlSetFont(-1, 15, 400, 0, "Verdana")
    GUICtrlSetColor(-1, 0x0046D5)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateLabel("Color-Generator", 1, 8, 240, 26, $SS_CENTER)
    GUICtrlSetFont(-1, 15, 400, 0, "Verdana")
    GUICtrlSetColor(-1, 0xB4B4B4)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    ;
    ; Farb-Code:
    GUICtrlCreateGroup("Color-Code:", 20, 50, 200, 55)
    $h_ColorCode_Input = GUICtrlCreateInput("", 55, 70, 80, 23, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
    GUICtrlSetLimit(-1, 8)
    GUICtrlSetFont(-1, 10, 400, 0, "Verdana")
    $h_OK_Button = GUICtrlCreateButton("OK", 145, 70, 40, 22)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    ;
    ; Farbausgabe:
    ;GUICtrlCreateGroup("Color:", 20, 110, 200, 70)
    $h_ColorExample_Graph = GUICtrlCreateGraphic(-1, 180, 260, 72)
    GUICtrlSetBkColor(-1, 0xF4F4F4)
    GUICtrlSetColor(-1, 0xD6D5D9)
    ;GUICtrlCreateGraphic(34, 122, 172, 42)
    GUICtrlCreateGraphic(33, 126, 174, 44)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xD6D5D9)
    ;
    ; Buttons:
    $h_Choose_Button = GUICtrlCreateButton("Choose", 30, 110, 81, 25)
    $h_Pipette_Button = GUICtrlCreateButton("Pipette", 130, 110, 81, 25)
    ;
    ; Checkbox
    $h_Clip_CheckBox = GUICtrlCreateCheckbox("To Clipboard", 8, 150, 90, 20)
    ;GUICtrlSetBkColor(-1, 0xF4F4F4)
    If $ai_Ini[1][1] = 1 Then
    GUICtrlSetState(-1, $GUI_CHECKED)
    Else
    GUICtrlSetState(-1, $GUI_UNCHECKED)
    EndIf
    ;
    ; ContextMenü:
    Global $h_ContextMenu = GUICtrlCreateContextMenu()
    Global $H_InfoItem_CM = GUICtrlCreateMenuItem("Info", $h_ContextMenu)
    GUISetState(@SW_SHOW)
    ;
    WinSetOnTop($h_Whndl, "", 1)
    ;
    ; OnEvents:
    GUISetOnEvent($GUI_EVENT_CLOSE, "_onEvent_Special")
    GUICtrlSetOnEvent($h_OK_Button, "_onEvent_OK_Button")
    GUICtrlSetOnEvent($h_Choose_Button, "_onEvent_Choose_Button")
    GUICtrlSetOnEvent($h_Pipette_Button, "_onEvent_Pipette_Button")
    GUICtrlSetOnEvent($H_InfoItem_CM, "_onEvent_InfoItem_CM")
    ;
    EndFunc ;==>_buildMainGUI
    ;
    ;===============================================================================
    ; OnEvent Functions
    ;===============================================================================
    Func _onEvent_OK_Button()
    Local $i_ColorCode = GUICtrlRead($h_ColorCode_Input)
    If $i_ColorCode Then
    If (StringInStr($i_ColorCode, "0x") <> 0) Or (StringInStr($i_ColorCode, "0X") <> 0) Then
    _setColor($i_ColorCode)
    ElseIf StringInStr($i_ColorCode, "#") == 1 Then
    _setColor(StringReplace($i_ColorCode, "#", "0x"))
    Else
    _setColor("0x" & $i_ColorCode)
    EndIf
    EndIf
    EndFunc ;==>_onEvent_OK_Button
    ;
    Func _onEvent_Choose_Button()
    _getChooseColor()
    EndFunc ;==>_onEvent_Choose_Button
    ;
    Func _onEvent_Pipette_Button()
    _setPipette()
    EndFunc ;==>_onEvent_Pipette_Button
    ;
    Func _onEvent_Special()
    Select
    Case @GUI_CtrlId = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    EndFunc ;==>_onEvent_Special
    ;
    Func _onEvent_InfoItem_CM()
    MsgBox(262144, "Info", 'Color-Generator ' & 'v' & FileGetVersion(@ScriptFullPath) & @CRLF & @CRLF & _
    '2008 by Patric Pendelin' & @CRLF & @CRLF & _
    '*********************************************************' & @CRLF & @CRLF & @CRLF & _
    'Anleitung:' & @CRLF & @CRLF & _
    'Choose:' & @CRLF & _
    'Mit dem Button "Choose" öffnet sich eine Farben Dialog Box' & @CRLF & _
    'mit der man eine Farbe auwählen kann.' & @CRLF & @CRLF & _
    'Pipette:' & @CRLF & _
    'Die Pipette lässt sich mit dem Pipette-Button aktivieren.' & @CRLF & _
    'Wahlweise kann man auch die "F3" Taste benutzen.' & @CRLF & @CRLF & _
    'Zeigt die Maus über eine gewünschten Farbe kann mit' & @CRLF & _
    'dem erneuten drücken von "F3"(zusätzlich zur linken Maus-Taste)' & @CRLF & _
    'die Pipette angehalten werden.')
    EndFunc ;==>_onEvent_InfoItem_CM