WinSetState('','',@sw_maximize) geht nicht wirklich

  • Hi,

    ich habe nen Hotkey, der das aktive fenster MAXIMIZEN soll.
    aber leider geht das nicht.

    code ist:

    [autoit]

    If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinSetState('','',@sw_maximize)

    [/autoit]

    der hotkey funktioniert (springt in die richtige funktion) und dort in die richtige IF-bedingung. wenn ich den hotkey was anderes ausführen lasse (winsettrans) geht es auch,
    nur maximizen geht nicht (immer).

    bei scite funzt das, aber bei autoit help oder excel zB nicht.
    jmd ne ahnung wodran das liegt ?

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

    HotKeySet('1', '_a')
    While 1
    Sleep(1000)
    WEnd

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

    Func _a()
    Local $a = Opt("WinTitleMatchMode", 4)
    Local $b = Opt("WinSearchChildren", 1)
    ToolTip(WinGetTitle('active', ''))
    Sleep(500)
    ToolTip('')
    If WinGetTitle('active', '') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinSetState('active', '', @SW_MAXIMIZE)
    Opt("WinTitleMatchMode", $a)
    Opt("WinSearchChildren", $b)
    EndFunc ;==>_a

    [/autoit]

    Mega

  • thx xeno, habs noch nicht getestet, jedoch ist mir gerade was aufgefallen.
    das es nicht geht, hat mit was anderem zu tun ... warum das so ist, kann ich aber noch nicht sagen.

    und zwar tritt das problem nur auf, wenn ich vorher das jeweile fenster verschoben habe ...

    [autoit]

    $aSize[1][1] = @DesktopWidth
    $aSize[2][1] = @DesktopWidth
    $aSize[1][2] = @DesktopHeight/2
    $aSize[2][2] = @DesktopHeight/2
    $aSize[1][3] = 0
    $aSize[2][3] = 0
    $aSize[1][4] = 0
    $aSize[2][4] = @DesktopHeight/2
    If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove($aSize[1][0], '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)

    [/autoit]

    dann kann ich es übrigens auch nicht mehr manuell am rand packen und vergrößern/-kleinern. und wann das nicht geht, geht auch kein maximieren mehr oO

    wenns geht, würde ich gerne das ändern, weil es schon vorkommt, dass wenn ich das fenster mit nem hotkey verschiebe (anzeige nur noch auf dem halben bildschirm), ich es manuell noch nen ticken kleiner machen muss.

    jmd ne idee wieso das so ist?

  • geht leider auch nicht.
    sobald ich die funktion oben vorher ausgeführt hat, reagiert er nicht mehr auf maximize.

    hier mal der auszug aus dem script zum testen

    Spoiler anzeigen
    [autoit]


    #include <array.au3>

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

    HotKeySet("!{UP}", "_MoveWindowUP")
    HotKeySet("!{DOWN}", "_MoveWindowDOWN")
    HotKeySet("!{LEFT}", "_MoveWindowLEFT")
    HotKeySet("!{RIGHT}", "_MoveWindowRIGHT")
    HotKeySet("!^{F9}", "_MoveWindowMax")

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

    Func _MoveWindowUP()
    _MoveWindow("UP")
    EndFunc
    Func _MoveWindowDOWN()
    _MoveWindow("DOWN")
    EndFunc
    Func _MoveWindowLEFT()
    _MoveWindow("LEFT")
    EndFunc
    Func _MoveWindowRIGHT()
    _MoveWindow("RIGHT")
    EndFunc
    Func _MoveWindowMax()
    _MoveWindow("Max")
    EndFunc

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

    Func _MoveWindow($dummy)
    Local $aSize[3][5] ; [0]=Handle, [1]=Breite, [2]=Höhe, [3]=x, [4]=y
    $aSize[0][1] = @DesktopWidth
    $aSize[0][2] = @DesktopHeight
    If $dummy = "UP" Then
    $aSize[1][1] = @DesktopWidth
    $aSize[2][1] = @DesktopWidth
    $aSize[1][2] = @DesktopHeight/2
    $aSize[2][2] = @DesktopHeight/2
    $aSize[1][3] = 0
    $aSize[2][3] = 0
    $aSize[1][4] = 0
    $aSize[2][4] = @DesktopHeight/2
    If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove($aSize[1][0], '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "DOWN" Then
    $aSize[1][1] = @DesktopWidth
    $aSize[2][1] = @DesktopWidth
    $aSize[1][2] = @DesktopHeight/2
    $aSize[2][2] = @DesktopHeight/2
    $aSize[1][3] = 0
    $aSize[2][3] = 0
    $aSize[1][4] = $aSize[1][2]
    $aSize[2][4] = @DesktopHeight/2
    If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove($aSize[1][0], '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "LEFT" Then
    $aSize[1][1] = @DesktopWidth/2
    $aSize[2][1] = @DesktopWidth/2
    $aSize[1][2] = @DesktopHeight
    $aSize[2][2] = @DesktopHeight
    $aSize[1][3] = 0
    $aSize[2][3] = @DesktopWidth/2
    $aSize[1][4] = 0
    $aSize[2][4] = 0
    If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove($aSize[1][0], '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "RIGHT" Then
    $aSize[1][1] = @DesktopWidth/2
    $aSize[2][1] = @DesktopWidth/2
    $aSize[1][2] = @DesktopHeight
    $aSize[2][2] = @DesktopHeight
    $aSize[1][3] = $aSize[1][1]
    $aSize[2][3] = @DesktopWidth/2
    $aSize[1][4] = 0
    $aSize[2][4] = 0
    If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove($aSize[1][0], '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "Max" Then
    If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinSetState('','',@sw_maximize)
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • habs jetzt so, es geht aber trotzdem nicht, was ist denn jetzt falsch?
    EDIT: es geht schon, wenn ich vorher keine andere funktion ausgeführt habe, das war aber vorher auch, also keine verbesserung zum alten zustand.

    [autoit]

    Func _MoveWindow($dummy)
    Local $aSize[3][5] ; [0]=Handle, [1]=Breite, [2]=Höhe, [3]=x, [4]=y
    Local $a = Opt("WinTitleMatchMode", 4)
    Local $b = Opt("WinSearchChildren", 1)
    $aSize[0][1] = @DesktopWidth
    $aSize[0][2] = @DesktopHeight
    If $dummy = "UP" Then
    $aSize[1][1] = @DesktopWidth
    $aSize[2][1] = @DesktopWidth
    $aSize[1][2] = @DesktopHeight/2
    $aSize[2][2] = @DesktopHeight/2
    $aSize[1][3] = 0
    $aSize[2][3] = 0
    $aSize[1][4] = 0
    $aSize[2][4] = @DesktopHeight/2
    If WinGetTitle('active','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "DOWN" Then
    $aSize[1][1] = @DesktopWidth
    $aSize[2][1] = @DesktopWidth
    $aSize[1][2] = @DesktopHeight/2
    $aSize[2][2] = @DesktopHeight/2
    $aSize[1][3] = 0
    $aSize[2][3] = 0
    $aSize[1][4] = $aSize[1][2]
    $aSize[2][4] = @DesktopHeight/2
    If WinGetTitle('active','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "LEFT" Then
    $aSize[1][1] = @DesktopWidth/2
    $aSize[2][1] = @DesktopWidth/2
    $aSize[1][2] = @DesktopHeight
    $aSize[2][2] = @DesktopHeight
    $aSize[1][3] = 0
    $aSize[2][3] = @DesktopWidth/2
    $aSize[1][4] = 0
    $aSize[2][4] = 0
    If WinGetTitle('active','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "RIGHT" Then
    $aSize[1][1] = @DesktopWidth/2
    $aSize[2][1] = @DesktopWidth/2
    $aSize[1][2] = @DesktopHeight
    $aSize[2][2] = @DesktopHeight
    $aSize[1][3] = $aSize[1][1]
    $aSize[2][3] = @DesktopWidth/2
    $aSize[1][4] = 0
    $aSize[2][4] = 0
    If WinGetTitle('active','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    ElseIf $dummy = "Max" Then
    If WinGetTitle('active', '') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinSetState('active', '', @SW_MAXIMIZE);If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinSetState('','',@sw_maximize)
    EndIf
    Opt("WinTitleMatchMode", $a)
    Opt("WinSearchChildren", $b)
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Hallo,

    bevor man ein maximiertes Fenster mit WinMove ändert sollt man ein @SW_RESTORE machen!


    Spoiler anzeigen
    [autoit]

    #include <array.au3>

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

    HotKeySet("!{UP}", "_MoveWindowUP")
    HotKeySet("!{DOWN}", "_MoveWindowDOWN")
    HotKeySet("!{LEFT}", "_MoveWindowLEFT")
    HotKeySet("!{RIGHT}", "_MoveWindowRIGHT")
    HotKeySet("!^{F9}", "_MoveWindowMax")

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

    While True
    Sleep(500)
    WEnd

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

    Func _MoveWindowUP()
    _MoveWindow("UP")
    EndFunc ;==>_MoveWindowUP
    Func _MoveWindowDOWN()
    _MoveWindow("DOWN")
    EndFunc ;==>_MoveWindowDOWN
    Func _MoveWindowLEFT()
    _MoveWindow("LEFT")
    EndFunc ;==>_MoveWindowLEFT
    Func _MoveWindowRIGHT()
    _MoveWindow("RIGHT")
    EndFunc ;==>_MoveWindowRIGHT
    Func _MoveWindowMax()
    _MoveWindow("Max")
    EndFunc ;==>_MoveWindowMax

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

    Func _MoveWindow($dummy)
    Local $aSize[3][5] ; [0]=Handle, [1]=Breite, [2]=Höhe, [3]=x, [4]=y
    Local $a = Opt("WinTitleMatchMode", 4)
    Local $b = Opt("WinSearchChildren", 1)
    $aSize[0][1] = @DesktopWidth
    $aSize[0][2] = @DesktopHeight

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

    Switch $dummy

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

    Case "UP"
    $aSize[1][1] = @DesktopWidth
    $aSize[2][1] = @DesktopWidth
    $aSize[1][2] = @DesktopHeight / 2
    $aSize[2][2] = @DesktopHeight / 2
    $aSize[1][3] = 0
    $aSize[2][3] = 0
    $aSize[1][4] = 0
    $aSize[2][4] = @DesktopHeight / 2
    If WinGetTitle('active', '') <> "WinSetOnTop - Set active Window with F9 on Top" Then
    If BitAND(WinGetState('active', ''), 32) = 32 Then WinSetState('active', '', @SW_RESTORE)
    WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    EndIf

    Case "DOWN"
    $aSize[1][1] = @DesktopWidth
    $aSize[2][1] = @DesktopWidth
    $aSize[1][2] = @DesktopHeight / 2
    $aSize[2][2] = @DesktopHeight / 2
    $aSize[1][3] = 0
    $aSize[2][3] = 0
    $aSize[1][4] = $aSize[1][2]
    $aSize[2][4] = @DesktopHeight / 2
    If WinGetTitle('active', '') <> "WinSetOnTop - Set active Window with F9 on Top" Then
    If BitAND(WinGetState('active', ''), 32) = 32 Then WinSetState('active', '', @SW_RESTORE)
    WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    EndIf

    Case "LEFT"
    $aSize[1][1] = @DesktopWidth / 2
    $aSize[2][1] = @DesktopWidth / 2
    $aSize[1][2] = @DesktopHeight
    $aSize[2][2] = @DesktopHeight
    $aSize[1][3] = 0
    $aSize[2][3] = @DesktopWidth / 2
    $aSize[1][4] = 0
    $aSize[2][4] = 0
    If WinGetTitle('active', '') <> "WinSetOnTop - Set active Window with F9 on Top" Then
    If BitAND(WinGetState('active', ''), 32) = 32 Then WinSetState('active', '', @SW_RESTORE)
    WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    EndIf

    Case "RIGHT"
    $aSize[1][1] = @DesktopWidth / 2
    $aSize[2][1] = @DesktopWidth / 2
    $aSize[1][2] = @DesktopHeight
    $aSize[2][2] = @DesktopHeight
    $aSize[1][3] = $aSize[1][1]
    $aSize[2][3] = @DesktopWidth / 2
    $aSize[1][4] = 0
    $aSize[2][4] = 0
    If WinGetTitle('active', '') <> "WinSetOnTop - Set active Window with F9 on Top" Then
    If BitAND(WinGetState('active', ''), 32) = 32 Then WinSetState('active', '', @SW_RESTORE)
    WinMove('active', '', $aSize[1][3], $aSize[1][4], $aSize[1][1], $aSize[1][2] - 25)
    EndIf

    Case "Max"
    If WinGetTitle('active', '') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinSetState('active', '', @SW_MAXIMIZE);If WinGetTitle('','') <> "WinSetOnTop - Set active Window with F9 on Top" Then WinSetState('','',@sw_maximize)

    EndSwitch

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

    Opt("WinTitleMatchMode", $a)
    Opt("WinSearchChildren", $b)
    EndFunc ;==>_MoveWindow

    [/autoit]