This commit is contained in:
118
Form1.cs
Normal file
118
Form1.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MultitabBrowser
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
|
||||
public static extern void mouse_event(uint dwFlags, int dx, int dy, uint cButtons, uint dwExtraInfo);
|
||||
|
||||
private const int MOUSEEVENTF_MOVE = 0x01;
|
||||
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
|
||||
private const int MOUSEEVENTF_LEFTUP = 0x04;
|
||||
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
|
||||
private const int MOUSEEVENTF_RIGHTUP = 0x10;
|
||||
|
||||
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void DoMouseClick(int iX, int iY)
|
||||
{
|
||||
//Call the imported function with the cursor's current position
|
||||
mouse_event(MOUSEEVENTF_MOVE, -10000, -10000, 0, 0);
|
||||
mouse_event(MOUSEEVENTF_MOVE, iX, iY, 0, 0);
|
||||
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, iX, iY, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
private void CheckKeyDown(PreviewKeyDownEventArgs e, int iViewIdx)
|
||||
{
|
||||
Console.WriteLine(iViewIdx);
|
||||
|
||||
if((e.Modifiers & Keys.Control) == Keys.Control)
|
||||
{
|
||||
if(e.KeyCode == Keys.D1)
|
||||
webBrowser1.Refresh();
|
||||
else if(e.KeyCode == Keys.D2)
|
||||
webBrowser2.Refresh();
|
||||
else if(e.KeyCode == Keys.D3)
|
||||
webBrowser3.Refresh();
|
||||
else if(e.KeyCode == Keys.D4)
|
||||
webBrowser4.Refresh();
|
||||
|
||||
System.Windows.Forms.WebBrowser[] aWebView = {
|
||||
webBrowser1,
|
||||
webBrowser2,
|
||||
webBrowser3,
|
||||
webBrowser4 };
|
||||
|
||||
if(e.KeyCode == Keys.U || e.KeyCode == Keys.H)
|
||||
iViewIdx = 0;
|
||||
else if(e.KeyCode == Keys.I || e.KeyCode == Keys.J)
|
||||
iViewIdx = 1;
|
||||
else if(e.KeyCode == Keys.O || e.KeyCode == Keys.K)
|
||||
iViewIdx = 2;
|
||||
else if(e.KeyCode == Keys.P || e.KeyCode == Keys.L)
|
||||
iViewIdx = 3;
|
||||
|
||||
int iBaseX = this.Left;
|
||||
int iBaseY = this.Top;
|
||||
for(int i=0; i<iViewIdx; i++)
|
||||
iBaseX += (aWebView[iViewIdx].Parent.Width+5);
|
||||
|
||||
if((e.Modifiers & Keys.Shift) == Keys.Shift)
|
||||
{
|
||||
if(e.KeyCode == Keys.U)
|
||||
DoMouseClick(iBaseX+aWebView[0].Left+aWebView[0].Width-50, iBaseY+aWebView[0].Top+40);
|
||||
else if(e.KeyCode == Keys.I)
|
||||
DoMouseClick(iBaseX+aWebView[1].Left+aWebView[1].Width-50, iBaseY+aWebView[1].Top+40);
|
||||
else if(e.KeyCode == Keys.O)
|
||||
DoMouseClick(iBaseX+aWebView[2].Left+aWebView[2].Width-50, iBaseY+aWebView[2].Top+40);
|
||||
else if(e.KeyCode == Keys.P)
|
||||
DoMouseClick(iBaseX+aWebView[3].Left+aWebView[3].Width-50, iBaseY+aWebView[3].Top+40);
|
||||
|
||||
if(e.KeyCode == Keys.H)
|
||||
DoMouseClick(iBaseX+aWebView[0].Left+aWebView[0].Width/2, iBaseY+aWebView[0].Top+aWebView[iViewIdx].Height+10);
|
||||
else if(e.KeyCode == Keys.J)
|
||||
DoMouseClick(iBaseX+aWebView[1].Left+aWebView[1].Width/2, iBaseY+aWebView[1].Top+aWebView[iViewIdx].Height+10);
|
||||
else if(e.KeyCode == Keys.K)
|
||||
DoMouseClick(iBaseX+aWebView[2].Left+aWebView[2].Width/2, iBaseY+aWebView[2].Top+aWebView[iViewIdx].Height+10);
|
||||
else if(e.KeyCode == Keys.L)
|
||||
DoMouseClick(iBaseX+aWebView[3].Left+aWebView[3].Width/2, iBaseY+aWebView[3].Top+aWebView[iViewIdx].Height+10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void webBrowser1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
CheckKeyDown(e, 0);
|
||||
}
|
||||
|
||||
private void webBrowser2_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
CheckKeyDown(e, 1);
|
||||
}
|
||||
|
||||
private void webBrowser3_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
CheckKeyDown(e, 2);
|
||||
}
|
||||
|
||||
private void webBrowser4_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
CheckKeyDown(e, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user