Hallo,
wie kann ich mit Autoit einen runden Button mit einer icon-Datei darauf machen?
Hallo,
wie kann ich mit Autoit einen runden Button mit einer icon-Datei darauf machen?
Einen runden Button gibt es nicht, aber Du kannst ein Icon auch als Klick-Event abfragen:
[autoit]
#include<GUIConstantsEx.au3>
GUICreate(" My GUI Icons", 250, 250)
$icon = GUICtrlCreateIcon("shell32.dll", -24, 20, 75, 32, 32)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $icon Then MsgBox(0,0,'angeklickt')
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Mach es doch als Icon und benutzt es wie ein button
$fenster = GUICreate("", 231, 172, 414, 226)
$Beispiel = GUICtrlCreateIcon(@ScriptDir&"\Beispielordner\Icon.ico", 0, 0, 0, 0, 0)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Beispiel
Das was dann getan werden soll
Wend
thx.
wie funktioniern dann die playbuttons beim WMP11 ?
ist das irgendwie mit plugins oder wie?
Wie gesagt, man kann auch (runde) Icons abfragen.
Probier einfach mal mein obiges Script-Beispiel aus.
Hab ich ja schon. funkt ja auch. Aber es soll beim draufklicken irgendwie sich vertiefen. Wie bei einem echen Button.
Man kann sowas simulieren:
#include<GUIConstantsEx.au3>
$hGui = GUICreate(" My GUI Icons", 250, 250)
$icon = GUICtrlCreateIcon("shell32.dll", -24, 20, 75, 32, 32)
GUISetState()
Global $old, $msg
While 1
$msg = GUIGetMsg()
$aInfo = GUIGetCursorInfo($hGui)
If $aInfo[4] = $icon Then
If $aInfo[4] <> $old Then
$old = $aInfo[4]
GUICtrlSetPos($icon, 21, 76, 32, 32)
EndIf
Else
If $aInfo[4] <> $old Then
$old = $aInfo[4]
GUICtrlSetPos($icon, 20, 75, 32, 32)
EndIf
EndIf
If $msg = $icon Then
GUICtrlSetImage($icon, "shell32.dll", -44)
MsgBox(0,0,'angeklickt')
GUICtrlSetImage($icon, "shell32.dll", -24)
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
klink interessant, aber geht das auch wenn man den button gedrüückt hält, dass n anderes icon erscheint?
Hey Danke
Genau das habe ich gesucht
Hallo
Sonst halt noch einfach mit Photoshop u.a. drei Bilddateien machen (Normal, Hover, Pressed) und dann einfach mit dem Script von Oscar, oder im engl Forum suchen, aufrufen
Mfg Spider
Ich habe mal noch eine andere Version erstellt, bei der man beliebig viele Buttons mit der Hover-Funktion belegen kann:
#include<GUIConstantsEx.au3>
Opt('GUIOnEventMode', 1)
$hGui = GUICreate(" My GUI Icons", 280, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, '_MoveOrDown')
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_MoveOrDown')
GUISetOnEvent($GUI_EVENT_PRIMARYUP, '_Up')
Global $aButton[3][7]
$aButton[0][0] = GUICtrlCreateIcon("shell32.dll", -24, 20, 20, 32, 32)
$aButton[0][1] = -24 ; Iconposition in der dll für nicht gedrückt
$aButton[0][2] = -44 ; Iconposition in der dll für gedrückt
$aButton[0][3] = False ; Check für Position bei gedrückt (verhindert flackern)
$aButton[0][4] = False ; Check für Icon-Image bei gedrückt (verhindert flackern)
$aButton[0][5] = 20 ; X-Position des Icons
$aButton[0][6] = 20 ; Y-Position des Icons
$aButton[1][0] = GUICtrlCreateIcon("shell32.dll", -14, 120, 20, 32, 32)
$aButton[1][1] = -14
$aButton[1][2] = -15
$aButton[1][3] = False
$aButton[1][4] = False
$aButton[1][5] = 120
$aButton[1][6] = 20
$aButton[2][0] = GUICtrlCreateIcon("shell32.dll", -10, 220, 20, 32, 32)
$aButton[2][1] = -10
$aButton[2][2] = -11
$aButton[2][3] = False
$aButton[2][4] = False
$aButton[2][5] = 220
$aButton[2][6] = 20
GUISetState()
[/autoit] [autoit][/autoit] [autoit]While 1
Sleep(50)
WEnd
Func _End()
Exit
EndFunc
Func _Up() ; wird aufgerufen, wenn die linke Maustaste losgelassen wird
Local $aInfo = GUIGetCursorInfo($hGui), $j = -1
For $i = 0 To UBound($aButton)-1
If $aInfo[4] = $aButton[$i][0] Then $j = $i
Next
If $j = -1 Then Return
MsgBox(0, 0, 'Button ' & $j+1 & ' wurde angeklickt')
GUICtrlSetImage($aButton[$j][0], "shell32.dll", $aButton[$j][1]) ; ursprüngliches Icon wiederherstellen
EndFunc
Func _MoveOrDown() ; wird aufgerufen, wenn entweder die Maus bewegt oder die linke Maustaste runtergedrückt wird
Local $aInfo = GUIGetCursorInfo($hGui), $j = -1
For $i = 0 To UBound($aButton)-1
If $aInfo[4] = $aButton[$i][0] Then $j = $i
Next
If $j = -1 Then
For $i = 0 To UBound($aButton)-1
if $aButton[$i][3] Then GUICtrlSetPos($aButton[$i][0], $aButton[$i][5], $aButton[$i][6])
if $aButton[$i][4] Then GUICtrlSetImage($aButton[$i][0], "shell32.dll", $aButton[$i][1])
$aButton[$i][3] = False
$aButton[$i][4] = False
Next
Return
EndIf
If Not $aButton[$j][3] Then
GUICtrlSetPos($aButton[$j][0], $aButton[$j][5]+1, $aButton[$j][6]+1)
$aButton[$j][3] = True
EndIf
If $aInfo[2] And Not $aButton[$j][4] Then
GUICtrlSetImage($aButton[$j][0], "shell32.dll", $aButton[$j][2])
$aButton[$j][4] = True
EndIf
EndFunc
Hier wird auch noch der linke Mausklick abgefangen und es wird, während man die Maustaste gedrückt hält, ein anderes Icon angezeigt. Der eigentliche Klick-Event erfolgt erst beim loslassen der Maustaste.