专注企业网站设计,成就互联网新动力。

www.cccidea.com

您当前的位置:首页>技术中心>程序专区

把EXCEL的数据录入到任何系统

时间:2015-06-24 01:08:19来源:作者:点击:69
DimEnv 句柄开关,保存热键,保存方法,顶层句柄
Public Declare Function SetSystemCursor Lib "user32" Alias "SetSystemCursor" (ByVal hcur As Long, ByVal id As Long) As Long
Public Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Public Declare Function SystemParametersInfo  Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long)
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
private Declare Function GetParent Lib "user32" Alias "GetParent" (ByVal hwnd As Long) As Long
Event Form1.Load
    PutAttachment "c:","变化.cur" //释放光标文件
    句柄开关=0
    Form1.InputBox13.Text=1000
    If Form1.CheckBox1.Value = 1 Then 
        Form1.CheckBox1.Caption = "粘贴输入"
    Else 
        Form1.CheckBox1.Caption = "按键码输入"
    End If
    If Form1.OptionBox2.Value = 1 Then 
        保存方法 = 2
    ElseIf Form1.OptionBox1.Value = 1 Then 
        保存方法 = 1
    End If
End Event
Event Form1.Timer1.Timer
    If GetLastClick= 32770 Then  //如果鼠标左键松开
        hwnd=Plugin.Window.MousePoint()
        Select Case 句柄开关
        Case 1
            Form1.Label1.Caption = hwnd 
            Form1.PictureBox1.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 2
            Form1.Label2.Caption = hwnd
            Form1.PictureBox2.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 3
            Form1.Label3.Caption = hwnd
            Form1.PictureBox3.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 4
            Form1.Label4.Caption = hwnd
            Form1.PictureBox4.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 5
            Form1.Label5.Caption = hwnd
            Form1.PictureBox5.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 6
            Form1.Label6.Caption = hwnd
            Form1.PictureBox6.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 7
            Form1.Label7.Caption = hwnd
            Form1.PictureBox7.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 8
            Form1.Label8.Caption = hwnd
            Form1.PictureBox8.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        Case 9
            Form1.Label9.Caption = hwnd
            Form1.PictureBox9.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        End Select
        Form1.PictureBox1.Picture = "Attachment:光标2.jpg" //图像控件图像改为光标2.jpg
        SystemParametersInfo 87, 0, 0, 2 //还原鼠标形状
        Form1.Timer1.Enabled = False 
    End If
End Event
Event Form1.PictureBox1.Click
    句柄开关=1
    call PictureBox的子函数()
    Form1.PictureBox1.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox2.Click
    句柄开关=2
    call PictureBox的子函数()
    Form1.PictureBox2.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox3.Click
    句柄开关=3
    call PictureBox的子函数()
    Form1.PictureBox3.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox4.Click
    句柄开关=4
    call PictureBox的子函数()
    Form1.PictureBox4.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox5.Click
    句柄开关=5
    call PictureBox的子函数()
    Form1.PictureBox5.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox6.Click
    句柄开关=6
    call PictureBox的子函数()
    Form1.PictureBox6.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox7.Click
    句柄开关=7
    call PictureBox的子函数()
    Form1.PictureBox7.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox8.Click
    句柄开关=8
    call PictureBox的子函数()
    Form1.PictureBox8.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.PictureBox9.Click
    句柄开关=9
    call PictureBox的子函数()
    Form1.PictureBox9.Picture="Attachment:光标1.jpg" //图像控件图像改为光标1.jpg
End Event
Event Form1.Button1.Click
    Form1.Label1.Caption=""
End Event
Event Form1.Button2.Click
    Form1.Label2.Caption=""
End Event
Event Form1.Button3.Click
    Form1.Label3.Caption=""
End Event
Event Form1.Button4.Click
    Form1.Label4.Caption=""
End Event
Event Form1.Button5.Click
    Form1.Label5.Caption=""
End Event
Event Form1.Button6.Click
    Form1.Label6.Caption=""
End Event
Event Form1.Button7.Click
    Form1.Label7.Caption=""
End Event
Event Form1.Button8.Click
    Form1.Label8.Caption=""
End Event
Sub PictureBox的子函数()
    hCursor = LoadCursorFromFile("c:变化.cur")'获取鼠标的句柄   //api加载光标文件,不能直接加载按键附件中的文件,需释放到电脑盘符中
    Call SetSystemCursor(hCursor, 32512)    //设置鼠标形状
    Form1.Timer1.Enabled = True
End Sub
Event Form1.Button9.Click
    Form1.InputBox1.Text=Plugin.File.SelectFile()
End Event
Event Form1.Hotkey1.Change
    保存热键=Form1.Hotkey1.VirtualKey
End Event
Event Form1.OptionBox1.Click
    保存方法=1
End Event
Event Form1.OptionBox2.Click
    保存方法=2
End Event
Event Form1.CheckBox1.Click
    If (Form1.CheckBox1.Value = 1) Then 
        Form1.CheckBox1.Caption = "粘贴输入"
    Else 
        Form1.CheckBox1.Caption = "按键码输入"
    End If
End Event
////////////////////////////////////////////////////////////////////////////////////////////////////////
If (UBound(split(Lib.网络.获得网页源文件("http://bbs.anjian.com/thread-551429-1-1.html"),"把EXCEL的数据录入到任何系统:开")=0)) then
    MessageBox "该软件有故障,或则网络故障,请联系作者QQ:118184017"
    ExitScript
End If
Dim 列数据(8),窗口数据(8),文件地址,页数,开始行,结束行,数据(8)
文件地址=Form1.InputBox1.Text
页数 = cint(Form1.InputBox2.Text)
开始行 = cint(Form1.InputBox3.Text)
结束行 = cint(Form1.InputBox4.Text)
列数据(1) = Cint(Form1.InputBox5.Text)
列数据(2) = Cint(Form1.InputBox6.Text)
列数据(3) = Cint(Form1.InputBox7.Text)
列数据(4) = Cint(Form1.InputBox8.Text)
列数据(5) = Cint(Form1.InputBox9.Text)
列数据(6)= Cint(Form1.InputBox10.Text)
列数据(7) = Cint(Form1.InputBox11.Text)
列数据(8) = Cint(Form1.InputBox12.Text)
窗口数据(1) = Form1.Label1.Caption
窗口数据(2) = Form1.Label2.Caption
窗口数据(3) = Form1.Label3.Caption
窗口数据(4) = Form1.Label4.Caption
窗口数据(5) = Form1.Label5.Caption
窗口数据(6) = Form1.Label6.Caption
窗口数据(7) = Form1.Label7.Caption
窗口数据(8) = Form1.Label8.Caption
保存窗口句柄=Form1.Label9.Caption
If 文件地址 = "" Then 
    MessageBox "请先设置文件地址"
    ExitScript
End If
If 页数 = "" Then 
    MessageBox "请先设置页数"
    ExitScript
End If
If 开始行 = "" Then 
    MessageBox "请先设置开始行"
    ExitScript
End If
If 结束行 = "" Then 
    MessageBox "请先设置结束行"
    ExitScript
End If
If 列数据(1) = "" Then 
    MessageBox "请先设置读取的位置"
    ExitScript
End If
If 窗口数据(1) = "" Then 
    MessageBox "请先设置要把数据写入哪个窗口(把箭头拖到要输入文字的位置)"
    ExitScript
End If
If 保存方法 <> 1 and 保存方法 <> 2 Then 
    MessageBox "请先设置保存方法"
    ExitScript
ElseIf 保存方法 = 1 Then
    If (保存热键&" " = " ") Then 
        MessageBox "请先设置保存方法1的热键"
        ExitScript
    End If
ElseIf 保存方法 = 2 Then
    If (保存窗口句柄 = "") Then 
        MessageBox "请先设置保存方法2把箭头拖到要点击的位置"
        ExitScript
    End If
End If
顶层句柄= 获取句柄的顶层句柄(窗口数据(1))
Call Plugin.Window.Active(顶层句柄)
Call Plugin.Window.Restore(顶层句柄)
Call Plugin.Window.Top(顶层句柄, 0)
For 当前行 = 开始行 To 结束行
    Call Plugin.Office.OpenXls(文件地址)
    For m = 1 To 8
        If (列数据(m) <> "") Then 
            数据(m)= Plugin.Office.ReadXls(页数,当前行,列数据(m))
        End If
    Next
    Call Plugin.Office.CloseXls()
    For n = 1 To 8
        If (列数据(n) <> "" or 窗口数据(n) <> "") Then 
            If (Form1.CheckBox1.Caption = "粘贴输入") Then 
                Call 粘贴输入(窗口数据(n),数据(n))
            Else 
                call 按键码输入(窗口数据(n),数据(n))
            End If
        End If
    Next
    If 保存方法 = 1 Then 
        KeyPress 保存热键, 1
    ElseIf 保存方法 = 2 Then
        Call 专业后台点击(保存窗口句柄,1,1)
    End If
    If (Form1.InputBox13.Text = "") Then 
        Delay 1000
    Else 
        Delay cint(Form1.InputBox13.Text)
    End If
Next
Sub OnScriptExit()
    Call Plugin.Window.Top(顶层句柄, 1)
    MessageBox "脚本已经停止!"
End Sub




'查找父句柄
Function 查找父句柄(Hwnd1)
        查找父句柄=GetParent(Hwnd1)
End Function

Function 获取句柄的顶层句柄(Hwnd)
    do
        获取句柄的顶层句柄=Hwnd
        Hwnd= 查找父句柄(Hwnd)
    Loop while (Hwnd<>0)
End Function


Sub 粘贴输入(H窗口句柄, 要输入的文字)
        //这种输入只能在前台运行
        Call Plugin.Window.Active(H窗口句柄)
        Call Plugin.Sys.SetCLB(要输入的文字)
        KeyDown 17, 1
        KeyPress 86, 1
        KeyUp 17, 1
        Call Plugin.Bkgnd.KeyPress(H窗口句柄,13)
End Sub

Sub 专业后台点击(Hwnd, x, y)
        SaveMousePos
        Call 鼠标指向窗口(Hwnd, x, y)
        LockMouse
        Call Plugin.Window.Active(Hwnd)
        Call Plugin.Bkgnd.LeftClick(Hwnd, x, y)
        //Call Plugin.Bkgnd.KeyPress(Hwnd, 13)
        UnlockMouse
        RestoreMousePos
End Sub
Sub 鼠标指向窗口(窗口句柄,窗口x,窗口y)
        Dim sRect
        sRect = Plugin.Window.GetClientRect(窗口句柄)
        MoveTo (Split(sRect, "|")(0)+窗口x),(Split(sRect, "|")(1)+窗口y)
End Sub




Sub 按键码输入(H窗口句柄, 要输入的文字)
    //这种输入只能在前台运行
    Call Plugin.Window.Active(H窗口句柄)
    call 按键码输入键盘上所有字符带汉字(要输入的文字)
    Call Plugin.Bkgnd.KeyPress(H窗口句柄,13)
End Sub
Sub 按键码输入键盘上所有字符带汉字(字符串)
    If GetKeyState(20) Then //检查切换大小写键是否打开
        KeyPress "CapsLock", 1
    End If                       
    //模版是为了判断特殊字和输出特殊字
    模版="|126-`|33-1|64-2|35-3|36-4|37-5|94-6|38-7|42-8|40-9|41-0|123-[|125-]|58-;|34-'|60-,|62-.|63-/|95--|43-=|124-|"
    For i=1 To len(字符串) 
        字符=mid(字符串,i,1)
        字符ASC = ASC(字符)
        If (字符ASC > 0) Then 
            if (字符ASC > 64 and 字符ASC < 91  ) Then //这里是输出大写字母
                KeyDown "Ctrl", 1
                KeyPress 字符, 1
                KeyUp "Ctrl", 1
            ElseIf (UBound(split(模版, "|" & 字符ASC & "-"))) Then//这里是输出需要切换的符号
                键=split(split(模版, "|" & 字符ASC & "-")(1),"|")(0)
                KeyDown "Ctrl", 1
                KeyPress 键, 1
                KeyUp "Ctrl", 1
            ElseIf (字符ASC = 32) Then//由于空格用字符不会输出所以另加一个判断
                KeyPress 字符ASC, 1
            Else
                KeyPress 字符, 1
            End If
        Else 
            Jnm = 字符ASC + 65536
            KeyDown "Alt", 1
            For j = 1 To len(Jnm)
                键码=Cint(Mid(Jnm,j,1))+96
                KeyPress 键码, 1
            Next
            KeyUp "Alt", 1
        End If
    Next  
End Sub

 把EXCEL的数据录入到任何系统.zip

 

相关热词搜索:
更多

上一篇:ECMALL功能拓扑图以及模式分析

下一篇:最详细AT指令

匿名