Thread: X lib Mouse Click Error

  1. #1
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193

    X lib Mouse Click Error

    I'm having an error while compiling this function I found

    Code:
    void mouseClick(int button){
    	Display *display = XOpenDisplay(NULL);
    	XEvent event;
    
    	if(display == NULL) {
    		fprintf(stderr, "Error en la apertura del display \n");
    		exit(EXIT_FAILURE);
    	}
    
    	memset(&event, 0×00, sizeof(event)); -> 1º Error here
    
    	event.type = ButtonPress;
    	event.xbutton.button = button;
    	event.xbutton.same_screen = True;
    
    	XQueryPointer(display, RootWindow(display, DefaultScreen(display)), &event.xbutton.root,
     &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x,
     &event.xbutton.y, &event.xbutton.state);
    
    	event.xbutton.subwindow = event.xbutton.window;
    
    	while(event.xbutton.subwindow){
    		event.xbutton.window = event.xbutton.subwindow;
    		XQueryPointer(display, event.xbutton.window, &event.xbutton.root, &event.xbutton.subwindow,
     &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x,
     &event.xbutton.y, &event.xbutton.state);
    	}
    
    	if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0){
    		fprintf(stderr, "Error al enviar el evento \n");
    	}
    	XFlush(display);
    	usleep(100000);
    
    	event.type = ButtonRelease;
    	event.xbutton.state = 0×100; -> 2º Error Here
    
    	if(XSendEvent(display, PointerWindow, True, 0xfff, &event) == 0){
    		fprintf(stderr, "Error al enviar el evento \n");
    	}
    
    	XFlush(display);
    
    	XCloseDisplay(display);
    }
    1º Error
    keyfunc.c:33: error: ‘\303’ parasite in the program
    keyfunc.c:33: error: ‘\227’parasite in the program
    keyfunc.c:33: error: expected ‘)’ before numeric constant
    keyfunc.c:33: error: faltan argumentos para la función ‘memset’
    2º Error
    keyfunc.c:55: error: ‘\303’ parasite in the program
    keyfunc.c:55: error: ‘\227’ parasite in the program
    keyfunc.c:55: error: expected ‘;’ before numeric constant

    Any help?
    I think it is because of the 0×00..
    Thanks in advice
    Last edited by lautarox; 12-07-2008 at 06:08 PM.

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    It looks like you're using a multiplication sign instead of the letter x. Since you say you found the function, whoever uploaded it probably did it via some method that stupidly converts an x in between two numbers to a multiplication sign.

    You can probably just change that × to an x (one that you just type on the keyboard) in your editor and it should work. Unless it's your editor doing the changes, in which case you'll have to figure out how to disable that.

  3. #3
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193
    Lol, how didn't I realize that xD
    I'm also getting this error in another function

    keyfunc.c:69: error: expected ‘;’ before ‘{’ token
    Code:
    void NKeyPress(char keyn){

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Without seeing any context at all, my best guess is that the previous function isn't closed yet, and you can't define a new function inside another one.

  5. #5
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    The code you have pasted to pastebin does not give the error you say it does (although it does mention two mistyped switches and the lack of a function usleep).

  7. #7
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193
    lol, thanks, silly mistakes

  8. #8
    C/C++ Learner & Lover
    Join Date
    Aug 2008
    Location
    Argentina
    Posts
    193
    I didn't wanted to create another post, for this, I think it has to be a little problem..
    Code:
    char sameWord(char *tolook, char *word){
    	char lenght, seclenght, i,j;
    	char buff[7][7];
    	char secbuff[7][7];
    	lenght = strlen(word);
    	for(i=0;i<lenght;i++){
    		buff[i] = word[i]; -> First Error (line 30)
    		for(j=0;j<lenght;j++){
    			if(word[j] == word[i]){
    				buff[i][i]++;
    			}
    		}
    	}
    	seclenght = strlen(tolook);
    	for(i=0;i<lenght;i++){
    		secbuff[i] = tolook[i]; -> Second error (line 39)
    		for(j=0;j<lenght;j++){
    			if(tolook[j] == tolook[i]){
    				secbuff[i][i]++;
    			}
    		}
    	}
    	j=0;
    	for(i=0;i<lenght;i++){
    		if(buff[i][i] <= secbuff[i][i]) {
    			j++;
    		}
    	}
    	if(j==lenght) {
    		return 1;
    	}
    	else {
    		return 0;
    	}
    }
    I'm getting this error
    keyfunc.c:30: error: incompatible types in the allocation
    keyfunc.c:39: error: incompatible types in the allocation
    Thanks in advance

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You can't assign to entire arrays. If you want to copy a string, use the string copy function strcpy.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM