| | |
Help printing on screen
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2006
Posts: 179
Reputation:
Solved Threads: 2
Hi all
My friend sent me this C++ program that opens up notepad and starts typing, its a joke he made to scare his little brother, I tried to modify it to display more of the message "Im watching you" but when I do it wont compile and I dont understand the error message, Im a noob lol
Heres the code all I did was copy and paste the spooky message a few more times underneath the original spooky messages, so instead of displaying the message 4 times it displayed it 6 times
Many thanks
HLA91
My friend sent me this C++ program that opens up notepad and starts typing, its a joke he made to scare his little brother, I tried to modify it to display more of the message "Im watching you" but when I do it wont compile and I dont understand the error message, Im a noob lol
Heres the code all I did was copy and paste the spooky message a few more times underneath the original spooky messages, so instead of displaying the message 4 times it displayed it 6 times
C++ Syntax (Toggle Plain Text)
#include <windows.h> #include <cstdlib> using namespace std; int main(int argc,char *argv[]) { //hides your program from the desktop HWND hwnd1 = FindWindow(NULL,argv[0]); ShowWindow(hwnd1,SW_HIDE); //array for your messge char text[75]= {'i','m',' ','w','a','t','c','h','i','n','g' ,' ','y','o','u','.','.','.' ,' ','i','m',' ','w','a','t','c','h','i','n','g' ,' ','y','o','u','.','.','.' ,' ','i','m',' ','w','a','t','c','h','i','n','g' ,' ','y','o','u','.','.','.' ,' ','i','m',' ','w','a','t','c','h','i','n','g' ,' ','y','o','u','.','.','.'}; //this allows your program to execute a minute later Sleep(15000); //plays the scary file - must link libwinmm.a PlaySound("C:/scary1.wav",NULL, SND_FILENAME); //Sleep(3000); //opens Microsoft Word ShellExecute(NULL, "open","C:/WINDOWS/system32/notepad.exe" , NULL, NULL, SW_SHOWNORMAL); HWND hwnd2= FindWindow(NULL,"Untitled - Notepad"); //makes Word the active window SetActiveWindow(hwnd2); Sleep(2000); //simulates a mouse left click mouse_event(MOUSEEVENTF_LEFTDOWN,200,200,0,0); mouse_event(MOUSEEVENTF_LEFTUP,200,200,0,0); // Sleep(1000); //writes your scary message for(int i=0;i<75;i++){ keybd_event(VkKeyScan(text[i]),0,0,0); Sleep(rand() %200); } return 0; }
Many thanks
HLA91
You know your a geek, if you introduce your wife as "mylady@home.wife"
•
•
Join Date: Oct 2006
Posts: 179
Reputation:
Solved Threads: 2
Sorry stupid me here they are 3 of them
In function 'int main(int,char**)':
too many initializers for 'char[75]'
[Build Error] [ghost4school.o] Error1
I thought the second message meant too many letters because I had only declared 75 but I counted the original number of letters and that went over 75 so I have no other ideas
In function 'int main(int,char**)':
too many initializers for 'char[75]'
[Build Error] [ghost4school.o] Error1
I thought the second message meant too many letters because I had only declared 75 but I counted the original number of letters and that went over 75 so I have no other ideas
Last edited by HLA91; Nov 7th, 2007 at 4:37 pm.
You know your a geek, if you introduce your wife as "mylady@home.wife"
>too many initializers for 'char[75]'
By my count you have exactly 75, so either the code you posted isn't the same code you've compiled, or you're getting a strange error. In fact, it compiles okay for me. Try removing the array size and using
By my count you have exactly 75, so either the code you posted isn't the same code you've compiled, or you're getting a strange error. In fact, it compiles okay for me. Try removing the array size and using
sizeof text in the loop instead of 75. That should sidestep the problem. Last edited by Narue; Nov 7th, 2007 at 4:49 pm.
I'm here to prove you wrong.
>what are you counting?
I'm counting the number of character literals. Alternatively, you can count the number of commas and add one. Anyway, you're making this harder on yourself because you could just do this:
Then instead of counting the number of characters, just traverse until you find '\0'. Much easier.
I'm counting the number of character literals. Alternatively, you can count the number of commas and add one. Anyway, you're making this harder on yourself because you could just do this:
C++ Syntax (Toggle Plain Text)
const char *text = "i'm watching you... " "i'm watching you... " "i'm watching you... " "i'm watching you...";
I'm here to prove you wrong.
•
•
Join Date: Oct 2006
Posts: 179
Reputation:
Solved Threads: 2
OK i got the *text part sorted and it works now thankyou but when it prints it does im watching you 4 times but on the fourth one it only prints
i'm watching yo
and then it re opens one of the windows i minimized
here is the code now
thanks for help
HLA91
i'm watching yo
and then it re opens one of the windows i minimized
here is the code now
C++ Syntax (Toggle Plain Text)
#include <windows.h> #include <cstdlib> using namespace std; int main(int argc,char *argv[]) { //hides your program from the desktop HWND hwnd1 = FindWindow(NULL,argv[0]); ShowWindow(hwnd1,SW_HIDE); //array for your messge const char *text = "i'm watching you... " "i'm watching you... " "i'm watching you... " "i'm watching you..."; //this allows your program to execute a minute later Sleep(15000); //plays the scary file - must link libwinmm.a PlaySound("C:/scary1.wav",NULL, SND_FILENAME); //Sleep(3000); //opens Microsoft Word ShellExecute(NULL, "open","C:/WINDOWS/system32/notepad.exe" , NULL, NULL, SW_SHOWNORMAL); HWND hwnd2= FindWindow(NULL,"Untitled - Notepad"); //makes Word the active window SetActiveWindow(hwnd2); Sleep(2000); //simulates a mouse left click mouse_event(MOUSEEVENTF_LEFTDOWN,200,200,0,0); mouse_event(MOUSEEVENTF_LEFTUP,200,200,0,0); // Sleep(1000); //writes your scary message for(int i=0;i<75;i++){ keybd_event(VkKeyScan(text[i]),0,0,0); Sleep(rand() %200); } return 0; }
thanks for help
HLA91
You know your a geek, if you introduce your wife as "mylady@home.wife"
You neglected to make all of the changes I suggested. Change this:
To this:
C++ Syntax (Toggle Plain Text)
for(int i=0;i<75;i++){
C++ Syntax (Toggle Plain Text)
for ( int i = 0; text[i] != '\0'; i++ ) {
I'm here to prove you wrong.
•
•
Join Date: Oct 2006
Posts: 179
Reputation:
Solved Threads: 2
OK thanks its runs fine for about 9 messages and then it just prints '''''''''''''''''''''''''''''''''''''''''''''
here is the code now
here is what is printed part of one of the messages is cut becasue msn popped up and it started writing in the search box lol
Im watching you… im watching you… im watching you… im watching you… im watching you… im watching you… you… im watching you… im watching you… im watching’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
I dont understand where it is getting the ''''''''' from can somebody help me again please?
Many thanks for time
HLA91
here is the code now
C++ Syntax (Toggle Plain Text)
#include <windows.h> #include <cstdlib> using namespace std; int main(int argc,char *argv[]) { //hides your program from the desktop HWND hwnd1 = FindWindow(NULL,argv[0]); ShowWindow(hwnd1,SW_HIDE); //array for your messge const char *text= "I'm Watching you..." "I'm Watching you..." "I'm Watching you..." "I'm Watching you..."; //this allows your program to execute a minute later Sleep(15000); //plays the scary file - must link libwinmm.a PlaySound("C:/scary1.wav",NULL, SND_FILENAME); //Sleep(3000); //opens Microsoft Word ShellExecute(NULL, "open","C:/WINDOWS/system32/notepad.exe" , NULL, NULL, SW_SHOWNORMAL); HWND hwnd2= FindWindow(NULL,"Untitled - Notepad"); //makes Word the active window SetActiveWindow(hwnd2); Sleep(2000); //simulates a mouse left click mouse_event(MOUSEEVENTF_LEFTDOWN,200,200,0,0); mouse_event(MOUSEEVENTF_LEFTUP,200,200,0,0); // Sleep(1000); //writes your scary message for ( int i = 0; text[i] != '\0'; i++ ) { keybd_event(VkKeyScan(text[i]),0,0,0); Sleep(rand() %200); } return 0; }
Im watching you… im watching you… im watching you… im watching you… im watching you… im watching you… you… im watching you… im watching you… im watching’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
I dont understand where it is getting the ''''''''' from can somebody help me again please?
Many thanks for time
HLA91
You know your a geek, if you introduce your wife as "mylady@home.wife"
>OK thanks its runs fine for about 9 messages
>and then it just prints '''''''''''''''''''''''''''''''''''''''''''''
It should only print four messages, because that's how many you've defined. In fact, that's precisely what it does for me. Did you post the actual code you're using?
>and then it just prints '''''''''''''''''''''''''''''''''''''''''''''
It should only print four messages, because that's how many you've defined. In fact, that's precisely what it does for me. Did you post the actual code you're using?
I'm here to prove you wrong.
![]() |
Similar Threads
- printing to the screen after using fopen() (PHP)
- Urgent Help- Printing Screen (Pascal and Delphi)
- Creating Functions to print to screen. (C++)
- reading(printing to screen) program (Python)
- Printing to Screen in a Class (C++)
- Dev-C++ Question (C++)
- Error message when I run my program in C++ (C++)
- Store Bluetooth remote address to a text file (C++)
Other Threads in the C++ Forum
- Previous Thread: overloading operator
- Next Thread: printf and reference issue
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






