using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace google_earth_test1
{
    public class WinApi
    {
        [DllImport("user32.dll", EntryPoint = "ShowWindow")]
        public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
        [DllImport("user32.dll", EntryPoint = "GetClassName")]
        public static extern int GetClassName(int hwnd, StringBuilder lpClassName, int nMaxCount);
        [DllImport("user32.dll")] 
        [return: MarshalAs(UnmanagedType.Bool)] 
        public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); 
 
        [DllImport("user32.dll")] 
        [return: MarshalAs(UnmanagedType.Bool)] 
        public static extern bool UnregisterHotKey(IntPtr hWnd, int id);

        [DllImport("user32.dll")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

        [DllImport("user32.dll")]
        public static extern int SetWindowPos(IntPtr hwnd,int ord,int x,int y,int dx,int dy,int uflag); 
　　//参数1为要顶层显示的窗口句柄，参数2指定显示的层次，参数7为附加选项，其余参数指定窗口位置和大小，均可忽略。在窗口的Open或Activate事件中加入如下函数调用： 
        [DllImport("winmm")]
        static extern bool PlaySound(string szSound, IntPtr hMod, PlaySoundFlags flags);
        [DllImport("user32.dll")]
        static extern IntPtr GetActiveWindow();
        [DllImport("user32.dll")]
        static extern bool SetCursorPos(int X, int Y);
        [DllImport("user32.dll")]
        static extern int ShowCursor(bool b);
        [DllImport("user32.dll")]
        static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);

        [Flags]
        public enum MouseEventFlag : uint
        {
            Move = 0x0001,
            LeftDown = 0x0002,
            LeftUp = 0x0004,
            RightDown = 0x0008,
            RightUp = 0x0010,
            MiddleDown = 0x0020,
            MiddleUp = 0x0040,
            XDown = 0x0080,
            XUp = 0x0100,
            Wheel = 0x0800,
            VirtualDesk = 0x4000,
            Absolute = 0x8000
        }

        public enum PlaySoundFlags : int
        {
            SND_SYNC = 0x0000,      /*  play  synchronously  (default)  */  //同步  
            SND_ASYNC = 0x0001,     /*  play  asynchronously  */  //异步  
            SND_NODEFAULT = 0x0002, /*  silence  (!default)  if  sound  not  found  */
            SND_MEMORY = 0x0004,    /*  pszSound  points  to  a  memory  file  */
            SND_LOOP = 0x0008,      /*  loop  the  sound  until  next  sndPlaySound  */
            SND_NOSTOP = 0x0010,    /*  don't  stop  any  currently  playing  sound  */
            SND_NOWAIT = 0x00002000,/*  don't  wait  if  the  driver  is  busy  */
            SND_ALIAS = 0x00010000, /*  name  is  a  registry  alias  */
            SND_ALIAS_ID = 0x00110000,/*  alias  is  a  predefined  ID  */
            SND_FILENAME = 0x00020000,/*  name  is  file  name  */
            SND_RESOURCE = 0x00040004 /*  name  is  resource  name  or  atom  */
        }


    }   
}
