C++ :: Program To Check If User Presses Power Button On Computer

Jun 19, 2014

How you can make a c++ program that checks to see if the user presses the power button on their computer? And if so, how?

View 1 Replies


ADVERTISEMENT

C :: Detect CPU Power Button Press Event In Console Application

Feb 5, 2015

I am using Windows 7 32bit OS and want to detect the CPU power button press event in my console application developing in C language.

I configured the power button setting to "Do Nothing" which is in "Choose what the power button does" options in Control Panel->Hardware and Sound->Power Options. So now i want to detect this power button press event and do some processing in my application then i will initate shut down from application itself. Looking for windows API details which will detect the power button press event.

View 2 Replies View Related

C++ :: Guessing Game Program - Ask User To Guess Computer Generator Number

Feb 11, 2013

I'm currently creating a guessing game program where the user will be asked to guess the computer generated number. Once the program is finished, at the end the user will be asked if they want to play again. If the user types "Y or Y" the program will loop and when the user types "n or N" it will not loop. Check out my code below.

#include<iostream.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#define g gotoxy
void main(){
int a,l,b,guess,row,col,answer,num,clue=5;

[Code] ....

I can't loop this program.

View 3 Replies View Related

C++ :: How To Cut Off Input When Using Getch - If User Repeatedly Presses Key

Nov 29, 2013

I am asking for input for a char by using the _getch() function. The thing is that when a key is pressed multiple times it screws the program because it executes every single key that is entered.

I am asking for the user to enter a letter that will determine an action to be used in battle, like attack, magic, "use item", etc.

char option;
cout<<"Enter your choice for battle: ";
option=getch();
if(option=='a')
//Executes an attack
else if(option=='b')
//Opens magic menu
else if(option=='c')
//Opens item menu

Suppose the user enters a character, then the program executes an action by the enemy monster. This is where the problem arises, if the user entered multiple keys or if he enters input during the time the monster attacks, the next time it is the user's turn it will execute the first attack automatically because it keeps reading the input.

I want to know how to cut it off, so that it doesn't ruin the program like that.

View 7 Replies View Related

C++ :: How To Make Program That Presses Key After Certain Amount Of Time

Mar 9, 2013

Say I want to leave a program running and it stops when I press F9 for instance, I'm looking for something like (and note this is just a generalization).

#include blah
using namespace std;
/wait 2 hours
/key.press = F9
return 0;

View 5 Replies View Related

C++ :: Spell Checker - Check If Inputted Word Is In Dictionary File On Computer

Jul 31, 2013

Over the last few days, I've been trying to implement a spell checker in c++ that checks if the inputted word is in the dictionary file on my computer. However, as I'm nearing completion of the project, I keep running into more and more errors, some of which I do not understand. My program is complete, albeit, with some minor bad practices (I hard coded a few things just to get the program up and running.For some reason, everything works well until I output spelling suggestions. I type in "mses" (attempting to spell mess) and it returns some strange characters. It does definitely recognize that there are two permutations that match words in the dictionary (however they are both mess due to the algorithm implemented), and I don't understand why? I will work on removing the duplicates after.

// Spell Checker.cpp : Defines the entry point for the console application.//

#include "stdafx.h"
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <iostream>

[Code] .....

View 7 Replies View Related

C++ :: Determine Health Of A Power Transformer - Graphic User Interface?

Nov 27, 2014

I have a program I want to write that determines the health of a power transformer. I know the syntax of all the other code I might have to use but I'm not too sure of how to make it fit into a graphic interface like you see in any other windows program.

View 1 Replies View Related

C++ :: Check If A Button Has Been Pressed?

Jul 7, 2014

I know how to check if a particular button has been pressed but I basically want to disable the delete button when ever the listbox has lost focus. I am having issues with the fact the button gets disabled before it receives the message. Is their a way around this that is non hacky?

BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{

[Code]....

View 1 Replies View Related

C++ :: Program To Search Soccer Players Data To Check Whether Name Supplied By User Is On That List

Oct 29, 2014

Write a program that will search soccer players data to check whether a name supplied by the user is on that list. For doing the search, the user may provide either the player’s full last name or one or more starting letters of the last name. If a matching last name is found, the program will display the player’s full name and date of birth. Otherwise, it will display “Not found”.

Requirements specification:At the start, the program will ask the user to enter information about 10 soccer players constituting soccer player data. Each soccer player data will consist of the following fields:

Last name
First name
Birth month
Birth day
Birth year

The user will be asked to enter each soccer player data on a separate line with the field values separated by a space.

Once the data is entered, the program will display a menu of choices as below:

Chose an option:

(1 – input data, 2 – display original data, 3 – sort data , 4 – display sorted data 5 – search by last name 6 – exit the program )

If the user chooses option 1, the program will ask the user for a data and populate the array of structures that will hold the data for each of the soccer players.

If the user chooses option 2, the program will display data in the order provided by the user (original data).

If use chooses option 3, the program will sort data by last name.

If user chooses number 4 the program will display the data sorted by last name.

If the user chooses option 5, the program will ask the user to enter one or more starting letters of the soccer player’s last name. It will then search the soccer player data for the matching last name. If a match is found, it will display the first player found with the matching pattern. If a match is not found, the program will display “Not found”. If the user enters two forward slashes (//) for the last name, it will no longer search for the name. Instead it will display the main option menu.

If the user chooses option 6, the program will display “Thank you for using this program” and will end.

Why my program isint executing correctly. Here is what i've so far . . . .

#include <iostream>
#include <string>
using namespace std;
struct data {
string lname;
string fname;
int birthmonth;
int birthday;
int birthyear;

[Code]...

View 3 Replies View Related

C++ :: Program To Find Shortest Path Between Vertices Using Matrix Power Multiplications

Feb 24, 2013

given matrix A find shortest path between vertices using matrix power multiplications untill u get nonzero values,use adjacency matrix

View 1 Replies View Related

C++ :: User Input Number And Then Computer Calculates It For Fibonacci Series

Mar 15, 2013

I was asked to write a code that has the user input a number and then the computer calculates it for the Fibonacci series. The output should be separated by commas and a period should follow the last number. Ex. 1,2,3,4,5. <---period

I can't seem to get the period at the end. I have the commas and everything else. Here is my code:

#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
double num;

cout << "How many Fibonacci numbers do you want to display?";

[Code] ....

View 3 Replies View Related

C# :: Program That Scans Computer Screen?

Nov 20, 2014

I have a problem with a program..I wanna make a program for scan the computer screen.I mean for example there is a video which shows just 5 pictures(apple,pear,banana,strawberry,cherry pictures) but this pictures are turning nonstop in one second. and this case is continuous progress.There are 5 pictures and are chancing. Lets get my problem, I wanna make a program and when apple on the screen my keyboard will push 1,when pear on the screen my keyboard will push 2,banana is 3,strawberry is 4,cherry is 5. I have this 5 pictures which are in the video and I will introduce tham to program and I wanna compare my lib. and screen and get output.

View 3 Replies View Related

C# :: How To Call Event When User Clicks A Button

Mar 25, 2014

I have a application that has a tab control and I change the font and color on form load.

But now I need to switch the font and color when I user clicks a button event.

I have 8 of these events, each customized to set different tab font and color.

tabControl1_DrawItem
tabControl1_DrawItem2
tabControl1_DrawItem3

I just do not know how to make this happen.

View 7 Replies View Related

C :: Program In Which Computer Will Read Txt File And Encrypt It

Jan 1, 2014

I am writing a program in which the computer will read a txt file and encypt it. The encryption works fine, but the computer cannot read the file perfectly. If there's a newline, the scanning process stops. For example I have the following text in the txt file.

One two three four five
(newline) Six seven eight

The computer will stop reading after 'five'. I assume that is because I use fgets.

View 4 Replies View Related

C++ :: Computer Restarts Every Time Program Is Compiled

Feb 26, 2013

I have a weird problem, my computer restarts imidiately after program writen in dev-cpp is compiled AND run. When I run any program, it lasts about 1 second, then program closes, and computer reboots. It doesn't matter whether program is writen now or earlier, my dev-cpp version is 4.9.9.2. Source code can be as simple as this:

#include <iostream>
#include <conio.h>
using namespace std;
int main() {
getch();
return 0;
}

and it restarts anyway...

View 2 Replies View Related

C :: Program Where A Computer And Player Take Turns Rolling Dice

Feb 19, 2013

I am making a program where a computer and player take turns rolling dice.

There seems to be an issue somewhere in my loop where when the player selects from the possible dice choices, it rolls for the computer and does not select the choice and it immediately becomes the player's turn again.

I am trying to get it to where when the computer rolls the dice, it should display the list of possible values, and ask the user to hit the enter key in order for the computer to choose which value to select using the following command:

Code:
while ( getchar() != '
' ) ; I've tried it a hundred times and no matter where I put the command it still skips the computer's turn.

Below is my code:

Code:
while (compscore < 99 && playerscore < 99){
printf("You have rolled the following pair of dice:
");
a =("%i ", rand() % (MAX_VAL - MIN_VAL + 1) + MIN_VAL);
b =("%i ", rand() % (MAX_VAL - MIN_VAL + 1) + MIN_VAL);
multiply = a * b;

[Code] ....

View 11 Replies View Related

Visual C++ :: Terminate A Thread When User Push Stop Button

Nov 16, 2012

I have a thread with a while(1) loop in it. When the user push the stop button I would like that thread to end.

I thought about creating a bool and checking its value periodically in the thread and when I push the stop button I change the value of the bool for that the thread breaks out of the loop and finishes.

View 5 Replies View Related

C++ :: Program To Model Operation Of Incoming Flights Computer Screen

Apr 14, 2013

The project is "Design and write a program to model the operation of incoming flights computer screen that is normally found at a typical small airport like Moshoeshoe I airport (if they do have one). The following provides the information that needs to be displayed about each flight:

• Airline - [string of maximum length 15] Name of the airline, eg. FlySAA
• Flight Number - [string of maximum length 5] eg. 04120
• Origin - [string of maximum length 25] Place where the flight originated from eg. Johannesburg
• Date/Time - [integers: Hour, Minute, Day, Month, Year] Arrival time of the flight
• Status - [string of maximum length 15] Whether the flight is "OnTime" or "Delayed"

View 4 Replies View Related

C :: How To Ignore All Key Presses On Keyboard Except 1-5

May 7, 2014

Here is the function I am trying to modify...

Code:
void DisplayAdminMenu() {
char ch;
system("cls");
printf("Admin Menu");

[Code] ......

Error! Must enter a number between 1 and 5

View 6 Replies View Related

C++ :: How To Check User Selection (yes / No) On Message Box

Feb 10, 2013

How can you tell what button(yes/no) on a message box is clicked? Below is what I have right now but I am getting errors.

if (MessageBox(NULL,"The Message", "The Title", MB_YESNO) == IDYES){
do something
}

View 7 Replies View Related

C++ :: How To Improve Validity Check For User Input

Apr 24, 2013

I wonder how can I improve my validity check for user input? I only want them to key in certain range of digit.

Also for my validity check, when I key in character such as ABC, it lead to infinity loop

Here is my code : Code: /*Write a program that can calculate user's age by getting user input their birth date.*/

#include "stdafx.h"
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
int yyyy, mm, dd; //year, month, day
int i = 0; //for the sake of validity check

[Code]...

View 3 Replies View Related

C++ :: Using Char To Check Whether The User Inputs The Right Command?

Mar 20, 2014

I've been trying to finish this airplane seating program I've been working on for a month or two. The problem I have right now is that if the user inputs a number when prompted to enter the column letter he wants, the program goes on to the next step as if the prompt had been answered correctly.

So I originally used string but I heard from Daleth that Char was better, but I don't know how to apply it. I figured out cin.fail, but I've yet to finish this part.

View 2 Replies View Related

C Sharp :: Loop In A Button / Runs Endless When Pressing The Button And Not Only Once

Jun 10, 2014

I have an code that makes form window + button bet bigger when pressed each time, but it runs endless till out of screen,

code:
{
int S1 = 300;
int S2 = 0;

[Code]...

make it so it runs only each time i press the button?

View 2 Replies View Related

C++ :: Formatting User Input And Check How Many Words Are In String

Feb 5, 2013

I'm trying to write a short program that takes the input from a user and trims any leading/trailing white space, and then checks how many words are in the string. Problem is, I'm only allowed to use stdio.h and stdlib.h. How can I accomplish this? Also, how would I check if any of the characters which were entered aren't either a number, letter, or '-'?

View 3 Replies View Related

C++ :: How To Error Check If User Input Is Letters And Not Numbers

Jun 9, 2014

How do I error check if the user is inputting letters and not numbers? For example, if the user inputs "Lab.txt" I need to display an error message. If they input "Lab2part2.txt" then this is correct and what I want.

I've found a lot of information online on how to error check for numbers or a single letter (EX: 1,2,3, etc. or 'A' 'B' 'C') but nothing for actual WORDS or maybe I should refer to it as a string of characters?

Is there any way to do this? Because my program requires I ask the user to input the name of the file. But the way my code is currently set up is even when the user inputs the wrong file name it still opens the file. I want to prevent this from happening so my thought was to error check user input.

/*Program to determine company's weekly payroll*/

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void OpenTheFile() {
ifstream inputFile;
string filename;
char letter;
int number;

[Code] .....

View 1 Replies View Related

C# :: How To Add Keyboard And Button Press To A Program

Apr 13, 2014

I have a problem where I need to add the ability to input numbers into a calculator program through either a form button press or keyboard press. I have the button press working fine though I can't seem to get the program to start with the cursor active in the textbox for keyboard input. I've use this.ActiveControl = result; "result" being the textbox. Though the issue here is the program starts off with the cursor active but only for the first instance of keyboard inputs.

Perhaps its the way I wrote the program but is there a way I can achieve this? I found a way to write this calc by having a single event for all button presses, opposed from an event for 1-9. Not sure if this is a good approach but here is some of the code.

private double num = 0;
private string calculate;
bool pressed = false;
private void button_Click(object sender, EventArgs e) {
if ((result.Text == "0")||(pressed == true)) {

[Code] ....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved