Search This Blog

Tuesday, April 2, 2013

WiggleMouse.ahk

Everyone knows AutoHotKey. If you don't, it is a good time to find out about it.

I'd used AutoHotKey to come with with the small program below.
What it does is to wigggle the mouse after a certain delay, to sttart wiggle the mouse.
How is it useful? With displays becoming bigger, sometimes it is easy for the mouse to get lost. With the script running, you will be able to locate the mouse cursor more easily.
To top it off, you will be doing it with your peripheral vision, those vision rods receptors in your eyes that is so much better than detecting movments than the cones. So we are actually leveraging on our born ability to do ti.
You might need to replace the greater than and less than signs below if you are planning to use it.
Btw, running this application will have the side effect of preventing the screensaver from kicking in. So this is something you might want to consider.

WigglyMouse.ahk
#persistent
coordmode, mouse, screen
count := 0

mousegetpos, sx, sy

settimer, check, 250
return

check:
mousegetpos, cx, cy
  ; mouse has moved, calculate by how much
  count := count + 1
  ;ToolTip,  count is %count% 
  if ( count > 100 ){
    ;msgbox, mouse has moved less than 20 pixels
    if ( ((cx < (sx+20) and cx > (sx-20)) and (cy < (sy+20) and cy > (sy-20)))) {
      random, x, 1, 18
      random, y, 1, 18
      x := sx+x -9
      y := sy+y -9
      mousemove, %x%, %y%, 80
    }else {
      count := 0
      mousegetpos, sx, sy ; get new mouse position
    } 
  } 
return



updated.

for fun sake, I'd updated the script to draw lines on the screen. take a look.

#persistent
coordmode, mouse, screen
count := 0
unit := 40

OnExit, ExitSub
pToken := Gdip_Startup()
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 1: Show, NA
hGui1 := WinExist()
hbm := CreateDIBSection(A_ScreenWidth, A_ScreenHeight), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc), Gdip_SetSmoothingMode(G, 4)
pPen := Gdip_CreatePen(0xff0000ff, 2)



mousegetpos, sx, sy

cx1 := sx 
cy1 := sy 

settimer, check, 200
return

check:
mousegetpos, zx, zy

if (( zx != sx and zx != cx ) or ( zy != sy and zy != cy )){
      count := 0
Gdip_GraphicsClear(G) ; not needed on first press, but never mind
UpdateLayeredWindow(hGui1, hdc, 0, 0, A_ScreenWidth, A_ScreenHeight)

}
cx := zx
cy := zy
  ; mouse has moved, calculate by how much
  count := count + 1
  ;ToolTip,  count is %count% 
  if ( count > 50 ){
    ;msgbox, mouse has moved less than unit pixels
    if ( ((cx < (sx+unit) and cx > (sx-unit)) and (cy < (sy+unit) and cy > (sy-unit)))) {
      random, x, 1, (unit-2)
      random, y, 1, (unit-2)
      cx := sx+x -((unit -2)/2)
      cy := sy+y -((unit -2)/2)
      mousemove, %cx%, %cy%, 5

Gdip_DrawLine(G, pPen, cx, cy, cx1, cy1)
UpdateLayeredWindow(hGui1, hdc, 0, 0, A_ScreenWidth, A_ScreenHeight)

      cx1 := cx
      cy1 := cy

    }else {
      count := 0
Gdip_GraphicsClear(G) ; not needed on first press, but never mind
UpdateLayeredWindow(hGui1, hdc, 0, 0, A_ScreenWidth, A_ScreenHeight)
      mousegetpos, sx, sy ; get new mouse position
    } 
  } 
return


ExitSub:
Gdip_DeletePen(pPen)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc), Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
ExitApp

#Include Gdip.ahk    ; by Tic http://www.autohotkey.com/forum/topic32238.html

Wednesday, July 14, 2010

Using python with Gnumeric in Windows XP

Background Screenshot-20100715054119Thu.png


Quite sometime ago, I had download Gnumeric as a portable spreadsheet solution. It is a nifty application that loads up fast and does what spreadsheets do. At the right is a screen shot of the memory usage of my Portable Gnumeric.


Side Note: I'm using Process Explorer to show you the stat. It is a great app which I think should be installed by default on every windows machine. Some explanation of what you see in the diagram. Private Bytes is the the memory that can only be accessed by the application, wheras Working Set = Private Bytes + Shared Memories.


Then I read that Gnumeric provides Python integration! But my initial tries to enable the python integration using the instructions from here failed. The instruction is geared to a Linux setup but it can be done on XP as well. And the rest of this post is about how I got it working.


My Setup


I'm using version 1.10.5 of Gnumeric. I'd downloaded my original version from portable appts and updated Gnumeric to the latest version.


The run down


I will tell you the run down to get the python integration working. Then I will talk about some of the errors that you might encounter.



  • Make sure that you have at least python version 2.6 installed. Gnumeric python integration needs python version 2.6. I'd tried using Python 2.5, but no go.

  • Make sure that you've installed the Py-GTK python module. Py-GTK can be found here, and it, in turn, needs 3 other python modules call PyGTK, PyCairo and PyGObject. So you need to individually click on the links to the 3 modules on the page and download and install them. And then....

  • Make sure that GTK is installed as well. This is simply a matter of going here and download a release then unzipping the package someone on your machine and adding the path of the bin subfolder to your path. i.e. you should see the following



C:\>set path


Path=...\gtk\bin\;...



And Success!


If everything goes smoothly, after start Gnumeric, goes to menu>Tools>Plugins scroll down to the check the 2 python related boxes. Then you should see a new Options appear under menu>Tools> called "Python console". Activate that and you should see the following.


Screenshot-20100715063554Thu.png


Possible Problems


If your Gnumeric crashed with a Windows Error message, probably one of the following occured.



  • Python, is not installed

  • Incorrect version of python is installed.

  • PythonHome is not specified.

  • GTK is not installed

  • GTK\bin is not added to %PATH%


And finally


For ideas about what you can do with Python plugin in Gnumeric, please refer to this page as mentioned above.


I hope you managed to get your Python setup for Gnumeric. And use the beautiful language that is Python to simplify your spreadsheet scripting. And did I mentioned that both Python and Gnumeric are opensourced? :)


Created : 2010.07.15.0647hrs(Thu);




Technorati :

Del.icio.us :

Saturday, July 10, 2010

Tiramisu

http://www.heavenlytiramisu.com/whatisit.htm




wow, fantastic description.. I must try it. and maybe learn to create heaven.

Monday, July 5, 2010

Facebook Cafeworld tip - turn off the eating sound

This is not the kind of productivity improvements that I have in mind for this blog. Game productivity is certainly also a kind of productivity. So here goes.



I'm sure FaceBook needs no introduction. Cafe World is a game within FaceBook where you run a restaurant by taking care of its deco, staffing, and primarily, by cooking a variety of dishes. Along the way, you upgrade earn cafe points which will allow you to upgrade your Cafe.


Background


Different dish requires different duration for cooking - from 5 mins to even more than a day! So there's plenty of clicking cooking to occupy your time.


You can actually close the page and the game will keep on running. However, the loading for the game sometimes will take a while. So, more often than not, I will leave the Cafe World running in the background while I do other work. Waiting for the distinctive chime of the food bell informing me that the cooking is done.


However the convenient chime comes with the irritating background noise of the restaurant - people eating, cash register tinkling etc. Not exactly optimal when you are trying to concentrate on other task. Yet when you turn off the sound option from within the game control, all the sound will be turned off. What to do?


The solution.


So I accidentally chance upon the solution. I'm sure the developer folks at Facebook must have deliberately designed it this way. You just need to click the "Save" button to eliminate the restaurant noise. The "Save Complete" box will pop up. But just leave it there. Now, alternate tab and do your other stuffs. i.e. Listen to your mp3s. When the food is done, you will still be able to hear the food bell chime!


So now, have fun cooking minus the noise!

Tuesday, May 11, 2010

Bioluminecence

I was reading this article http://news.nationalgeographic.com/news/2010/05/100506-bioluminescence-sea-life-embed-video/ when I got into thinking about the reason for bioluminescence.




My hypothesis is that any living things must have a sense of self, and in the murky depth of the sea, being able to see oneself is a huge help to contributing constructing this sense of self.




Of course, there is the somewhat conflicting observation that most dark dwellers are somewhat blind. This could be explained in that once the sense of self is formed by the young, the sense of sight becomes less important, thence it degenerated.

Sunday, December 13, 2009

Sir John Templeton

I only have to look at this page to know that he was a remarkable man.
A man who did not discriminate against others of different religion,
not towards people who are not religious at all.

A man who believes that everything have it's place, in the world, who believes that
science and religion can co-exist peacefully. This was a man whose ideals we should
emulate and spread.

He is a man with bigture.