zoukankan      html  css  js  c++  java
  • 【转】调用 开始 运行 直接执行命令

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Diagnostics;

    namespace fasta2011
    {
    public class Cmd
    {
    private const byte VK_LWIN = (byte)Keys.LWin;
    private const byte VK_R = (byte)Keys.R;
    private const int KEYEVENTF_KEYUP = 0x02;
    private const int WM_SETTEXT = 0x000C;
    private const int WM_CLICK = 0x00F5;

    [DllImport("user32")]
    public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

    [DllImport("user32.dll")]
    static extern int FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll")]
    public static extern int FindWindowEx(int parentHandle, int childAfter, string className, string windowTitle);

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


    public static void Run(string CmdText)
    {
    keybd_event(VK_LWIN, 0, 0, 0);
    keybd_event(VK_R, 0, 0, 0);
    keybd_event(VK_R, 0, KEYEVENTF_KEYUP, 0);
    keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);

    System.Threading.Thread.Sleep(50);

    int h1 = 0, h2 = 0, h3;
    h1 = FindWindow(null, "运行"); //这要修改为窗口标题
    if (h1 != 0)
    {
    h2 = FindWindowEx(h1, 0, "ComboBox", null);
    if (h2 != 0)
    {
    SendMessage(h2, WM_SETTEXT, 0, CmdText);
    System.Threading.Thread.Sleep(10);

    h3 = FindWindowEx(h1, 0, null, "确定"); //这要修改为按钮文本
    if (h3 != 0)
    {
    SendMessage(h3, WM_CLICK, 0, null);
    }
    else
    {
    MessageBox.Show("h3==0");
    }
    }
    else
    {
    MessageBox.Show("h2==0");
    }
    }
    else
    {
    MessageBox.Show("h1==0");
    }
    }
    }
    }
  • 相关阅读:
    Andriod 简介
    Java 记录日志
    Java 国际化
    Java 正则表达式的使用
    Java 日期、时间类,日期、时间的格式化
    Java Random类、ThreadLocalRandom类
    Java Math类、BigDecimal类、NumberFormat类、浮点数的精确度问题
    Java String类、StringBuilder类、StringBuffer类
    Java System类、RunTime类、Object类、垃圾回收
    span 右浮动折行 解决ie6/7中span右浮动折行问题
  • 原文地址:https://www.cnblogs.com/chusiping/p/2254036.html
Copyright © 2011-2022 走看看