Archive for the ‘fixes’ Category

Easy Resize Script: Fix

Posted: February 4, 2011 by jellymann in computers, fixes, hotkeys, keyboard, mouse, windows

I forgot something on my last post. The Easy Window Resize script I showed you had the same labels as the original Easy Window Move, so it didn’t work unless you ran them on separate scripts. The simple fix is to rename all the labels to unique ones. Otherwise, you can just use the fixed one below. I replaced all “EWD” with “EWR” and changed all “LButton” to “MButton”.

#MButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWR_MouseStartX, EWR_MouseStartY, EWR_MouseWin
WinGetPos, EWR_OriginalPosX, EWR_OriginalPosY,,, ahk_id %EWR_MouseWin%
WinGet, EWR_WinState, MinMax, ahk_id %EWR_MouseWin%
if EWR_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWR_WatchMouse, 10 ; Track the mouse as the user drags it.
return

EWR_WatchMouse:
GetKeyState, EWR_MButtonState, MButton, P
if EWR_MButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, EWR_WatchMouse, off
return
}
GetKeyState, EWR_EscapeState, Escape, P
if EWR_EscapeState = D ; Escape has been pressed, so drag is cancelled.
{
SetTimer, EWR_WatchMouse, off
WinMove, ahk_id %EWR_MouseWin%,, %EWR_OriginalPosX%, %EWR_OriginalPosY%
return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWR_MouseX, EWR_MouseY
WinGetPos, EWR_WinX, EWR_WinY, EWR_WinW, EWR_WinH, ahk_id %EWR_MouseWin%
SetWinDelay, -1 ; Makes the below move faster/smoother.
if (EWR_MouseX-EWR_WinX) <= (EWR_WinW/3)
{
if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)
{
WinMove, ahk_id %EWR_MouseWin%,, EWR_WinX + EWR_MouseX - EWR_MouseStartX, EWR_WinY + EWR_MouseY - EWR_MouseStartY, EWR_WinW + EWR_MouseStartX - EWR_MouseX, EWR_WinH + EWR_MouseStartY - EWR_MouseY
}
else if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)*2
{
WinMove, ahk_id %EWR_MouseWin%,, EWR_WinX + EWR_MouseX - EWR_MouseStartX, , EWR_WinW + EWR_MouseStartX - EWR_MouseX,
}
else
{
WinMove, ahk_id %EWR_MouseWin%,, EWR_WinX + EWR_MouseX - EWR_MouseStartX, , EWR_WinW + EWR_MouseStartX - EWR_MouseX, EWR_WinH + EWR_MouseY - EWR_MouseStartY
}
}
else if (EWR_MouseX-EWR_WinX) <= (EWR_WinW/3)*2
{
if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/2)
{
WinMove, ahk_id %EWR_MouseWin%,,, EWR_WinY + EWR_MouseY - EWR_MouseStartY,, EWR_WinH + EWR_MouseStartY - EWR_MouseY
}
else
{
WinMove, ahk_id %EWR_MouseWin%,,,,, EWR_WinH + EWR_MouseY - EWR_MouseStartY
}
}
else
{
if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)
{
WinMove, ahk_id %EWR_MouseWin%,,, EWR_WinY + EWR_MouseY - EWR_MouseStartY, EWR_WinW + EWR_MouseX - EWR_MouseStartX, EWR_WinH + EWR_MouseStartY - EWR_MouseY
}
else if (EWR_MouseY-EWR_WinY) <= (EWR_WinH/3)*2
{
WinMove, ahk_id %EWR_MouseWin%,,, , EWR_WinW + EWR_MouseX - EWR_MouseStartX,
}
else
{
WinMove, ahk_id %EWR_MouseWin%,,, , EWR_WinW + EWR_MouseX - EWR_MouseStartX, EWR_WinH + EWR_MouseY - EWR_MouseStartY
}
}
EWR_MouseStartX := EWR_MouseX ; Update for the next timer-call to this subroutine.
EWR_MouseStartY := EWR_MouseY
return

My Escape key stopped working today. After freaking out for a few minutes about where I’m going to get the money to buy a new keyboard, I made a quick AHK script that remaps the Caps Lock key to Escape. Then I realised that I would probably tap it by accident doing some irreversible damage while typing, so I thought I’d remap Scroll Lock to Escape (Who uses scroll lock, anyway?):

