Hab nochmal das wichtige abgetrennt ...
Spoiler anzeigen
Global Const $CC_ANYCOLOR = 0x100
Global Const $CC_FULLOPEN = 0x2
Global Const $CC_RGBINIT = 0x1
Global Const $CF_EFFECTS = 0x100
Global Const $CF_PRINTERFONTS = 0x2
Global Const $CF_SCREENFONTS = 0x1
Global Const $CF_NOSCRIPTSEL = 0x800000
Global Const $CF_INITTOLOGFONTSTRUCT = 0x40
Global Const $DEFAULT_PITCH = 0
Global Const $FF_DONTCARE = 0
Global Const $LOGPIXELSX = 88
Func _ChooseColor($i_ReturnType = 0, $i_colorref = 0, $i_refType = 0)
Local $custcolors = "int[16]"
Local $struct = "dword;int;int;int;ptr;dword;int;ptr;ptr"
Local $p = DllStructCreate($struct)
If @error Then
SetError(-1)
Return -1
EndIf
Local $cc = DllStructCreate($custcolors)
If @error Then
SetError(-2)
Return -1
EndIf
If ($i_refType == 1) Then
$i_colorref = Int($i_colorref)
ElseIf ($i_refType == 2) Then
$i_colorref = Hex(String($i_colorref), 6)
$i_colorref = '0x' & StringMid($i_colorref, 5, 2) & StringMid($i_colorref, 3, 2) & StringMid($i_colorref, 1, 2)
EndIf
DllStructSetData($p, 1, DllStructGetSize($p))
DllStructSetData($p, 2, 0)
DllStructSetData($p, 4, $i_colorref)
DllStructSetData($p, 5, DllStructGetPtr($cc))
DllStructSetData($p, 6, BitOR($CC_ANYCOLOR, $CC_FULLOPEN, $CC_RGBINIT))
Local $ret = DllCall("comdlg32.dll", "long", "ChooseColor", "ptr", DllStructGetPtr($p))
If ($ret[0] == 0) Then
SetError(-3)
Return -1
EndIf
Local $color_picked = DllStructGetData($p, 4)
If ($i_ReturnType == 1) Then
Return '0x' & Hex(String($color_picked), 6)
ElseIf ($i_ReturnType == 2) Then
$color_picked = Hex(String($color_picked), 6)
Return '0x' & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2)
ElseIf ($i_ReturnType == 0) Then
Return $color_picked
Else
SetError(-4)
Return -1
EndIf
EndFunc
Func _ChooseFont($s_FontName = "Courier New", $i_size = 10, $i_colorref = 0)
Local $ret = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", 0, "long", $LOGPIXELSX)
If ($ret[0] == -1) Then
SetError(-3)
Return -1
EndIf
Local $lfHeight = Round(($i_size * $ret[2]) / 72, 0)
Local $logfont = "int;int;int;int;int;byte;byte;byte;byte;byte;byte;byte;byte;char[32]"
Local $struct = "dword;int;int;ptr;int;dword;int;int;ptr;ptr;int;ptr;dword;int;int"
Local $p = DllStructCreate($struct)
If @error Then
SetError(-1)
Return -1
EndIf
Local $lf = DllStructCreate($logfont)
If @error Then
SetError(-2)
Return -1
EndIf
DllStructSetData($p, 1, DllStructGetSize($p))
DllStructSetData($p, 2, 0)
DllStructSetData($p, 4, DllStructGetPtr($lf))
DllStructSetData($p, 5, $i_size)
DllStructSetData($p, 6, BitOR($CF_SCREENFONTS, $CF_PRINTERFONTS, $CF_EFFECTS, $CF_INITTOLOGFONTSTRUCT, $CF_NOSCRIPTSEL))
DllStructSetData($p, 7, $i_colorref)
DllStructSetData($p, 13, 0)
DllStructSetData($lf, 1, $lfHeight + 1)
DllStructSetData($lf, 6, 0)
DllStructSetData($lf, 7, 0)
DllStructSetData($lf, 8, 0)
DllStructSetData($lf, 14, $s_FontName)
$ret = DllCall("comdlg32.dll", "long", "ChooseFont", "ptr", DllStructGetPtr($p))
If ($ret[0] == 0) Then
SetError(-3)
Return -1
EndIf
Local $fontname = DllStructGetData($lf, 14)
If (StringLen($fontname) == 0 And StringLen($s_FontName) > 0) Then
$fontname = $s_FontName
EndIf
Local $italic = 0
Local $underline = 0
Local $strikeout = 0
If (DllStructGetData($lf, 6)) Then
$italic = 2
EndIf
If (DllStructGetData($lf, 7)) Then
$underline = 4
EndIf
If (DllStructGetData($lf, 8)) Then
$strikeout = 8
EndIf
Local $attributes = BitOR($italic, $underline, $strikeout)
Local $size = DllStructGetData($p, 5) / 10
Local $weight = DllStructGetData($lf, 5)
Local $colorref = DllStructGetData($p, 7)
Local $color_picked = Hex(String($colorref), 6)
Return StringSplit($attributes & "," & $fontname & "," & $size & "," & $weight & "," & $colorref & "," & '0x' & $color_picked & "," & '0x' & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2), ",")
EndFunc
Func _ClipPutFile($sFile, $sSeperator = "|")
Local $vDllCallTmp, $nGlobMemSize, $hGlobal, $DROPFILES, $i, $hLock
Local $GMEM_MOVEABLE = 0x0002, $CF_HDROP = 15
$sFile = $sFile & $sSeperator & $sSeperator
$nGlobMemSize = StringLen($sFile) + 20
$vDllCallTmp = DllCall("user32.dll", "int", "OpenClipboard", "hwnd", 0)
If @error Or $vDllCallTmp[0] = 0 Then
SetError(1)
Return False
EndIf
$vDllCallTmp = DllCall("user32.dll", "int", "EmptyClipboard")
If @error Or $vDllCallTmp[0] = 0 Then
SetError(2)
Return False
EndIf
$vDllCallTmp = DllCall("kernel32.dll", "long", "GlobalAlloc", "int", $GMEM_MOVEABLE, "int", $nGlobMemSize)
If @error Or $vDllCallTmp[0] < 1 Then
SetError(3)
Return False
EndIf
$hGlobal = $vDllCallTmp[0]
$vDllCallTmp = DllCall("kernel32.dll", "long", "GlobalLock", "long", $hGlobal)
If @error Or $vDllCallTmp[0] < 1 Then
SetError(4)
Return False
EndIf
$hLock = $vDllCallTmp[0]
$DROPFILES = DllStructCreate("dword;ptr;int;int;int;char[" & StringLen($sFile) & "]", $hLock)
If @error Then
SetError(5)
Return False
EndIf
DllStructSetData($DROPFILES, 1, DllStructGetSize($DROPFILES) - StringLen($sFile))
DllStructSetData($DROPFILES, 2, 0)
DllStructSetData($DROPFILES, 3, 0)
DllStructSetData($DROPFILES, 4, 0)
DllStructSetData($DROPFILES, 5, 0)
DllStructSetData($DROPFILES, 6, $sFile)
For $i = 1 To StringLen($sFile)
If DllStructGetData($DROPFILES, 6, $i) = Asc($sSeperator) Then DllStructSetData($DROPFILES, 6, 0, $i)
Next
$vDllCallTmp = DllCall("user32.dll", "long", "SetClipboardData", "int", $CF_HDROP, "long", $hGlobal)
If @error Or $vDllCallTmp[0] < 1 Then
SetError(6)
$DROPFILES = 0
Return False
EndIf
$vDllCallTmp = DllCall("user32.dll", "int", "CloseClipboard")
If @error Or $vDllCallTmp[0] = 0 Then
SetError(7)
$DROPFILES = 0
Return False
EndIf
$vDllCallTmp = DllCall("kernel32.dll", "int", "GlobalUnlock", "long", $hGlobal)
If @error Then
SetError(8)
$DROPFILES = 0
Return False
EndIf
$vDllCallTmp = DllCall("kernel32.dll", "int", "GetLastError")
If $vDllCallTmp = 0 Then
$DROPFILES = 0
SetError(8)
Return False
Else
$DROPFILES = 0
Return True
EndIf
EndFunc
Func _Iif($f_Test, $v_TrueVal, $v_FalseVal)
If $f_Test Then
Return $v_TrueVal
Else
Return $v_FalseVal
EndIf
EndFunc
Func _MouseTrap($i_left = 0, $i_top = 0, $i_right = 0, $i_bottom = 0)
Local $av_ret
If @NumParams == 0 Then
$av_ret = DllCall("user32.dll", "int", "ClipCursor", "int", 0)
Else
If @NumParams == 2 Then
$i_right = $i_left + 1
$i_bottom = $i_top + 1
EndIf
Local $Rect = DllStructCreate("int;int;int;int")
If @error Then Return 0
DllStructSetData($Rect, 1, $i_left)
DllStructSetData($Rect, 2, $i_top)
DllStructSetData($Rect, 3, $i_right)
DllStructSetData($Rect, 4, $i_bottom)
$av_ret = DllCall("user32.dll", "int", "ClipCursor", "ptr", DllStructGetPtr($Rect))
EndIf
Return $av_ret[0]
EndFunc
Func _Singleton($occurenceName, $flag = 0)
Local $ERROR_ALREADY_EXISTS = 183
$occurenceName = StringReplace($occurenceName, "\", "")
Local $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $occurenceName)
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
If $lastError[0] = $ERROR_ALREADY_EXISTS Then
If $flag = 0 Then
Exit -1
Else
SetError($lastError[0])
Return 0
EndIf
EndIf
Return $handle[0]
EndFunc
Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
Return 0
EndFunc
;Hier fängt das Hauptprogramm an:
[/autoit] [autoit][/autoit] [autoit]$dll = DllOpen("user32.dll")
While 1
If _IsPressed("13", $dll) Then
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
$i = 1
While $i >= 0 ;bis zum nächsten WEnd werden hier die Befehle eingegeben, die ausgeführt werden sollen
Send ("{Space}") ; {SPACE} steht für leertaste
sleep (300) ;pause in ms
send ("w") ;tast "w" wird gedrückt
sleep (200)
send ("w")
sleep (200)
MouseClick ("") ;("")=linksklick; ("left")=linksklick; ("right")=rechtsklick; ("middle")=mausrad/mittlere taste klick
sleep (400)
send ("+")
sleep (300)
MouseClick ("")
sleep (400)
send ("+")
WEnd
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc
Func Terminate()
Exit 0
EndFunc
EndIf
WEnd
DllClose($dll)