Author Topic: Writing a small Windows Application (Programming Thread)  (Read 7771 times)

0 Members and 1 Guest are viewing this topic.

n45048

  • Guest
Writing a small Windows Application (Programming Thread)
« on: March 11, 2015, 07:04:49 am »
I want to write a small Windows application which I can run as a standalone EXE (without installation). Essentially all I need it to do is periodically check a webpage (or multiple sites) for changes and if it's updated, play a WAV file and display a small alert on top of all other windows alerting the user there are changes. The visual alert ideally should be something unobtrusive that just sits in the corner until it's dismissed (rather than a dialog box that pops up and steals focus).

I'm not a programmer at all and the last time I touched Visual Basic was in high school. Any suggestions on some software or language I can use to achieve this? I'm pretty out of touch with software development.
« Last Edit: March 11, 2015, 07:07:11 am by Halon »
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: Writing a small Windows Application (Programming Thread)
« Reply #1 on: March 11, 2015, 08:32:59 am »
I would recommend one of the .NET languages (which includes Visual Basic). It means you do need to have the .NET framework installed, but implementing all the functionality without a rich framework will be a lot of work.

Offline Fred27

  • Supporter
  • ****
  • Posts: 726
  • Country: gb
    • Fred's blog
Re: Writing a small Windows Application (Programming Thread)
« Reply #2 on: March 11, 2015, 09:01:59 am »
Grab a free version of Visual Studio (was Express, but now Community Edition for the latest version I think). Great IDE, lots of help about. I'd suggest C# over VB, but either will do.
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5125
  • Country: nl
Re: Writing a small Windows Application (Programming Thread)
« Reply #3 on: March 11, 2015, 11:21:50 am »
There is an extension for Chrome that does exactly that, look for page monitor in the chrome store.
Keyboard error: Press F1 to continue.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Writing a small Windows Application (Programming Thread)
« Reply #4 on: March 11, 2015, 11:50:54 am »
If all you are looking for is changes on websites.. I suggest you steer clear of VB, C#, .NET and all that. Yes, it will get you a standalone EXE, but you will also have to write SOOOOOO much more code to make it work for you, and you will be tearing your hair out.

If you started with VB in high school and you say you are not much of a programmer, then I would recommend python. It's very easy to learn, and there are many online tutorials and many more available libraries to do exactly what you want to do.

