Sign in to follow this  
Followers 0
nf67

Resais

1 post in this topic

Posted Image

Click the image to download the .exe (32-bit) or take the 64-bit version.

Source:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Misc.au3>
#NoTrayIcon

If _Singleton("Resais",1) = 0 Then
     MsgBox(0,"RESAIS","RESAIS is already running.")
     Exit
EndIf

;=================TRAY==================
Opt("TrayMenuMode",1)

$HelpItem = TrayCreateItem("Help")
TrayCreateItem("")
$OptionsItem = TrayCreateItem("Options")
TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")

TraySetState()
;=================VARIABLES==============
$W = @DesktopWidth
$H = @DesktopHeight

$HW = @DesktopWidth / 2
$HH = @DesktopHeight / 2

If FileExists(@ScriptDir & "\Settings.conf") = 0 Then
    $WBorderCorrect = FileReadLine(@ScriptDir & "\Settings.conf" ,1)
    $HBorderCorrect = FileReadLine(@ScriptDir & "\Settings.conf" ,2)
Else
    $WBorderCorrect = 0
    $HBorderCorrect = 0
EndIf

$Old = "[active]"

$DeleteFailed = 0
$Changed = 1
;========================================

;=================HOTKEYS================

;CORNERS
HotKeySet("{NUMPAD7}", "TopLeft")
HotKeySet("{NUMPAD9}", "TopRight")
HotKeySet("{NUMPAD1}", "BottomLeft")
HotKeySet("{NUMPAD3}", "BottomRight")
    ;ctrl (no resize)
HotKeySet("^{NUMPAD7}", "TopLeft")
HotKeySet("^{NUMPAD9}", "TopRight")
HotKeySet("^{NUMPAD1}", "BottomLeft")
HotKeySet("^{NUMPAD3}", "BottomRight")
    ;alt (use previous window)
HotKeySet("!{NUMPAD7}", "TopLeft")
HotKeySet("!{NUMPAD9}", "TopRight")
HotKeySet("!{NUMPAD1}", "BottomLeft")
HotKeySet("!{NUMPAD3}", "BottomRight")
    ;ctrl + alt (use previous window without resize)
HotKeySet("^!{NUMPAD7}", "TopLeft")
HotKeySet("^!{NUMPAD9}", "TopRight")
HotKeySet("^!{NUMPAD1}", "BottomLeft")
HotKeySet("^!{NUMPAD3}", "BottomRight")

;TOP & BOTTOM
HotKeySet("{NUMPAD8}", "Top")
HotKeySet("{NUMPAD2}", "Bottom")
    ;alt (use previous window)
HotKeySet("!{NUMPAD8}", "Top")
HotKeySet("!{NUMPAD2}", "Bottom")

;LEFT & RIGHT
HotKeySet("{NUMPAD4}", "Left")
HotKeySet("{NUMPAD6}", "Right")
    ;alt (use previous window)
HotKeySet("!{NUMPAD4}", "Left")
HotKeySet("!{NUMPAD6}", "Right")

;FULL & MINIMIZE
HotKeySet("{NUMPAD5}", "Full")
HotKeySet("{NUMPAD0}", "Minimize")
    ;alt (use previous window)
HotKeySet("!{NUMPAD5}", "Full")
HotKeySet("!{NUMPAD0}", "Minimize")

;========================================

While 1
    $Event = TrayGetMsg()
    Select
    Case $Event = 0
    ContinueLoop
    Case $Event = $HelpItem
    Msgbox(0, "RESAIS Help", "Use the numpad keys to move windows around, make sure NumLock is on." & @CRLF & _
                    "Hold down Ctrl to prevent resizing. Problems? Try the (advanced) options!" & @CRLF & _
                    "Hold down Alt to move the previously moved windows instead of the active one.")
    Case $Event = $OptionsItem
    Options()
    Case $Event = $ExitItem
    Exit
    EndSelect
WEnd

;=================FUNCTIONS==============

;CORNERS
Func TopLeft()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    If _IsPressed("11")=1 Then
        WinMove($Window,"",0,0)
    Else
        WinMove($Window,"",0,0,$HW,$HH)
    EndIf
    $Old = WinGetHandle($Window)
EndFunc

Func TopRight()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    If _IsPressed("11")=1 Then
        $Size = WinGetPos($Window)
        WinMove($Window,"",$W-$Size[2]+$WBorderCorrect,0)
    Else
        WinMove($Window,"",$HW,0,$HW,$HH)
    EndIf
    $Old = WinGetHandle($Window)
EndFunc

Func BottomLeft()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    If _IsPressed("11")=1 Then
        $Size = WinGetPos($Window)
        WinMove($Window,"",0,$H-$Size[3]+$HBorderCorrect)
    Else
        WinMove($Window,"",0,$HH,$HW,$HH)
    EndIf
    $Old = WinGetHandle($Window)
