Пример #1
0
        public frmMain()
        {
            InitializeComponent();

            AppRunning = true;

            //Pull in some settings from an ini file:
            ini = new IniFile(Application.StartupPath + "\\AutoItX.ini");
            bool success;
            int SendKeyDelay = myUtils.StringToInt(ini.IniReadValue("AUTOITXSETTINGS", "SendKeyDelay"), out success);
            if (!success) SendKeyDelay = 5;     //load default value
            int WinWaitDelay = myUtils.StringToInt(ini.IniReadValue("AUTOITXSETTINGS", "WinWaitDelay"), out success);
            if (!success) WinWaitDelay = 250;

            ///Alters the the length of the brief pause in between sent keystrokes.
            ///Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead.
            AutoItX.AU3_AutoItSetOption("SendKeyDelay", SendKeyDelay);

            ///Alters the method that is used to match window titles during search operations.
            ///1 = Match the title from the start (default)
            ///2 = Match any substring in the title
            ///3 = Exact title match
            ///4 = Advanced mode, see Window Titles & Text (Advanced)
            AutoItX.AU3_AutoItSetOption("WinTitleMatchMode", 2);

            ///WinWaitDelay Alters how long a script should briefly pause after a successful window-related operation.
            ///Time in milliseconds to pause (default=250).
            AutoItX.AU3_AutoItSetOption("WinWaitDelay", WinWaitDelay);

            ///WinSearchChildren Allows the window search routines to search child windows as well as top-level windows.
            ///0 = Only search top-level windows (default)
            ///1 = Search top-level and child windows
            AutoItX.AU3_AutoItSetOption("WinSearchChildren", 0);

            //When using the COM library (rater than dllimport):
            //AutoItX3Lib.AutoItX3Class Au3Class = new AutoItX3Lib.AutoItX3Class();
            //Au3Class.

            //Simple keyboard hook set up with a callback to eventKeyPress on keyboard events:
            myKeyboardMouseHook = new KeyboardMouseHook(eventKeyPress);

            //Simple hotkey handler to allow registering hotkeys each with their own callbacks
            //(also hotkeys pressed are CONSUMED, meaning windows will not pass them down to other applications)
            //Or in other words, if this application registers a given hotkey, that hotkey will ONLY be seen by this
            //application.
            //Very important: be sure to override WndProc(ref Message m) and add a function call to myHotkeyHandler.WndProc(ref m)
            myHotkeyHandler = new HotkeyHandler(this.Handle);

            myHotkeyHandler.HotkeySet(HotkeyHandler.KeyModifiers.Control | HotkeyHandler.KeyModifiers.Alt, Keys.A, eventHotkeyCtrlAltA);
            myHotkeyHandler.HotkeySet(HotkeyHandler.KeyModifiers.None, Keys.B, eventHotkeyB);

            myHotkeyHandler.HotkeySet(HotkeyHandler.KeyModifiers.Control, Keys.B, AutoItXScriptRun);

            //Set up a tray icon with a context menu
            SetupTrayIcon();

            //Comment this out to cause the form to start hidden (only show the tray icon):
            this.Show();
        }
Пример #2
0
 void eventHotkeyCtrlAltA(Keys KeyCode, HotkeyHandler.KeyModifiers KeyMods)
 {
     //MessageBox.Show("Hotkey Ctrl Alt A pressed!");
     lblHotkey.Text = "Hotkey Ctrl Alt A pressed!";
 }
Пример #3
0
 void AutoItXScriptRun(Keys KeyCode, HotkeyHandler.KeyModifiers KeyMods)
 {
     AutoItXScript();
 }