|
OS interrupts are only used in 16-bit MSDOS apps. More [here ]
You can try this code for a WIN32 console app.
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
HANDLE hIn;
HANDLE hOut;
COORD KeyWhere;
COORD MouseWhere;
COORD EndWhere;
bool Continue = TRUE;
int KeyEvents = 0;
int MouseEvents = 0;
INPUT_RECORD InRec;
DWORD NumRead;
hIn = GetStdHandle(STD_INPUT_HANDLE);
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
cout << "Key Events : " << endl;
cout << "Mouse Events : " << flush;
KeyWhere.X = 15;
KeyWhere.Y = 0;
MouseWhere.X = 15;
MouseWhere.Y = 1;
EndWhere.X = 0;
EndWhere.Y = 3;
while (Continue)
{
ReadConsoleInput(hIn,
&InRec,
1,
&NumRead);
switch (InRec.EventType)
{
case KEY_EVENT:
++KeyEvents;
SetConsoleCursorPosition(hOut,
KeyWhere);
cout << KeyEvents << flush;
if (InRec.Event.KeyEvent.uChar.AsciiChar == 'x')
{
SetConsoleCursorPosition(hOut,
EndWhere);
cout << "Exiting..." << endl;
Continue = FALSE;
}
break;
case MOUSE_EVENT:
++MouseEvents;
SetConsoleCursorPosition(hOut,
MouseWhere);
cout << MouseEvents << flush;
break;
}
}
return 0;
}
More : [here ]
|
|
|
|
|
Is this the header file?
I need mouse.h for turbo c++. Thanks for the code.
|
|
|
|
|
Turbo C++ code.
Copy paste this to a file named mouse.h .
<-------- start of mouse.h
include <fstream.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#include <alloc.h>
const ress=0xb;
unsigned hspd,vspd,thv,button,mouse_x,mouse_y;
int dirx,diry,dir_x,dir_y,trshold;
unsigned char mousestep;
void initmouse(void)
{
asm{
mov ax,1h
int 33h
}
}
void hidemouse(void)
{
asm{
mov ax,2h
int 33h
}
}
void getmousepos(void)
{
asm{
mov ax,3h
int 33h
mov button,bx
mov mouse_x,cx
mov mouse_y,dx
}
}
void getmousedirection(void)
{
asm{
mov ax,ress
int 33h
mov trshold,bx
mov dirx,cx
mov diry,dx
}
}
void getmousespeed(void)
{
asm{
mov ax,1bh
int 33h
mov bx,hspd
mov cx,vspd
mov dx,thv
}
}
<-------- end of mouse.h
|
|
|
|
|
Thanks, I think it works, error relating to mouse.h is gone but not all so I will reply as soon as I debug it.
|
|
|
|
|
Hi, SuperCoder2014 your codes and links solve the problem about mouse handling during runtime but I stuck at deleting the bar3d(). At some point I have to create bar3d() using <graphics.h> and after pressing mouse button I have to make disapper that bar3d() on the same background. Thanks for your help before, and I would appreciate any reply.
|
|
|
|
|
I don't think this message was meant for me.
Veni, vidi, abiit domum
|
|
|
|
|
Yes, RICHARD it wasn't, it was for SUPERCODER2014. And as u said I posted on author's forum too, I think that might help
|
|
|
|
|
And my message was not directed at you, but SuperCoder2014.
Veni, vidi, abiit domum
|
|
|
|
|
Ohh, sorry my bad, u know that I posted the problem, right? I changed name from number to myth1990.
Sorry for misunderstanding
|
|
|
|
|
Hello!
I have following problem. I want to create a application, which is using Netsh. I have created following code:
private: System::Void button1_Click( System::Object ^ sender, System::EventArgs ^ e ) {
Process ^ mojProces = gcnew Process();
ProcessStartInfo ^ startInfo = gcnew ProcessStartInfo( "cmd.exe" );
startInfo->Verb = "runas";
startInfo->Arguments =( "Administrator /c \"netsh wlan start hostednetwork\" " );
startInfo->UseShellExecute = false;
startInfo->CreateNoWindow = true;
startInfo->RedirectStandardOutput = true;
startInfo->RedirectStandardInput = true;
info->Text = "Sieć została uruchomiona.";
mojProces->StartInfo = startInfo;
mojProces->Start();
StreamReader ^ wynik = mojProces->StandardOutput;
String ^ wynik_konsoli = wynik->ReadToEnd();
wynik_wysw->Text = wynik_konsoli;
mojProces->WaitForExit();
mojProces->Close();
Now I would like to redirect output of CMD, but there is following problem. When I set UseShellExecute=false, I cannot run CMD with administrator privileges, which is required to use Netsh. But when I set true I cannot redirect output. Could you please help, how can I solve this problem? Thank you in advance!
|
|
|
|
|
|
camillo87 wrote: Could you please help, how can I solve this problem? You might also try this forum.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
hi there
I would appreciate if someone could tell me how can I read character by character from a file?
I did some research about it but there weren't work in mine for example:
it couldn't verified infile although i use fstream library or is.get none of them working
char singlecharacter;
int singleCharacter ;
ifstream file ("vurudi");
file.is_open() ;
infile.get(singlecharacter);
|
|
|
|
|
Maybe this[^] link will help.
|
|
|
|
|
tnx for your replay.
as I said I used the code which I mention before from this link but it didnt work
|
|
|
|
|
You are going to have to get more specific on what's not working, are you able to open the file? Posting the whole program would probably help.
|
|
|
|
|
|
Just put the file.get into a while statement.
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char singlecharacter ;
ifstream file ("vurudi.txt");
file.is_open() ;
while(file.get(singlecharacter))
{
cout<<singlecharacter;
}
file.close();
cout<<"\n\n\n";
return 0;
}
|
|
|
|
|
There are a number of ways to do this depending on your preference and setup of C++ program
Using standard windows API:
HANDLE Handle;
char Ch;
unsigned long Li;
Handle = CreateFile("c:\\yourfile.txt",
GENERIC_READ, 0, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
if (Handle != INVALID_HANDLE_VALUE){
ReadFile(Handle, &Ch, 1, &Li, 0);
}
CloseHandle(Handle);
Using the standard ifstream unit:
#include <fstream>
char Ch;
ifstream myFile;
myFile.open("c:\\yourfile.txt");
if (myFile.is_open()) {
myFile.read(Ch, sizeof(Ch));
}
myFile.Close();
Using the standard MFC CFile assuming you are using MFC:
UINT nActual = 0;
char Ch;
CFile myFile;
if ( myFile.Open( _T("c:\\yourfile.txt"), CFile::modeRead | CFile::shareDenyWrite ) )
{
nActual = myFile.Read( Ch, sizeof(Ch) );
}
myFile.Close();
|
|
|
|
|
|
MalDrHoop wrote: I have a C program I just posted some minutes ago.
Not that I can see.
|
|
|
|
|
Thank you for looking it over. I dont know why it isnt giving me the desired results.
|
|
|
|
|
Please give this[^] a read, as I have no idea what you have or want.
|
|
|
|
|
I have skimmed through those. The problem is, I can't find a problem with my program. Idk what is going on unless I haven't made a mistake and just misunderstood the professor. I just know that my program fails after many iterations and it shouldn't take many to achieve the desired result.
Thank you for your time anyways
|
|
|
|
|
MalDrHoop wrote: The problem is, I can't find a problem with my program
You haven't asked a specific question.
You haven't posted any code.
And possibly worst of all, you used text speak.
MalDrHoop wrote: I have skimmed through those.
Apparently not well enough.
|
|
|
|