Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Friday, March 25, 2011

Disable flashing notification in Windows

Use regedit to set HKEY_CURRENT_USER\Control Panel\Desktop\ForegroundFlashCount to 1 (more info here)

There's also ForegroundLockTimeout, I'm not quite sure what that does.

Be sure to log out for the changes to take effect.

Tuesday, February 1, 2011

Center mouse after aero snap keyboard shortcut (auto hotkey)

True X-Mouse has a few problems. The most noticeable (for me) is that if the window the mouse is over moves (ie: you use the Aero Snap keyboard shortcuts, practically my favorite command in Windows 7), the window focus changes to the window below it. (This can really mess with your muscle memory!)

Turns out AutoHotKey can remedy the situation (I'm new to AutoHotKey, so there's probably a more elegant way to do this):

; Aero-Snap Mouse
; Move mouse to center of windows that are aero-snapped (True X-Mouse won't do this)
CenterMouseInWindow(Title)
{
WinActivate, %Title% ; True X-Mouse may have taken focus away when we moved
WinGetPos, X, Y, width, height, %Title%
center_x:=width/2
center_y:=height/2
MouseMove,center_x,center_y
return
}

#Left::
WinGetTitle, Title, A
SendInput #{Left}
CenterMouseInWindow(Title)
return

#+Left::
WinGetTitle, Title, A
SendInput #+{Left}
CenterMouseInWindow(Title)
return

#Right::
WinGetTitle, Title, A
SendInput #{Right}
CenterMouseInWindow(Title)
return

#+Right::
WinGetTitle, Title, A
SendInput #+{Right}
CenterMouseInWindow(Title)
return

#Up::
WinGetTitle, Title, A
SendInput #{Up}
CenterMouseInWindow(Title)
return

#Down::
WinGetTitle, Title, A
SendInput #{Down}
CenterMouseInWindow(Title)
return



This captures the aero snap shortcuts, gets the title for the current window, sends the aero snap shortcut to windows (which moves the window), then re-activates the old window and centers the mouse.

It's not instant (even with MoveMouse speed=0, I tried it), so you can't do Win+Shift+Left/Right rapid fire, but it works pretty well other than that.

Wednesday, January 26, 2011

Focus follows mouse for Windows

True X-Mouse does a good job of focus-follows-mouse in Windows. It's *really* nice for switching focus from remote desktop to local windows, since alt-tab is (intentionally) eaten by the remote machine

It also does some clip-board stuff to simulate X-Windows cut/copy/paste behavior, which I don't really care about (but so far hasn't gotten in my way).

Wednesday, November 24, 2010

Easily sleep/restart/shutdown Windows via remote desktop

To easily shutdown/restart/sleep a windows machine via remote desktop, click on the desktop and press Alt+F4. This will bring up the standard Windows shutdown prompt (where you can choose shutdown, restart, sleep, etc). (I didn't know that!)

More info here.

Thursday, November 11, 2010

Vertical Split (sort of) in Microsoft Word 2010

Word (along with other Microsoft products, such as Visual Studio) only allows you to "split" a document horizontally (that is, into two sections on top of each other). Since the trend these days is towards widescreen monitors, it would really be more helpful to split vertically (that is, two sections side by side).

You actually can do this in Word (and VS), they just don't call it "split". The paradigm seems to be making "new windows", which you can then position side by side yourself (VS's inner window management does this for you).

In Word 2010, go to "View" on the Ribbon and click "New Window". If you have Windows 7, then you can use Win+Left and Win+Right (or drag the windows into the corners) to make each window take up half the screen.

A true vertical split would let you resize both views by dragging one separator, but this works well enough most of the time.

Saturday, September 18, 2010

"Show All Files" crash work-around (Visual Studio 2010)

When I upgraded to Visual Studio 2010, I hit the following problem: after converting my old project to the new format, I made the mistake of clicking on "Show All Files". Once you've done this, it seems you can't go back -- any time I tried to deselect it, VS crashed.

Here's how I fixed it:

  1. Open up PowerShell in your project folder

  2. Run ls -rec | select-string Show

  3. Use your favorite text editor to set all references to "ShowAllFiles" to false



In my case, this ended up being [ProjectName].vcxproj.user, but do the Select-String search to be sure.

