windows-store-apps - 用于安装光标包的 Windows 应用商店应用
问题描述
我设计了一套完整的动画光标,我想将它们放在 Microsoft Store 中,以便人们直接从那里安装它们。
在 Visual Studio 2019 中,我启动了一个新项目并选择了Windows Application Packaging Project。
我写了两个文件,install.inf
文件和set-new-scheme.ps1
下面的文件。
从这里我不知道如何合并我的代码来安装游标以上传到 Microsoft Store。
这是install.inf
文件的内容,我必须将光标放在正确的目录中。这些.ani
文件与文件位于同一文件夹中install.inf
。
[Version]
signature="$CHICAGO$"
[DefaultInstall]
CopyFiles = Scheme.Cur, Scheme.Txt
AddReg = Scheme.Reg
[DestinationDirs]
Scheme.Cur = 10,"%CUR_DIR%"
Scheme.Txt = 10,"%CUR_DIR%"
[Scheme.reg]
HKCU,"Control Panel\Cursors\Schemes","%SCHEME_NAME%",,"%10%\%CUR_DIR%\%NormalSelect%,%10%\%CUR_DIR%\%Help%,%10%\%CUR_DIR%\%WorkingInBG%,%10%\%CUR_DIR%\%Busy%,%10%\%CUR_DIR%\%PrecisionSelect%,%10%\%CUR_DIR%\%TextSelect%,%10%\%CUR_DIR%\%Handwriting%,%10%\%CUR_DIR%\%Unavailable%,%10%\%CUR_DIR%\%VerticalResize%,%10%\%CUR_DIR%\%HorizontalResize%,%10%\%CUR_DIR%\%DiagonalResize_1%,%10%\%CUR_DIR%\%DiagonalResize_2%,%10%\%CUR_DIR%\%Move%,%10%\%CUR_DIR%\%AlternateSelect%,%10%\%CUR_DIR%\%LinkSelect%,%10%\%CUR_DIR%\%LocationSelect%,%10%\%CUR_DIR%\%PersonSelect%"
; -- Installed files
[Scheme.cur]
install.inf
RGBAnimatedPointer.ani
RGBAnimatedHelp.ani
RGBAnimatedWorkingInBG.ani
RGBAnimatedBusy.ani
RGBAnimatedPrecisionSelect.ani
RGBAnimatedTextSelect.ani
RGBAnimatedHandwriting.ani
RGBAnimatedUnavailable.ani
RGBAnimatedVerticalResize.ani
RGBAnimatedHorizontalResize.ani
RGBAnimatedDiagonalResize_1.ani
RGBAnimatedDiagonalResize_2.ani
RGBAnimatedMove.ani
RGBAnimatedAlternateSelect.ani
RGBAnimatedLinkSelect.ani
RGBAnimatedLocationSelect.ani
RGBAnimatedPersonSelect.ani
[Strings]
CUR_DIR = "Cursors\RGB Animated"
SCHEME_NAME = "RGB Animated"
NormalSelect = "RGBAnimatedPointer.ani"
Help = "RGBAnimatedHelp.ani"
WorkingInBG = "RGBAnimatedWorkingInBG.ani"
Busy = "RGBAnimatedBusy.ani"
PrecisionSelect = "RGBAnimatedPrecisionSelect.ani"
TextSelect = "RGBAnimatedTextSelect.ani"
Handwriting = "RGBAnimatedHandwriting.ani"
Unavailable = "RGBAnimatedUnavailable.ani"
VerticalResize = "RGBAnimatedVerticalResize.ani"
HorizontalResize = "RGBAnimatedHorizontalResize.ani"
DiagonalResize_1 = "RGBAnimatedDiagonalResize_1.ani"
DiagonalResize_2 = "RGBAnimatedDiagonalResize_2.ani"
Move = "RGBAnimatedMove.ani"
AlternateSelect = "RGBAnimatedAlternateSelect.ani"
LinkSelect = "RGBAnimatedLinkSelect.ani"
LocationSelect = "RGBAnimatedLocationSelect.ani"
PersonSelect = "RGBAnimatedPersonSelect.ani"
然后我有一个 PowerShell 脚本来使它们成为当前的方案。
Function New-WPFDialog() {
Param([Parameter(Mandatory = $True, HelpMessage = 'XaML Data defining a GUI', Position = 1)]
[string]$XamlData)
# Add WPF and Windows Forms assemblies
try {
Add-Type -AssemblyName PresentationCore, PresentationFramework, WindowsBase, system.windows.forms
}
catch {
Throw 'Failed to load Windows Presentation Framework assemblies.'
}
# Create an XML Object with the XaML data in it
[xml]$xmlWPF = $XamlData
# Create the XAML reader using a new XML node reader, UI is the only hard-coded object name here
Set-Variable -Name XaMLReader -Value @{ 'UI' = ([Windows.Markup.XamlReader]::Load((new-object -TypeName System.Xml.XmlNodeReader -ArgumentList $xmlWPF))) }
$Timer = New-Object System.Windows.Forms.Timer
$Timer.Interval = 2000
$Timer.Add_Tick({$WPFGui.UI.Close()})
$Timer.Start()
# Create hooks to each named object in the XAML reader
$Elements = $xmlWPF.SelectNodes('//*[@Name]')
ForEach ( $Element in $Elements ) {
$VarName = $Element.Name
$VarValue = $XaMLReader.UI.FindName($Element.Name)
$XaMLReader.Add($VarName, $VarValue)
}
return $XaMLReader
}
Function New-PopUpWindow () {
param(
[string]
$MessageText = "No Message Supplied")
# This is the XaML that defines the GUI.
$WPFXamL = @'
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Popup" Background="#FF0066CC" Foreground="#FFFFFFFF" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" WindowStyle="None" Padding="20" Margin="0">
<Grid>
<TextBlock Name="Message" Margin="100,40,100,40" TextWrapping="Wrap" Text="_CONTENT_" FontSize="28"/>
</Grid>
</Window>
'@
# Build Dialog
$WPFGui = New-WPFDialog -XamlData $WPFXaml
$WPFGui.Message.Text = $MessageText
$null = $WPFGUI.UI.Dispatcher.InvokeAsync{$WPFGui.UI.ShowDialog()}.Wait()
}
# Sets the new cursors, without having to open 'Mouse properties' to do so.
# Or if the scheme is not installed them it sets the default one.
$cursorName = "RGB Animated"
$cursorShortName = "RGBAnimated"
$cursorPath = "C:\Windows\Cursors\$cursorName\"
function SetMouseStyle {
$fileCheck = Test-Path $cursorPath -PathType Any
If ($fileCheck -eq $true) {
$RegConnect = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"CurrentUser", "$env:COMPUTERNAME")
$RegCursors = $RegConnect.OpenSubKey("Control Panel\Cursors", $true)
$RegCursors.SetValue("", $cursorName)
$RegCursors.SetValue("Scheme Source", 1, 'DWord')
$RegCursors.SetValue("AppStarting", $cursorPath + $cursorShortName + "WorkingInBG.ani")
$RegCursors.SetValue("Arrow", $cursorPath + $cursorShortName + "Pointer.ani")
$RegCursors.SetValue("Crosshair", $cursorPath + $cursorShortName + "PrecisionSelect.ani")
$RegCursors.SetValue("Hand", $cursorPath + $cursorShortName + "LinkSelect.ani")
$RegCursors.SetValue("Help", $cursorPath + $cursorShortName + "Help.ani")
$RegCursors.SetValue("IBeam", $cursorPath + $cursorShortName + "TextSelect.ani")
$RegCursors.SetValue("No", $cursorPath + $cursorShortName + "Unavailable.ani")
$RegCursors.SetValue("NWPen", $cursorPath + $cursorShortName + "Handwriting.ani")
$RegCursors.SetValue("SizeAll", $cursorPath + $cursorShortName + "Move.ani")
$RegCursors.SetValue("SizeNESW", $cursorPath + $cursorShortName + "DiagonalResize_2.ani")
$RegCursors.SetValue("SizeNS", $cursorPath + $cursorShortName + "VerticalResize.ani")
$RegCursors.SetValue("SizeNWSE", $cursorPath + $cursorShortName + "DiagonalResize_1.ani")
$RegCursors.SetValue("SizeWE", $cursorPath + $cursorShortName + "HorizontalResize.ani")
$RegCursors.SetValue("UpArrow", $cursorPath + $cursorShortName + "AlternateSelect.ani")
$RegCursors.SetValue("Wait", $cursorPath + $cursorShortName + "Busy.ani")
$RegCursors.SetValue("Pin", $cursorPath + $cursorShortName + "LocationSelect.ani")
$RegCursors.SetValue("Person", $cursorPath + $cursorShortName + "PersonSelect.ani")
$RegCursors.Close()
$RegConnect.Close()
$CSharpSig = @'
[DllImport("user32.dll", SetLastError = true, EntryPoint = "SystemParametersInfo")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
bool pvParam,
uint fWinIni);
'@
$CursorRefresh = Add-Type -MemberDefinition $CSharpSig -Name WinAPICall -Namespace SystemParamInfo –PassThru
$CursorRefresh::SystemParametersInfo(0x0057, 0, $null, 0)
} else {
$RegConnect = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"CurrentUser", "$env:COMPUTERNAME")
$RegCursors = $RegConnect.OpenSubKey("Control Panel\Cursors", $true)
$RegCursors.SetValue("", "")
$RegCursors.SetValue("Scheme Source", 0, 'DWord')
$RegCursors.SetValue("AppStarting", "")
$RegCursors.SetValue("Arrow", "")
$RegCursors.SetValue("Crosshair", "")
$RegCursors.SetValue("Hand", "")
$RegCursors.SetValue("Help", "")
$RegCursors.SetValue("IBeam", "")
$RegCursors.SetValue("No", "")
$RegCursors.SetValue("NWPen", "")
$RegCursors.SetValue("SizeAll", "")
$RegCursors.SetValue("SizeNESW", "")
$RegCursors.SetValue("SizeNS", "")
$RegCursors.SetValue("SizeNWSE", "")
$RegCursors.SetValue("SizeWE", "")
$RegCursors.SetValue("UpArrow", "")
$RegCursors.SetValue("Wait", "")
$RegCursors.SetValue("Pin", "")
$RegCursors.SetValue("Person", "")
$RegCursors.Close()
$RegConnect.Close()
$CSharpSig = @'
[DllImport("user32.dll", SetLastError = true, EntryPoint = "SystemParametersInfo")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
bool pvParam,
uint fWinIni);
'@
$CursorRefresh = Add-Type -MemberDefinition $CSharpSig -Name WinAPICall -Namespace SystemParamInfo –PassThru
$CursorRefresh::SystemParametersInfo(0x0057, 0, $null, 0)
}
}
SetMouseStyle | New-PopUpWindow -MessageText "Cursor scheme set to $cursorName..."
也许我正在处理这个错误,但这里的任何帮助都会很棒,因为我从未为商店上传或编写过应用程序。
解决方案
推荐阅读
- azure-synapse - 高级 SME 在 Azure Synapse Analytics 中的作用是什么?
- excel - 根据包含内容的列中的最后一个单元格选择范围
- html - 使用 Bootstrap 编写相对路径时要基于哪个文件?
- javascript - 如何在这些链接之一下输入下拉功能?
- vba - ChDir (Environ("USERPROFILE") & "\Desktop") 运行时错误 '76'
- ruby-on-rails - 从 Rails 的 /public/assets 文件夹导入 javascript 和 css 文件
- r - 如何在 R 中使用 Dataframes 根据日期时间对事件进行计数并按条件分组
- c# - Xamarin 表单选项卡标题未更改
- google-colaboratory - 在 google colab 上进行长期训练的官方方法是什么?
- python - 使用服务员服务代码时出错 --port 8000