produktive langeweile

  • hier mal 2 Scripte aus langweiligen phasen


    zum ersten ein maus-informations-tool

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #include <array.au3>
    #include <arraymore.au3>
    #include <GUIConstantsEx.au3>
    #include <ListBoxConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>
    #include <WinAPI.au3>
    $start = TimerInit()
    HotKeySet("^{END}", "raus")
    HotKeySet("!p", "play")
    $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
    $GUI = GUICreate("Colors", 178, 436, 190, 122, $WS_SIZEBOX, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE))
    $List = GUICtrlCreateListView("Colors ", 0, 0, 177, 418, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    _GUICtrlListView_SetExtendedListViewStyle($List, $exStyles)
    $hImage = _GUIImageList_Create(11, 11)
    _GUICtrlListView_SetImageList($List, $hImage, 1)
    GUISetState(@SW_SHOW)
    Dim $arcolor[1] = [0], $n, $ncoli, $Mouseposold = MouseGetPos(), $Pixel, $Posis[1][2] = [[0, 0]]
    If FileExists(@ScriptDir & "\positions.ini") Then IniDelete(@ScriptDir & "\positions.ini", "POS")
    While 1
    $Mousepos = MouseGetPos()
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then raus()
    If $Mousepos[0] <> $Mouseposold[0] Or $Mousepos[1] <> $Mouseposold[1] Then
    $n += 1
    $color = Hex(PixelGetColor($Mousepos[0], $Mousepos[1]), 6)
    $colindex = _ArraySearch($arcolor, $color, 0, 0, 0, 1)
    If $colindex = -1 Then
    _ArrayAdd($arcolor, 1 & "x" & $color)
    ToolTip($n & " : " & $Mousepos[0] & " , " & $Mousepos[1] & _
    @CRLF & $arcolor[UBound($arcolor) - 1])
    _GUICtrlListView_AddItem($List, $arcolor[UBound($arcolor) - 1], $ncoli)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($List, "0x" & $color, 11, 11))
    $ncoli += 1
    Else
    $listindex = _GUICtrlListView_FindInText($List, $arcolor[$colindex])
    $spl = StringSplit($arcolor[$colindex], "x")
    $spl[1] += 1
    $arcolor[$colindex] = $spl[1] & "x" & $spl[2]
    ToolTip($n & " : " & $Mousepos[0] & ", " & $Mousepos[1] & _
    @CRLF & $arcolor[$colindex])
    _GUICtrlListView_SetItem($List, $arcolor[$colindex], $listindex)
    EndIf
    $Pixel += dif($Mousepos[0], $Mouseposold[0]) + dif($Mousepos[1], $Mouseposold[1])
    $Mouseposold = MouseGetPos()
    _Array2dAdd($Posis, $Mousepos[0] & "|" & $Mousepos[1])
    EndIf
    WEnd
    Func play()
    For $i = 1 To $n
    MouseMove($Posis[$i][0], $Posis[$i][1], 1)
    Sleep(25)
    Next
    raus()
    EndFunc ;==>play
    Func raus()
    ToolTip("")
    GUISetState(@SW_HIDE)
    Local $arcsort[1][2], $max[6] = [0, 0, 0, 0, 0, 0]
    Local Const $LOGPIXELSX = 88
    $ScreenDC = _WinAPI_GetDC(0)
    $DPI = _WinAPI_GetDeviceCaps($ScreenDC, $LOGPIXELSX)
    _WinAPI_ReleaseDC(0, $ScreenDC)
    $arcolor[0] = UBound($arcolor) - 1
    For $i = 1 To $arcolor[0]
    $spl = StringSplit($arcolor[$i], "x")
    _Array2dAdd($arcsort, $spl[1] & "|" & $spl[2])
    Next
    _ArrayDisplay($arcsort, "Farben")
    For $i = 1 To UBound($arcsort) - 1
    If $arcsort[$i][0] >= $max[0] Then
    $max[0] = Number($arcsort[$i][0]) ;Num 1
    $max[1] = $i ;Index 1
    EndIf
    Next
    For $i = 1 To UBound($arcsort) - 1
    If $arcsort[$i][0] >= $max[2] And $arcsort[$i][0] < $max[0] Then
    $max[2] = Number($arcsort[$i][0]) ; Num 2
    $max[3] = $i ; Index 2
    EndIf
    Next
    For $i = 1 To UBound($arcsort) - 1
    If $arcsort[$i][0] >= $max[4] And $arcsort[$i][0] < $max[2] Then
    $max[4] = Number($arcsort[$i][0]) ; Num 3
    $max[5] = $i ; Index 3
    EndIf
    Next
    ToolTip($n & " : " & $Mousepos[0] & ", " & $Mousepos[1] & @CRLF & $color)
    MsgBox(0, @UserName, $Mousepos[0] & "," & $Mousepos[1] & _
    @CRLF & _
    @CRLF & $n & " Bewegungen gezählt." & _
    @CRLF & "Die Maus wurde über " & $Pixel & " Pixel & " & Round($Pixel * 2.54 / $DPI, 2) & " cm bewegt." & _
    @CRLF & @DesktopHeight * @DesktopWidth & " Pixel insgesamt." & _
    @CRLF & Round($Pixel / (@DesktopHeight * @DesktopWidth) * 100, 2) & "% aller Pixel überquert." & _
    @CRLF & _
    @CRLF & $ncoli & " Verschiedene farben." & _
    @CRLF & $n & " Farben." & _
    @CRLF & "Meist verwendete Farbe: " & $arcsort[$max[1]][1] & " (" & $max[0] & ")" & _
    @CRLF & "2te Farbe: " & $arcsort[$max[3]][1] & " (" & $max[2] & ")" & _
    @CRLF & "3te Farbe: " & $arcsort[$max[5]][1] & " (" & $max[4] & ")" & _
    @CRLF & _
    @CRLF & "Data lost: " & Round($Pixel / $n, 2) & "%" & _
    @CRLF & "Runtime: " & Round(TimerDiff($start) / 1000) & " sec.")
    Exit
    EndFunc ;==>raus
    Func dif($Dif1, $Dif2)
    Local $Result
    If $Dif1 > $Dif2 Then
    $Result = $Dif1 - $Dif2
    ElseIf $Dif1 < $Dif2 Then
    $Result = $Dif2 - $Dif1
    ElseIf $Dif1 = $Dif2 Then
    $Result = 0
    EndIf
    Return $Result
    EndFunc ;==>dif

    [/autoit]

    und zum anderen ein kleines spiel: Catch the window!
    mit der einzigen Regel: Catch the window!

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    HotKeySet("^{END}", "END")
    $gui = GUICreate("Catch me!", 72, 53, 193, 125, -1, $WS_EX_TOOLWINDOW)
    $up = GUICtrlCreateRadio("", 31, 2, 16, 17)
    $down = GUICtrlCreateRadio("", 31, 34, 16, 17)
    $left = GUICtrlCreateRadio("", 8, 18, 16, 17)
    $right = GUICtrlCreateRadio("", 52, 18, 16, 17)
    GUICtrlCreateRadio("", 31, 18, 16, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)
    MouseMove(@DesktopWidth - 200, @DesktopHeight - 200)
    $Mposold = MouseGetPos()
    GUISetState()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    $Mpos = MouseGetPos()
    If $Mpos[1] <> $Mposold[1] Or $Mpos[0] <> $Mposold[0] Then
    $winpos = WinGetPos($gui)
    if ($winpos[0] < $Mpos[0] And $winpos[1] < $Mpos[1]) and ($Mpos[0] < $winpos[0] + 78 And $Mpos[1] < $winpos[1] + 77) Then
    MsgBox(0, "", "YOU WIN :D")
    EndIf
    If $Mpos[0] > $Mposold[0] Then
    GUICtrlSetState($right, $GUI_CHECKED)
    WinMove($gui, "", $winpos[0] + ($Mpos[0] - $Mposold[0]), $winpos[1])
    ElseIf $Mpos[0] < $Mposold[0] Then
    GUICtrlSetState($left, $GUI_CHECKED)
    WinMove($gui, "", $winpos[0] - ($Mposold[0] - $Mpos[0]), $winpos[1])
    ElseIf $Mpos[1] < $Mposold[1] Then
    GUICtrlSetState($up, $GUI_CHECKED)
    WinMove($gui, "", $winpos[0], $winpos[1] - ($Mposold[1] - $Mpos[1]))
    ElseIf $Mpos[1] > $Mposold[1] Then
    GUICtrlSetState($down, $GUI_CHECKED)
    WinMove($gui, "", $winpos[0], $winpos[1] + ($Mpos[1] - $Mposold[1]))
    EndIf
    $Mposold = MouseGetPos()
    EndIf
    WEnd
    Func End()
    Exit
    EndFunc ;==>End

    [/autoit]

    Edit: Na, wie habt ihr das fenster gefangen?

    Einmal editiert, zuletzt von Worfox (18. November 2008 um 14:19)

  • @funkex
    Reicht es nicht aus, wenn man hinter Zeile 26 ein EXIT schreibt?
    Ich bekomme das Fenster nicht gefangen ;)

    Alina

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • schon wieder zu viel langeweile gehabt

    hier n zwichenablage speicher tool (eine weiteres)

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ListBoxConstants.au3>
    #include <WindowsConstants.au3>
    #Include <Constants.au3>
    #include <GuiListBox.au3>
    #include <Array.au3>
    Opt("TrayMenuMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $GUI = GUICreate('Clipper', 490, 430, 193, 125)
    Global $GUIEdit = GUICtrlCreateEdit('', 0, 0, 369, 409)
    Global $GUIList = GUICtrlCreateList('', 368, 0, 121, 409)

    [/autoit] [autoit][/autoit] [autoit]

    Global $Con = GUICtrlCreateContextMenu($GUIList)
    Global $ConEmpty = GUICtrlCreateMenuItem("Empty", $Con)

    [/autoit] [autoit][/autoit] [autoit]

    Global $MenuFile = GUICtrlCreateMenu('File')
    Global $MenuHide = GUICtrlCreateMenuItem('Hide Window', $MenuFile)
    Global $MenuSave = GUICtrlCreateMenuItem('Save', $MenuFile)
    Global $MenuSaveAs = GUICtrlCreateMenuItem('Save As...', $MenuFile)
    GUICtrlCreateMenuItem('', $MenuFile)
    Global $MenuExit = GUICtrlCreateMenuItem('Exit', $MenuFile)
    Global $MenuEdit = GUICtrlCreateMenu('Edit')
    Global $MenuEmpty = GUICtrlCreateMenuItem('Empty', $MenuEdit)
    Global $MenuPause = GUICtrlCreateMenuItem('Pause', $MenuEdit)
    Global $MenuArray = GUICtrlCreateMenuItem('Array', $MenuEdit)

    [/autoit] [autoit][/autoit] [autoit]

    Global $TrayHide = TrayCreateItem("Hide/Show")
    Global $TrayExit = TrayCreateItem("Exit")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $arClip[1][2] = [[0, '']], $Start = True, $SaveAs = "", $GUIstate = True

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)
    While 1
    Switch TrayGetMsg()
    case $TrayExit
    Exit
    Case $TrayHide
    If $GUIstate Then
    GUISetState(@SW_HIDE)
    Else
    GUISetState(@SW_SHOW)
    EndIf
    $GUIstate = Not $GUIstate
    EndSwitch


    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $MenuExit
    Exit
    Case $MenuHide
    If $GUIstate Then
    GUISetState(@SW_HIDE)
    Else
    GUISetState(@SW_SHOW)
    EndIf
    $GUIstate = Not $GUIstate
    Case $MenuEmpty, $ConEmpty
    GUICtrlSetData($GUIEdit, '')
    GUICtrlSetData($GUIList, '')
    Global $arClip[1][2] = [[0, '']]
    Case $MenuPause
    If BitAND(GUICtrlRead($MenuPause), $GUI_CHECKED) == $GUI_CHECKED Then
    GUICtrlSetState($MenuPause, $GUI_UNCHECKED)
    Else
    GUICtrlSetState($MenuPause, $GUI_CHECKED)
    EndIf
    $Start = Not $Start
    Case $MenuSaveAs
    SaveDialog()
    Case $MenuSave
    If $SaveAs <> "" Then
    SaveDialog(1)
    Else
    SaveDialog()
    EndIf
    Case $MenuArray
    _ArrayDisplay($arClip, "arClip")
    Case $GUIList
    GUICtrlSetData($GUIEdit, $arClip[_ArraySearch($arClip, GUICtrlRead($GUIList), 0, 0, 1, 0, 1, 0)][1])
    EndSwitch

    If $Start Then
    If ClipGet() <> $arClip[UBound($arClip) - 1][1] Then
    $arClip[0][0] += 1
    ReDim $arClip[UBound($arClip) + 1][2]
    $arClip[UBound($arClip) - 1][0] = StringLeft(ClipGet(), 18)
    $arClip[UBound($arClip) - 1][1] = ClipGet()
    GUICtrlSetData($GUIList, $arClip[UBound($arClip) - 1][0])
    EndIf
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func SaveDialog($iFlag = 0)
    SetError(0)
    If $iFlag == 0 Then
    Global $SaveAs = FileSaveDialog('Save As..', @ScriptDir, 'Clipper(*.txt)', -1, 'Clipper.txt')
    If @error Then $SaveAs = ""
    EndIf
    If @error == 0 Then
    If StringRight($SaveAs, 4) <> '.txt' Then $SaveAs &= '.txt'
    If FileExists($SaveAs) And $iFlag == 0 Then
    $Answer = MsgBox(49, 'Clipper', 'Datei gibts schon, überschreiben?')
    If $Answer == 1 Then
    FileDelete($SaveAs)
    EndIf
    Else
    $Answer = 1
    EndIf
    If $Answer == 1 Then
    For $i = 1 To UBound($arClip) - 1
    FileWriteLine($SaveAs, $arClip[$i][1])
    FileWriteLine($SaveAs, "##############################################################")
    Next
    EndIf
    EndIf
    EndFunc ;==>SaveDialog

    [/autoit]

    edit: wtf? nach ner weile spuckt das prog fehler aus, im array steht z.b. 50 mal der gleiche text, obwohl sich in der zwichenablage nix verändert hat...
    und noch ganz viele andere...

    Einmal editiert, zuletzt von Worfox (19. November 2008 um 16:12)