Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cursor Position mithilfe einer funktion zurückgeben in c

Empfohlene Antworten

Veröffentlicht

hallo erstmals,

habe unter "suchen" leider kein befriedigendes ergebniss bekommen und auch google konnte mit nicht weiterhelfen.

ich möchte ein Programm schreiben das die x,y-Koordinaten auf meinem Desktop in 2 parametern zurückgibt

Wichtig:

ich bin noch kompletter neuling, also es wäre mir leichter ihr benutzt c, nur wenn es keinen anderen weg als c++-code gibt

und bitte erklärung dazu, damit ich es auch in zukunft benutzen kann und nicht nur sinnlos einen code kopiere

Kurzes Beispiel:

[COLOR="Lime"]

#include <windows.h>

#include <stdio.h>[/COLOR]



[COLOR="Navy"]void[/COLOR] funktion([COLOR="Navy"]int[/COLOR] x*, [COLOR="Navy"]int[/COLOR] y*);

[COLOR="DarkGreen"]/*Die Funktion soll die x,y-koordinaten des Cursers zurückgeben in die 2 parameter

*/[/COLOR]


[COLOR="Navy"]int[/COLOR] main()

{

     [COLOR="Navy"]int[/COLOR] x,y;

     [COLOR="Magenta"]do[/COLOR]

     {

          funktion(&x,&y);

          [COLOR="Magenta"]printf[/COLOR]("(%d|%d)\n\n",x,y);

          [COLOR="Magenta"]Sleep[/COLOR](500);

     }[COLOR="Magenta"]while[/COLOR](x!=0||y!=0);

     [COLOR="Magenta"]return[/COLOR] 0;

}


[COLOR="Navy"]void[/COLOR] funktion(int x*, int y*)

{

   [COLOR="DarkGreen"]  //ich wüsste gerne was hier hineinkommt[/COLOR]

}

das programm sollte folgendes machen:

alle halbe sekunden gibt es die x-y-koordinaten aus..fertig

aber die dazugehörige funktion weiß ich nicht.

Ich benutze zum kompilieren kleinerer programme dev-c++ da man nicht gleich ein neues projekt eröffnen muss wenn es kleiner ist.

sonst nehme ich visual c++ 2008 express edition

Betriebssystem: windows7

lg

laubi

zur vollständigkeit die lösung:

#include <windows.h>

#include <stdlib.h>

#include <stdio.h>


using namespace std;


int main()

{

  POINT mPos;


  while(1)

  {

    Sleep(1);

    GetCursorPos(&mPos);

    printf("X: %d  Y: %d\n",mPos.x,mPos.y);

    system("cls");

    //cout << "\nX:" << mPos.x << "  Y:" << mPos.y << endl;

  }

  return 0;

} 

aber nun möchte ich, so eitel ich bin..das alles nur angezeigt wird, wenn ich mit der maus klicke, und es in einen array abspeichere.

das abspeichern ist null-problem, aber das klicken schon, also ich nehe einfach das programm, minimiere es und klicke in einem externen programm ein mal, und die koordinaten sollen in dem 2-dimensionalen array gespeichert werden...

wie mache ich es das die schleife nur weitergeht bis ich 1 mal irgentwohin geklickt habe?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.