activate task view programmatically windows 10 - batch-file

Is there a way to activate task view programmatically in windows 10?
There was a way to activate Flip3D programmatically in win7 using the following copied from VBScript SendKeys CTRL+LWIN+TAB?
CreateObject("WScript.Shell").Run "rundll32 DwmApi #105"
I just want to make a .vbs or .bat file that activates windows 10 Task View.

OK Found a way to do it with C#
Install Visual studio
Install NuGet http://docs.nuget.org/consume/installing-nuget
File > New Project
Name it taskview
Visual C# > Console application
File > Save All
Tools > NuGet Package Manager > Package Manager Console
Type "Install-Package InputSimulator" in Package Manager console
window
Paste Following text in taskview.cs window
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WindowsInput.Native;// Importante
namespace taskview
{
class Program
{
static void Main(string[] args)
{
WindowsInput.InputSimulator kb = new WindowsInput.InputSimulator();
kb.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.TAB);
Console.Read();// Keep console window open
}
}
}
Change Dropdown with Debug in it to Release
Build > Build Solution
Build > Build taskview
It should be in: My Documents\Visual Studio 2015\Projects\taskview\taskview\bin\Release\taskview.exe

You can use the function having the ordinal 105 within dwmapi.dll. You can use rundll32.exe to execute that function. This is how the command line looks like:
start rundll32.exe dwmapi.dll #105
It will trigger the Flip 3D functionality on Windows Vista and later, if Aero is enabled.

Related

Can Fody and its plugins be used with .NET Core (3.0)?

As the title says, I'm having trouble getting Fody, and the plugin Fody.PropertyChanged, to work in .NET Core 3.0, or any .NET Core version. Reading the issues on the respective GitHub pages doesn't answer my question, nor am I able to find any relevant answers.
Once installed I cannot run my WPF project anymore and I am given the following error:
The target process exited without raising a CoreCLR started event.
Ensure that the target process is configured to use .NET Core.
This may be expected if the target process did not run on .NET Core.
The program '[21820] CalculationToolsApp.exe' has exited with code -2147450749 (0x80008083).
Any suggestions?
EDIT: I found out that I (maybe) cant use "Fody.Costura" with "Fody.PropertyChanged" like this in the FodyWeavers.xml file:
<Weavers>
<PropertyChanged />
<Costura />
</Weavers>
Which shouldn't be a problem because with .NET Core I can create a single file application anyway. Removing the Costura reference from the FodyWeavers.xml solved my problem!
It should work. Fody is compatible with .NET Standard.
Create a new WPF app using the WPF App (.NET Core) template in Visual Studio 2019 or using the dotnet new wpf command
Install the Fody and PropertyChanged.Fody NuGet packages
Add a file named "FodyWeavers.xml" with the following contents to the project:
<Weavers>
<PropertyChanged />
</Weavers>
Build
If you then decompile the assembly using a decompiler such as for example dotPeek, you should see the injected code as expected, e.g.:
public string GivenNames
{
// Method get_GivenNames with token 06000009
get
{
return this.<GivenNames>k__BackingField;
}
// Method set_GivenNames with token 0600000A
set
{
if (string.Equals(this.<GivenNames>k__BackingField, value, StringComparison.Ordinal))
return;
this.<GivenNames>k__BackingField = value;
this.<>OnPropertyChanged(<>PropertyChangedEventArgs.FullName);
this.<>OnPropertyChanged(<>PropertyChangedEventArgs.GivenNames);
}
}
Costura didnt work in wpf with .net core 3.1 for me either.
In .net core 3.1 you can use this instead:
Build -> publish -> create profile -> Edit "Configuration"
Target Runtime = win-x64 (or what ever target system you want, but NOT "portable")
expand "File Publish Options"
check: Produce single file
save
When you now choose build -> publish -> publish button it will create the single file.
It seems to be that they stopped the costura project because of the "Single-file executables" feature of .net core. Though this feature is still behind costura because you have to set a target runtime.
https://github.com/Fody/Costura/issues/442
In dotnet core 3 there are two new features
Single-file executables
Assembly linking
With these features included in the dotnet tool set, the value
proposition of Costura is greatly diminished. With that in mind I
think long term Costura should cease to be used as people transition
over.
Please comment with any input.
Plan:
disable issues
PR will still be accepted but only for bug fixes
add note to readme
add note to nuget description
write a warning in
update for .NET 5:
for .NET 5 and the current visual studio version 16.10.2 the wizard changed. I could not get this to work with the wizard anymore though i checked the options for single file etc.. But using the console worked: tools -> command line -> developer command prompt -> enter this:
dotnet publish -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true
.NET 5 not compiling to single file executables

