2014-11-30 10 views
1

저는 현재 일부 프로젝트에서 차단 라이브러리를 사용하고 있으며 좌표를 보내고 기존 코드 내에서 마우스 클릭을 시뮬레이션 할 수 있다면 매우 유용 할 것입니다. 나는 현재 라이브러리 내에 이런 일을하는 것을 알고 있지만, 문서가 부족하고 (개발자와의 접촉으로) 내 목표를 성취 할 수 없을지 모른다는 것을 알고 있습니다.Oblita/Interception 라이브러리로 마우스 클릭/좌표 전송 중입니까?

내가 지금까지 가지고있는 유일한 단점은 마우스 좌표가 실제 마우스 좌표를 사용한다는 것입니다 (특정 변수를 -1로 설정하면 마우스를 뒤집을 수 있습니다. 그런 식으로)하지만 화면 좌표를 전달할 수 있기를 바랍니다. 그것 대신에. 또한 특정 마우스 플래그 (INTERCEPTION_MOUSE1_DOWN, INTERCEPTION_MOUSE1_UP 등)가 있지만 SendInput과 함께 전달하려고 시도하면 실패한 것 같습니다.

누구나 도움을 줄 수 있다면 축복이 될 것입니다. 감사합니다.

http://oblita.com/interception.html

P.S - 나는 누군가가 여기에, 여전히 몇 가지 합병증 및 정보 부족의 약간이 있었다 비슷한 무언가를 물어 또 다른 질문을 참조했다. 다시 한번 감사드립니다.

+0

라이브러리 거래, 윈도우 제시한다. 당신이 쉽게 (화면 좌표를 사용하여) 할 수있는 더 높은 수준의 인터페이스를 다루지는 않습니다. 이러한 원시 데이터를 사용하여 빌드 할 수 있습니다. 일반적으로 권장하는 것은 가장 기본적인 응용 프로그램 인 이벤트를 기록하고 전달하는 응용 프로그램을 사용하여 라이브러리를 사용하는 것입니다. –

+0

@pepper_chico 전에 한 번도 시도한 적이 없습니까? 마우스 클릭 시뮬레이션 (기존 코드 사용)은 가능했던 것처럼 보입니다. 또한, 작업중인 원시 마우스 데이터 유형 (이름이있는 경우)에 대한 정보를 제공하고 제 종류를 만들기 위해 어떤 방법을 사용해야하는지, 정말로 가능해야합니다. 답변 해 주셔서 다시 한 번 감사드립니다. – Fiend

+0

나는 전에 해봤는데, 아무런 문제없이 그것을 해낸 다른 사람들을 알고있다. 나는 당신이 그것을 조금 더 열심히 시도해야한다고 생각한다. 헤더와 예제는 매우 자명하다. (다른 사람들이 그렇게 어렵지 않게 애플리케이션을 생성 할 수 있었기 때문에 이것을 말하고있다.) –

답변

0
#include <cmath> 
#include <iostream> 

#include <utils.h> 
#include <interception.h> 

using namespace std; 

namespace scancode { 
    enum { 
     esc = 0x01, 
     num_0 = 0x0B, 
     num_1 = 0x02, 
     num_2 = 0x03, 
     num_3 = 0x04, 
     num_4 = 0x05, 
     num_5 = 0x06, 
     num_6 = 0x07, 
     num_7 = 0x08, 
     num_8 = 0x09, 
     num_9 = 0x0A, 
    }; 
} 

const double pi = 3.14159265358979323846264338327950288419716939937510582097494; 
const double scale = 15; 
const int screen_width = get_screen_width(), screen_height = get_screen_height(); 
const unsigned long milliseconds = calculate_busy_wait_millisecond(); 

struct point { 
    double x; 
    double y; 
    point(double x, double y) : x(x), y(y) {} 
}; 

typedef point (*curve)(double t); 

point circle(double t) { 
    double f = 10; 

    return point(scale * f * cos(t), scale * f * sin(t)); 
} 

point mirabilis(double t) { 
    double f = 1./2., k = 1./(2. * pi); 

    return point(scale * f * (exp(k * t) * cos(t)), 
       scale * f * (exp(k * t) * sin(t))); 
} 

point epitrochoid(double t) { 
    double f = 1, R = 6, r = 2, d = 1; 
    double c = R + r; 

    return point(scale * f * (c * cos(t) - d * cos((c * t)/r)), 
       scale * f * (c * sin(t) - d * sin((c * t)/r))); 
} 

