Win Maximizer

  • Hi @all

    Ich hab mal ein kleines Tool geschrieben mit welchem mann wenn es angeschaltet ist ein aktives fenster per Maus bewegung an den oberen Rand Maximieren kann.
    Es wird natürlich erweitert und das design auf jeden fall überarbeitet weil das mit an und aus gefällt mir nicht, daher würde ich mich über eure vorschläge freuen.

    Die Button namen .. kommen dadurch her , weil ich die gui mit dem Koda von Scite erstellt habe.
    Ich hoffe das Tool gefällt euch.

    Version 1.5
    Author: simon

    Uppdate:

    • 1.1 :Jetzt ist das An und Aus Schalten auch per Hotkey Möglich (Per F1 [an] und F2 [aus]), diese ist aber auch per Häckchen abzustellen.
    • 1.2 Rahmen bei maximieren(wenn man die maus wegzieht wird nciht maximiert), Checckbox wird gespeichert,Beenden per F3
    • 1.5 Neue Funktion zum maximieren von links bis zur mitte!

    Code:

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=icon.ico
    #AutoIt3Wrapper_Res_Comment=Maximizer für Windows
    #AutoIt3Wrapper_Res_Description=Maximizer für Windows
    #AutoIt3Wrapper_Res_Fileversion=1.2.0.0
    #AutoIt3Wrapper_Res_LegalCopyright=Simon (http://www.autoit.de)
    #AutoIt3Wrapper_Res_Language=1031
    #AutoIt3Wrapper_Tidy_Stop_OnError=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    ;(C) Simon (http://www.autoit.de)
    ; Lizenz: Verwendung ist kostenlos aber es darf nichts verändert oder umbenannt werden und auch nirgendwo hochgeladen werden
    ;support unter [email='support@simon-webstation.de'][/email]
    ;Version: 1.5

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

    Global $cfg_file = @ScriptDir & "\config.data"
    Global $max_state = 0
    Global $max_middle_state = 0
    ; 0 = aus
    ; 1 = ein

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

    $check_read = FileReadLine(@ScriptDir & "\config.data", 1)
    If $check_read = "" Then
    $check_read = $GUI_CHECKED
    ElseIf $check_read = 1 Then
    $check_read = $GUI_CHECKED
    ElseIf $check_read = 4 Then
    $check_read = $GUI_UNCHECKED
    EndIf

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

    If $check_read = $GUI_CHECKED Then
    HotKeySet("{F1}", "_hotkey_an")
    HotKeySet("{F2}", "_hotkey_aus")
    EndIf

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

    HotKeySet("{F3}", "_exit")

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Window Maximizer by simon", 306, 325, -1, -1)
    $menu = GUICtrlCreateMenu("?")
    $menuitem1 = GUICtrlCreateMenuItem("Info", $menu)
    $Label1 = GUICtrlCreateLabel("Hier kannst du den Window Maximizer ein oder Ausschalten:", 8, 8, 290, 17)
    $Button1 = GUICtrlCreateButton("An", 8, 32, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Aus", 88, 32, 75, 25, $WS_GROUP)
    $Label2 = GUICtrlCreateLabel("", 168, 32, 28, 25)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $Label3 = GUICtrlCreateLabel("Erklärung:", 8, 64, 52, 17)
    $Label4 = GUICtrlCreateLabel("Wenn du mit der Maus an den Oberen Bildschirmrand kommst,", 8, 88, 295, 17)
    $Label5 = GUICtrlCreateLabel("dann Maximiert sich das Aktive Fenster.", 8, 112, 191, 17)
    $Label6 = GUICtrlCreateLabel("(C) simon(www.autoit,de", 8, 136, 124, 17)
    $Checkbox1 = GUICtrlCreateCheckbox("An und Aus per Hotkey", 8, 160, 161, 17)
    GUICtrlSetState(-1, $check_read)
    $Button3 = GUICtrlCreateButton("An", 10, 206, 75, 25, $WS_GROUP)
    $Button4 = GUICtrlCreateButton("Aus", 91, 206, 75, 25, $WS_GROUP)
    $Label7 = GUICtrlCreateLabel("", 179, 206, 28, 25)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $Label8 = GUICtrlCreateLabel("Hier kannst du den Maximizer der Linken Seite einstellen:", 8, 184, 273, 17)
    $Label9 = GUICtrlCreateLabel("Erklärung:", 8, 232, 52, 17)
    $Label10 = GUICtrlCreateLabel("Wenn du mit der Maus an den Linken Bildschrmrand kommst", 8, 256, 290, 17)
    $Label11 = GUICtrlCreateLabel("Maximiert sich das Aktive Fenster bis zur mitte des Bildschrims", 8, 280, 294, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    If FileExists($cfg_file) Then
    FileDelete($cfg_file)
    EndIf
    $state_read_for_File = GUICtrlRead($Checkbox1)
    FileWriteLine(@ScriptDir & "\config.data", $state_read_for_File)
    Exit
    Case $Button1
    GUICtrlSetBkColor($Label2, 0x00FF00)
    $max_state = 1
    Case $Button2
    GUICtrlSetBkColor($Label2, 0xFF0000)
    $max_state = 0
    Case $Button3
    GUICtrlSetBkColor($Label7, 0x00FF00)
    $max_middle_state = 1
    Case $Button4
    GUICtrlSetBkColor($Label7, 0xFF0000)
    $max_middle_state = 0
    Case $menuitem1
    MsgBox(0, "", "")
    EndSwitch
    If $max_state = 1 Then
    _maximize()
    EndIf
    If $max_middle_state = 1 Then
    _max_middle()
    EndIf
    If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then
    HotKeySet("{F1}")
    HotKeySet("{F2}")
    ElseIf GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
    HotKeySet("{F1}", "_hotkey_an")
    HotKeySet("{F2}", "_hotkey_aus")
    EndIf
    WEnd

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

    Func _maximize()
    $pos = MouseGetPos()
    If $pos[1] = 0 Or $pos[1] = 1 Or $pos[1] = 2 Then
    $window_active = WinGetTitle("[ACTIVE]", "")
    $state = WinGetState($window_active)
    _rahmen($window_active, 1)
    Sleep(400)
    EndIf
    EndFunc ;==>_maximize

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

    Func _max_middle()
    $pos1 = MouseGetPos()
    If $pos1[0] = 0 Or $pos1[0] = 1 Or $pos1[0] = 2 Then
    $window_active = WinGetTitle("[ACTIVE]", "")
    $state = WinGetState($window_active)
    _rahmen($window_active, 2)
    Sleep(400)
    EndIf
    EndFunc ;==>_max_middle

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

    Func _hotkey_an()
    $max_state = 1
    GUICtrlSetBkColor($Label2, 0x00FF00)
    EndFunc ;==>_hotkey_an

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

    Func _hotkey_aus()
    $max_state = 0
    GUICtrlSetBkColor($Label2, 0xFF0000)
    EndFunc ;==>_hotkey_aus

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

    Func _rahmen($active, $kind)
    If $kind = 1 Then
    $1 = GUICreate("", 2, @DesktopHeight - 60, 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $2 = GUICreate("", @DesktopWidth - 30, 2, 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState(@SW_SHOW)
    $3 = GUICreate("", @DesktopWidth - 20, 2, 10, @DesktopHeight - 50, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState(@SW_SHOW)
    $4 = GUICreate("", 2, @DesktopHeight - 60, @DesktopWidth - 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState(@SW_SHOW)

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

    $mouse = MouseGetPos()
    Sleep(500)
    If $mouse[1] = Not 0 Then
    GUIDelete($1)
    GUIDelete($2)
    GUIDelete($3)
    GUIDelete($4)
    Else
    WinActivate($active)
    WinSetState($active, "", @SW_MAXIMIZE)
    GUIDelete($1)
    GUIDelete($2)
    GUIDelete($3)
    GUIDelete($4)
    EndIf
    ElseIf $kind = 2 Then
    $1 = GUICreate("", 2, @DesktopHeight - 60, 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $2 = GUICreate("", (@DesktopWidth/2) - 30, 2, 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState(@SW_SHOW)
    $3 = GUICreate("", (@DesktopWidth/2) - 20, 2, 10, @DesktopHeight - 50, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState(@SW_SHOW)
    $4 = GUICreate("", 2, @DesktopHeight - 60, (@DesktopWidth/2) - 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW)
    GUISetBkColor(0xFF0000)
    GUISetState(@SW_SHOW)

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

    $mouse1 = MouseGetPos()
    Sleep(600)
    If $mouse1[0] = Not 0 Then
    GUIDelete($1)
    GUIDelete($2)
    GUIDelete($3)
    GUIDelete($4)
    Else
    WinActivate($active)
    WinMove($active,"",0,0,@DesktopWidth /2,@DesktopHeight - 60)
    GUIDelete($1)
    GUIDelete($2)
    GUIDelete($3)
    GUIDelete($4)
    EndIf
    EndIf
    EndFunc ;==>_rahmen

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

    Func _exit()
    Exit
    EndFunc ;==>_exit

    [/autoit]

    Bekannte Bugs:
    Auch wenn die Maus weg ist wird maximiert, wer eine lösung hat bitte posten!

    gruß Simon

    3 Mal editiert, zuletzt von simon (15. April 2010 um 19:30)

  • Ich auch PLS ein Button bsp weil ich kenne mich mit GDI nciht aus hab zwar hier mal ein bsp gepostet aber mehr kann ich nicht
    Oder wäre es schöner mit bilder buttons mit hover?

    gruß Simon

  • Zitat

    Und ich würde davon gern ein Beispielskript sehen :D


    Wenns denn sein muss. :rolleyes:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstants.au3>

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

    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode", 2)

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

    $iGUIWidth = 400
    $iGUIHeight = 400
    $GUIColorBG = 0xFFFFFFFF

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

    $iX_Button1 = 10
    $iY_Button1 = 10
    $iWidth_Button1 = 50
    $iHeight_Button1 = 50

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

    $iX_Button2 = 70
    $iY_Button2 = 10
    $iWidth_Button2 = 50
    $iHeight_Button2 = 50

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

    $sString_Button1 = "1"
    $sString_Button2 = "2"

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

    $hWnd = GUICreate("Test", $iGUIWidth, $iGUIHeight)
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)

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

    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Tahoma")
    $hFont = _GDIPlus_FontCreate($hFamily, 16)

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

    $aInfoString1 = _GDIPlus_GraphicsMeasureString($hBuffer, $sString_Button1, $hFont, _GDIPlus_RectFCreate(), $hFormat)
    $aInfoString2 = _GDIPlus_GraphicsMeasureString($hBuffer, $sString_Button2, $hFont, _GDIPlus_RectFCreate(), $hFormat)

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

    $iStringWidth_Button1 = Ceiling(DllStructGetData($aInfoString1[0], "Width"))
    $iStringHeight_Button1 = Ceiling(DllStructGetData($aInfoString1[0], "Height"))
    $iStringWidth_Button2 = Ceiling(DllStructGetData($aInfoString2[0], "Width"))
    $iStringHeight_Button2 = Ceiling(DllStructGetData($aInfoString2[0], "Height"))

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

    $tLayout_Button1 = _GDIPlus_RectFCreate($iX_Button1 + $iWidth_Button1 / 2 - $iStringWidth_Button1 / 2, $iY_Button1 + $iHeight_Button1 / 2 - $iStringHeight_Button1 / 2)
    $tLayout_Button2 = _GDIPlus_RectFCreate($iX_Button2 + $iWidth_Button2 / 2 - $iStringWidth_Button2 / 2, $iY_Button2 + $iHeight_Button2 / 2 - $iStringHeight_Button2 / 2)

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

    $hBrush_Button1 = _GDIPlus_LineBrushCreate($iX_Button1, $iY_Button1, $iX_Button1 + $iWidth_Button1, $iY_Button1 + $iHeight_Button1, 0xFF00FF00, 0xFF000000)
    $hBrush_Button2 = _GDIPlus_LineBrushCreate($iX_Button2, $iY_Button2, $iX_Button2 + $iWidth_Button2, $iY_Button2 + $iHeight_Button2, 0xFFFF0000, 0xFF000000)
    $hBrushText = _GDIPlus_BrushCreateSolid(0xFF0F0F0F)

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_PDown")

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

    While 1
    _GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
    _GDIPlus_GraphicsFillEllipse($hBuffer, $iX_Button1, $iY_Button1, $iWidth_Button1, $iHeight_Button1, $hBrush_Button1)
    _GDIPlus_GraphicsFillEllipse($hBuffer, $iX_Button2, $iY_Button2, $iWidth_Button2, $iHeight_Button2, $hBrush_Button2)
    _GDIPlus_GraphicsDrawStringEx($hBuffer, $sString_Button1, $hFont, $tLayout_Button1, $hFormat, $hBrushText)
    _GDIPlus_GraphicsDrawStringEx($hBuffer, $sString_Button2, $hFont, $tLayout_Button2, $hFormat, $hBrushText)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
    WEnd

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

    Func _PDown()
    $aMousePos = MouseGetPos()
    If _PointIsInCircle($aMousePos[0], $aMousePos[1], $iX_Button1 + $iWidth_Button1 / 2, $iY_Button1 + $iHeight_Button1 / 2, $iWidth_Button1 / 2) <> -1 Then MsgBox(64, "Info", "Button 1 wurde geklickt")
    If _PointIsInCircle($aMousePos[0], $aMousePos[1], $iX_Button2 + $iWidth_Button2 / 2, $iY_Button2 + $iHeight_Button2 / 2, $iWidth_Button2 / 2) <> -1 Then MsgBox(64, "Info", "Button 2 wurde geklickt")
    EndFunc

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

    Func _PointIsInCircle($iX_Point, $iY_Point, $iX_Circle, $iY_Circle, $iRadius_Circle)
    $iDistPoints = _GetPointsDistance($iX_Point, $iY_Point, $iX_Circle, $iY_Circle)
    If ($iRadius_Circle > 0 And $iDistPoints < $iRadius_Circle) Or ($iRadius_Circle < 0 And $iDistPoints > $iRadius_Circle) Or $iDistPoints = 0 Then Return $iDistPoints
    Return -1
    EndFunc ;==>_PointIsInCircle

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

    Func _GetPointsDistance($iPointX1, $iPointY1, $iPointX2, $iPointY2)
    Return Sqrt(($iPointX1 - $iPointX2) ^ 2 + ($iPointY1 - $iPointY2) ^ 2)
    EndFunc ;==>_GetPointsDistance

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

    Func _Exit()
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BrushDispose($hBrush_Button1)
    _GDIPlus_BrushDispose($hBrush_Button2)
    _GDIPlus_BrushDispose($hBrushText)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GDIPlus_LineBrushCreate
    ; Description ...: Creates a LinearGradientBrush object from a set of boundary points and boundary colors
    ; Syntax.........: _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2[, $iWrapMode = 0])
    ; Parameters ....: $nX1 - X coordinate of the starting point of the gradient. The starting boundary line passes through the
    ; +starting point
    ; $nY1 - Y coordinate of the starting point of the gradient. The starting boundary line passes through the
    ; +starting point
    ; $nX2 - X coordinate of the ending point of the gradient. The ending boundary line passes through the
    ; +ending point
    ; $nY2 - Y coordinate of the ending point of the gradient. The ending boundary line passes through the
    ; +ending point
    ; $iARGBClr1 - Alpha, Red, Green and Blue components of the starting color of the line
    ; $iARGBClr2 - Alpha, Red, Green and Blue components of the ending color of the line
    ; $iWrapMode - Wrap mode that specifies how areas filled with the brush are tiled:
    ; |0 - Tiling without flipping
    ; |1 - Tiles are flipped horizontally as you move from one tile to the next in a row
    ; |2 - Tiles are flipped vertically as you move from one tile to the next in a column
    ; |3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column
    ; |4 - No tiling takes place
    ; Return values .: Success - Pointer to a new LinearGradientBrush object
    ; Failure - 0 and either:
    ; |@error and @extended are set if DllCall failed
    ; |$GDIP_STATUS contains a non zero value specifying the error code
    ; Remarks .......: After you are done with the object, call _GDIPlus_BrushDispose to release the object resources
    ; Related .......: _GDIPlus_BrushDispose
    ; Link ..........; @@MsdnLink@@ GdipCreateLineBrush
    ; Example .......; No
    ; ===============================================================================================================================
    Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0)
    Local $tPointF1, $pPointF1
    Local $tPointF2, $pPointF2
    Local $aResult

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

    $tPointF1 = DllStructCreate("float;float")
    $pPointF1 = DllStructGetPtr($tPointF1)
    $tPointF2 = DllStructCreate("float;float")
    $pPointF2 = DllStructGetPtr($tPointF2)

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

    DllStructSetData($tPointF1, 1, $nX1)
    DllStructSetData($tPointF1, 2, $nY1)
    DllStructSetData($tPointF2, 1, $nX2)
    DllStructSetData($tPointF2, 2, $nY2)

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

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "int*", 0)

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

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[6]
    EndFunc ;==>_GDIPlus_LineBrushCreate

    [/autoit]
  • name22

    schon mal danke aber ich würde gerne Ovale Buttons machen, daher glaube ich das Buttons aus Bildern ein wenig besser sind, später baue ich dann einen hover effekt ein.
    Aber danke dir !
    Ich poste heute noch eine neue Version
    bis dann

    gruß Simon

  • Zitat

    schon mal danke aber ich würde gerne Ovale Buttons machen


    Wo liegt dann das Problem? :P
    Ovale Buttons sind auch möglich, nur funktioniert dann meine _PointIsInCircle Funktion nicht mehr, oder zumindest ist sie nicht mehr genau. ;)
    Also müsstest du mithilfe eines imaginären Rechtecks auf Buttonklicks regieren.

  • Hi name22

    Zitat

    Wo liegt dann das Problem? :P
    Ovale Buttons sind auch möglich, nur funktioniert dann meine _PointIsInCircle Funktion nicht mehr, oder zumindest ist sie nicht mehr genau. ;)
    Also müsstest du mithilfe eines imaginären Rechtecks auf Buttonklicks regieren.

    ???
    Ich habe von GDI Keine ahnung daher verstehe ich null von deiner Aussage

    gruß Simon