Archive for November, 2009

21Nov

The following video shows off Andy’s and mine’s Imagine Cup 2010 submission. The project dubbed Tesla is about conserving and monitoring energy consumption across a home or office network (or any other for that matter). Tesla has 2 aspects the client side which records data of individual computers and the server/web side which will create new users, networks and display device data.

Currently the user experience is not that amazing; however, the website almost looks awesome and the functionality exists! We are looking to expand in user experience of course; however, we are also looking to make functional enhancements (if we get into the next round). These include enhancing our database of known products (to get more accurate statistics), making an awesome visualizer for the data, and giving alternatives for your computer components in order to reduce consumption. I hope you guys enjoy our video. More coming from us soon on this hopefully!

Someone also mentioned how this could also be applied for overclocking machines and trying to get the biggest bang for the buck/power.

PS: We were running on fumes while recording this, please discard my lame explanations :)!

Share
10Nov

UPDATED: Nov 11th, 09 , changes: added python info

I have been struggling to find a way to get around selenium’s onload deficiencies. I tried all sorts of ways to hack up my script, but alas it mostly ended up in turmoil. Onload is one of the main ways most developers use to make sure certain actions happen in code, and my entire content bed was about go into flames before I found the light at the end of the tunnel. A magical gift from the heavens known as AutoIt saved me from a timely demise…

All retardedness aside… (sarcasm)..

AutoIt really did solve this problem for me. It may not work so well for others.. it depends on your situation. For me a simply wanted to close a popup window after it loaded from a different windows onload and then click the popup’s confirmation’s Ok button. Then close the original window that started all the madness…

The cool thing about running the code below is that it just runs as a daemon of sorts in the background waiting for some unruley popup to be struck down with Wrath of Kahn, plus it can also test for popups with different names. I am hoping I can do some sweet regex stuff, otherwise, life may prove difficult. In any case here is my AutoIt script:


While True
   If WinWait('Name of the final Popup', '', 1) == 1 Then
     ;Wait for page to load if found
     Sleep(10000)
     ;Close Page
     Send('!{F4}')
     Sleep(5000)
     ;Confirm Dialog
     Send('{ENTER}')
     Sleep(1000)
     ;Close Lanucher Page
     Send('!{F4}')
   EndIf
   ;Let another thread have a turn
   sleep(3)
WEnd

Now, lets say you want the above to be directly embedded into your script rather than have it constantly running externally. I personally use python for my Selenium scripting so in python you can do the follwoing (which is the equivalent of the above script).


from selenium import selenium
import unittest, re, time
from datetime import date, datetime
from xml.dom import minidom
from win32com.client import Dispatch

# Auto it window closing stuff
def autoItCloseWindows(self):
   auto = Dispatch("AutoItX3.Control")
   #Your Popup Name Here is the name of the window...
   #I did this because different windows could open for my project
   if (auto.WinWait("Your Popup Name Here", "", 1) == 1):
      # chill
      time.sleep(5)
      # close window
      auto.Send("!{F4}")
      # wait
      time.sleep(2)
      # confirm dialog box
      auto.Send("{ENTER}")
      time.sleep(5)
      # close the launcher window
      auto.Send("!{F4}")

To run this script you mainly need selenium, time, autoit3 and win32 dispatch. To download win32 stuff for python click here. Another thing to note is that this will only work for windows. There are similar solutions available for *nix. If you are using a mac to do things like this it is probably a waste of your mac ha, but there are also similar solutions.

Good luck oh weary travelers…

Share