point hypotrochoid(double t) { 
    double f = 10./7., R = 5, r = 3, d = 5; 
    double c = R - r; 

    return point(scale * f * (c * cos(t) + d * cos((c * t)/r)), 
       scale * f * (c * sin(t) - d * sin((c * t)/r))); 
} 

point hypocycloid(double t) { 
    double f = 10./3., R = 3, r = 1; 
    double c = R - r; 

    return point(scale * f * (c * cos(t) + r * cos((c * t)/r)), 
       scale * f * (c * sin(t) - r * sin((c * t)/r))); 
} 

point bean(double t) { 
    double f = 10, c = cos(t), s = sin(t); 

    return point(scale * f * ((pow(c, 3) + pow(s, 3)) * c), 
       scale * f * ((pow(c, 3) + pow(s, 3)) * s)); 
} 

point Lissajous(double t) { 
    double f = 10, a = 2, b = 3; 

    return point(scale * f * (sin(a * t)), scale * f * (sin(b * t))); 
} 

point epicycloid(double t) { 
    double f = 10./42., R = 21, r = 10; 
    double c = R + r; 

    return point(scale * f * (c * cos(t) - r * cos((c * t)/r)), 
       scale * f * (c * sin(t) - r * sin((c * t)/r))); 
} 

point rose(double t) { 
    double f = 10, R = 1, k = 2./7.; 

    return point(scale * f * (R * cos(k * t) * cos(t)), 
       scale * f * (R * cos(k * t) * sin(t))); 
} 

point butterfly(double t) { 
    double f = 10./4., c = exp(cos(t)) - 2 * cos(4 * t) + pow(sin(t/12), 5); 

    return point(scale * f * (sin(t) * c), scale * f * (cos(t) * c)); 
} 

void math_track(InterceptionContext context, InterceptionDevice mouse, 
       curve curve, point center, double t1, double t2, 
       unsigned int partitioning) { 
    lower_process_priority(); 

    InterceptionMouseStroke mstroke; 
    double delta = t2 - t1; 
    point position = curve(t1); 

    mstroke.flags = INTERCEPTION_MOUSE_MOVE_ABSOLUTE; 

    mstroke.state = INTERCEPTION_MOUSE_LEFT_BUTTON_UP; 
    mstroke.x = static_cast<int>((0xFFFF * center.x)/screen_width); 
    mstroke.y = static_cast<int>((0xFFFF * center.y)/screen_height); 
    interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 

    mstroke.state = 0; 
    mstroke.x = static_cast<int>((0xFFFF * (center.x + position.x))/screen_width); 
    mstroke.y = static_cast<int>((0xFFFF * (center.y - position.y))/screen_height); 
    interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 

    for (unsigned int i = 0, j = 0; i <= partitioning + 2; ++i, ++j) { 
     if (j % 250 == 0) { 
      busy_wait(25 * milliseconds); 
      mstroke.state = INTERCEPTION_MOUSE_LEFT_BUTTON_UP; 
      interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 

      busy_wait(25 * milliseconds); 
      mstroke.state = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN; 
      interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 
      mstroke.state = 0; 

      if (i > 0) 
       i -= 2; 
     } 

     position = curve(t1 + (i * delta)/partitioning); 
     mstroke.x = static_cast<int>((0xFFFF * (center.x + position.x))/screen_width); 
     mstroke.y = static_cast<int>((0xFFFF * (center.y - position.y))/screen_height); 
     interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 

     busy_wait(3 * milliseconds); 
    } 

    busy_wait(25 * milliseconds); 
    mstroke.state = INTERCEPTION_MOUSE_LEFT_BUTTON_DOWN; 
    interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 

    busy_wait(25 * milliseconds); 
    mstroke.state = INTERCEPTION_MOUSE_LEFT_BUTTON_UP; 
    interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 

    busy_wait(25 * milliseconds); 
    mstroke.state = 0; 
    mstroke.x = static_cast<int>((0xFFFF * center.x)/screen_width); 
    mstroke.y = static_cast<int>((0xFFFF * center.y)/screen_height); 
    interception_send(context, mouse, (InterceptionStroke *)&mstroke, 1); 

    raise_process_priority(); 
} 

int main() { 
    InterceptionContext context; 
    InterceptionDevice device, mouse = 0; 
    InterceptionStroke stroke; 
    point position(screen_width/2, screen_height/2); 

    raise_process_priority(); 

    context = interception_create_context(); 

    interception_set_filter(context, interception_is_keyboard, 
          INTERCEPTION_FILTER_KEY_DOWN | INTERCEPTION_FILTER_KEY_UP); 
    interception_set_filter(context, interception_is_mouse, 
          INTERCEPTION_FILTER_MOUSE_MOVE); 

    cout << "NOTICE: This example works on real machines.\n" 
     << "  Virtual machines generally work with absolute mouse\n" 
     << "  positioning over the screen, which this samples isn't\n" 
     << "  prepared to handle.\n\n"; 

    cout << "Now please, first move the mouse that's going to be impersonated." << endl; 

    while (interception_receive(context, device = interception_wait(context), &stroke, 1) > 0) { 
     if (interception_is_mouse(device)) { 
      if (!mouse) { 
       mouse = device; 
       cout << "Impersonating mouse " << device - INTERCEPTION_MOUSE(0) << ".\n\n"; 

       cout << "Now:\n" 
        << " - Go to Paint (or whatever place you want to draw)\n" 
        << " - Select your pencil\n" 
        << " - Position your mouse in the drawing board\n" 
        << " - Press any digit (not numpad) on your keyboard to draw an equation\n" 
        << " - Press ESC to exit." << endl; 
      } 

      InterceptionMouseStroke &mstroke = *(InterceptionMouseStroke *)&stroke; 

      position.x += mstroke.x; 
      position.y += mstroke.y; 

      if (position.x < 0) 
       position.x = 0; 
      if (position.x > screen_width - 1) 
       position.x = screen_width - 1; 
      if (position.y < 0) 
       position.y = 0; 
      if (position.y > screen_height - 1) 
       position.y = screen_height - 1; 

      mstroke.flags = INTERCEPTION_MOUSE_MOVE_ABSOLUTE; 
      mstroke.x = static_cast<int>((0xFFFF * position.x)/screen_width); 
      mstroke.y = static_cast<int>((0xFFFF * position.y)/screen_height); 

      interception_send(context, device, &stroke, 1); 
     } 

     if (mouse && interception_is_keyboard(device)) { 
      InterceptionKeyStroke &kstroke = *(InterceptionKeyStroke *)&stroke; 

      switch (kstroke.state) { 
       case INTERCEPTION_KEY_DOWN: 
        switch (kstroke.code) { 
         case scancode::num_0: 
          math_track(context, mouse, circle, position, 0, 2 * pi, 200); 
          break; 
         case scancode::num_1: 
          math_track(context, mouse, mirabilis, position, -(6 * pi), 6 * pi, 200); 
          break; 
         case scancode::num_2: 
          math_track(context, mouse, epitrochoid, position, 0, 2 * pi, 200); 
          break; 
         case scancode::num_3: 
          math_track(context, mouse, hypotrochoid, position, 0, 6 * pi, 200); 
          break; 
         case scancode::num_4: 
          math_track(context, mouse, hypocycloid, position, 0, 2 * pi, 200); 
          break; 
         case scancode::num_5: 
          math_track(context, mouse, bean, position, 0, pi, 200); 
          break; 
         case scancode::num_6: 
          math_track(context, mouse, Lissajous, position, 0, 2 * pi, 200); 
          break; 
         case scancode::num_7: 
          math_track(context, mouse, epicycloid, position, 0, 20 * pi, 1000); 
          break; 
         case scancode::num_8: 
          math_track(context, mouse, rose, position, 0, 14 * pi, 500); 
          break; 
         case scancode::num_9: 
          math_track(context, mouse, butterfly, position, 0, 21 * pi, 2000); 
          break; 
         default: 
          interception_send(context, device, &stroke, 1); 
          break; 
        } 
        break; 
       case INTERCEPTION_KEY_UP: 
        switch (kstroke.code) { 
         case scancode::num_0: 
         case scancode::num_1: 
         case scancode::num_2: 
         case scancode::num_3: 
         case scancode::num_4: 
         case scancode::num_5: 
         case scancode::num_6: 
         case scancode::num_7: 
         case scancode::num_8: 
         case scancode::num_9: 
          break; 
         default: 
          interception_send(context, device, &stroke, 1); 
          break; 
        } 
        break; 
       default: 
        interception_send(context, device, &stroke, 1); 
        break; 
      } 

      if (kstroke.code == scancode::esc) 
       break; 
     } 
    } 

    interception_destroy_context(context); 
} 

출처 : 전적으로 원시 장치 데이터 https://github.com/oblitum/Interception/tree/master/samples/mathpointer