Beispiel #1
0
        void tempButton_Click(object sender, EventArgs e)
        {
            ToolStripButton button = (ToolStripButton)sender;
            QuickData       data   = null;
            int             index  = -1;

            for (int i = 0; i < m_quickDatas.Count; i++)
            {
                if (((QuickData)m_quickDatas[i]).name == button.Text)
                {
                    data  = (QuickData)m_quickDatas[i];
                    index = i + 1;
                    break;
                }
            }

            if (m_lastWin != IntPtr.Zero)
            {
                if (index <= 25)
                {
                    //让putty自己完成
                    int keyCode = 111 + index;
                    SendMessage(m_lastWin, WM_KEYDOWN, keyCode, 0);
                    SendMessage(m_lastWin, WM_KEYUP, keyCode, 0);
                    SetForegroundWindow(m_lastWin);
                }
            }
        }
Beispiel #2
0
        private void execQuick(String scriptType)
        {
            int    index = -1;
            string line  = "";

            for (int i = 0; i < quickDatas.Count; i++)
            {
                QuickData data = (QuickData)quickDatas[i];
                if (data.name == scriptType)
                {
                    index = i + 1;
                    line  = data.data;
                }
            }
            if (index != -1)
            {
                if (index <= 25)
                {
                    int keyCode = 111 + index;
                    SendMessage(appWin, WM_KEYDOWN, keyCode, 0);
                    SendMessage(appWin, WM_KEYUP, keyCode, 0);
                }
                else
                {
                    for (int i = 0; i < line.Length; i++)
                    {
                        char c = line[i];
                        SendMessage(appWin, WM_CHAR, c, 0);
                        Thread.Sleep(30);
                    }
                }
            }
        }
Beispiel #3
0
 private void QuickForm_Load(object sender, EventArgs e)
 {
     foreach (QuickData data in this.baseKeys)
     {
         QuickData temp = new QuickData(data.name, data.data);
         this.resultList.Items.Add(temp);
     }
 }
Beispiel #4
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((resultList.SelectedIndex != -1) && (resultList.SelectedIndex != lastIndex))
     {
         QuickData select = (QuickData)resultList.SelectedItem;
         this.keyname.Text = select.name;
         this.keydata.Text = select.data;
         lastIndex         = resultList.SelectedIndex;
     }
 }
Beispiel #5
0
 public void run()
 {
     //wait
     if (this.waitTime != null)
     {
         try
         {
             int count = Convert.ToInt32(this.waitTime);
             Thread.Sleep(count);
         }
         catch (Exception exp)
         {
         }
     }
     //send FX
     if (this.scriptType != null && quickDatas != null)
     {
         int index = -1;
         for (int i = 0; i < quickDatas.Count; i++)
         {
             QuickData data = (QuickData)quickDatas[i];
             if (data.name == scriptType)
             {
                 index = i + 1;
             }
         }
         if (index != -1)
         {
             int keyCode = 111 + index;
             SendMessage(appWin, WM_KEYDOWN, keyCode, 0);
             SendMessage(appWin, WM_KEYUP, keyCode, 0);
         }
     }
     //send Command
     else if (this.command != null)
     {
         string[] array = this.command.Replace("\r", "").Split('\n');
         foreach (string line in array)
         {
             for (int i = 0; i < line.Length; i++)
             {
                 char c = line[i];
                 SendMessage(appWin, WM_CHAR, c, 0);
                 Thread.Sleep(30);
             }
             Thread.Sleep(100);
             SendMessage(appWin, 0, 13, 0);
             SendMessage(appWin, WM_KEYUP, 13, 0);
             Thread.Sleep(500);
         }
     }
 }
Beispiel #6
0
 private void loadKey()
 {
     if (!File.Exists("config.ini"))
     {
         return;
     }
     try
     {
         StreamReader  reader = new StreamReader("config.ini", Encoding.GetEncoding("gb2312"));
         string        input;
         string        keyword = "";
         StringBuilder keyData = new StringBuilder();
         while ((input = reader.ReadLine()) != null)
         {
             if (input.StartsWith("[DEFAULT-COLOR="))
             {
                 defaultColor = input.Replace("[DEFAULT-COLOR=", "").Replace("]", "");
             }
             else if (input.StartsWith("["))
             {
                 if (keyword != "")
                 {
                     QuickData quickData = new QuickData(keyword, keyData.ToString());
                     m_quickDatas.Add(quickData);
                 }
                 keyword = input.Replace("[", "").Replace("]", "");
                 keyData = new StringBuilder();
             }
             else
             {
                 keyData.Append(input + "\r\n");
             }
         }
         if (keyword != "")
         {
             QuickData quickData = new QuickData(keyword, keyData.ToString());
             m_quickDatas.Add(quickData);
         }
         reader.Close();
     }
     catch (Exception exp)
     {
     }
 }
Beispiel #7
0
        private void saveKey()
        {
            StreamWriter writer = new StreamWriter("config.ini", false, Encoding.GetEncoding("gb2312"));

            for (int i = 0; i < m_quickDatas.Count; i++)
            {
                QuickData quickData = (QuickData)(m_quickDatas[i]);
                writer.WriteLine("[" + quickData.name + "]");
                if (i != m_quickDatas.Count - 1)
                {
                    writer.WriteLine(quickData.data.Trim());
                }
                else
                {
                    writer.Write(quickData.data.Trim());
                }
            }
            writer.Close();
        }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            QuickData newData = new QuickData("+ new +", "");

            this.resultList.Items.Add(newData);
        }