Skip to content

Commit

Permalink
Merge pull request #7 from martinsmith1968/feature/auto-save-window-p…
Browse files Browse the repository at this point in the history
…ositions_and_desktop_icons

Feature/auto save window positions and desktop icons
  • Loading branch information
martinsmith1968 authored Jan 8, 2020
2 parents 64619cd + 2084763 commit fdb465b
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 33 deletions.
Binary file modified Docs/ConfigurationDialog1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/ConfigurationDialog2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/ConfigurationDialog3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/ConfigurationDialog4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/ConfigurationDialog5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion Docs/releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Release Notes

## v1.6.2 - 2020-01-05
## v1.6.3 - 2020-01-08

- Auto-Save Window Positions on a schedule
- Auto-Save Desktop Icons on a schedule

## v1.6.2 - 2020-01-07

- Redesigned Configuration dialog to tabbed dialog
- Reformatted user options data file to have values in appropriate sections
Expand Down
6 changes: 2 additions & 4 deletions Docs/todo.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# To Do

- History list of Saved Window Positions
- History list of Saved Desktop Icon Positions
- Support History of Saved Window Positions
- Support History of Saved Desktop Icon Positions
- Add icons to other context menu items
- Auto-Save Window Positions on a schedule
- Auto-Save Desktop Icons on a schedule

## Bugs

Expand Down
17 changes: 10 additions & 7 deletions Lib/DesktopIcons.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ HasIconMoved(icon1, icon2)
}

;--------------------------------------------------------------------------------
SaveDesktopIcons()
SaveDesktopIcons(notify)
{
desktop := new Desktop()
if (!desktop.IsValid)
Expand Down Expand Up @@ -186,13 +186,16 @@ SaveDesktopIcons()

LogText("DesktopIcons: " . saveCount . " icons written to " . fileName)

notifyText := "No Desktop Icons saved"
If saveCount > 0
{
notifyText := saveCount . " Desktop Icons saved"
if (notify)
{
notifyText := "No Desktop Icons saved"
If saveCount > 0
{
notifyText := saveCount . " Desktop Icons saved"
}

new PleasantNotify("Desktop Icons", notifyText, 250, 100, "b r")
}

new PleasantNotify("Desktop Icons", notifyText, 250, 100, "b r")
}

;--------------------------------------------------------------------------------
Expand Down
15 changes: 9 additions & 6 deletions Lib/WindowPositions.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ HasWindowMoved(window1, window2)

;--------------------------------------------------------------------------------
; SaveWindowPositions - Save all the current window positions to a file
SaveWindowPositions(includeOffScreenWindows)
SaveWindowPositions(includeOffScreenWindows, notify)
{
desktopSize := GetDesktopSize()

Expand Down Expand Up @@ -174,13 +174,16 @@ SaveWindowPositions(includeOffScreenWindows)

LogText("WindowPositions: " . saveCount . " windows written to " . fileName)

notifyText := "No Window Positions saved"
If saveCount > 0
if (notify)
{
notifyText := saveCount . " Window Positions saved"
}
notifyText := "No Window Positions saved"
If saveCount > 0
{
notifyText := saveCount . " Window Positions saved"
}

new PleasantNotify("Window Positions", notifyText, 250, 100, "b r")
new PleasantNotify("Window Positions", notifyText, 250, 100, "b r")
}
}

;--------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ A Configuration dialog, available from the tray icon, allows controlling some as

![Configuration Dialog Tab 4](Docs/ConfigurationDialog4.png)

![Configuration Dialog Tab 5](Docs/ConfigurationDialog5.png)

## Features

### Optimum Positioning
Expand Down
2 changes: 1 addition & 1 deletion Setup/WindowMenu_Setup.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define AppName "WindowExtensions"
#define AppTitle "Window Extensions"
#define AppVersion "1.6.2"
#define AppVersion "1.6.3"