Tuesday, September 14, 2010

ThinkPad trackpoint scrolling on Windows

For my model (T61), at least, go here.

Download and install the "ThinkPad UltraNav Driver". Requires a restart (lame), but works like a charm afterward.

Saturday, May 22, 2010

Focus-follows-mouse in Windows (AutoHotKey)

This AutoHotKey code gives you focus-follows-mouse behavior: whatever window the mouse is over has "focus" (keys pressed are sent here). This lets you select a window faster than alt-tabbing though all the options. This script does not raise the window, so you can type in part of a window that is still partially covered (this comes in handy more often than you might think).

Thanks to sooyke, who posted it here.


~ScrollLock::

SLStatus := GetKeyState("ScrollLock", "T")
SPI_SETACTIVEWINDOWTRACKING = 0x1001
SPIF_UPDATEINIFILE = 1
SPIF_SENDCHANGE = 2
DllCall("SystemParametersInfo",UInt,SPI_SETACTIVEWINDOWTRACKING,UInt,0,UInt,SLStatus,UInt,SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
return

There and back again: last week's brief return to linux

I put Ubuntu back on my machine recently, because the ATI drivers for my card under Win7 weren't working with my shaders. It was kind of fun, and I do remember liking the control it gave me over customization. However, to my surprise, I noticed several things:
1) Lots of fit and finish bugs (options missing or not being saved, UI elements in the wrong place, stuff like that). And these were all within the first few hours of using the product!
2) At least one completely unexpected hard crash (while scrolling a page in firefox!)
3) I *really* missed the (Shift)+Win+Left/Right/Up window management and Win+P display management from Win7
4) Something in the font smoothing or colors in X gives me a headache! (I can stare at gvim with the desert colorscheme for hours in Win7, but had trouble concentrating after a few minutes in Ubuntu)

I actually remember getting headaches in college when working on code late at night, but I always assumed it was because it was late or I was tired. Now I'm not so sure...

As surprised as I am to say it, I really prefer working in Windows now. As I said, I like the customizability of the linux world, but the quality bar isn't nearly as high as Win7 or OS X. Only the hard-crash prevented me from doing my work, but that's the problem with how the linux world tends to view these problems. There's a sort of broken window theory at play: if it's understood that "minor" bugs can be left in (because "they don't really affect functionality, just work around it! They should use the command line anyway..."), then other more severe bugs will start to creep in.

That said, I'm a stubborn person, and would've scripted my way around it, were it not for the fact that using it literally gave me a headache! Rebooting back to Win7, I was actually comforted by aero theme, taskbar, and other things i have limited control over. Sure, I can't customize them to my hearts content, but I can count on them. I feel at home in Windows now, and if I ever want to really get crazy with customizability, I can look into AutoHotkey.

I'm still curious about why X gave me a headache, though.

Tuesday, February 16, 2010

Changing a VSTS Agent's Controller

The controller pointed to by a Visual Studio Team Test Agent can be changed with AgentConfigUtil.exe. ie (from powershell):
. ${env:ProgramFiles(x86)}\*Test*Load*Agent\LoadTest\AgentConfigUtil.exe /controller:(machine)

You should then restart the Visual Studio Team Test Agent service:
net stop “Visual Studio Team Test Agent”
net start “Visual Studio Team Test Agent”

Saturday, January 16, 2010

Rudimentary PowerShell wrapper (CMD.exe replacement)

PowerShell rocks, but CMD.exe sucks is too limited for my tastes. I'm going to try making a wrapper/CMD.exe replacement for PowerShell. And what better language to write it in than PowerShell script itself? I'm calling it "IggyPosh" for now (POwer SHell).

Here's an early draft. No prompt or command history, but you can type commands and they are executed, so it's a start.


function test($str) {
$str = $rs.CreatePipeline($str).Invoke() | Out-String
$history.Text += $str -replace "\s+$([Environment]::NewLine)",[Environment]::NewLine
$history.SelectionStart = $history.Text.Length
$history.ScrollToCaret()
}

# Prepare the window
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object Windows.Forms.Form
$form.Text = "IggyPosh"
$form.Size = New-Object Drawing.Point 600,400

$history = New-Object Windows.Forms.TextBox
$history.Multiline = $true
$history.ReadOnly = $true
$history.ScrollBars = [System.Windows.Forms.ScrollBars]::Vertical
$history.Dock = [System.Windows.Forms.DockStyle]::Fill
$history.BackColor = [System.Drawing.Color]::FromArgb(0,64,0)
$history.ForeColor = [System.Drawing.Color]::FromArgb(224,224,224)
$history.Font = New-Object System.Drawing.Font("Consolas", 9)
$form.Controls.Add($history)

$command = New-Object Windows.Forms.TextBox
$command.Dock = [System.Windows.Forms.DockStyle]::Bottom
$command.add_KeyDown({
if ($_.KeyCode -eq "Enter") { test($command.Text); $command.Text="" }
})
$form.Controls.Add($command)

# Try to init a powershell instance we can talk to
$rs = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs.Open()

$form.ShowDialog()

Wednesday, January 6, 2010

Fix: Installers fail because of "pending reboot" (windows)

If an installer refuses to run because of a "pending reboot" to your system, it may be because of files listed in the "PendingFileRenameOperations" key in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

Open that key in Regedit and check the entries. If they look harmless (especially if they are in some sort of Temp folder), remove them and try again.

More information here.

Tuesday, January 5, 2010

Create directories and upload files to Sharepoint from PowerShell

Create a new folder on Sharepoint server hosted at http://server/:
$url = "http://server/Shared%20Documents/newfolder/"
$req = [System.Net.HttpWebRequest]::Create($url)
$req.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$req.Method = "MKCOL"
$res = $req.GetResponse()


Add a file to that folder:
$dest = $url+"newfile.txt"
$src = "C:\myfile.txt"
$wc = New-Object System.Net.WebClient
$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc.uploadfile("$dest", "PUT", $src)

Sunday, December 27, 2009

Louder SMPlayer volume

For some reason, a number of my shows and movies seem to be at a low volume. SMPlayer, my video player of choice, didn't seem to have a way of boosting the sound beyond 100%. Turns out it does, you just have to hunt for it:

Options->Preferences: General->Audio->Max. Amplification

Set that to 200 or so to allow further amplification in software.

Audio->Filters->Volume Normalization is another way to help boost sound.

Sunday, December 20, 2009

PowerShell script to play latest video linked on web page

My auto-piracy machine do-it-yourself media center lists the most recently downloaded TV shows in a way that looks like this (in HTML, that is):

<a href="http://www.blogger.com/tv/How%20I%20Met%20Your%20Mother/05/how.i.met.your.mother.s05e11.720p.hdtv.x264-ctu.mkv">Season 5 Episode 11</a>;

The web interface isn't bad, but I like to mess around with scripting and command line stuff, so here's a powershell script that will play the latest show matching a given string. (Examples: latest how, latest -n 2 dollhouse)


param(
[switch]$switch = $false,
[string]$query = $(Read-Host -prompt "Keyword"),
[int]$num = $(if ($switch) {Read-Host -prompt "Number"} else {1})
)

$player = "C:\Program Files\SMPlayer\smplayer.exe"
$client = New-Object System.Net.WebClient
$data = $client.DownloadData("http://spot/")
$page = [System.Text.Encoding]::ASCII.GetString($data)