ScrollLock::
{
Send {Esc}
return
}

On the topic of Caps Lock, everyone know how annoying it is when you accidentally press it and your wall post’s mood changes significantly. SERIOUSLY ANNOYING. So here is how to remap the Caps Lock key to something else. In this case, it acts as a third Control key:

CapsLock::Ctrl

If you sometimes do need to use the Caps Lock, like when you’re flaming a forum, or coding a serious error message, you can map Shift+Caps Lock to toggle Caps Lock. I tried doing it like this, which is the way most people did it in the foums:

+CapsLock::CapsLock

But unfortunately that only turned Caps Lock on and not off. And since my Caps Lock key is remapped to Control, I couldn’t turn it off without killing the AHK script.

The following script does work, as it checks the state of Caps Lock and then acts accordingly:

+CapsLock::
{
if GetKeyState("Capslock", "T")
SetCapsLockState, Off
else
SetCapsLockState, On
return
}

I’ve always wanted my scroll wheel to be an easy volume-control, as my keyboard does not have media keys. I Googled and went through forum after forum to find out what AHK commands control volume, but none of them worked right. Then today I stumbled across something. The media keys are keyboard keys after all, and can be mapped and remapped in AHK just like any other, even if your keyboard doesn’t have them. Here is a simple script that uses the scroll wheel and middle mouse button to change and mute the volume:

#MButton::Volume_Mute
#WheelDown::Volume_Down
#WheelUp::Volume_Up

When in doubt, consult the AutoHotkey Key List.
I also recommend you also take a look at my other post on AutoHotkey.

Tech Support

Posted: September 3, 2010 by jellymann in computers, fixes, laptop, tech

I had a very productive day today. Not only did I get stuff done, I had fun doing it. Most of the time I hate computers because of their tendencies to fail, so I enjoy dismembering them into a pile of separate electronic guts.

Taking apart a laptop is so much fun! If you manage not to break anything, that is. My friend’s Acer Travelmate took a knock a while ago and finally gave into constantly being beaten on a day-to-day basis. Plugged in the charger and nothing happened. No light, nothing. I absolutely hate when stuff just stops working and I have no idea what went wrong. Fortunately there was a telltale chunk missing from the case where the AC plug is. Now we know where the problem is, all we need is “what” and “how”.

The problem we had with getting to the AC power socket in this thing was that we ended up literally dismantling every component inside the laptop. After much unscrewing and unnecessary brute force (which may have resulted in a few missing pieces of plastic, thanks to me) we had separated it into seven significant figures: chassis, cover, keyboard, motherboard, hard drive, optical drive, and screen.

The problem was evident once we noticed a tiny piece of metal fall out of the laptop half way through unscrewing the chassis. It so happened it was the pin from inside the AC power socket! Encouraging news for us that the problem was only a misplaced piece of metal about a centimeter long, but we still had to take everything apart. Sigh…

When we finally got to the socket, all we had to do was put the pin back in. I set it in place, plugged it in and kazam! A nice shock and a spark and nothing happened. I thought I had blown the motherboard. Nevertheless I realized my mistake and placed the pin the right way around. All very well, I slotted in the battery and inserted the AC Power cable and, w00t! Lo and behold the long-awaited orange “charging” light lit up. Great work now I stuck a piece of stickytape to keep the pin in place and put everything back together ­čÖé

Reassembling the laptop was quicker than taking it apart, I don’t know why. Once every component was plugged in there were five little screws left over. oops…

The scary thing was that it didn’t appear to switch on when I pushed the power button. Don;t you hate feeling when you spend half your morning fixing something only to find you made it worse? Turns out there was a broken screw just under the little circuit board on which the power button is situated. It seems I fixed one problem and introduced another one. Thankfully the new problem doesn’t stop the laptop from being useful. All it needs is a push down in the right place and the power button will function.

Problem is now that if the screen switches off after a few minutes you can’t tell if the laptop is on or not because the power light is also attached to this slightly misplaced board. Oh well, at least I moved the problem to a more accessible location.

It was fun, too! I feel like taking apart my dad’s netbook just to see what it looks like. lol