Program giving a quote upon starting?

Recommended Videos

Mersadeon

New member
Jun 8, 2010
350
0
0
So, I'm looking for something pretty specific: a program that shows a random sentence from a list of quotes every time the computer starts up/get's to the desktop. I have searched, but can't find anything - and I understand that this is not exactly something many people WANT to have. So, does anyone know of something?

(Background: I want to make my laptop WH40K themed. I want it to give one of those neat "Thought of the Day" quotes whenever it starts up.)


Edit: Thanks for you tips! I will try them out ASAP!
 

Esotera

New member
May 5, 2011
3,400
0
0
I'm pretty sure you should be able to find an email list that will send you this if you google it? I get word-of-the-day emails which improves my vocabulary, I'd be amazed if someone didn't run a similar list.

Otherwise it sounds like a really easy thing to program, if you asked someone with the right skills nicely enough I'm sure they'd make it for you.
 

Mersadeon

New member
Jun 8, 2010
350
0
0
Well, I don't want it to send an email - I want it to show up on the screen immediately.

You are right, it is pretty easy. Unfortunately, I can barely programm at all and none of my friends can, either.
 

Frezzato

New member
Oct 17, 2012
2,448
0
0
Mersadeon said:
snipped in case you missed this
.

I think a good first step would be using Windows Task Scheduler [http://windows.microsoft.com/en-US/windows/schedule-task#1TC=windows-7][footnote]I don't know why Microsoft insists on going through the Control Panel. Just hit your START menu and go to All Programs, then the Administrative Tools folder, then Task Scheduler.[/footnote]to run some Visual Basic scripting.

Here's an example of an extremely simple script:
window=msgbox("I'll die if you close this window!",0,"Hello")
Copy/paste that into notepad and change the "Save as Type" to 'All files'. Make sure to add the suffix of ".vbs" to the file name.
Double-click on the file once saved and you can see which text ends where in the pop-up window.

Like I said, it's very basic and quite easy because I don't know a thing about programming.

.

Now, I'm sure that a determined individual would be able to find out how to populate and access a table so you can get your pop-up quotes. Surely there has to be one or two people here that know programming.

I did run into a minor hiccup with my firewall, but otherwise the script will run and Task Scheduler will work. The window might not be as large as you want, but the fact that it works is a good sign I think.
 

asdfgtrew

New member
May 19, 2012
14
0
0
Mersadeon said:
Well, I don't want it to send an email - I want it to show up on the screen immediately.

You are right, it is pretty easy. Unfortunately, I can barely programm at all and none of my friends can, either.
Sorry if this is a bit late but I saw this and thought I'ld give it a try. Im not sure if I'm allowed to post links to files here and you probably shouldn't trust a stranger offering candy on the internet anyway, but I can post the sourcecode if you want it so all you'll need to do is compile it and add images at the correct size.

Edit

Space marine

Chaos
Is this the right sort of thing btw?

Edit 2
Far as I can tell it's ok to link to the program so if anyone wants it:
https://mega.co.nz/#!bAxVUBzL!gA4mxqCJvecvhfr-2msdSwI-p-b2UKoVll4ADwmOZes
 

Frezzato

New member
Oct 17, 2012
2,448
0
0
Woo! I'm glad I stuck around on this thread. This is definitely getting more interesting.

asdfgtrew said:
Just want to say that Mersadeon is definitely not the only one interested in your code. Count me in please, if you don't mind that is.
 

asdfgtrew

New member
May 19, 2012
14
0
0
Frezzato said:
Just want to say that Mersadeon is definitely not the only one interested in your code. Count me in please, if you don't mind that is.
Yh that's fine if you can forgive me for my messy code. I should probably point out it's in Java though.
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Diary extends JFrame{

/**
*
*/
private static final long serialVersionUID = 1L;
JLabel l2;
JLabel l1;
String quotes[] = {
//Space Marine quotes 0 - 20
"Some may question your right to let them live.",
"A Heretic may see the truth the world as a Traitor.",
"knowledge is power, hide it well",
"To admit defeat is toblaspheme against the Emperor",
"Sow the seeds of damnination andI shall reap the souls of the tainted.",
"Do not fail your Brothers. Though your charge.",
"Blessed is the mind too small for doubt.",
"We may be few, and our enemies galaxy shall yet know hope.",
"Give me a hundred Space Marines. other troops",
"Raise the flag high. Let thoseclaim their lives this day!",
"The Wolves aren't animals. No others outside its pack.",
"Pain and death are illusions its relevance.",
"Faith is purest whenit is unquestioning.",
"Each path must be chosen withwhole.",
"Come all you Xeno Throne's gaze!",
"Honour your Chapter.",
"The enemies of the the Space Marines!",
"My sword is at theor dead.",
"If you can see us, can hear is our laughter.",
"We have been woundedshall teach them otherwise.",
"I have travelled far andvery world tremble.",

//Chaos marine quotes
"If the path to salvation of purgatory, then so be it.",
"Do you hear the voices too?!!",
"Sanity is for the weak!",
"Know this! What will comelet the universe drown in it!",
"In the embrace of the great I once most feared: Death.",
"Let the Galaxy burn.",
"Though my guards may sleep never tire.",
"All power demands sacrifice... blood for the promise of power.",
"Let us play hide and slay!",
"There, feel the glory of necrosis, and rejoice! Nurgle loves you!",
"It is the fate of the weak to die Give me glory, or give me death!",
"The minds of gods are not for have to play.",
"Kill! Maim! Burn! Kill! Maim! Burn!",
"WE ARE THE DESTROYER!",
"By the Worm Eye that darkest depths of the Warp!",
"The lesson is this. The To aim low.",
"Long shall be your suffering. Joyous be your pain.",
"Horus was weak. and he let it slip away.",
"We're back, and better than ever!",
"Cast down the idols! a rotting corpse!"
};
JLabel showQuotes;

public static void main(String[] args) {
Diary frame = new Diary();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setSize(600, 300);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.details();

}

public void details()
{
setLayout(new BorderLayout());
JLabel background=new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().createImage(Diary.class.getResource("background.jpg"))));
add(background);
background.setLayout(new FlowLayout());
l1=new JLabel("Lessons from a life of war");
l2=new JLabel("---------------------------------------");

int now = (int) showthis();
showQuotes = new JLabel(quotes[now]);
//size refresh is needed to display correctly
setSize(399,399);
setSize(600,300);

JPanel quotes = new JPanel();
add(quotes, BorderLayout.WEST);

//sets initial background
JLabel quoteimg = new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().createImage(Diary.class.getResource("quotesImg.jpg"))));
quoteimg.setLayout(new FlowLayout());
quotes.add(quoteimg);
quoteimg.add(l1);
quoteimg.add(l2);
quoteimg.add(showQuotes);


if(now < 21)
setTitle("Diary of a Space Marine");

//changes the background if a chaos quote is used
else if(now < 41){
setTitle("Memoirs of Chaos");
remove(background);
background=new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().createImage(Diary.class.getResource("chaos.jpg"))));
setSize(399,399);
setSize(600,300);
add(background);}


pack();


//Thread pauses the program and then stops it after 15 secs
Thread thread = new Thread() {
public void run(){
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

System.exit(0);
}
};

thread.run();

}


//temp method until I have 100 quotes
public double showthis()
{
double finalNum;
do{
finalNum = Math.random() * 100;
}while(finalNum >= 41 );
return finalNum;
}
}

EDIT
Just noticed the strings are displaying wrong as the break line tag is html and is being read by the browser instead of displayed in it.
Normally it would look like:
[http://postimg.org/image/8fuauhjn9/]
 

Esotera

New member
May 5, 2011
3,400
0
0
asdfgtrew said:
Frezzato said:
Just want to say that Mersadeon is definitely not the only one interested in your code. Count me in please, if you don't mind that is.
Yh that's fine if you can forgive me for my messy code. I should probably point out it's in Java though.
Code:
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Diary extends JFrame{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	JLabel l2;
	JLabel l1;
	String quotes[] = {
						//Space Marine quotes 0 - 20
						"Some may question your right  to let them live.",
						"A Heretic may see the truth the world as a Traitor.",
						"knowledge is power, hide it well",
						"To admit defeat is toblaspheme against the Emperor",
						"Sow the seeds of damnination andI shall reap the souls of the tainted.",
						"Do not fail your Brothers. Though your charge.",
						"Blessed is the mind too small for doubt.",
						"We may be few, and our enemies  galaxy shall yet know hope.",
						"Give me a hundred Space Marines. other troops",
						"Raise the flag high. Let thoseclaim their lives this day!",
						"The Wolves aren't animals. No others outside its pack.",
						"Pain and death are illusions its relevance.",
						"Faith is purest whenit is unquestioning.",
						"Each path must be chosen withwhole.",
						"Come all you Xeno  Throne's gaze!",
						"Honour your Chapter.",
						"The enemies of the the Space Marines!",
						"My sword is at theor dead.",
						"If you can see us, can hear is our laughter.",
						"We have been woundedshall teach them otherwise.",
						"I have travelled far andvery world tremble.",
						  
						  //Chaos marine quotes
						"If the path to salvation of purgatory, then so be it.",
						"Do you hear the voices too?!!",
						"Sanity is for the weak!",
						"Know this! What will comelet the universe drown in it!",
						"In the embrace of the great I once most feared: Death.",
						"Let the Galaxy burn.",
						"Though my guards may sleep never tire.",
						"All power demands sacrifice... blood for the promise of power.",
						"Let us play hide and slay!",
						"There, feel the glory of necrosis, and rejoice! Nurgle loves you!",
						"It is the fate of the weak to die Give me glory, or give me death!",
						"The minds of gods are not for have to play.",
						"Kill! Maim! Burn! Kill! Maim! Burn!",
						"WE ARE THE DESTROYER!",
						"By the Worm Eye that darkest depths of the Warp!",
						"The lesson is this. The To aim low.",
						"Long shall be your suffering. Joyous be your pain.",
						"Horus was weak. and he let it slip away.",
						"We're back, and better than ever!",
						"Cast down the idols! a rotting corpse!"
							};
	JLabel showQuotes;
	
	public static void main(String[] args) {
		Diary frame = new Diary();
		frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
		frame.setSize(600, 300);
		frame.setVisible(true);
		frame.setLocationRelativeTo(null);
		frame.details();
		frame.setResizable(false);
		
	}
	
	public void details()
	{
		setLayout(new BorderLayout());
		JLabel background=new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().createImage(Diary.class.getResource("background.jpg"))));
		add(background);
		background.setLayout(new FlowLayout());
		l1=new JLabel("Lessons from a life of war");
		l2=new JLabel("---------------------------------------");
		
		int now = (int) showthis();
		showQuotes = new JLabel(quotes[now]);
		//size refresh is needed to display correctly
		setSize(399,399);
		setSize(600,300);
		
		JPanel quotes = new JPanel();
		add(quotes, BorderLayout.WEST);
		JLabel quoteimg = new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().createImage(Diary.class.getResource("quotesImg.jpg"))));
		quoteimg.setLayout(new FlowLayout());
		quotes.add(quoteimg);
		quoteimg.add(l1);
		quoteimg.add(l2);
		quoteimg.add(showQuotes);
		if(now < 21)
			setTitle("Diary of a Space Marine");
		else if(now < 41){
			setTitle("Memoirs of Chaos");
			remove(background);
		    background=new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().createImage(Diary.class.getResource("chaos.jpg"))));
		    setSize(399,399);
			setSize(600,300);
			add(background);}
		pack();
		
		
		//Thread pauses the program and then stops it after 15 secs
		Thread thread = new Thread() {
			public void run(){
				try {
					Thread.sleep(15000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				System.exit(0);
			}
		};
		
		thread.run();
		
	}
	
	public double showthis()
	{
		double finalNum;
		do{
		finalNum = Math.random() * 100;
	}while(finalNum >= 41 );
			return finalNum;
		}
}
The escapist has code tags apparently, makes it a lot easier to read...

Also I would have initialised the String array by defining each quote as a single line in a text file. You can then declare a filestream that iteratively reads each line & pushes it to the array. This avoids hardcoding & makes it easy to for the user to change the available quotes. I just can't be bothered to write it at the minute and I'm sure you probably thought of it too.
 

asdfgtrew

New member
May 19, 2012
14
0
0
I guess I'm having a thick day today. In all honesty you're right but it never occurred to me that the user might want to change it. I'll get round to it if it's wanted though. Thanks for the advice.
 

Frezzato

New member
Oct 17, 2012
2,448
0
0
asdfgtrew said:
This is fantastic. I can't wait to start looking through this code.
Regardless of the outcome, thanks for putting in the work, man!
 

DazZ.

Elite Member
Jun 4, 2009
5,542
0
41
If I was going to have something like this I'd use Rainmeter and have it change according to the date.

That way it can easily start as the computer starts, but also be a part of your background so it doesn't go away just as the computer loads, then it can be in whatever Warhammer font you want as well.
 

asdfgtrew

New member
May 19, 2012
14
0
0
Frezzato said:
asdfgtrew said:
This is fantastic. I can't wait to start looking through this code.
Regardless of the outcome, thanks for putting in the work, man!
No worries, It's all quite basic and I presume I've messed up somewhere. But, if you have any questions on it I'll try my best to make some sense.
 

Esotera

New member
May 5, 2011
3,400
0
0
Ok, I got bored & decided to have a go at writing a program. It's very simple and just displays quotes in a message dialog, but it's easy to change what the messages are as they're defined in a text file.

The compiled program with installation instructions are here [https://sourceforge.net/projects/quotomatic/], although you can always try and compile it yourself from source if you are paranoid. Let me know if there are any bugs and I will try and fix them. Also there are only about 15 quotes (I'm lazy) so if anyone feels like collecting some more quotes for their personal program, please pass on the text file to me so I can update the project file.


edit:
Code:
package com.astigan.quotomatic;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;

import javax.swing.JOptionPane;

public class Quotomatic {

	public static void main(String[] args) {

		String quote = getRandomQuote();
		JOptionPane.showMessageDialog(null, quote, "Quote of the Day",
				JOptionPane.INFORMATION_MESSAGE);
	}

	public static String getRandomQuote() {

		String filePath = "quotes.txt";
		String selectedQuote;
		FileReader fileReader;
		BufferedReader bufferedReader;
		ArrayList availableQuotes = new ArrayList();

		try {
			fileReader = new FileReader(filePath);
			bufferedReader = new BufferedReader(fileReader);
			String line;

			while ((line = bufferedReader.readLine()) != null) {
				availableQuotes.add(line);
			}

			bufferedReader.close();
			fileReader.close();

			if (availableQuotes.size() == 1) {
				selectedQuote = availableQuotes.get(0);
			}

			else if (availableQuotes.size() > 0) {

				Random random = new Random();
				int element = random.nextInt(availableQuotes.size());
				selectedQuote = availableQuotes.get(element);
			}

			else {
				selectedQuote = "No quotes are present in quotes.txt - please add some!";
			}

		} catch (FileNotFoundException e) {
			selectedQuote = "Unable to find quotes.txt, please ensure that the file is in the correct location";

		} catch (IOException e) {
			selectedQuote = "Unable to read from quotes.txt due to an IO error";
		}

		return selectedQuote;
	}
}