'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
'
' NAME:
'
' AUTHOR: Microsoft , Microsoft
' DATE : 2014/8/10
'
' COMMENT:
'
'===================定義變量,注冊API對象==================================
Dim UserWrap,hWnd

Set UserWrap = CreateObject("DynamicWrapper")
Set ws=WScript.CreateObject("wscript.shell")

WScript.Sleep 500

ws.Run "calc",0

WScript.Sleep 500

'Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
UserWrap.Register "USER32.DLL", "ShowWindow", "I=hl", "f=s", "R=l"

'Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

UserWrap.Register "USER32.DLL", "FindWindow", "I=ss", "f=s", "R=l"

'Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

UserWrap.Register "USER32.DLL", "SetWindowPos", "I=Hllllll", "f=s", "R=l"

'Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
UserWrap.Register "USER32.DLL", "PostMessage", "I=hlls", "f=s", "R=l"

'Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
UserWrap.Register "USER32.DLL", "SetWindowText", "I=Hs", "f=s", "R=l"

'Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
UserWrap.Register "USER32.DLL", "FindWindowEx", "I=llss", "f=s", "R=l"

'Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

UserWrap.Register "USER32.DLL", "SetCursorPos", "I=ll", "f=s", "R=l"

'===================查找控件或者窗體句柄===============================

hWnd = UserWrap.FindWindow(vbNullString,"計算器")
'hWnd = UserWrap.FindWindow("kugou_ui",vbNullString)

hWnd1 = UserWrap.FindWindowEx(hWnd,0,vbNullString,Edit)

'UserWrap.ShowWindow hWnd,SW_HIDE

'UserWrap.SetWindowText hWnd,"hello world"

' MsgBox hWnd
' MsgBox hWnd1

'UserWrap.SetWindowPos hWnd, -1, 0, 0, 0, 0, 3

'MsgBox "將鼠標移到左上角"

'UserWrap.SetCursorPos 0,0

'=================定義系統常量===========================

Private Const WM_KEYDOWN = &H100
Private Const wm_keyup= &H101
Private Const WM_CHAR = &H102
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105

'=================發送F1按鍵=====================
UserWrap.PostMessage hWnd, WM_KEYDOWN, 112, 0

'=================發送1002========================
UserWrap.PostMessage hWnd,WM_KEYDOWN ,97,0
UserWrap.PostMessage hWnd,WM_KEYDOWN ,96,0
UserWrap.PostMessage hWnd,WM_KEYDOWN ,96,0
UserWrap.PostMessage hWnd,WM_KEYDOWN ,98,0

VBS調用windows api函數(postmessage)實現后台發送按鍵腳本的更多相關文章

  1. VBS調用Windows API函數

    Demon's Blog 忘記了,喜歡一個人的感覺 Demon's Blog  »  程序設計  »  VBS調用Windows API函數 « 用VBS修改Windows用戶密碼 在VB中創建和使用 ...

  2. C#調用Windows API函數截圖

    界面如下: 下面放了一個PictureBox 首先是聲明函數: //這里是調用 Windows API函數來進行截圖 //首先導入庫文件 [System.Runtime.InteropServices ...

  3. Python調用Windows API函數編寫錄音機和音樂播放器

    功能描述: 1)使用tkinter設計程序界面: 2)調用Windows API函數實現錄音機和音樂播放器. . 參考代碼: ​ 運行界面: ​

  4. MFC中調用Windows API函數的方式

    windows aoi 函數的調用前面加::

  5. c#讓窗體永在最前 調用windows api 將窗體設為topmost

    有時候應用程序需要將一個窗體始終位於屏幕的最前面,即使切換到其它窗體也能看到該窗體,這樣的窗體就叫做TopMost窗體. 用C#制作TopMost窗體之前,首先要了解如何聲明SetWindowPos函 ...

  6. Windows API 函數列表 附幫助手冊

    所有Windows API函數列表,為了方便查詢,也為了大家查找,所以整理一下貢獻出來了. 幫助手冊:700多個Windows API的函數手冊 免費下載 API之網絡函數 API之消息函數 API之 ...

  7. WINDOWS API 函數(超長,值得學習)

    一.隱藏和顯示光標 函數: int ShowCursor ( BOOL bShow );  參數 bshow,為布爾型,bShow的值為False時隱藏光標,為True時顯示光標:該函數的返回值為整型 ...

  8. Windows API函數大全(精心總結)

    WindowsAPI函數大全(精心總結)    目錄 1. API之網絡函數... 1 2. API之消息函數... 1 3. API之文件處理函數... 2 4. API之打印函數... 5 5. ...

  9. Windows API函數大全(完整)

    Windows API函數大全,從事軟件開發的朋友可以參考下 1. API之網絡函數 WNetAddConnection 創建同一個網絡資源的永久性連接 WNetAddConnection2 創建同一 ...

隨機推薦

  1. [轉]C#讀寫TEXT文件

    1.使用FileStream讀寫文件 文件頭: using System; using System.Collections.Generic; using System.Text; using Sys ...

  2. 使用jquery的delay方式模擬sleep

    javascript中並沒有原生sleep函數可供調用,一般來說為了實現sleep功能,大都是采用SetTimeout來模擬,以下片段采用jquery的delay方法來模擬,也算是提供了另外一個視角吧 ...

  3. iOS學習筆記---c語言第十天

    動態內存分配 一.存儲區划分 從低到高(內存地址小----內存地址大)  :  代碼區---常量區---靜態區---堆區---棧區 棧內存 //凡是在函數體內定義的變量 都存儲在棧區(包括形參). ; ...

  4. Html table 實現Excel多格粘貼

    Html table 實現Excel多格粘貼 電商網站的后台總少不了各種繁雜數據的錄入,旁邊的運營妹子錄完第138條商品的時候,終於忍不住轉身吼到:為什么后台的錄入表不能像Excel那樣多行粘貼!!! ...

  5. LATEX學習筆記1

    LATEX源文件的結構分三大部分,依次為:文檔類聲明.序言(可選).正文. 文檔結構 \documentclass{article} \usepackage{amsmath} \usepackage{ ...

  6. 歐幾里德算法gcd及其拓展終極解釋

    這個困擾了自己好久,終於找到了解釋,還有自己改動了一點點,耐心看完一定能加深理解   擴展歐幾里德算法-求解不定方程,線性同余方程. 設過s步后兩青蛙相遇,則必滿足以下等式: (x+m*s)-(y+n ...

  7. 最新VMware Workstation 10注冊碼,絕對可用!

    最近公司要在solaris上測試產品,需要用到虛擬機,於是下載了最新的虛擬機VMware Workstation 10,並找到了破解碼,與大家共享: VMware workstation 10破解序列 ...

  8. 面向切面編程之cglib代理方式

    思想: 和上一篇面向切面編程之手動JDK代理方式上的需求和開發模式一樣.不同的是目標類沒有接口,只有實現類,采用的是spring中提供的Enhancer類繼承目標類實現的代理方式. 需要導入的jar包 ...

  9. SDL2源代碼分析5:更新紋理(SDL_UpdateTexture())

    ===================================================== SDL源代碼分析系列文章列表: SDL2源代碼分析1:初始化(SDL_Init()) SDL ...

  10. JavaScript面向對象--多態

    一.多態的概念 相同的函數作用於不同的對象,會得到不同的結果,這就是多態. 二.如果不用多態,會怎么樣? 這里有個淺顯易懂的例子,定義一個函數叫makeSound,傳入不同的對象,函數體里要寫不同的情 ...