Hallo, habe mir mal nen kleines Script gebastelt für Mouseclick. Just 4 fun zum Lernen usw. Jedoch sieht der Code nicht so schön aus. Vielleicht könnt ihr mir ein paar Vorschläger oder sogar ein paar Tips geben wie ich es verschönern bzw in Zukunft gleich besser machen kann.
Quellcode:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <WindowsConstants.au3>
Global $Mfile = @ScriptDir & "\Mouseclick.au3", $Pos, $Toogle = 0
[/autoit] [autoit][/autoit] [autoit]; Gui -->
$Options = GUICreate("Options", 400, 190)
GUISetBkColor(0x00E0FFFF) ; will change background color
GUICtrlCreateGroup("Speed", 15, 15, 230, 70)
$label = GUICtrlCreateLabel("Speed = 45", 23, 37)
$slider = GUICtrlCreateSlider(23, 57, 200, 20, BitOR($TBS_AUTOTICKS, $WS_BORDER))
GUICtrlSetState(-1, $Gui_FOCUS)
GUICtrlSetLimit(-1, 100, 0) ; change min/max value
GUICtrlCreateGroup("Key", 15, 100, 230, 70)
GUICtrlCreateLabel("Choose the key which will get pressed.", 23, 122)
$Key = GUICtrlCreateCombo("Left", 23, 140, 75)
GUICtrlSetData(-1, "Right|Middle", "Left") ; add other item snd set a new default
GUICtrlSetData($slider, 10) ; set cursor
GUICtrlCreateGroup("Clicks", 260, 15, 125, 70)
$1Click = GUICtrlCreateRadio("1 Click", 267, 37)
GUICtrlSetState(-1, $GUI_CHECKED)
$2Click = GUICtrlCreateRadio("2 Click's", 267, 57)
$Start = GUICtrlCreateButton("Starten", 262, 105, 123, 65)
GUISetState()
;==>
; Führt die Funktion Test alle 10ms aus
AdlibEnable("Test", 10)
;==>
; Schleife für die Gui
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Start
$Speed = GUICtrlRead($slider)
$Keys = GUICtrlRead($Key)
$1 = GUICtrlRead($1Click)
$2 = GUICtrlRead($2Click)
GUIDelete()
_getPos()
EndSwitch
WEnd
;==>
; Erneuert den Slider
Func Test()
GUICtrlSetData($label, "Speed = " & GUICtrlRead($slider))
EndFunc
;==>Test
; Wartet bis F6 Gedrückt wird und Zeigt einen TrayTip an
Func _getPos()
Do
HotKeySet("{F6}", "_Get")
HotKeySet("{ESC}", "_Exit")
TrayTip("Press" & " 'ESC' " & "to Exit.", "Press" & " 'F6' " & "to get the coordinates", 500)
Sleep(500)
Until $Toogle <> 0 ; Do schleife entstand durch einen Versuch
EndFunc
;==>_getPos
; Checkt alle Daten und schreibt sie in die Datei
Func _Get()
$Pos = MouseGetPos()
Sleep(1000)
$cFile = FileOpen($Mfile, 1)
If $1 = $GUI_CHECKED Then
$clicks = 1
ElseIf $2 = $GUI_CHECKED Then
$clicks = 2
EndIf
FileWrite($cFile, "MouseClick('" & $Keys & "', " & $Pos[0] & ", " & $Pos[1] & ", " & $clicks & ", " & $Speed & ")" & @CRLF)
FileClose($cFile)
Exit
EndFunc
;==>_Get
; Beendet das Script
Func _Exit()
Exit
EndFunc
;==>_Exit
Danke schonmal an alle.
Edit: Mit schöner meinte ich "nicht" Kommentare. Die werde ich wenn der Code besser aussieht hinzufügen.