need to press some keys

Aug 12, 2011 at 4:15pm
when i start my computer i need to press ctrl+shift+alt+u to start a program.
how can i do this using a console c(or c++) program.
Aug 12, 2011 at 5:21pm
Read about the SendInput() function.
Aug 14, 2011 at 5:22pm
i tried to use SendInput() but my compiler says that
 
error: 'SendInput' was not declared in this scope


i included some header files windows.h, winuser.h but still i am getting this error.

am i missing something?

Aug 14, 2011 at 5:39pm
There are some tasks that C++ are perfect for, and there are others that are possible but will have you chasing your tail like a lost puppy. Your question falls into the later catagory. Instead of writing a program to press a bunch of keys, just create a startup entry.

If you want this application to start up when you log in then you'll drop the shortcut to the launcher in "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\". This will start the application for any user who logs into that PC.

EDIT: Sorry, this directory becomes "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" and is a hidden system folder in Windows 7.

If you want this to happen when the PC boots then you'll probably run into a few issues with application dependancies, also depending on what version of Windows you are running some methods are better then others. tl;dr I'll need more detail if this is what you are trying to do.
Last edited on Aug 14, 2011 at 5:43pm
Aug 14, 2011 at 6:12pm
i know about that startup folder, msconfig and register entry thing i just want to learn how so send input commands without pressing any key using only a c or c++ console program.

and this is the task i want to do i want to create that program and put it on startup folder.

if you know about how to do things i mentioned above then please help me.

that SendInput() thing looks promising but i am facing some problem which i mentioned on my previous post.
Aug 14, 2011 at 6:34pm
You need #define _WIN32_WINNT 0x500 // or any other value higher than 403 before including windows.h
Aug 17, 2011 at 7:09pm
i defined that thing but still same error.
BTW compiler is now also giving me warning that _WIN32_WINNT is redefined.
Aug 17, 2011 at 7:19pm
What compiler do you use ? For sure it has a "prepocessor definitions" setting, define here _WIN32_WINNT, WIN32_WINNT, WINVER and _WINVER also as 0x0501 or higher.
Aug 18, 2011 at 8:23am
i am using codeblocks and my OS is windows 7.

Aug 18, 2011 at 11:53am
Go to Project/Build options/#defines and add the line _WIN32_WINNT=0x500 there.
Topic archived. No new replies allowed.