Author Topic: Workaround for Date formatting and (maybe) comma delimiter  (Read 6388 times)

0 Members and 1 Guest are viewing this topic.

Offline SaberSnail (OP)

  • Leading Rate
  • *
  • Posts: 7
  • Thanked: 4 times
It's considered working as intended (or not to be fixed) that your system formatting settings for Date and Decimal can cause problems with the game. 

I put together a script that changes your system settings, starts the game, then restores your settings back to what they were. 

I've tested this with the Date formatting.   I haven't tested with the Decimal, but this should work with that as well. 

I'm offering this with no guarantees.   Use at your own risk.   That said, I did my best to make sure this doesn't cause problems. 

Instructions:
  • Download the attached zip file.   Extract the contained PowerShell script file to someplace where it can live.   Example: C:\Games\AuroraTools\
  • Edit the file.   Replace the path set on the first line to the path to where the Aurora.  exe file is located.   If you want, replace the second line with your desired date format.   This page might help: https://docs.  microsoft.  com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
  • Create a new shortcut to this script.   Then right click on the script and open the properties.   Change the target to tell PowerShell to ignore the normal check for permission to run scripts.   Example: powershell.  exe -ExecutionPolicy ByPass -File C:\Games\AuroraTools\StartAurora.  ps1

If this doesn't seem to be having an effect, try increasing the value on the fifth line (delayBeforeExitInSeconds).   This will force the script to wait a little longer after the application starts before setting the system settings back to their old values. 

This script works by changing the system settings in the registry and then starting the game.   At some point early on, the application gets its formatting settings from the system.   After this, the system settings can be restored and the script can exit.   The game will continue using the modified settings it initially got from the system, even though the original settings have been restored. 

Please let me know if you run into any problems. 
« Last Edit: May 04, 2020, 05:57:47 PM by SaberSnail »
 
The following users thanked this post: Larsaal, DeMatt, YABG, Foxxonius Augustus

Offline Larsaal

  • Able Ordinary Rate
  • L
  • Posts: 4
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #1 on: May 04, 2020, 10:13:01 AM »
Works fine!
Thanks makes it quiet a bit more comfortable.
 

Offline Second Foundationer

  • Warrant Officer, Class 1
  • *****
  • Posts: 94
  • Thanked: 34 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #2 on: May 05, 2020, 07:11:18 AM »
(I haven't tested yet, I'll have a look at it later/one of these days when I have a quiet moment to play around with system settings and set them to various stuff Aurora can't digest by design. But if – no doubts implied, only prudence – this indeed works smoothly to solve date format problems and bridge the decimal separation channel:)

Suggestion: Could/should this be put into the installation folder and/or stickied? Possibly with a placative change in title such as "Aurora startup tool for users who write 3.14 as 3,14 or see dates cut off" or something to that effect, so that new users, especially those who initially aren't even aware of the restrictions (I find it a challenge to find Aurora and miss them, but it may happen.) don't have to experience problems in the first place, don't have to bother with system settings they may not be familiar with, and don't have to deal with or report issues that aren't really.

Secondary suggestion: Eventually, if someone with experience, confidence and a helpful spirit creates one, the script could be included in a launcher/database backup package for Aurora, where dates and desperators go under the hood and out of the way as far as possible.

In any case, thank you very much for working on a carefree script solution for date- or comma-impaired continentals (or wherever we use insane/sane – all a matter of perspective – date & number formats).

copy-edited

PS, 2020/05/06: Tested it briefly, for three configurations of Aurora-indigestible decimal separators and digit-grouping symbols, including one mildly customized date format. Seems to work smoothly for starting up Aurora with the right settings and restore previous settings properly. For anyone who has to switch date or number format twice for running Aurora once (presumably most affected by comma-kaputness in terms of numbers: French, Spanish, German, Italian users): this script may be the shortest shortcut you may find, apart from the also viable separate user method described by Omnivore in http://aurora2.pentarch.org/index.php?topic=11139.msg128952#msg128952.

One thing I cannot tell due to insufficient technical knowledge on several fronts: Is the save process absolutely "comma-safe"? Because that would happen with original settings restored. But maybe you or someone who has used the script for a while can answer that.
« Last Edit: May 06, 2020, 03:04:22 PM by Second Foundationer »
 

Offline vorpal+5

  • Captain
  • **********
  • Posts: 597
  • Thanked: 121 times
  • Silver Supporter Silver Supporter : Support the forums with a Silver subscription
    2021 Supporter 2021 Supporter : Donate for 2021
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #3 on: May 08, 2020, 11:45:00 AM »
Is PowerShell installed with Windows?
 

Offline SaberSnail (OP)

  • Leading Rate
  • *
  • Posts: 7
  • Thanked: 4 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #4 on: May 08, 2020, 05:10:26 PM »
Quote from: vorpal+5 link=topic=11237. msg131862#msg131862 date=1588956300
Is PowerShell installed with Windows?

According to Microsoft's website, "Windows PowerShell comes installed by default in every Windows, starting with Windows 7 SP1 and Windows Server 2008 R2 SP1. "

https://docs. microsoft. com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-7
 

Offline vorpal+5

  • Captain
  • **********
  • Posts: 597
  • Thanked: 121 times
  • Silver Supporter Silver Supporter : Support the forums with a Silver subscription
    2021 Supporter 2021 Supporter : Donate for 2021
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #5 on: May 09, 2020, 03:40:15 AM »
mmmh, so it should in theory not be opened as a text file I double click on it but executed? (Windows 10)
 

Offline SaberSnail (OP)

  • Leading Rate
  • *
  • Posts: 7
  • Thanked: 4 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #6 on: May 09, 2020, 07:40:57 AM »
Quote from: vorpal+5 link=topic=11237. msg132001#msg132001 date=1589013615
mmmh, so it should in theory not be opened as a text file I double click on it but executed? (Windows 10)

It doesn't execute when I double click it on my system, so that's probably normal.  Instructions for how I run it are in the original post.  You actually run powershell and pass the script as an argument.
 

Offline DeMatt

  • Warrant Officer, Class 2
  • ****
  • D
  • Posts: 50
  • Thanked: 17 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #7 on: May 13, 2020, 12:39:08 AM »
It's worth noting that, as written, this script requires PowerShell version 5.0 or greater (which, apparently, is when "Get-ItemPropertyValue" was added).  This is a newer version than that included with Windows 7 or 8.

I've attached a modified script that runs on PowerShell 2.0 (and presumably better), for those of us who refuse to upgrade.
 
The following users thanked this post: SaberSnail

Offline TMaekler

  • Vice Admiral
  • **********
  • Posts: 1112
  • Thanked: 298 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #8 on: September 22, 2020, 07:35:24 AM »
I couldn't find it again, but in the beginning we had a description about creating a separate user account in windows that is already set to any needs Aurora has and then start the game with "open as user..." and you select that user. Anything works fine this way. But, I can't find that post... .
 

Offline Tree

  • Sub-Lieutenant
  • ******
  • Posts: 143
  • Thanked: 27 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #9 on: September 23, 2020, 03:09:12 AM »
I couldn't find it again, but in the beginning we had a description about creating a separate user account in windows that is already set to any needs Aurora has and then start the game with "open as user..." and you select that user. Anything works fine this way. But, I can't find that post... .

http://aurora2.pentarch.org/index.php?topic=11139.msg128952#msg128952
 

Offline Trekkie1985

  • Leading Rate
  • *
  • T
  • Posts: 6
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #10 on: November 03, 2020, 09:15:52 PM »
Is it compatible to newer Versions?
 

Offline Garfunkel

  • Registered
  • Admiral of the Fleet
  • ***********
  • Posts: 2781
  • Thanked: 1048 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #11 on: November 04, 2020, 05:18:00 AM »
Should work, it's version-independent as far as I can tell.
 
The following users thanked this post: Trekkie1985

Offline Trekkie1985

  • Leading Rate
  • *
  • T
  • Posts: 6
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #12 on: November 04, 2020, 09:35:28 PM »
I may have made a mistake.  When I double click on the File StartAuroraq. ps1 my Windows opened the File in the Editor.
 

Offline db48x

  • Commodore
  • **********
  • d
  • Posts: 641
  • Thanked: 200 times
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #13 on: November 04, 2020, 09:55:15 PM »
I may have made a mistake.  When I double click on the File StartAuroraq. ps1 my Windows opened the File in the Editor.

Right click on it and choose the 'Run with PowerShell' action. The default action is to open it in your default text editor. If you want to change the default action or to add additional actions to the file type you will need to consult a tutorial elsewhere. It involves registry editing and Microsoft doesn't make the documentation for it very prominent.
 

Offline Trekkie1985

  • Leading Rate
  • *
  • T
  • Posts: 6
Re: Workaround for Date formatting and (maybe) comma delimiter
« Reply #14 on: November 05, 2020, 01:27:17 PM »
Can you help me via AnyDesk? I have multiple errors.   


Sry for my bad english.     German is my native language.   
AnyDesk is a Teamviewer alternative.   


This is the content of the StartAurora.  ps file.   I have modified it as I should:

Code: [Select]
$gamePath = "C:\Aurora4xC#"
$dateFormat = "dd, mm, yyyy"
$decimalFormat = ","
$thousandFormat = "."
$delayBeforeExitInSeconds = 30

Add-Type @"
    using System;
    using System.Runtime.InteropServices;
    public class Windows {
    [DllImport("user32.dll")]
    public static extern IntPtr GetForegroundWindow();
    [DllImport("user32.dll")]
    public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
}
"@

$originalDateFormat = $null
$originalDecimalFormat = $null
$originalThousandFormat = $null

try
{
    $originalDateFormat = Get-ItemProperty -Path "HKCU:\Control Panel\International" -Name sLongDate
    $originalDecimalFormat = Get-ItemProperty -Path "HKCU:\Control Panel\International" -Name sDecimal
    $originalThousandFormat = Get-ItemProperty -Path "HKCU:\Control Panel\International" -Name sThousand

    Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sLongDate -Value $dateFormat
    Write-Host ("Date format set to " + $dateFormat)
    Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sDecimal -Value $decimalFormat
    Write-Host ("Decimal format set to " + $decimalFormat)
    Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sThousand -Value $thousandFormat
    Write-Host ("Thousand format set to " + $thousandFormat)

    $game = Start-Process -PassThru -WorkingDirectory $gamePath -FilePath ($gamePath + "Aurora.exe")

    $gameWindow = $game.MainWindowHandle
    do
    {
        Start-Sleep -Milliseconds 100

        $game.Refresh()
        if ($game.HasExited -eq $true)
        {
            break
        }
        if ($game.MainWindowHandle -ne 0)
        {
            break
        }
    } while ($true)

    Start-Sleep -Seconds $delayBeforeExitInSeconds
}
finally
{
    if ($originalDateFormat -ne $null)
    {
        Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sLongDate -Value $originalDateFormat.sLongDate
        Write-Host ("Date format set to " + $originalDateFormat.sLongDate)
    }
    if ($originalDecimalFormat -ne $null)
    {
        Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sDecimal -Value $originalDecimalFormat.sDecimal
        Write-Host ("Decimal format set to " + $originalDecimalFormat.sDecimal)
    }
    if ($originalThousandFormat -ne $null)
    {
        Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sThousand -Value $originalThousandFormat.sThousand
        Write-Host ("Thousand format set to " + $originalThousandFormat.sThousand)
    }
}


The Content of properties and and target is:

C:\Windows\System32\WindowsPowerShell\v1. 0\powershell. exe -ExecutionPolicy ByPass -File C:\Users\AKint\Desktop\StartAurora. ps1
« Last Edit: November 05, 2020, 01:44:03 PM by Trekkie1985 »