private void Pad01_MouseMove(object sender, MouseEventArgs e) { double ang; double x, y; SendKeyCode send = new SendKeyCode(); SendMouseCode mouse = new SendMouseCode(); if (flg == true) { Point pos = e.GetPosition(Pad01); x = pos.X - dPadPointX; y = pos.Y - dPadPointY; ang = Math.Atan2( dStartPointX * y - dStartPointY * x, dStartPointX * x + dStartPointY * y ); if (ang > 0.1) { dStartPointX = x; dStartPointY = y; // send.Sendkey(0x31); mouse.Sendwheel(-40); } if (ang < -0.1) { dStartPointX = x; dStartPointY = y; // send.Sendkey(0x32); mouse.Sendwheel(40); } } }
private void ButtonFake_MouseUp(object sender, MouseButtonEventArgs e) { double difX, difY; SendKeyCode send = new SendKeyCode(); Point pos = e.GetPosition((Image)sender); difX = dStartPointX - pos.X; difY = dStartPointY - pos.Y; int id = fblist.FindIndex(delegate(Image im) { return(sender.Equals(im)); }); // アクティブなウィンドウハンドルの取得 IntPtr hWnd = GetForegroundWindow(); //IMEハンドルの取得 IntPtr hIMC = ImmGetDefaultIMEWnd(hWnd); //IMEをOFF SendMessage(hIMC, WM_IME_CONTROL, IMC_SETOPENSTATUS, 0); if (System.Math.Abs(difX) < System.Math.Abs(difY)) { if (System.Math.Abs(difY) < iFrickRange) { //フリックなし send.Sendkey(fd[id].KeyAsign[0]); } else if (System.Math.Abs(difY) > iFrickCancel) { //処理なし } else if (difY > 0) { //上フリック send.Sendkey(fd[id].KeyAsign[1]); } else { //下フリック send.Sendkey(fd[id].KeyAsign[2]); } } else { if (System.Math.Abs(difX) < iFrickRange) { //フリックなし send.Sendkey(fd[id].KeyAsign[0]); } else if (System.Math.Abs(difX) > iFrickCancel) { //処理なし } else if (difX > 0) { //左フリック send.Sendkey(fd[id].KeyAsign[3]); } else { //右フリック send.Sendkey(fd[id].KeyAsign[4]); } } Mouse.Capture(null); System.Threading.Thread.Sleep(100); FrickPop.IsOpen = false; }