This one line in python scrapes a web page: (note: spelling htttp incorrectly on purpose, by my choice.. there is a bug in the forum, if you put code with http links, it rewrites them, EVEN INSIDE THE CODE BLOCK THAT IT SHOULD NOT TOUCH!!. So I know its http but I put htttp to trip up the forum parser.

Code: (python) [Select]
page  = requests.get('htttp://example.com').text

The complete python program to load the webpage and save it to a disk file is:

Code: (python) [Select]
import requests
page  = requests.get('htttp://example.com').text
fd = open('/tmp/thepage.html', 'w')
fd.write(page)
fd.close()

If you need to examine the tree structure of the page, to look for specific changes on the page, then there is a library called BeautifulSoup that will help you do that very easily.

You can write a loop around this program above to scrape the same page periodically and compare it to the saved page on disk. If it's different, you can raise a desktop notice to let the user know.  There are libraries to help you do that too, such as Growl for windows (http://www.growlforwindows.com/gfw/) and growl transport for python GNTP (https://github.com/kfdm/gntp/)

The following 4 lines of additional code added to the above python code would pop-up a screen notification.

Code: (python) [Select]
import logging
logging.basicConfig(level=logging.INFO)
import gntp.notifier

gntp.notifier.mini("The webpage example.com has changed!")

The point of me writing this code is to show you how dead-simple it can be in python.  Don't install some massive IDE and start writing a windows EXE to do what you want to do. 

PS: I realize you said no installer. All the above requires an installer, to install python and the library you need and the Growl Notifier.
So you can finish it in 1 day with an installer, or attempt it 1 month or more with a standalone EXE written in .NET, as you try to write and learn at the same time.
« Last Edit: March 11, 2015, 12:00:54 pm by codeboy2k »
 

Offline ElektroQuark

  • Supporter
  • ****
  • Posts: 1244
  • Country: es
    • ElektroQuark
Re: Writing a small Windows Application (Programming Thread)
« Reply #5 on: March 11, 2015, 12:48:34 pm »
Try wget.

Offline Mechanical Menace

  • Super Contributor
  • ***
  • Posts: 1288
  • Country: gb
Re: Writing a small Windows Application (Programming Thread)
« Reply #6 on: March 11, 2015, 12:53:07 pm »
...

+1

That plus this https://github.com/pyinstaller/pyinstaller/wiki could be the perfect solution for you if you really need the standalone exe.
Second sexiest ugly bloke on the forum.
"Don't believe every quote you read on the internet, because I totally didn't say that."
~Albert Einstein
 

Offline Wilksey

  • Super Contributor
  • ***
  • Posts: 1329
Re: Writing a small Windows Application (Programming Thread)
« Reply #7 on: March 11, 2015, 12:59:11 pm »
Personally i'd use C#.

You can do it in C/C++ but it will take a much longer to write.

Your best bet, if you get confused, and you probably will after reading everyones responses is to contract it out, there was a website where you could do this, Rent A Coder I think it was called, people asking for bids on work.

The task itself is insignificant and can be done quite easily for someone who has time / progrramming knowledge.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Writing a small Windows Application (Programming Thread)
« Reply #8 on: March 11, 2015, 05:20:53 pm »
Try wget.
Yep, you can shell script it with wget.  My first choice on Linux would be that way, but scripts on Windows suck :)
Python seemed to me to be the better "scripting" language for this on Windows.
 

Offline magetoo

  • Frequent Contributor
  • **
  • Posts: 284
  • Country: se
Re: Writing a small Windows Application (Programming Thread)
« Reply #9 on: March 11, 2015, 07:33:20 pm »
Do the sites come with RSS feeds, by any chance?

If so, IFTTT could be an option, and it is simpler than writing your own tool.  I put together a small "recipe" to send me an email whenever a feed updated in just a couple of minutes.  It's free and pretty self explanatory.

Yeah, being purely a web based service it won't be able to reach into your computer and play an audio file, but there are "actions" available that can do other useful things like send notifications to phones or talk to various Internet-of-Things hardware, so there might be something there that works for you.

