├── .editorconfig ├── Wintermelon_demo.jpg ├── Screen_unlock_Extend_display_Restore_window.xml ├── Screen_lock_Save_window_position_Clone_display.xml ├── Wintermelon.csproj ├── uninstall_wintermelon.ps1 ├── Wintermelon.sln ├── install_wintermelon.ps1 ├── .gitattributes ├── README.md ├── .gitignore ├── Program.cs └── LICENSE /.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root = true 3 | 4 | [*] 5 | end_of_line = lf 6 | -------------------------------------------------------------------------------- /Wintermelon_demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ilovefreesw/Wintermelon/HEAD/Wintermelon_demo.jpg -------------------------------------------------------------------------------- /Screen_unlock_Extend_display_Restore_window.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ilovefreesw/Wintermelon/HEAD/Screen_unlock_Extend_display_Restore_window.xml -------------------------------------------------------------------------------- /Screen_lock_Save_window_position_Clone_display.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ilovefreesw/Wintermelon/HEAD/Screen_lock_Save_window_position_Clone_display.xml -------------------------------------------------------------------------------- /Wintermelon.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | true 8 | true 9 | win-x64 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /uninstall_wintermelon.ps1: -------------------------------------------------------------------------------- 1 | #Requires -RunAsAdministrator 2 | 3 | # PowerShell script to unregister Wintermelon with Windows Task Scheduler 4 | # in admin mode 5 | $task1 = "Wintermelon screen lock save window position clone display" 6 | $task2 = "Wintermelon screen unlock extend display restore window" 7 | 8 | # Unregister task1 with Task Scheduler 9 | Write-Host "Removing task 1 - Wintermelon screen lock save window position clone display..." 10 | if ($(Get-ScheduledTask -TaskName $task1 -ErrorAction SilentlyContinue).TaskName -eq $task1) { 11 | Unregister-ScheduledTask -TaskName $task1 -Confirm:$false 12 | } else { 13 | Write-Host "No such task exists." 14 | } 15 | 16 | 17 | 18 | # Unregister task2 with Task Scheduler 19 | Write-Host "Removing task 2 - Wintermelon screen unlock extend display restore window..." 20 | if ($(Get-ScheduledTask -TaskName $task2 -ErrorAction SilentlyContinue).TaskName -eq $task2) { 21 | Unregister-ScheduledTask -TaskName $task2 -Confirm:$false 22 | } else { 23 | Write-Host "No such task exists." 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Wintermelon.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30204.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wintermelon", "Wintermelon.csproj", "{39465C18-3060-49FF-B682-A14875CFDFFF}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {39465C18-3060-49FF-B682-A14875CFDFFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {39465C18-3060-49FF-B682-A14875CFDFFF}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {39465C18-3060-49FF-B682-A14875CFDFFF}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {39465C18-3060-49FF-B682-A14875CFDFFF}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {02097D8C-38D0-43F1-8BCF-43BFACDE7D4C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /install_wintermelon.ps1: -------------------------------------------------------------------------------- 1 | #Requires -RunAsAdministrator 2 | 3 | # PowerShell script to register Wintermelon with Windows Task Scheduler 4 | # by running the command below in PowerShell terminal launched in admin mode 5 | # powershell -File "Path to this script" 6 | 7 | # Step 1: Enable audit of lock/unlock eventIDs 4800, 4801 using secpol.msc 8 | # Windows search -> Local Security Policy (secpol.msc) 9 | # -> Advanced Audit Policy Configuration 10 | # -> System Audit Policies - Local Group Policy Object 11 | # -> Logon/Logoff 12 | # -> Audit Other Logon/Logoff Events = Success 13 | # Step 2: Set up scheduled tasks using template XML files for lock/unlock event 14 | 15 | 16 | # Step 1 17 | # auditpol /set /subcategory:"Other Logon/Logoff Events" /success:enable /failure:enable 18 | auditpol /set /subcategory:{0CCE921C-69AE-11D9-BED3-505054503030} /success:enable /failure:enable 19 | 20 | # Step 2 21 | $scriptdir = Split-Path -Parent $PSCommandPath 22 | $xml1 = $scriptdir + "\Screen_lock_Save_window_position_Clone_display.xml" 23 | $xml2 = $scriptdir + "\Screen_unlock_Extend_display_Restore_window.xml" 24 | $user = "$env:USERDOMAIN\$env:USERNAME" 25 | $timestamp = Get-Date -format s 26 | 27 | # Customize XML1 and then register with Task Scheduler 28 | [xml]$schtask1 = Get-Content $xml1 29 | $schtask1.Task.RegistrationInfo.Date = $timestamp.ToString() 30 | $schtask1.Task.RegistrationInfo.Author = $user 31 | $schtask1.Task.Principals.Principal.UserId = $user 32 | $schtask1.Task.Actions.Exec.Command = $scriptdir + "\bin\Release\netcoreapp3.1\publish\Wintermelon.exe" 33 | $schtask1.Save($xml1) 34 | Write-Host "Setting up task 1 - Wintermelon screen lock save window position clone display..." 35 | Register-ScheduledTask -Xml (Get-Content $xml1 | Out-String) -TaskName "Wintermelon screen lock save window position clone display" -User $user 36 | 37 | # Customize XML2 and then register with Task Scheduler 38 | [xml]$schtask2 = Get-Content $xml2 39 | $schtask2.Task.RegistrationInfo.Date = $timestamp.ToString() 40 | $schtask2.Task.RegistrationInfo.Author = $user 41 | $schtask2.Task.Principals.Principal.UserId = $user 42 | $schtask2.Task.Actions.Exec.Command = $scriptdir + "\bin\Release\netcoreapp3.1\publish\Wintermelon.exe" 43 | $schtask2.Save($xml2) 44 | Write-Host "Setting up task 2 - Wintermelon screen unlock extend display restore window..." 45 | Register-ScheduledTask -Xml (Get-Content $xml2 | Out-String) -TaskName "Wintermelon screen unlock extend display restore window" -User $user 46 | 47 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wintermelon 2 | ***Wintermelon*** is a C# console app-based workaround that emulates dual/multi monitor lockscreen feature in Windows 10/11. The ability to duplicate lockscreen existed until Windows 7 but Windows 10 & 11 have chosen to forgo this feature by displaying the lockscreen only on primary (or main) display while the secondary (or non-main) displays go black. 3 | 4 | The name ***Wintermelon*** is an acronym with 2 possible expansions: 5 | 6 | - **WIN**dows **T**en & **E**leven **R**endering of **M**irrored **E**vent-triggered **L**ockscreens **O**n **N**on-main displays 7 | 8 | - **WIN**dows **T**en & **E**leven **R**estorer of **M**ultiple **E**quivalent **L**ockscreens **O**n **N**on-main displays 9 | 10 | Here's a demo showing Wintermelon in action on Windows 11: 11 | ![Dual lockscreen on laptop screen and external display implemented on a Win11 machine using Wintermelon](Wintermelon_demo.jpg "Dual lockscreen using Wintermelon") 12 | 13 | 14 | ## How it works ## 15 | In Windows 10 & 11, lockscreen will appear on multiple displays only if the display projection mode (accessed by pressing Win+P hotkey) is set to "Duplicate". Most users will typically use primary/secondary (main/non-main) monitors in "Extend" mode to multitask between various opened application windows. Wintermelon sets up a scheduled task that monitors for lock/unlock events. When a lock event is detected the projection mode is switched to "Duplicate" which will replicate the main display's lockscreen across all non-main displays and when an unlock event is triggered the projection mode will revert to "Extend" mode. 16 | Before switching to "Duplicate" mode the position of opened application windows on the desktop are recorded since the duplication of displays will cause all windows to move over to the primary/main display. When reverting to "Extend" mode following the unlock event the recorded positions are retrieved and used to reposition/restore the application windows to their original state. 17 | 18 | 19 | ## Requirements ## 20 | Wintermelon is a C# project relying on .NET Core 3.1 and it was originally developed on & for Windows 10 using Visual Studio 2019. 21 | 22 | To build Wintermelon executable you'll need: 23 | 24 | 1) [.NET Core SDK 3.1](https://dotnet.microsoft.com/en-us/download/dotnet/3.1) 25 | 26 | 2) [Visual Studio IDE](https://visualstudio.microsoft.com/vs/older-downloads/) 27 | 28 | 3) Windows PC 29 | 30 | To test and install Wintermelon you'll need: 31 | 32 | 1) Windows 10 or Windows 11 PC 33 | 34 | 2) .NET Core Runtime 3.1 35 | 36 | 3) PowerShell 37 | 38 | 4) Lockscreen enabled via *Personalize* settings menu 39 | 40 | The installer for the C# executable is a PowerShell script which will need to be executed by running it within a PowerShell terminal launched using administrator mode. 41 | 42 | 43 | ## Lockscreen personalization settings ## 44 | To enable lockscreen for primary display in Windows 10 & 11: 45 | 46 | 1) Right click on desktop and choose *Personalize*. 47 | 48 | 2) Search for *Lock screen* setting. Choose appropriate lockscreen background. Pick *Windows spotlight* for background if you want Windows to dynamically update lockscreen background. 49 | 50 | 3) In Windows 11, turn on the option *Show the lock screen background picture on the sign-in screen*. 51 | 52 | 4) Go to *Screen timeout settings* and set the sleep setting *When plugged in, turn off after* to *Never* if you don't want the lockscreen to timeout. 53 | 54 | 5) When doing a sign-in the lockscreen background typically becomes blurred. Follow [these instructions](https://www.tenforums.com/tutorials/124993-enable-disable-acrylic-blur-effect-sign-screen-windows-10-a.html) to turn off this acrylic blur effect. 55 | 56 | 57 | ## Building the executable ## 58 | 59 | 1) Open the solution file *Wintermelon.sln* in Visual Studio. The C# source code resides in *Program.cs*. 60 | 61 | 2) Build the solution by choosing **Build --> Build Solution (Ctrl+Shift+B)** from the menu bar. 62 | 63 | 3) If there are no build errors then select **Build --> Publish Wintermelon** and pass the following publish information: 64 | 65 | **Target location**=bin\Release\netcoreapp3.1\publish\ 66 | 67 | **Configuration**=Release 68 | 69 | **Delete existing files**=false 70 | 71 | **Target Framework**=netcoreapp3.1 72 | 73 | **Target Runtime**=win-x64 74 | 75 | Expand "**Show all**" and set the options under it to following values: 76 | 77 | **Configuration**=Release | Any CPU 78 | 79 | **Target framework**=netcoreapp3.1 80 | 81 | **Deployment mode**=Framework-dependent 82 | 83 | **Target runtime**=win-x64 84 | 85 | **Target location**=bin\Release\netcoreapp3.1\publish\ 86 | 87 | 88 | Expand "**File publish options**", set **Produce single file** as checked and leave **Enable ReadyToRun compilation** unchecked. 89 | 90 | 4) Press Publish button which will generate the executable **Wintermelon.exe** at the path *bin\Release\netcoreapp3.1\publish\Wintermelon.exe* relative to the C# solution folder. 91 | 92 | This executable handles the switching of projection mode between Duplicate and Extend modes during lock/unlock events and does recording, retrieval of window positions from a text file saved at *C:\Users\Your_Username\AppData\Local\Wintermelon\winpos.txt*. 93 | 94 | ## Using Wintermelon ## 95 | To monitor lock/unlock event and switch the projection mode two separate scheduled tasks will need to be registered with the Windows Task Scheduler. These tasks are: 96 | 97 | - Task 1 : **Wintermelon screen lock save window position clone display** 98 | - Task 2 : **Wintermelon screen unlock extend display restore window** 99 | 100 | The PowerShell scripts *install_wintermelon.ps1* and *uninstall_wintermelon.ps1* will need to be executed to register or unregister the aforementioned tasks, respectively. 101 | 102 | ### Registering the Scheduled tasks ### 103 | - Open PowerShell by going to Start Menu, searching for Windows PowerShell and choosing "Run As Administrator" from right click context menu. 104 | 105 | - To register the tasks run the following command 106 | 107 | `powershell -File install_wintermelon.ps1` 108 | 109 | - Open Task Scheduler from Start Menu and you should see 2 new tasks under Task Scheduler Library with names beginning with *Wintermelon*. The Actions tab for these 2 scheduled tasks will list Wintermelon.exe as the program that should start when these tasks are triggered. Task 1 will invoke Wintermelon.exe by passing the argument 'save' while task 2 will invoke Wintermelon.exe by passing the argument 'restore'. 110 | 111 | - Lock the display by pressing Win+L keys and the lockscreen will appear on all displays. 112 | 113 | - Enter your login credentials to unlock the displays. When the displays are unlocked they are all in duplicate mode momentarily and then the C# app fetches the positions of active application windows and relocates them to the appropriate positions. This requires a 3 second wait and is a limitation of this workaround. 114 | 115 | 116 | ### Unregistering the Scheduled tasks ### 117 | - To unregister the tasks run the following command 118 | 119 | `powershell -File uninstall_wintermelon.ps1` 120 | 121 | - Open Task Scheduler from Start Menu and you should no longer see the 2 tasks with names beginning with *Wintermelon* under Task Scheduler Library. 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | *************************************************************************** 4 | Author : arun-goud 5 | Github project : Wintermelon 6 | (WIN)dows (T)en & (E)leven (R)endering of (M)irrored (E)vent-triggered (L)ockscreens (O)n (N)on-main displays 7 | Description : C# program for Win 10 & 11 that toggles projection mode 8 | between duplicate and extend setting. 9 | Accepts optional arguments 'save' and 'restore' that 10 | store and retrieve positions of open windows, respectively, 11 | using a settings file at 12 | C:\Users\Username\AppData\Local\Wintermelon\winpos.txt 13 | Use case : Allows lockscreen mirroring by registering as a task 14 | with task scheduler and using lock, unlock events as 15 | the task triggers. 16 | Created on : 2020/06/19 17 | Last modified on : 2021/07/05 18 | References : Code snippets were borrowed from below URLs 19 | https://docs.microsoft.com/en-us/windows/win32/gdi/positioning-objects-on-multiple-display-monitors 20 | https://docs.microsoft.com/en-us/archive/blogs/davidrickard/saving-window-size-and-location-in-wpf-and-winforms 21 | https://bytes.com/topic/net/answers/855274-getting-child-windows-using-process-getprocess 22 | https://stackoverflow.com/questions/15448266/how-do-you-find-what-windowhandle-takes-process-ownership-and-get-the-handle 23 | http://pinvoke.net/default.aspx/user32.EnumDesktopWindows 24 | https://stackoverflow.com/questions/19867402/how-can-i-use-enumwindows-to-find-windows-with-a-specific-caption-title 25 | https://stackoverflow.com/questions/38460253/how-to-use-system-windows-forms-in-net-core-class-library 26 | https://github.com/BiNZGi/WinPos 27 | 28 | *************************************************************************** 29 | */ 30 | 31 | using System; 32 | using System.Collections.Generic; 33 | using System.Diagnostics; 34 | using System.IO; 35 | using System.Linq; 36 | using System.Runtime.InteropServices; 37 | using System.Text; 38 | using System.Windows.Forms; 39 | 40 | namespace Wintermelon 41 | { 42 | class Program 43 | { 44 | // PInvoke imports for controlling Window placement 45 | [DllImport("user32.dll")] 46 | private static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl); 47 | [DllImport("user32.dll")] 48 | private static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl); 49 | 50 | // PInvoke imports to get handles to multiple windows having the same process name 51 | public delegate bool EnumDelegate(IntPtr hWnd, int lParam); 52 | [DllImport("user32.dll")] 53 | [return: MarshalAs(UnmanagedType.Bool)] 54 | public static extern bool IsWindowVisible(IntPtr hWnd); 55 | [DllImport("user32.dll")] 56 | public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount); 57 | [DllImport("user32.dll")] 58 | public static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDelegate lpEnumCallbackFunction, IntPtr lParam); 59 | [DllImport("User32.dll")] 60 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); 61 | [DllImport("dwmapi.dll")] 62 | public static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out bool pvAttribute, int cbAttribute); 63 | [Flags] 64 | public enum DwmWindowAttribute 65 | { 66 | DWMWA_NCRENDERING_ENABLED = 1, 67 | DWMWA_NCRENDERING_POLICY, 68 | DWMWA_TRANSITIONS_FORCEDISABLED, 69 | DWMWA_ALLOW_NCPAINT, 70 | DWMWA_CAPTION_BUTTON_BOUNDS, 71 | DWMWA_NONCLIENT_RTL_LAYOUT, 72 | DWMWA_FORCE_ICONIC_REPRESENTATION, 73 | DWMWA_FLIP3D_POLICY, 74 | DWMWA_EXTENDED_FRAME_BOUNDS, 75 | DWMWA_HAS_ICONIC_BITMAP, 76 | DWMWA_DISALLOW_PEEK, 77 | DWMWA_EXCLUDED_FROM_PEEK, 78 | DWMWA_CLOAK, 79 | DWMWA_CLOAKED, 80 | DWMWA_FREEZE_REPRESENTATION, 81 | DWMWA_LAST 82 | } 83 | 84 | // Display switch imports 85 | [DllImport("user32.dll", CharSet = CharSet.Unicode)] 86 | private static extern long SetDisplayConfig(uint numPathArrayElements, 87 | IntPtr pathArray, uint numModeArrayElements, IntPtr modeArray, uint flags); 88 | 89 | public enum SDC_FLAGS 90 | { 91 | SDC_TOPOLOGY_INTERNAL = 1, 92 | SDC_TOPOLOGY_CLONE = 2, 93 | SDC_TOPOLOGY_EXTEND = 4, 94 | SDC_TOPOLOGY_EXTERNAL = 8, 95 | SDC_APPLY = 128 96 | } 97 | 98 | public static void CloneDisplays() 99 | { 100 | SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, ((uint) SDC_FLAGS.SDC_APPLY | (uint) SDC_FLAGS.SDC_TOPOLOGY_CLONE)); 101 | } 102 | 103 | public static void ExtendDisplays() 104 | { 105 | SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, ((uint) SDC_FLAGS.SDC_APPLY | (uint) SDC_FLAGS.SDC_TOPOLOGY_EXTEND)); 106 | } 107 | 108 | public static void ExternalDisplay() 109 | { 110 | SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, ((uint) SDC_FLAGS.SDC_APPLY | (uint) SDC_FLAGS.SDC_TOPOLOGY_EXTERNAL)); 111 | } 112 | 113 | public static void InternalDisplay() 114 | { 115 | SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, ((uint) SDC_FLAGS.SDC_APPLY | (uint) SDC_FLAGS.SDC_TOPOLOGY_INTERNAL)); 116 | } 117 | 118 | // RECT structure required by WINDOWPLACEMENT structure 119 | [Serializable] 120 | [StructLayout(LayoutKind.Sequential)] 121 | public struct RECT 122 | { 123 | public int Left; 124 | public int Top; 125 | public int Right; 126 | public int Bottom; 127 | public RECT(int left, int top, int right, int bottom) 128 | { 129 | this.Left = left; 130 | this.Top = top; 131 | this.Right = right; 132 | this.Bottom = bottom; 133 | } 134 | public override string ToString() 135 | { 136 | return "(" + this.Left.ToString() + "," + this.Top.ToString() + "," + 137 | this.Right.ToString() + "," + this.Bottom.ToString() + ")"; 138 | } 139 | } 140 | 141 | // POINT structure required by WINDOWPLACEMENT structure 142 | [Serializable] 143 | [StructLayout(LayoutKind.Sequential)] 144 | public struct POINT 145 | { 146 | public int X; 147 | public int Y; 148 | public POINT(int x, int y) 149 | { 150 | this.X = x; 151 | this.Y = y; 152 | } 153 | public override string ToString() 154 | { 155 | return "(" + this.X.ToString() + "," + this.Y.ToString() + ")"; 156 | } 157 | } 158 | 159 | // WINDOWPLACEMENT stores the position, size, and state of a window 160 | [Serializable] 161 | [StructLayout(LayoutKind.Sequential)] 162 | private struct WINDOWPLACEMENT 163 | { 164 | public int length; 165 | public int flags; 166 | public int showCmd; 167 | public POINT minPosition; 168 | public POINT maxPosition; 169 | public RECT normalPosition; 170 | public override string ToString() 171 | { 172 | return "Length=" + length.ToString() + "\tFlags=" + flags.ToString()+"\tCmd="+showCmd.ToString()+ 173 | "\tMin=" + minPosition.ToString() + "\tMax=" + maxPosition.ToString() + "\tRect=" + normalPosition.ToString(); 174 | } 175 | } 176 | 177 | static void Main(string[] args) 178 | { 179 | if (args.Length == 0) 180 | { 181 | //*Console.WriteLine("Usage: Wintermelon [save | restore]"); 182 | return; 183 | } 184 | 185 | string appDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Wintermelon"); 186 | if (!Directory.Exists(appDir)) 187 | Directory.CreateDirectory(appDir); 188 | string settingsFile = Path.Combine(appDir, "winpos.txt"); 189 | 190 | Screen[] screens = Screen.AllScreens; 191 | 192 | // Get collection of .exe processes with top-level desktop windows and save to handleInfo[] 193 | var procSettings = new List(); 194 | var handleInfo = new List(); 195 | EnumDelegate filter = delegate (IntPtr hWnd, int lParam) 196 | { 197 | StringBuilder strbTitle = new StringBuilder(255); 198 | int nLength = GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1); 199 | string strTitle = strbTitle.ToString(); 200 | 201 | if (IsWindowVisible(hWnd) && string.IsNullOrEmpty(strTitle) == false) 202 | { 203 | //procSettings.Add(strTitle); 204 | WINDOWPLACEMENT wp = new WINDOWPLACEMENT(); 205 | wp.length = Marshal.SizeOf(wp); 206 | GetWindowPlacement(hWnd, out wp); 207 | 208 | uint pid = 0; 209 | GetWindowThreadProcessId(hWnd, out pid); 210 | 211 | //if (wp.flags != 0 && wp.showCmd != 1) 212 | DwmGetWindowAttribute(hWnd, DwmWindowAttribute.DWMWA_CLOAKED, out bool isCloaked, Marshal.SizeOf(typeof(bool))); 213 | if (!isCloaked) // Gets rid of WinRT apps such as Microsoft Store which remain cloaked 214 | { 215 | string exeName = Process.GetProcessById((int)pid).MainModule.FileName; 216 | if (exeName.ToLower().EndsWith(".exe")) // Save only .exe generated window positions 217 | { 218 | var screen = Screen.FromHandle(hWnd); 219 | //Console.WriteLine(screen); 220 | procSettings.Add("Title=" + strTitle + "\tPID=" + pid.ToString() + "\tID=" + hWnd.ToString() + "\tName=" + exeName + 221 | "\t" + wp.ToString() + "\tPrimary=" + screen.Primary.ToString() + "\tDisplay=" + screen.DeviceName); 222 | handleInfo.Add(hWnd); 223 | } 224 | } 225 | } 226 | return true; 227 | }; 228 | // Enumerate visible windows using filter defined above 229 | if (!EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero)) 230 | { 231 | // Get the last Win32 error code 232 | int nErrorCode = Marshal.GetLastWin32Error(); 233 | string strErrMsg = String.Format("EnumDesktopWindows failed with code {0}.", nErrorCode); 234 | throw new Exception(strErrMsg); 235 | } 236 | 237 | // Take appropriate action based on whether "save" or "restore" was passed in 238 | // 'save' --> Save window positions and then clone displays 239 | if (string.Equals(args[0], "save", StringComparison.OrdinalIgnoreCase)) 240 | { 241 | //*Console.WriteLine("Saving window positions to {0}...", settingsFile); 242 | File.WriteAllText(settingsFile, ""); 243 | 244 | foreach (var item in procSettings) 245 | { 246 | File.AppendAllText(settingsFile, item + "\n"); 247 | } 248 | //*Console.WriteLine("Done."); 249 | 250 | // Duplicate screen using DisplaySwitch.exe process (slow approach) 251 | //ProcessStartInfo startInfo = new ProcessStartInfo(); 252 | //startInfo.FileName = @"C:\Windows\System32\DisplaySwitch.exe"; 253 | //startInfo.Arguments = @"/clone"; 254 | //Process.Start(startInfo); 255 | 256 | // Duplicate using SetDisplayConfig() (faster approach) 257 | CloneDisplays(); 258 | } 259 | // 'restore' --> Extend displays and then restore windows 260 | else if (string.Equals(args[0], "restore", StringComparison.OrdinalIgnoreCase)) 261 | { 262 | // Extend using DisplaySwitch.exe process (slow approach) 263 | //Process p = new Process(); 264 | //p.StartInfo.FileName = @"C:\Windows\System32\DisplaySwitch.exe"; 265 | //p.StartInfo.Arguments = @"/extend"; 266 | //p.Start(); 267 | //p.WaitForExit(); 268 | 269 | // Extend using SetDisplayConfig() (faster approach) 270 | ExtendDisplays(); 271 | 272 | 273 | //*Console.WriteLine("Restoring window positions from {0}...", settingsFile); 274 | // Read settings.txt into a dictionary with pid+"_"+ptitle serving as key 275 | var processInfo = new Dictionary(); 276 | System.IO.StreamReader infile = new System.IO.StreamReader(@settingsFile); 277 | string line; 278 | while ((line = infile.ReadLine()) != null) 279 | { 280 | if (string.IsNullOrWhiteSpace(line)) 281 | { 282 | continue; 283 | } 284 | //System.Console.WriteLine(line); 285 | var dict = line.Split('\t').Select(x => x.Split('=')).ToDictionary(x => x[0], x => x[1]); 286 | string pid = dict["PID"]; 287 | string id = dict["ID"]; 288 | string ptitle = dict["Title"]; 289 | bool isPrimary = string.Equals(dict["Primary"], "True", StringComparison.OrdinalIgnoreCase); 290 | 291 | // Save only for those that are not on the primary screen 292 | if (!isPrimary) 293 | { 294 | WINDOWPLACEMENT wp = new WINDOWPLACEMENT(); 295 | wp.length = Marshal.SizeOf(wp); 296 | wp.flags = int.Parse(dict["Flags"]); 297 | wp.showCmd = int.Parse(dict["Cmd"]); 298 | var minxy = dict["Min"].Replace("(", "").Replace(")", "").Split(","); 299 | wp.minPosition = new POINT(int.Parse(minxy[0]), int.Parse(minxy[1])); 300 | var maxxy = dict["Max"].Replace("(", "").Replace(")", "").Split(","); 301 | wp.maxPosition = new POINT(int.Parse(maxxy[0]), int.Parse(maxxy[1])); 302 | var pqrs = dict["Rect"].Replace("(", "").Replace(")", "").Split(","); 303 | wp.normalPosition = new RECT(int.Parse(pqrs[0]), int.Parse(pqrs[1]),int.Parse(pqrs[2]), int.Parse(pqrs[3])); 304 | 305 | processInfo.Add(pid + "_" + id + "_" + ptitle, wp); 306 | //Console.WriteLine("Info='{0}'", pid + "_" + id + "_" + ptitle); 307 | } 308 | } 309 | infile.Close(); 310 | 311 | //*Console.WriteLine("Restoring {0} windows", handleInfo.Count()); 312 | 313 | foreach (var handle in handleInfo) 314 | { 315 | StringBuilder strbTitle = new StringBuilder(255); 316 | int nLength = GetWindowText(handle, strbTitle, strbTitle.Capacity + 1); 317 | string ptitle = strbTitle.ToString(); 318 | uint procid = 0; 319 | GetWindowThreadProcessId(handle, out procid); 320 | 321 | string pid = procid.ToString(); 322 | string id = handle.ToString(); 323 | 324 | // Get window positions for the processes from settings.txt, if present, and enforce them 325 | if (processInfo.ContainsKey(pid + "_" + id + "_" + ptitle)) 326 | { 327 | //*Console.WriteLine("Info={0}", pid + "_" + id + "_" + ptitle); 328 | // To restore maximized windows 329 | WINDOWPLACEMENT wp = processInfo[pid + "_" + id + "_" + ptitle]; 330 | wp.length = Marshal.SizeOf(wp); 331 | wp.showCmd = 1; 332 | SetWindowPlacement(handle, ref wp); 333 | 334 | // To restore rest of them 335 | WINDOWPLACEMENT wp2 = processInfo[pid + "_" + id + "_" + ptitle]; 336 | wp2.length = Marshal.SizeOf(wp2); 337 | SetWindowPlacement(handle, ref wp2); 338 | } 339 | 340 | } 341 | 342 | //*Console.WriteLine("Done."); 343 | } 344 | else 345 | { 346 | //*Console.WriteLine("Usage: Wintermelon [save | restore]"); 347 | return; 348 | } 349 | 350 | } 351 | } 352 | } 353 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------