feat(*): Hide vpet window from task switcher

Add `hide from taskswitcher` via `WS_EX_TOOLWINDOW`.
Add an option in settings window to toggle `hide from taskswitcher.
Add English translation for changes.

Close #210
This commit is contained in:
Kuriko Moe 2023-09-16 17:33:54 +08:00 committed by ZouJin
parent 88eb7ae3ff
commit 510df00e17
5 changed files with 30 additions and 35 deletions

View File

@ -444,6 +444,14 @@ namespace VPet_Simulator.Windows.Interface
this["gameconfig"].SetBool("autogift", value); this["gameconfig"].SetBool("autogift", value);
} }
} }
/// <summary>
/// 在任务切换器(Alt+Tab)中隐藏窗口
/// </summary>
public bool HideFromTaskControl
{
get => this["gameconfig"].GetBool("hide_from_task_control");
set => this["gameconfig"].SetBool("hide_from_task_control", value);
}
public bool MoveAreaDefault public bool MoveAreaDefault
{ {

View File

@ -847,6 +847,13 @@ namespace VPet_Simulator.Windows
{ {
var styleStruct = (STYLESTRUCT)Marshal.PtrToStructure(lParam, typeof(STYLESTRUCT)); var styleStruct = (STYLESTRUCT)Marshal.PtrToStructure(lParam, typeof(STYLESTRUCT));
styleStruct.styleNew |= (int)Win32.ExtendedWindowStyles.WS_EX_LAYERED; styleStruct.styleNew |= (int)Win32.ExtendedWindowStyles.WS_EX_LAYERED;
// Hide windows from alt+tab: https://stackoverflow.com/questions/357076/best-way-to-hide-a-window-from-the-alt-tab-program-switcher
if (Set.HideFromTaskControl)
{
styleStruct.styleNew |= (int)Win32.ExtendedWindowStyles.WS_EX_TOOLWINDOW;
}
Marshal.StructureToPtr(styleStruct, lParam, false); Marshal.StructureToPtr(styleStruct, lParam, false);
handled = true; handled = true;
} }

View File

@ -377,7 +377,6 @@
<RowDefinition Height="35" /> <RowDefinition Height="35" />
<RowDefinition Height="35" /> <RowDefinition Height="35" />
<RowDefinition Height="35" /> <RowDefinition Height="35" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<pu:Switch x:Name="CalFunctionBox" Grid.Column="2" Background="Transparent" <pu:Switch x:Name="CalFunctionBox" Grid.Column="2" Background="Transparent"
BorderBrush="{DynamicResource PrimaryDark}" BoxHeight="18" BoxWidth="35" BorderBrush="{DynamicResource PrimaryDark}" BoxHeight="18" BoxWidth="35"
@ -405,7 +404,7 @@
<ComboBoxItem Content="Ill" /> <ComboBoxItem Content="Ill" />
</ComboBox> </ComboBox>
</Grid> </Grid>
<Grid Grid.Row="5" Grid.RowSpan="4" Grid.Column="2"> <Grid Grid.Row="5" Grid.RowSpan="2" Grid.Column="2">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
@ -492,38 +491,7 @@
</ComboBoxItem> </ComboBoxItem>
</ComboBox> </ComboBox>
</Grid> </Grid>
<Grid Grid.Row="7" Grid.Column="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<WrapPanel Grid.ColumnSpan="3" >
<TextBlock Text="{ll:Str '当前移动区域:'}" />
<TextBlock x:Name="textMoveArea" Text="{ll:Str '主屏幕'}" />
</WrapPanel>
<Button x:Name="BtnSetMoveArea_Default" Grid.Row="1" Grid.Column="0" Margin="5,5,5,5"
Padding="1" pu:ButtonHelper.CornerRadius="4"
Background="{DynamicResource SecondaryLight}"
Click="BtnSetMoveArea_Default_Click" Content="{ll:Str 重置为主屏}"
ToolTip="{ll:Str '设置桌宠只在主屏幕进行移动'}" />
<Button x:Name="BtnSetMoveArea_DetectScreen" Grid.Row="1" Grid.Column="1"
Margin="5,5,5,5" Padding="1" pu:ButtonHelper.CornerRadius="4"
Background="{DynamicResource SecondaryLight}"
Click="BtnSetMoveArea_DetectScreen_Click" Content="{ll:Str 设为当前屏幕}"
ToolTip="{ll:Str '设置桌宠只在当前桌宠所在的屏幕范围进行移动'}" />
<Button x:Name="BtnSetMoveArea_Window" Grid.Row="1" Grid.Column="2" Margin="5,5,5,5"
Padding="1" pu:ButtonHelper.CornerRadius="4"
Background="{DynamicResource SecondaryLight}"
Click="BtnSetMoveArea_Window_Click" Content="{ll:Str 自定移动范围}"
ToolTip="{ll:Str '手动设置桌宠可移动范围'}"
/>
</Grid>
<TextBlock Grid.Row="0" VerticalAlignment="Center" Text="{ll:Str 数据计算}" /> <TextBlock Grid.Row="0" VerticalAlignment="Center" Text="{ll:Str 数据计算}" />
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="{ll:Str 显示状态}" /> <TextBlock Grid.Row="1" VerticalAlignment="Center" Text="{ll:Str 显示状态}" />
<TextBlock Grid.Row="5" VerticalAlignment="Center" Text="{ll:Str 桌宠移动}" /> <TextBlock Grid.Row="5" VerticalAlignment="Center" Text="{ll:Str 桌宠移动}" />

View File

@ -61,6 +61,7 @@ namespace VPet_Simulator.Windows
SmartMoveEventBox.IsChecked = mw.Set.SmartMove; SmartMoveEventBox.IsChecked = mw.Set.SmartMove;
PressLengthSlider.Value = mw.Set.PressLength / 1000.0; PressLengthSlider.Value = mw.Set.PressLength / 1000.0;
SwitchMsgOut.IsChecked = mw.Set.MessageBarOutside; SwitchMsgOut.IsChecked = mw.Set.MessageBarOutside;
SwitchHideFromTaskControl.IsChecked = mw.Set.HideFromTaskControl;
StartUpBox.IsChecked = mw.Set.StartUPBoot; StartUpBox.IsChecked = mw.Set.StartUPBoot;
StartUpSteamBox.IsChecked = mw.Set.StartUPBootSteam; StartUpSteamBox.IsChecked = mw.Set.StartUPBootSteam;
@ -1306,5 +1307,13 @@ namespace VPet_Simulator.Windows
BtnCGPTReSet.Content = "打开 {0} 设置".Translate(mw.TalkBoxCurr?.APIName ?? "Steam Workshop"); BtnCGPTReSet.Content = "打开 {0} 设置".Translate(mw.TalkBoxCurr?.APIName ?? "Steam Workshop");
} }
private void SwitchHideFromTaskControl_OnChecked(object sender, RoutedEventArgs e)
{
if (!AllowChange)
return;
mw.Set.HideFromTaskControl = SwitchHideFromTaskControl.IsChecked == true;
ButtonRestartGraph.Visibility = Visibility.Visible;
}
} }
} }

View File

@ -31,3 +31,6 @@ EXP#EXP:|
按好感度#By favorability:| 按好感度#By favorability:|
更好买老顾客大优惠!桌宠的食物钱我来出!\n更好买提示您:$10以下的食物/药品等随便赊账#Better buy old customers big discounts! I'll pay for the food money of the VPET!\nBetter buy tips you: $10 or less food / medicine, etc. can be charged at will:| 更好买老顾客大优惠!桌宠的食物钱我来出!\n更好买提示您:$10以下的食物/药品等随便赊账#Better buy old customers big discounts! I'll pay for the food money of the VPET!\nBetter buy tips you: $10 or less food / medicine, etc. can be charged at will:|
看到您囊中羞涩,桌宠拿出了1000块私房钱出来给你#Seeing that you are shy in your pocket, the VPET took out 1000 yuan of private money to give you:| 看到您囊中羞涩,桌宠拿出了1000块私房钱出来给你#Seeing that you are shy in your pocket, the VPET took out 1000 yuan of private money to give you:|
隐藏窗口#Hide Window:|
在任务切换器中隐藏窗口#Hide window from task switcher:|
在Alt+Tab中隐藏#Hide from Alt+Tab:|