EndFunc

Func BottomRight()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    If _IsPressed("11")=1 Then
        $Size = WinGetPos($Window)
        WinMove($Window,"",$W-$Size[2]+$WBorderCorrect,$H-$Size[3]+$HBorderCorrect)
    Else
        WinMove($Window,"",$HW,$HH,$HW,$HH)
    EndIf
    $Old = WinGetHandle($Window)
EndFunc

;TOP & BOTTOM
Func Top()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    WinMove($Window,"",0,0,$W,$HH)
    $Old = WinGetHandle($Window)
EndFunc

Func Bottom()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    WinMove($Window,"",0,$HH,$W,$HH)
    $Old = WinGetHandle($Window)
EndFunc

;LEFT & RIGHT
Func Left()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    WinMove($Window,"",0,0,$HW,$H)
    $Old = WinGetHandle($Window)
EndFunc

Func Right()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    If BitAnd(WinGetState($Window), 16) = 16 Then
        WinSetState($Window, "", @SW_Restore)
    EndIf

    WinMove($Window,"",$HW,0,$HW,$H)
    $Old = WinGetHandle($Window)
EndFunc

;FULL & MINIMIZE
Func Full()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf

    WinSetState($Window,"",@SW_Restore) ;Workaround, otherwise @SW_MAXIMIZE won't work.
    WinSetState($Window,"", @SW_MAXIMIZE)
    $Old = WinGetHandle($Window)
EndFunc

Func Minimize()
    If _IsPressed("12") Then
        $Window = $Old
    Else
        $Window = "[active]"
    EndIf
    $Old = WinGetHandle($Window)
    WinSetState($Window,"", @SW_MINIMIZE)
EndFunc
;========================================

;===============OPTIONS==================
Func Options()
    $GUI = GUICreate("", 120, 75, @DesktopWidth/2 - 60, @DesktopHeight/2 - 37.5)
    $WCorrectL = GUICtrlCreateLabel("Hor. Correct", 0, 8, 60, 17)
    $WCorrectI = GUICtrlCreateInput("0", 60, 5, 60, 20, $ES_Number)
    $HCorrectL = GUICtrlCreateLabel("Ver. Correct", 0, 33, 60, 17)
    $HCorrectI = GUICtrlCreateInput("0", 60, 30, 60, 20, $ES_Number)

    $ApplyB = GUICtrlCreateButton("Apply", 0, 55, 120, 20)

    If FileExists(@ScriptDir & "\Settings.conf") Then
        GUICtrlSetData($WCorrectI, FileReadLine(@ScriptDir & "\Settings.conf",1))
        GUICtrlSetData($HCorrectI, FileReadLine(@ScriptDir & "\Settings.conf",2))
    EndIf

    GUISetState(@SW_SHOW)


    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($GUI)
                ExitLoop
            Case $ApplyB
                If GUICtrlRead($WCorrectI) = "0" or GUICtrlRead($WCorrectI) = "" Then
                    If GuiCtrlRead($HCorrectI) = "0" or GuiCtrlRead($HCorrectI) = "" Then
                        $Changed = 0
                    EndIf
                EndIf

                If $Changed = 0 Then
                    $WBorderCorrect = GUICtrlRead($WCorrectI)
                    $HBorderCorrect = GUICtrlRead($HCorrectI)
                    If FileExists(@ScriptDir & "\Settings.conf") Then
                        $Delete = FileDelete(@ScriptDir & "\Settings.conf")
                        If $Delete = 0 Then
                            MsgBox(0,"Error","Settings.conf couldn't be deleted, but you can do this yourself if you want. If not, your old settings will be loaded next restart.")
                        EndIf
                    EndIf
                Else

                    If FileExists(@ScriptDir & "\Settings.conf") Then
                        $Delete = FileDelete(@ScriptDir & "\Settings.conf")
                        If $Delete = 0 Then
                            $DeleteFailed = 1
                            MsgBox(0,"Error","Couldn't delete the old Settings.conf, changes will not be applied.")
                        EndIf
                    EndIf

                    If $DeleteFailed = 0 Then
                        $Write = FileWrite(@ScriptDir & "\Settings.conf", GUICtrlRead($WCorrectI) & @CRLF & GUICtrlRead($HCorrectI))
                        If $Write = 0 Then
                            MsgBox(0,"Error","Couldn't generate your new Settings.conf, changes will not be applied.")
                        Else
                            $WBorderCorrect = GUICtrlRead($WCorrectI)
                            $HBorderCorrect = GUICtrlRead($HCorrectI)
                            MsgBox(0,"Success","Because you now use modified settings, a file called Settings.conf has been generated. Change the values back to 0 in order to revert to the default.")
                        EndIf
                    EndIf

                EndIf

                $Changed = 1
                $DeleteFailed = 0
        EndSwitch
    WEnd
EndFunc
;========================================

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0