Monday, October 26, 2009

Tired of typing big directory path to change to it frequently? (or)

Tired of typing big command frequently in Linux/Unix?

Have your own (small)shortcut command for those long commands.

Steps :

· Create a shell script(.sh) file with the (long)command that needs to be run frequently.

For example,

Create a file '/root/p.sh' and add the following 'cd' command to it.

-------------

cd /var/www/html

· Create an alias to that shell script.

For example,

alias w=’. /root/p.sh’

[Note: dot in the beginning makes the command to be executed in the same shell.]

Add this alias command in ‘.bashrc’ file (anywhere in the file)


Next time, to change to the ‘/var/www/html’ directory, just need to use the command ‘p’.

Note: Any long command(s) can be added to that shell script as required.

Typical commands sequence may be as follows,

vi /root/p.sh

cd /path/to/long/directory

!wq

vi .bashrc

alias w=’. /root/p.sh’

Saturday, July 4, 2009

pyHook Example - Capture Mouse and Keyboard Events in Windows using Python

Here is a sample python program to capture mouse and keyboard events in windows.


import os
import time
import pyHook # http://sourceforge.net/projects/pyhook/
from win32gui import GetWindowRect, GetClassName, GetWindowText

curTime = time.strftime("%Y%m%d_%H%M%S", time.localtime(time.time()))

if not os.path.exists("Messages"):
os.mkdir("Messages")

f = open("Messages\\messages"+ curTime +".txt", "w")

def Log(logStr):
print str(logStr)
f.write(logStr + "\n")


def OnMouseEvent(event):
Log('MessageName:' + str(event.MessageName))
Log('Message:' + str(event.Message))
Log('Time:' + str(event.Time))
Log('Window:' + str(event.Window))
if event.Window != 0:
Log('Window Rect:' + str( GetWindowRect(event.Window)))
Log('Window Class Name:' + str( GetClassName(event.Window)))
#Log('Window Text:' + str( GetWindowText(event.Window)))
Log('WindowName:' + str(event.WindowName))
Log('Position:' + str(event.Position))
Log('Wheel:' + str(event.Wheel))
Log('Injected:' + str(event.Injected))
Log('---')

# return True to pass the event to other handlers
# return False to stop the event from propagating
return True

def OnKeyboardEvent(event):
Log('MessageName:' + str(event.MessageName))
Log('Message:' + str(event.Message))
Log('Time:' + str(event.Time))
Log('Window:' + str(event.Window))
if event.Window != 0:
Log('Window Rect:' + str( GetWindowRect(event.Window)))
Log('Window Class Name:' + str( GetClassName(event.Window)))
#Log('Window Text:' + str( GetWindowText(event.Window)))
Log('WindowName:' + str(event.WindowName))
Log('Ascii:' + str( event.Ascii) + str( chr(event.Ascii)))
Log('Key:' + str( event.Key))
Log('KeyID:' + str( event.KeyID))
Log('ScanCode:' + str( event.ScanCode))
Log('Extended:' + str( event.Extended))
Log('Injected:' + str( event.Injected))
Log('Alt' + str( event.Alt))
Log('Transition' + str( event.Transition))
Log('---')

# return True to pass the event to other handlers
# return False to stop the event from propagating
return True

# create the hook mananger
hm = pyHook.HookManager()
# register two callbacks
hm.MouseAllButtonsDown = OnMouseEvent
hm.KeyDown = OnKeyboardEvent

# hook into the mouse and keyboard events
hm.HookMouse()
hm.HookKeyboard()

if __name__ == '__main__':
import pythoncom
pythoncom.PumpMessages()

My second open source project - Eyecare

I have released my second software "Eyecare". Here is the information about the software.

https://sourceforge.net/projects/eyecare/

* Simple application to take care of your eyes while working n computers for long time.

* This application sits in System Tray and keeps displaying a blank screen after every 20 minutes for 20 seconds.
Currently, this interval time is hard-coded/not configurable.

* Please stretch your legs, look at distance objects, move eyes around, *blink* your eyes and relax yourself during the rest duration.

* Incase you are doing very very important work and don't want the software to disturb you, you can disable blank screen display
by selecting "Disable" option in the system tray icon.
Even if the blank screen is displayed, you can still come out by clicking on the blank window and pressing "ESC" button/ by selecting "Close" option
from "File" Menu.
* My personal recommendation is not disable the software. Because of the "Breakout Principle" http://www.google.co.in/search?q=breakout+principle

* Initially, I have choosen "wxPython" to get the cross platform software. But, now there are some issues in linux machines :(.
Looking for supporting linux environment too.

Wish-List:
* Customizable timing.
* Still counting :)

Take care your vision!

Tuesday, May 12, 2009

My First Open Source Project

I have started writing a small system utility in python to schedule my system shutdown. Later, I thought of adding GUI to it and release it as open source project. Here we go! http://sourceforge.net/project/showfiles.php?group_id=260807

Locking the windows PC using python.

import ctypes
ctypes.windll.user32.LockWorkStation ()


Getting Screen resolutions in python

from win32api import GetSystemMetrics
width = GetSystemMetrics (0)
height = GetSystemMetrics (1)
print "Screen resolution = %dx%d" % (width, height)

Requires the python COM module(http://sourceforge.net/projects/pywin32/).

Monday, May 4, 2009

Moving out of comfort Zone

Here is an nice info to you(which I grabbed from the internet).
Courtesy :http://siva.edaichamy.com/

Someone told a story about the frog and hot water. if you take a frog and put it in boiling water, it will jump right out immediately, but if you put the frog in cold water and then you slowly turn the heat up, the frog will eventually fall asleep and die. I thought what a dumb forg! But when I think about it, it is true that some of us are like that frog, got stuck in a comfort zone.

So what is a comfort zone? It’s where you have no feeling of risk or anxiety concerning decisions make and things you do. Most likely a regular routine where you know what is happening and how things work . It could be physical, emotional, cultural, intellectual and financial.

How can you say that you are in Comfort zone? When you are faced with a new situation, maybe a job opportunity, and you talk yourself out of giving it a shot. Maybe there is no risk but you are still not comfortable with that something unknown. Yes, Comfort zone often enables us to ‘look the our way’ - often shielding us from uncomfortably truths.

While operating within your comfort zone may seem safe, it does not give you the opportunity to grow in your career. By being in comfort zone, You may be good at what you do, but if you continue to do things in the same way, you may lose your value eventually and hence lose bigger opportunities coming on your way. Going outside of your comfort zone enables you to take responsibility for your future, determine what you want from life and act on it.Yes,it is where the Growth takes place. There’s nothing wrong with having a comfort zone but getting stuck there can be like a frog in a warm pot of water.

Moving out of our comfort zone can seem to be frightening, painful & traumatic. But it is really not so. We have all experienced a time when we stepped out of our comfort zone and took a chance.For example, you were always behind the lectern but one day you moved out. (Move out from Lectern at this point) Maybe you asked someone you liked out on a date and they said YES!! What about the moment after you completed your Ice Breaker speech? What about the day you proposed! Yes, sometimes it is very risky but think about the rewards!

So If you think you are stuck in a comfort zone and want to make a change, ask yourself the following questions:

1. What do I want to achieve?
2. What is the best thing that will happen to me if I take this chance
3. What is the worst thing that can happen to me if I take this route?
4. How can I overcome the problems or minimize the loss - if I must take this opportunity?
5. What is the first thing I can do to help me to achieve it?

Taking the first step is important for that is the toughest part. A good beginning is half the victory! You may feel out of your depth or scared to begin with, but each small step will take you towards your goal. Remember, A ship is safe in harbor but that is not a what ship is for. Throw off the bowlines,.Sail away from comfort zone and catch the trade winds in your sails.

Thursday, April 2, 2009

Dictionary + Thesaurus + Word Finder

Dictionary + Thesaurus + Word Finder
http://wordweb.info/
WordWeb is a single-click English thesaurus and dictionary for Windows OS. This can be used to look up words, synonyms and related words. The pronunciations and usage examples are also available.

Free version is also available for download.
Once installed in the Windows System, the word's meanings can be found by selecting/highlighting the word and then by pressing "Ctrl+Alt+W" or "Ctrl+click"

Wednesday, April 1, 2009

Windows and Web Applications Automation

The following tools can be used for automating the testing activities.

1) AutoHotKey (
http://www.autohotkey.com/) [for windows applications automation]:
Any desktop related activities can be automated. For example, open notepad, type something there etc like this.
* AutoHotkey is a free, open-source utility for Windows.
With it, you can:
* Automate almost anything (windows activities) by sending keystroke sand mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder.
* Also you can convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.
* If you install this, there will be a help file in the installation folder. That file has huge coverage of all usage of that application with example.
* A "windows spy" utility is very much useful while automating any windows application

2) iMacros (
http://www.iopus.com/) [for web applications automation]:
* Record & replay all web surfing activities
* Automatically fill out web forms
* Automate uploads, downloads, and data extraction etc

3) Python (
http://www.python.org/) [for various system activities and more and more!]
* Used in many big corporates like Google, NASA etc.
* Very much easy to learn for all! (even for a person who is learning a language for the first time!)
* Multi-platform, free, open source etc.
* Can convert the python files to stand-alone "exe" files. (py2exe.org)
* Very much handy for various system activities like copy files, find text in files, replace text in files, parse XLS files, create report in XLS format (http://sourceforge.net/projects/pyexcelerator) etc.
* Uses white spaces as block delimiters.
* Nice start-up/beginner tutorial is available at
http://www.ibiblio.org/swaroopch/byteofpython/files/120/byteofpython_120.pdf (a must read for beginners!)http://www.swaroopch.com/notes/Python

3) pyWinAuto (
http://pywinauto.openqa.org/) [for windows applications automation]:
* This is a third party python module.
* When u want the power of python while automating the windows applications, this is a fine choice.
* A simple video describes the basic introduction and usage of this python module
http://showmedo.com/videos/video?name=UsingpyWinAutoToControlAWindowsApplication(use head phone)

Similar things are,
1) Watir (
http://wtr.rubyforge.org/) : for web applications automation
2) Apache JMeter (
http://jakarta.apache.org/jmeter) : for load testing
Quick start link (recording the test): http://jakarta.apache.org/jmeter/usermanual/jmeter_proxy_step_by_step.pdf
3) htmlunit (http://htmlunit.sourceforge.net/) : for web application testing automation

It may be extremely useful in automating the day today activities which will make the work easier.

Followers