Create a WinForm project based on .net core 3

I am trying to figure out what I am missing here, must be something quite obvious but I am unable to see it.
what I am trying to achieve is to have a working solution/project of WinForms app based on .net core 3. it might be too early to look into it as they just announced it but still why not if we can. here are steps I've done so far:
create a blank solution
run the ".net new winforms" command
attempt to add the generated project to the solution.
i'm getting the error: Project File is incomplete. Expected imports are missing.
here is the output of the CLI:
Package Manager Console Host Version 4.9.2.5706
Type 'get-help NuGet' to see all available NuGet commands.
PM> dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.2.105 [C:\Program Files\dotnet\sdk]
3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]
PM> dotnet new winforms
The template "Windows Forms Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on C:\DevProjects\winformscore3\winformscore3.csproj...
Persisting no-op dg to C:\DevProjects\winformscore3\obj\winformscore3.csproj.nuget.dgspec.json
Restore completed in 113.9 ms for C:\DevProjects\winformscore3\winformscore3.csproj.
Restore succeeded.
PM>
https://dotnet.microsoft.com/download/dotnet-core/3.0
"To use .NET Core 3.0 with Visual Studio, you'll need Visual Studio 2019 Preview."

MSBuild opens a new instance of Visual Studio

We have been using Visual studio 2010 - 2013 on the build server using the following MSBuild command so far:
Set msBuilder=%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
However recently we moved to VS 2015, and had to uninstall all other VS versions (for saving space), and used the following build location (partially also to cater compilation of C# 6.0 features):
Set msBuilder =%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
This seems to work for most of the VS Solutions we have,however for one particular VS solution, when we execute this line:
Set doSolutionBuild=%msBuilder% MySolution.sln /t:clean;Build /p:Configuration=Release;Architecture=x86;Platform=x86 /v:n
it opens and instance of VS 2015 of the same project on the build server and the build process just hangs there in the command prompt.
Can anyone explain how we could resolve this?

How to build shader effect (.fx) in csproj

I'm trying to build pixel shader in a C# class library.
I have added fx file to the project. Since I can't find any suitable build action I tried to manually edit csproj:
<FxCompile Include="MyEffect.fx">
<ShaderType>Pixel</ShaderType>
</FxCompile>
but when I try to locate the ps file, I get System.IO.IOException: Cannot locate resource 'MyEffect.ps'
here is the code that throws error:
public class MyEffect : ShaderEffect
{
public MyEffect(){
this.PixesShader = new Uri("pack://application:,,,/WpfControlLibrary1;component/MyEffect.ps");
}
}
How to setup my project so that I can locate the compiled shader?
All the tutorials I have found are for C++ projects or deals with old tools like custom build task, but I think that is not required since VS2012.
EDIT:
Visual Studio does compile .fx files only in C++ projects. In C# projects it does not work. It is mentioneded here: http://blogs.msdn.com/b/chuckw/archive/2012/05/07/hlsl-fxc-and-d3dcompile.aspx
You can set a Postbuild option to compile your fx files with fxc:
fxc /O0 /Fc /Zi /T fx_5_0 /Fo myShader.fxo myShader.fx
But I compile all my shaders at runtime when developing.
I'm not sure what C# library you are using but you can do this in both SharpDX and SlimDX:
ShaderBytecode.CompileFromFile(effectFile, "fx_5_0", ShaderFlags.None, EffectFlags.None);

Add files/folders to a visual studio project using command line tool

Is there a way to automatically add/include new files/folders into a Visual Studio project or to add/include them using a command line tool?
You can access Visual Studio automation from VB Script. See the following sample .vbs file that can be run as an executable:
Dim dte
Dim project
Set dte = CreateObject("VisualStudio.DTE.11.0")
dte.Solution.Open("C:\Users\sv\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1.sln")
For Each project In dte.Solution.Projects
If project.Name = "ConsoleApplication1" Then
project.ProjectItems.AddFromFile("C:\Users\sv\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\1.txt")
project.Save(project.FullName)
End If
Next
dte.Solution.Close()

Resources