Last active
December 14, 2015 14:19
-
-
Save kunst1080/5099908 to your computer and use it in GitHub Desktop.
VBScriptから Printscreen・Alt+Printscreen するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set SHELL = WScript.CreateObject("WScript.Shell") | |
Set Excel = WScript.CreateObject("Excel.Application") | |
'KEY CODE | |
Const VK_SNAPSHOT = &H2C | |
Const VK_MENU = &H12 | |
Sub PrintScreen | |
'PrintScreen On | |
Call API_keybd_event(VK_SNAPSHOT,0,1,0) | |
'PrintScreen Off | |
Call API_keybd_event(VK_SNAPSHOT,0,3,0) | |
End Sub | |
Sub AltPrintScreen(window_name) | |
SHELL.AppActivate window_name | |
'Alt On | |
Call API_keybd_event(VK_MENU,0,1,0) | |
PrintScreen | |
'Alt Off | |
Call API_keybd_event(VK_MENU,0,3,0) | |
End Sub | |
Sub API_keybd_event(bVk, bScan, dwFlags, dwExtraInfo) | |
Dim strFunction | |
Const API_STRING = "CALL(""user32"",""keybd_event"",""JJJJJ"", $1, $2, $3, $4)" | |
strFunction = Replace(Replace(Replace(Replace(API_STRING, "$1", bVk), "$2", bScan), "$3", dwFlags), "$4", dwExtraInfo) | |
Call Excel.ExecuteExcel4Macro(strFunction) | |
End Sub | |
'*************************************** | |
'Simplae Test | |
'*************************************** | |
'PrintScreen | |
AltPrintScreen "Garden" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment