Cursor Stand ermitteln
-
Hrhr langsam nervt mich das... mein Code sieht jetzt so aus:
#include <windows.h> #include <conio.h> #include <iostream> using namespace std; int main(int argc, char* argv[]) { while(1) { POINT pt; ::GetCursorPos(&pt); //cout << "Position: " << pt.x << " / " << pt.y; system("CLS"); if (kbhit()) { char cInp = getchar(); //click position 1 if( cInp == 'Y' || cInp == 'y' ) { SetCursorPos(1020, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 2 if( cInp == 'X' || cInp == 'x' ) SetCursorPos(1090, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 3 if( cInp == 'C' || cInp == 'c' ) SetCursorPos(1160, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 4 if( cInp == 'V' || cInp == 'v' ) SetCursorPos(1230, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //go back SetCursorPos(pt.x, pt.y); //break, if program has to shut down //break; } } } return 0; }Und der Fehler liegt in der Zeile:
if( cInp == 'C' || cInp == 'c' )Wie kann das denn sein wenn das mit Y und X geht???
Edit: Hehe ja es ist ein Hotkeytool für Warcraft 3 - DotA
-
ein wenig logisch denken musst du schon

wo eine geschlossene geschweifte klammer ist, muss irgendwo auch ne geöffnete sein, oder nicht?#include <windows.h> #include <conio.h> #include <iostream> using namespace std; int main(int argc, char* argv[]) { while(1) { POINT pt; ::GetCursorPos(&pt); //cout << "Position: " << pt.x << " / " << pt.y; //system("CLS"); if (kbhit()) { char cInp = getchar(); //click position 1 if( cInp == 'Y' || cInp == 'y' ) { SetCursorPos(1020, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 2 else if( cInp == 'X' || cInp == 'x' ) { SetCursorPos(1090, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 3 else if( cInp == 'C' || cInp == 'c' ) { SetCursorPos(1160, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 4 else if( cInp == 'V' || cInp == 'v' ) { SetCursorPos(1230, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //go back SetCursorPos(pt.x, pt.y); //break, if program has to shut down //break; } } } return 0; }btw: wenn du nix schreibst, musst du auch nicht mit CLS löschen...

EDIT: als "hotkeytool" ist das aber wenig sinnvoll, da die konsole zum abfragen der tasten immer im vordergrund sein muss... da gibts bessere lösungen

-
Hmm ja das klingt einläuchtend
jetzt macht return 0; Stress und system("pause") mag er auch nicht... was tun?
-
"macht stress" ist ne nicht wirklich gute fehlerbeschreibung

-
Boah
der Kompiler möchte das nicht kompilieren weil:
expected unqualified-id before "return"
expected,' or;' before "return"
expected declaration before '}' token
-
da kommst du nicht selber drauf? steht doch da was falsch ist... wahrscheinlich fehlt das semikolon nach system("pause")...
-
Nein es ist return 0 und das Semikolon ist da...
-
dann poste deinen code, raten kann ich nicht... mein code funzt so...
-
Da oben ist er doch... Nur noch Semikola dabei:
#include <windows.h> #include <conio.h> #include <iostream> using namespace std; int main(int argc, char* argv[]) { while(1) { POINT pt; ::GetCursorPos(&pt); //cout << "Position: " << pt.x << " / " << pt.y; if (kbhit()) { char cInp = getchar(); //click position 1 if( cInp == 'Y' || cInp == 'y' ) { SetCursorPos(1020, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 2 if( cInp == 'X' || cInp == 'x' ) { SetCursorPos(1090, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 3 if( cInp == 'C' || cInp == 'c' ) { SetCursorPos(1160, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //click position 4 if( cInp == 'V' || cInp == 'v' ) { SetCursorPos(1230, 975); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } //go back SetCursorPos(pt.x, pt.y); //break, if program has to shut down //break; } } } return 0; }
-
zähl mal geöffnete geschweifte klammern und geschlossene... was fällt dir auf? eine geschlossene zuviel

und wo ist dein system("pause") ?????

-
Da steht doch return 0 hab ich doch gesagt

So jetzt macht der Kompiler keine Mucken mehr aber jetzt hab ich ein Program, das stumpf das aufschreibt was ich eintippe, bzw erst die Befehle ausführt wenn ich Enter drücke... Ich blick nichts mehr