[Setup]
AppName={#AppName}
Expand Down
3 changes: 2 additions & 1 deletion WindowExtensions.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AppDescription := "Window Extensions Menu and HotKeys"
AppCopyright := "Copyright © 2020 Martin Smith"
AppNotes := "Concise and consistent control over Window Positions. Right-click right half of Window Caption bar to invoke, or hit WinKey-W"
AppURL := "https://github.com/martinsmith1968/WindowExtensions"
AppVersion := "1.6.2.0"
AppVersion := "1.6.3.0"

;--------------------------------------------------------------------------------
; Includes
Expand Down Expand Up @@ -124,4 +124,5 @@ OnUserConfigUpdated()
{
BuildWindowMenu()
BuildTrayMenu()
WindowExtensionsUserConfig_OnConfigUpdated()
}
186 changes: 185 additions & 1 deletion WindowExtensionsUserConfig.ahk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#Include Lib\Logging.ahk
#Include Lib\UserConfig.ahk

MenuLocationNone := 0
Expand All @@ -9,6 +10,11 @@ MenuLocationItems := []

MenuLocationValues := []

WindowPositions_TimerEnabled := false
WindowPositions_TimerIntervalMinutes := 0
DesktopIcons_TimerEnabled := false
DesktopIcons_TimerIntervalMinutes := 0

;--------------------------------------------------------------------------------
; Initialisation
WindowExtensionsUserConfig_OnInit()
Expand All @@ -21,6 +27,11 @@ WindowExtensionsUserConfig_OnInit()
global MenuLocationItems
global MenuLocationValues

global WindowPositions_TimerEnabled
global WindowPositions_TimerIntervalMinutes
global DesktopIcons_TimerEnabled
global DesktopIcons_TimerIntervalMinutes

MenuLocationNone := 0
MenuLocationWindowMenu := 1
MenuLocationTrayMenu := 2
Expand All @@ -38,6 +49,11 @@ WindowExtensionsUserConfig_OnInit()
MenuLocationValues.push(MenuLocationTrayMenu)
MenuLocationValues.push(MenuLocationAll)

WindowPositions_TimerEnabled := false
WindowPositions_TimerIntervalMinutes := 0
DesktopIcons_TimerEnabled := false
DesktopIcons_TimerIntervalMinutes := 0

UserConfig_OnInit()
}

Expand All @@ -55,8 +71,92 @@ WindowExtensionsUserConfig_OnStartup()
{
RestoreWindowPositions(G_UserConfig.WindowPositions_IncludeOffScreenWindows)
}

WindowExtensionsUserConfig_OnConfigUpdated()
}

;--------------------------------------------------------------------------------
; OnConfigUpdated
WindowExtensionsUserConfig_OnConfigUpdated()
{
global G_UserConfig

WindowPositionsConfigureTimer(G_UserConfig.WindowPositions_AutoSave, G_UserConfig.WindowPositions_AutoSaveIntervalMinutes)
DesktopIconsConfigureTimer(G_UserConfig.DesktopIcons_AutoSave, G_UserConfig.DesktopIcons_AutoSaveIntervalMinutes)
}

;--------------------------------------------------------------------------------
; WindowPositionsConfigureTimer - Configure the timer
WindowPositionsConfigureTimer(enabled, intervalMinutes)
{
global WindowPositions_TimerEnabled
global WindowPositions_TimerIntervalMinutes

if (enabled = WindowPositions_TimerEnabled && intervalMinutes = WindowPositions_TimerIntervalMinutes)
{
return
}

LogText("Deleting WindowPositionsAutoSave_OnTimer")
Try SetTimer, WindowPositionsAutoSave_OnTimer, Delete

if (enabled)
{
milliseconds := (intervalMinutes * 60) * 1000

LogText("Setting WindowPositionsAutoSave_OnTimer for : " . milliseconds)
SetTimer, WindowPositionsAutoSave_OnTimer, %milliseconds%
}
}

;--------------------------------------------------------------------------------
; DesktopIconsConfigureTimer - Configure the timer
DesktopIconsConfigureTimer(enabled, intervalMinutes)
{
global DesktopIcons_TimerEnabled
global DesktopIcons_TimerIntervalMinutes

if (enabled = DesktopIcons_TimerEnabled && intervalMinutes = DesktopIcons_TimerIntervalMinutes)
{
return
}

LogText("Deleting DesktopIconsAutoSave_OnTimer")
Try SetTimer, DesktopIconsAutoSave_OnTimer, Delete

if (enabled)
{
milliseconds := (intervalMinutes * 60) * 1000

LogText("Setting DesktopIconsAutoSave_OnTimer for : " . milliseconds)
SetTimer, DesktopIconsAutoSave_OnTimer, %milliseconds%
}
}

;--------------------------------------------------------------------------------
; WindowPositionsAutoSave_OnTimer - Timer execute
WindowPositionsAutoSave_OnTimer()
{
global G_UserConfig

LogText("Executing: " . A_ThisFunc)

SaveWindowPositions(G_UserConfig.WindowPositions_IncludeOffScreenWindows, G_UserConfig.WindowPositions_AutoSaveNotify)
}

;--------------------------------------------------------------------------------
; DesktopIconsAutoSave_OnTimer - Timer execute
DesktopIconsAutoSave_OnTimer()
{
global G_UserConfig

LogText("Executing: " . A_ThisFunc)

SaveDesktopIcons(G_UserConfig.DesktopIcons_AutoSaveNotify)
}

;--------------------------------------------------------------------------------
; WindowExtensionsUserConfig class
class WindowExtensionsUserConfig extends UserConfig
{
Default_About_Version := ""
Expand All @@ -69,6 +169,12 @@ Default_Startup_RestoreWindowPositions := false
Default_MenuControl_WindowPositionsMenuLocation := 0
Default_MenuControl_DesktopIconsMenuLocation := 0
Default_WindowPositions_IncludeOffScreenWindows := false
Default_WindowPositions_AutoSave := false
Default_WindowPositions_AutoSaveIntervalMinutes := 5
Default_WindowPositions_AutoSaveNotify := false
Default_DesktopIcons_AutoSave := false
Default_DesktopIcons_AutoSaveIntervalMinutes := 5
Default_DesktopIcons_AutoSaveNotify := false

InitDefaults()
{
Expand Down Expand Up @@ -100,6 +206,12 @@ Default_WindowPositions_IncludeOffScreenWindows := false
this.Properties.push("MenuControl_WindowPositionsMenuLocation")
this.Properties.push("MenuControl_DesktopIconsMenuLocation")
this.Properties.push("WindowPositions_IncludeOffScreenWindows")
this.Properties.push("WindowPositions_AutoSave")
this.Properties.push("WindowPositions_AutoSaveIntervalMinutes")
this.Properties.push("WindowPositions_AutoSaveNotify")
this.Properties.push("DesktopIcons_AutoSave")
this.Properties.push("DesktopIcons_AutoSaveIntervalMinutes")
this.Properties.push("DesktopIcons_AutoSaveNotify")

this.ObsoleteProperties.push("General_RestoreDesktopIconsOnStartup")
this.ObsoleteProperties.push("General_RestoreWindowPositionsOnStartup")
Expand Down Expand Up @@ -234,4 +346,76 @@ Default_WindowPositions_IncludeOffScreenWindows := false
base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), value)
}
}
}

WindowPositions_AutoSave
{
get
{
return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_WindowPositions_AutoSave, "boolean")
}
set
{
base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), value)
}
}

WindowPositions_AutoSaveIntervalMinutes
{
get
{
return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_WindowPositions_AutoSaveIntervalMinutes, "integer")
}
set
{
base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), value)
}
}

WindowPositions_AutoSaveNotify
{
get
{
return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_WindowPositions_AutoSaveNotify, "boolean")
}
set
{
base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), value)
}
}

DesktopIcons_AutoSave
{
get
{
return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_DesktopIcons_AutoSave, "boolean")
}
set
{
base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), value)
}
}

DesktopIcons_AutoSaveIntervalMinutes
{
get
{
return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_DesktopIcons_AutoSaveIntervalMinutes, "integer")
}
set
{
base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), value)
}
}

DesktopIcons_AutoSaveNotify
{
get
{
return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_DesktopIcons_AutoSaveNotify, "boolean")
}
set
{
base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), value)
}
}
}
Loading

0 comments on commit fdb465b

Please sign in to comment.