I've just bought a Apple Keyboard (USB) and wanted to switch the key mapping of the right windows and right alt key..
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,5c,e0,38,e0,38,e0,5c,e0,\
00,00,00,00
To swap both the left and the right Windows and Alt Key use:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,07,00,00,00,37,e0,64,00,5b,e0,38,00,\
38,00,5b,e0,5c,e0,38,e0,38,e0,5c,e0,47,e0,63,e0,00,00,00,00
Reboot or log off afterwards.
Surley some of you know the Brainfuck programming language... there are many compilers and interpreters around, yet I haven't found some for powershell... so here we go:
Powershell Brainfuck Interpreter:
param ($i)
$t = @{ '>'='$p++;';
'<'='$p--;';
'+'='$m[$p]++';
'-'='$m[$p]--';
'.'='write-host $([char]$m[$p]) -n ';
','='$m[$p]=$host.ui.ReadLine() ';
'['='while ($m[$p] -ne 0) {';
']'='}';
}
$c = '$p=0;$m=new-object "byte[]" 32768'+"`n" ; gc $i -Enc Byte -r 1 | % {$c+=$t["$([char]$_)"]+"`n"}
invoke-expression $c
Powershell Brainfuck Compiler:
param ( [string] $infile = $(throw "Please specify input file (.b)"),
[string] $outfile = $(throw "Please specify output file (.cs)"),
[switch] $run = $false
)
$csc = (join-path ($env:windir) Microsoft.NET\Framework\v2.0.50727\csc.exe)
$transpose = @{'>' = 'p++;';
'<' = 'p--;';
'+' = 'm[p]++;';
'-' = 'm[p]--;';
'.' = 'Console.Write(m[p]);';
',' = 'm[p]=Console.ReadLine();';
'[' = "while (m[p]!=0) {"
']' = '}';
}
$header = @"
using System;
public class Program {
public static void Main() {
int p=0;
char[] m=new char[32768];
"@
if ($(test-path $outfile)) { rm $outfile | out-null }
$header | out-file $outfile -append
get-content $infile -encoding Byte -readcount 1 |
% { $transpose["$([char]$_)"] } | out-file $outfile -append
"}}" | out-file $outfile -append
& $csc `/target:exe $outfile | out-null
if ($run) {
$outfile = $outfile.Replace(".cs",".exe")
& .`/$outfile
}
You can find the both script files (compiler and interpreter) in the attachment of this post.
Have fun!
MVPs sind Experten, die sich in der Microsoft Community engagieren. Erfahren Sie im Gespräch mit 3 MVPs und dem MVP Betreuer von Microsoft, was einen guten MVP ausmacht, wie man MVP wird und Vieles mehr! Erfahren Sie mehr im Interview auf MSDN Talk.
I've written a small and rather simple powershell cmdlet which allows you to list the core and application properties of office documents, so that you can do something like this:
Samples:
Get-DocProps –path "*.docx" | where { $_.Creator –eq "John Doe" }
Get-ChildItem "*.docx" | get-docprops | where { $_.Lines –gt 100 } | select Path,Lines
Get-ChildItem * -include "*.docx","*.xlsx" –recurse | get-docprops | select Path, Creator, Lines, Paragraphs
Get-ChildItem * -include "*.docx" –recurse | get-docprops | measure-object Words,Lines,Paragraphs –sum –min –max -ave
The Cmdlet itself reads the docProps/app.xml and docProps/core.xml files inside Office 2007 documents using the System.IO.Packaging namespace, so therefore install .NET Framework 3.0 to use this cmdlet.
You can download the DocProps Cmdlet here. (No warranty, provided "AS IS", use at your own risk ;-)) If you are interested in the source code just drop me a mail.
After installation just run
add-pssnapin DocProps.Snapin
at your powershell command prompt and enjoy.
Here is a list of the core properties:
Property Name | Type |
Category | String |
Created | DateTime |
Creator | String |
Description | String |
Keywords | String |
Language | String |
LastModifiedBy | String |
LastPrinted | DateTime |
Modified | DateTime |
Revision | String |
Subject | String |
Title | String |
Version | String |
Word Documents additionally have following properties:
Property Name | Type |
Template | String |
TotalTime | String |
Pages | Int32 |
Words | Int32 |
Characters | Int32 |
Application | String |
DocSecurity | String |
Lines | Int32 |
Paragraphs | Int32 |
ScaleCrop | String |
Company | String |
LinksUpToDate | Boolean |
CharactersWithSpaces | Int32 |
SharedDoc | Boolean |
HyperlinksChanged | Boolean |
AppVersion | String |
I also run into some implementation, which uses Windows Search to filter for properties.
For several more cmdlets visit the Powershell Community Extensions Project at Codeplex.
Right at the moment there's just a get-docprop cmdlet included in the setup, the set-docprop will follow in a few days, so come back again ;-)
If you develop your custom ribbon interface and actually need to implement an action handler Ken Getz has published a Ribbon User Interface for Developers FAQ, which describes the callback signatures for each ribbon control.
If you want to add a Event Handler Assembly to a specific list in Sharepoint with a Feature you have to pass a ListTemplateId.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="104">
<Receiver>
<Name>EventHandler Delete</Name>
<Type>ItemDeleting</Type>
…
Here's a little codesnippet to get those ListTemplateIds, just add a Reference to Microsoft.Sharepoint.dll.
string[] typeNames = System.Enum.GetNames(typeof(SPListTemplateType));
Array typeValues = System.Enum.GetValues(typeof(SPListTemplateType));
int j = 0;
foreach (int i in typeValues)
{
Console.WriteLine(typeNames[j++].ToString() + " " + i.ToString ());
}
The output of the codesnippet above should look something like this:
GenericList 100
DocumentLibrary 101
Survey 102
Links 103
Announcements 104
Contacts 105
Events 106
Tasks 107
DiscussionBoard 108
PictureLibrary 109
…
Actually these ListTemplateIds (Types) are part of the ListTemplate definitions you can find in ONET.XML
More Posts