SendKeys Python module

Tedious copy and pasting to make sure the right amount of tabs was pressed to get to a certain link

Tedious copy and pasting to make sure the right amount of tabs was pressed to select a certain link on a webpage.

A few posts ago, I mentioned that I had been tasked with a script that would automate web browsing to a website. I felt, after doing a little bit of research, that the SendKeys module was best suited for the job. The only problem I encountered was when entering the same key command over and over again became extremely tedious as you can see on the right.

The script would load up a webpage, unfortunately using Internet Explorer, accept a security certificate, type in log in details, open a certain page and then activate an online platform that is used by the company I work for. With this script running on another PC to the one it was developed on, I needed to use another module, Py2Exe, to convert the .py file into an executable file.

Despite the length of the script and the repetitive nature of the commands, the script works absolutely perfectly. The pauses need to be planned in advance – especially when loading an application such as Internet Explorer. I obviously will not be posting the script I built due to the fact it does include an internal IP address of a company’s SNMP probe and log in details but I thoroughly recommend the SendKeys module for any automated tasks you encounter.

If you know of a better way in which automated web browsing can be achieved, I am extremely happy to hear any ideas you may have =)



The Apprentice 2014

Today, I have started my application to be on BBC’s The Appentice 2014. I do not want to disclose too much information as I really do not know if I have the time to complete the application but I have had an idea of a business that I wish to start up but the initial start-up costs are quite astronomical. I will obviously keep you up to date if I actually make it any further in the process. Here’s to remaining optimistic!


Video: Lego Computer

Whilst browsing some of my favourite programming forums, a user posted this video up which is absolutely fantastic. The physical representation of the different computational gates is mind boggling and is definitely worth a watch.



Scripting, scripting, scripting

I have been tasked with some more scripts to build for work. I’ve wanted to get into programming in the past six to twelve months but I find working from reference books extremely abstract but having an actual goal to work towards, in my opinion, aids in the development of a skill.

Recently, I have been given the opportunity to hone my scripting and programming skills by undertaken various Cisco Contact Centre Express projects which involves a lot of call flow scripting, and because of this, I have been tasked with more and more generic scripting jobs.

The latest non-trivial script I have to build requires automated web browsing. As per usual, I will make all of my scripts available once they have been built. If you download any of them, please let me know what you think of it and also report any bugs to me for further development =)


New theme

I’ve decided to change the theme of my blog. I noticed a few things had gone wrong with the previous theme, as much as I liked it, and I am a little bit of a perfectionist at times.

Anyway, I like the minimalistic theme… for now!



Pinging with times

Today, I found the need to write a simple batch script that would be able to ping a remote host as well as output the times as to when a group of pings were sent. The need for this stemmed from a customer of the company I work for having problems with Cisco IP phones re-registering with the central Cisco Unified Communications Manager server at a certain time every day. Initially, the prognosis was that DHCP was the root cause of the re-registering whereby the devices were renewing their DHCP lease, which by default on Cisco routers is every 24 hours, disconnecting from the network briefly then reconnecting to the network with the same IP address and then re-registering with CUCM. However, this turned out to not be the case as the DHCP lease was extended to occur every seven days but the phones continued to re-register every day. The times in which the re-registering occurred began to change also, varying from 11:30am to 3:45am.

A colleague of mine, during the diagnostic stage, pointed out that the office in which all these phones were re-registering at has a satellite ADSL link to the main office where the CUCM server is at. Now, to prove that this satellite link is the root cause of the re-registering every day, as it is known to be flaky, a constant stream of pings would need to be sent to the remote site’s voice gateway. Simply pinging an interface wouldn’t suffice as time data is not captured and any drops in packets would not be able to be married up to any data captured from the Real Time Monitoring Tool which can be used to view logs on CUCM servers. This is where my very simple, not so clean, batch script comes in handy.

The build of  the script is simple – there’s two files; pingWithTimes.bat and output.bat. The pingWithTimes batch file simple echos the current system time and then pings the the desired interface IP address for, by default, ten times before looping back to the start. Output.bat runs the pingWithTimes.bat file and then saves any output to a text file name output.txt.

The IP address and name of the text document can be edited by using a text editor such as Notepad or Notepad++. Ideally, I would like the script to have prompts but for now, this will suffice.

You can download the .rar of these files here.


And he’s over the line!

Well… hello again! It has been a while since my last post, almost bang on three months to be exact. In that relatively short period of time I have managed to get my University assignments and dissertation done with what time I had at my disposal as well as get myself a job! YAY! I guess I won’t be the statistic I referred to in my previous blog post. This is just a blog post to get me back in to the swing of blogging.

In the few upcoming blog posts I intend to post about my future intentions of the direction of this blog as well as announcing a few of my future projects. For now though, I will be moving into a new house so that my girlfriend can begin to establish herself as a newborn photographer.

For now, it is nice to see you again and keep checking back for more regular updates now that I have finished with University 🙂



Hello all,

Long time since I last posted. University has taken up a lot of my time, so as my daughter! Anyway, I thought I would let you know that I have ventured into the world of Skype so add me: james.bates =)