# They are displayed on the page with newest on top, but we want to play them in order (oldest to newest)
$matches = [regex]::Matches($page, "href=`"([^\<\>]*?$query[^\<\>]*?\.[^\<\>]*?)`"", "IgnoreCase") | Select-Object -first $num | Sort-Object

$files = ""
foreach ($m in $matches) {
$files += "'http://spot/$($m.groups[1])' "
}

if ($files.Length -gt 0) {
echo $files
Start-Process $player $files
}
else { echo "Could not find anything matching '$query'" }


Notes:

  • [^\<\>] means "any character except < or >". The *? means "any number of the preceding". So in this case, it means "any number of characters except < or >". Useful for reading the text between tags.

  • The bit at the top lets you optionally specify the number of matches to use with -num (or -n), defaulting to 1 otherwise. If you don't give it a query, it will prompt you. (It doesn't properly handle the case of -num w/o a number, but I don't care at this point. You'll get an error message, just not a nice one).

Wednesday, September 30, 2009

Clear IE cache from command line

Turns out you can avoid the awkward series of menus to empty Internet Explorer's temporary internet files, history, cookies, etc by typing the following in the command line:
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

Very useful for automated testing!

More details here.

Monday, June 29, 2009

My Windows Extras

A list of software I use to make me feel more at home in Windows:

AutoHotkey Customize keyboard shortcuts and automate common actions. (Apparently advanced window management is possible...KDE Mover-Sizer is based on this).
CDBurnerXP (iso and gap-less Audio CD burning)
Filezilla (SFTP)
Firefox (web browser, can be extended with plugins)
- Vimperator (vim bindings, link numbering/hints)
- Adblock Plus (blocks ads)
- Custom Download Manager (stop download window from popping up)
- Colorful Tabs (tab colors)
Foobar2000 (minimalistic/functional media player replacement; never mind, I like WinAmp better)
GMail Notifier Plus (checks gmail, displays with Windows 7's jump lists)
GVim (programmer/admin's text editor)
KDE Mover-Sizer (move and resize windows by alt-clicking anywhere in window)
Notepad++ Coder/Admin text editor with a less...unique...control-scheme than GVim. Also, handles working off of UNC shares better (gvim frequently locks up for half a minute or so).
Paint.NET (somewhere between Paint and Photoshop)
Pidgin (AIM, GTalk)
Process Explorer (a much better Task Manager)
PuTTY (SSH)
SMplayer (video player; linux's mplayer w/GUI)
Steam (Games)
Sumatra PDF Viewer (no-nonsense PDF viewer)
TortiseSVN (SVN)
VirtualBox (virtualization: lets you run other OSs at the same time as Windows; supports 3D acceleration!)
WinAmp (watch folders, jump to file, global hotkeys...everything I want in a music player)
WinRAR (zip,rar,tar,etc; nag screen, but never expires)
WMP Keys (global hotkeys for Windows Media Player; since rendered unnecessary WinAmp)

Wednesday, June 10, 2009

Global hotkeys in Windows Media Player

The main reason I used to use Winamp was for a feature called "global hotkeys". This let me assign arbitrary keys to play/pause, fast forward, etc, while Winamp was minimized (it even worked while playing full-screen games!) Turns out you can do the same thing (for my purposes, at least) in Windows Media Player with something called WMP Keys. (Instructions on linked page.)

Thursday, May 28, 2009

Using opengl, glut, and cg with Visual Studio

These pages describe the process (the first one is out of date, but the changes to directory structure are minor):

OpenGL and GLUT
Cg

In case those pages go away, it boils down to this:

GLUT

  • Get GLUT for Win32

  • Copy...


    • glut32.dll to %WinDir%\System

    • glut32.lib to $(VSDir)\VC\lib

    • glut.h to $(VSDir)\include\GL


  • ...where $(VSDir) is something like C:\Program Files\Microsoft Visual Studio 9.0\VC


Cg


Visual Studio

  • Make a new Win32 Console Application project: File->New Project->Visual C++->Win32->Win32 Console Application

    • In the "Application Settings" page of the wizard, make sure Application type is Console Application and Empty project (under Additional options) is checked.

  • Go to Project->(project name) Settings


    • Set Configuration to All Configurations

    • Expand Configuration Properties

    • In C/C++->General, add $(CG_INC_PATH) to Additional Include Directories

    • In Linker->General, add $(CG_LIB_PATH) to Additional Library Directories

    • In Linker->Input, add opengl32.lib glu32.lib glut32.lib cg.lib cgGL.lib to Additional Dependencies


Saturday, August 9, 2008

Remap keys in Windows with SharpKeys

Caps lock is such a useless key. I almost never hit it intentionally. When I do strike it, the results are at best annoying (I LOOK LIKE I'M SHOUTING) and at worst are catastrophic! (try hitting caps lock in the middle of a vim session sometime. Or better yet, try hitting it in the middle of someone else's. I guarantee you there will be profanity. :)

Given my vim-ish tendencies, I decided to map Caps Lock to Escape (a very important key in vim, which is in a crappy location on many keyboards). There are several ways to do this under Linux. Under Windows, registry magic is needed.

Fortunately, a free program called SharpKeys will do this for you. (It looks like it can map just about any key to any other key. I haven't played with it.)