If the thing you want to monitor doesn't have an RSS feed, I'm not sure how one would do it.  (Maybe it would be possible to use Yahoo Pipes, it can pull data from the web and generate a RSS feed from anything... but it's probably not worth the trouble.)
« Last Edit: March 11, 2015, 07:42:36 pm by magetoo »
 

Offline DavidDLC

  • Frequent Contributor
  • **
  • Posts: 755
  • Country: us
Re: Writing a small Windows Application (Programming Thread)
« Reply #10 on: March 11, 2015, 07:45:06 pm »
When you have it done, share with me, I just missed 3 free office chairs in perfect condition at Craiglist  :'(

David.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Writing a small Windows Application (Programming Thread)
« Reply #11 on: March 11, 2015, 07:49:51 pm »
Personally i'd use C#.

You can do it in C/C++ but it will take a much longer to write.

Your best bet, if you get confused, and you probably will after reading everyones responses is to contract it out, there was a website where you could do this, Rent A Coder I think it was called, people asking for bids on work.

The task itself is insignificant and can be done quite easily for someone who has time / progrramming knowledge.

C# or PowerShell.

For C#, compiling with .NET 2 or 3 will work just about on any computer. 

PowerShell can do almost anything C# can do since it's also .NET based. The difference being you have to invoke the .NET stuff manually.

I wrote a digital signage application at work in PowerShell for an assembly line.  It has 2 timer threads that query a database one thread every 15 seconds, the other every 60 seconds.  The 15 second interval is just an overall system status (Running, Unplanned Stop, Planned Stop), the 60 second thread queries the stats. How many widgets completed, in progress, how many have passed through a specific production point, down time per line etc.

The script was a proof of concept / challenge on my own time that I could write a replacement for our licensed digital signage application myself in C#, but was sort of shot down a bit when I showed the non-functional display mockup to my boss and he said that deploying compiled code makes management nervous.  So I about gave up on it, until I figured out how to reference WPF in PowerShell.  Now the only compiled code is the .NET framework itself and nothing I wrote.

Basically I taught myself powershell during the Christmas break this past year.
« Last Edit: March 11, 2015, 08:02:10 pm by Stonent »
The larger the government, the smaller the citizen.
 

Offline Prime73

  • Regular Contributor
  • *
  • Posts: 174
  • Country: ca
Re: Writing a small Windows Application (Programming Thread)
« Reply #12 on: March 11, 2015, 08:05:24 pm »
have considered a web browser extension?
something like this one: https://chrome.google.com/webstore/detail/page-monitor/pemhgklkefakciniebenbfclihhmmfcd?hl=en

I want to write a small Windows application which I can run as a standalone EXE (without installation). Essentially all I need it to do is periodically check a webpage (or multiple sites) for changes and if it's updated, play a WAV file and display a small alert on top of all other windows alerting the user there are changes. The visual alert ideally should be something unobtrusive that just sits in the corner until it's dismissed (rather than a dialog box that pops up and steals focus).

I'm not a programmer at all and the last time I touched Visual Basic was in high school. Any suggestions on some software or language I can use to achieve this? I'm pretty out of touch with software development.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26891
  • Country: nl
    • NCT Developments
Re: Writing a small Windows Application (Programming Thread)
« Reply #13 on: March 11, 2015, 09:29:38 pm »
Personally i'd use C#.

You can do it in C/C++ but it will take a much longer to write.
Not really. It's just a matter of using the right framework. With WxWidgets you can easily create a static linked exe file which will work standalone on about any version of Windows.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Writing a small Windows Application (Programming Thread)
« Reply #14 on: March 11, 2015, 10:53:24 pm »
...  IFTTT could be an option, and it is simpler than writing your own tool.  I put together a small "recipe" to send me an email whenever a feed updated in just a couple of minutes.  It's free and pretty self explanatory.

Oh, yes. +1.

I forgot about IFTTT but that's also a good choice, worthy of a look.  Won't be able to do the desktop notifications directly, but email or IM , or TWILIO SMS as an output notification might be an option here.

https://ifttt.com/wtf
 

n45048

  • Guest
Re: Writing a small Windows Application (Programming Thread)
« Reply #15 on: March 11, 2015, 10:57:37 pm »
Thanks for all the great suggestions guys.

Unfortunately the site is part of our intranet and doesn't have RSS. I also don't have the option of installing Chrome plugins for security reasons. If I write the application myself, I can easily have it checked and cleared so I can bring it to work.
 

Offline Galenbo

  • Super Contributor
  • ***
  • Posts: 1469
  • Country: be
Re: Writing a small Windows Application (Programming Thread)
« Reply #16 on: March 15, 2015, 06:40:55 pm »
Althroug I haven't used it for a while, I played around some time wit this:

http://en.wikipedia.org/wiki/Processing_%28programming_language%29

Seems a lightweight install, producing lightweight programs.
No idea if it can produce .exe without extras.
If you try and take a cat apart to see how it works, the first thing you have on your hands is a nonworking cat.
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5125
  • Country: nl
Re: Writing a small Windows Application (Programming Thread)
« Reply #17 on: March 15, 2015, 08:24:18 pm »
To get a page in HTML with visual basic is not that hard:

Code: [Select]
Imports System.Net
Imports System.IO

Function getHTML(ByVal Address As String) As String
        Dim wREQ As WebRequest
        Dim wRSP As WebResponse
        Dim Reader As StreamReader
        wREQ = WebRequest.Create(Address)
        wRSP = wREQ.GetResponse
        Reader = New StreamReader(wRSP.GetResponseStream)
        Return Reader.ReadToEnd
        Reader.Close()
End Function

Call the function like this:
     String1 = getHTML("http://www.google.com")
then use a timer to call it again and compare the result with String1. If there is a difference do whatever alert you want.

Or if you want to play with it test it put a button and a textbox on your form and
Code: [Select]
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = getHTML("http://www.google.com")
End Sub
Keyboard error: Press F1 to continue.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Writing a small Windows Application (Programming Thread)
« Reply #18 on: March 16, 2015, 12:56:54 am »
To get a page in HTML with visual basic is not that hard:

Code: [Select]
Imports System.Net
Imports System.IO

Function getHTML(ByVal Address As String) As String
        Dim wREQ As WebRequest
        Dim wRSP As WebResponse
        Dim Reader As StreamReader
        wREQ = WebRequest.Create(Address)
        wRSP = wREQ.GetResponse
        Reader = New StreamReader(wRSP.GetResponseStream)
        Return Reader.ReadToEnd
        Reader.Close()
End Function

Call the function like this:
     String1 = getHTML("http://www.google.com")
then use a timer to call it again and compare the result with String1. If there is a difference do whatever alert you want.

Or if you want to play with it test it put a button and a textbox on your form and
Code: [Select]
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = getHTML("http://www.google.com")
End Sub

And just for fun because C# and VB.NET almost word for word translate, I translated it.

Code: [Select]
using System.Net;
using System.IO;

namespace httpget
{
    class Program
    {
        static void Main(string[] args)
        {
// this will just dump raw data to the screen
            System.Console.WriteLine(getHTML("http://www.google.com"));
            System.Console.ReadLine();
// or you could do
// string string1 = getHTML("http://www.google.com");
        }

        static string getHTML(string Address)
        {
            WebRequest wREQ;
            WebResponse wRSP;
            wREQ = WebRequest.Create(Address);
            wRSP = wREQ.GetResponse();
            StreamReader Reader = new StreamReader(wRSP.GetResponseStream());

            try
            {
                return Reader.ReadToEnd();
            }

            finally
            {
                Reader.Close();
            }
        }
    }
}
The larger the government, the smaller the citizen.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Writing a small Windows Application (Programming Thread)
« Reply #19 on: March 16, 2015, 01:03:04 am »
But wait! There's more.  No need to compile anything, just use PowerShell!

Code: [Select]
# // first argument is mapped to $url
param($url)

# // create a request
[Net.HttpWebRequest] $req = [Net.WebRequest]::create($url)
$req.Method = "GET"
$req.Timeout = 600000 # = 10 minutes

# // Set if you need a username/password to access the resource
#$req.Credentials = New-Object Net.NetworkCredential("username", "password");

[Net.HttpWebResponse] $result = $req.GetResponse()
[IO.Stream] $stream = $result.GetResponseStream()
[IO.StreamReader] $reader = New-Object IO.StreamReader($stream)
[string] $output = $reader.readToEnd()
$stream.flush()
$stream.close()

# // return the text of the web page
Write-Host $output
Usage:
powershell script.ps1 http://yoururl.com
The larger the government, the smaller the citizen.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Writing a small Windows Application (Programming Thread)
« Reply #20 on: March 16, 2015, 02:24:23 am »
PowerShell is da bomb.

There are like 8 hours of training at Microsoft, I did a couple of hours but it's in my list of things to continue

http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Writing a small Windows Application (Programming Thread)
« Reply #21 on: March 16, 2015, 03:06:23 am »
PowerShell is da bomb.

There are like 8 hours of training at Microsoft, I did a couple of hours but it's in my list of things to continue

http://www.microsoftvirtualacademy.com/training-courses/getting-started-with-powershell-3-0-jump-start

I'd say 90%+ of things you can do in C# you can do in PowerShell, even GUI stuff.
The larger the government, the smaller the citizen.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf