Jump to content

DLLCalls using VBScripts Possible


Recommended Posts

DLLCalls using VBScripts

Out if the box it is not possible to do DllCalls from VBScripts. But thanks to the +20 year COM Library called DynaWrap this is still possible

Anyhow the process of calling Win API functions need some basic knowledge and understanding on how to do this. 

More specifically the input Data Types parameters used and Calling Formats are key here, as well as the Return Data Types

 

DynaWrap COM Library

Keep in mind that this COM Library is a 32Bit only library. Which means that you need to register is using the SysWOW64 regsvr32

But to overcome this annoyance I created RegFree method so you can start using it as a portable COM Library

 

DynaWrap Documentation

I created a PDF documention on what I still could find on the internet on how to use the COM Library.

 

Examples

The second post will hold some VBScript Examples and an AutoIt Example

 

Attached

You will find the PDF and the ZIP File needed to run your code in a portable way.

Thanks to the @Professor_Bernd to provide the VBScript code to get the VBScript scripting directory and the Shortcut to run the 32Bit SysWOW64 VBScript host

Just drop the VBScript on the 32Bit Shortcut to get going.

 

Source Code

Anyhow here you can find the source code of the DynaWrap 32Bit Library.

If someone has the C++ Tools to convert it to 64Bit Library that would give a new live to it...

http://www.borncity.com/web/WSHBazaar1/WSHDynaCall.htm

Interesting reading :

https://www.drdobbs.com/windows/an-automation-object-for-dynamic-dll-cal/210200078

DynaCall.zip How to use DllCalls in VBScript using DynaWrap COM Object.pdf

Edited by ptrex
Link to post
Share on other sites

Examples :

MessageBox ANSI and UNICODE

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

Dim obj
Set obj = oActCtx.CreateObject("DynamicWrapper")

Msgbox "You are calling RegFree Windows API's from VBScript !" 

' call MessageBoxA(), first register the API function
obj.register "USER32.DLL", "MessageBoxA", "I=HsSu", "f=s", "R=l"

' call the MessageBoxA
Dim val
val = obj.MessageBoxA (Null, "MessageBox (ANSI)", "VBS Next Level From DynaWrap Object", 3)

' call MessageBoxW
obj.Register "USER32.DLL", "MessageBoxW", "I=Hwwu", "f=S", "R=l"
val = obj.MessageBoxW(Null, "MessageBox (UNICODE)", "From DynaWrap Object", 3)


Set obj = Nothing
Set oActCtx = Nothing

Screen Dimensions : Height and Width

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

Dim obj
Set obj = oActCtx.CreateObject("DynamicWrapper")

Msgbox "You are calling RegFree Windows API's from VBScript !" 

' Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
obj.register "USER32.DLL", "GetSystemMetrics", "I=l", "f=s", "R=l"

Private Const SM_CXSCREEN = 0 'Screen width
Private Const SM_CYSCREEN = 1 'Screen height

Dim ScreenWidth, ScreenHeight 

'The width of the screen, in pixels
' Public Function ScreenWidth() As Long
ScreenWidth = obj.GetSystemMetrics(SM_CXSCREEN)
msgbox "ScreenWidth : " & ScreenWidth 

'The height of the screen, in pixels
'Public Function ScreenHeight() As Long
ScreenHeight = obj.GetSystemMetrics(SM_CYSCREEN)
msgbox "ScreenHeight : " & ScreenHeight 

GetForegroundWindow

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

Dim  Dw, GetForegroundWindow
Set  Dw = oActCtx.CreateObject ( "DynamicWrapper" ) 
Dw.Register "User32.Dll", "GetForegroundWindow", "F=S" , "R=H" 
GetForegroundWindow = Dw.GetForegroundWindow() 

msgbox = " & GetForegroundWindow

Capture KeyPressed

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

Public Const VK_UP = &H26
Public Const VK_DOWN = &H28
Public Const VK_LEFT = &H25
Public Const VK_RIGHT = &H27
Public Const VK_DELETE = &H2E

Dim oDyn, ExcelApp
Set oDyn = oActCtx.CreateObject("DynamicWrapper")
oDyn.Register "User32.dll", "GetAsyncKeyState", "i=l", "r=t"

Set ExcelApp = WScript.CreateObject("EXCEL.application")
ExcelApp.Visible = True
ExcelApp.workbooks.Add
ExcelApp.sheets(1).Activate
ExcelApp.DataEntryMode = True

WScript.Echo "Start : Press UP / DOWN / LEFT / RIGHT or" & vbCr & "DELETE button to stop"

Dim continue
continue = True

While (continue)
    If (oDyn.GetAsyncKeyState(VK_UP) <> 0) Then
        WScript.Echo "UP"
    End If
    If (oDyn.GetAsyncKeyState(VK_DOWN) <> 0) Then
        WScript.Echo "DOWN"
    End If
    If (oDyn.GetAsyncKeyState(VK_LEFT) <> 0) Then
        WScript.Echo "LEFT"
    End If
    If (oDyn.GetAsyncKeyState(VK_RIGHT) <> 0) Then
        WScript.Echo "RIGHT"
    End If
    If (oDyn.GetAsyncKeyState(VK_DELETE) <> 0) Then
        continue = False
    End If
    WScript.Sleep(50)
Wend

ExcelApp.DisplayAlerts = False
ExcelApp.Quit
ExcelApp.DisplayAlerts = True

Set ExcelApp = Nothing

Set oActCtx = Nothing
Set oDyn = Nothing

Clipboard Example

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

Dim a, b, c, data
Set a = oActCtx.CreateObject("DynamicWrapper")

data = "Data that was placed in your clipboard !!"

a.register "kernel32.dll", "GlobalAlloc", "i=uu", "f=s", "r=l"
a.register "kernel32.dll", "GlobalLock", "i=l", "f=s", "r=l"
a.register "kernel32.dll", "lstrcpy", "i=hs", "f=s", "r=h"
a.register "user32.dll", "OpenClipboard", "i=h", "f=s", "r=l"
a.register "user32.dll", "EmptyClipboard", "f=s", "r=l"
a.register "user32.dll", "SetClipboardData", "i=uh", "f=s", "r=l"
a.register "user32.dll", "CloseClipboard", "f=s", "r=l"
b = a.lstrcpy(a.GlobalLock(a.GlobalAlloc(0, cint(len(data)+1))), cstr(data))

c = a.OpenClipboard(0)
c = a.EmptyClipboard()
c = a.SetClipboardData(1, b)
c = a.CloseClipboard()

Msgbox "Data that is placed in your clipboard !!"

set a = nothing
set b = nothing
set c = nothing

UpTime Example

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

Dim Dw, iTicks

Set  Dw = oActCtx.CreateObject ( "DynamicWrapper" ) 
Dw.Register "kernel32.dll", "GetTickCount", "f=s" , "r=l" 

iTicks = Dw.GetTickCount

msgbox "GetTickCount : " & iTicks

Dim iDays, iHours, iMins, iSecs

iTicks = iTicks / 1000
iDays  = CInt(iTicks / 86400)
iHours = CInt(iTicks / 3600)
iTicks = iTicks Mod 3600
iMins = CInt(iTicks / 60)
iSecs = iTicks Mod 60

Msgbox "PC UpTime : " & vbCrLf & vbCrLf & _
       "Days " & iDays & " Hours " & iHours & " Min. " & iMins & " Sec. " & iSecs

 

Get Window Title

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

' demo script to illustrate using "GetActiveWindowText", jw 07Mar01
' https://microsoft.public.scripting.vbscript.narkive.com/OseMULX0/dynamicwrapper-string-by-reference

' instante ActX components here (to assure DynaWrap is available)...
Dim oDW : Set oDW = oActCtx.CreateObject ("DynamicWrapper")  ' no events
Dim oSH : Set oSH = WScript.CreateObject("WScript.Shell")
'
Dim hActWin, nRtn ' as long
Dim sWinCaption ' as string
Const MAX_PATH = 260

' --- end of declarations and constants ----------

' ================================================
' === MAIN LINE SCRIPT LOGIC =====================
' ================================================

' allocate space for the return string...
sWinCaption = String(MAX_PATH, vbNullChar)

oSH.Run "notepad.exe"

' wait for notepad to load...
' (using AppActivate's undocumented feature, re: returns t/f)...
Do : WScript.Sleep 100
Loop Until oSH.AppActivate("Notepad")

hActWin = GetActiveWindow()
BugAssert (hActWin <> 0), "no window activated at this time, sorry."

nRtn = GetWindowText(hActWin, sWinCaption, MAX_PATH)
MsgBox(sWinCaption)

oSH.SendKeys "%{F4}" ' alt-F4 (to close window)

Set oDW = nothing ' clean up
Set oSH = nothing
WScript.Quit

Function GetActiveWindow()
Set oDW = nothing ' clear any previous instance
Set oDW = oActCtx.CreateObject ("DynamicWrapper") ' start over...
' register (declare) this flavor of api call...
' (note: no parameters, so LEAVE OUT "i=" argument)...
oDW.Register "USER32.DLL", "GetActiveWindow", "f=s", "r=h"
GetActiveWindow = oDW.GetActiveWindow()
End Function

Function GetWindowText(hWnd, lpString, cch)
Set oDW = nothing ' clear any previous instance
Set oDW = oActCtx.CreateObject ("DynamicWrapper") ' start over...
' register (declare) this flavor of api call...
' (note: string passed byref to allow for proper return address)...
oDW.Register "USER32.DLL", "GetWindowTextA", "i=lrl", "f=s", "r=h"
GetWindowText = oDW.GetWindowTextA(hWnd, lpString, cch)
End Function


' --- BUGASSERT (yes, it's for debugging) --------
Sub BugAssert (bTest, sErrMsg)

' BugAssert is a Bruce McKinney creation.
' It is used to test for intermediate results...
if bTest then Exit Sub
MsgBox "Error Detected by BugAssert: " & vbCr & vbCr & sErrMsg, _
vbCritical, " << BugAssert FAILED >> "
WScript.Quit

End Sub

 

 

Edited by ptrex
Link to post
Share on other sites

Examples :

Compare AutoIt DLLCall to DynaWrap : Sinus

#AutoIt3Wrapper_UseX64=N

Local $iVal = 1/2

; AutoIT DllCall Example
Local $ret = DllCall("msvcrt.dll", "double:cdecl", "sin", "double", $iVal)
MsgBox(0, "AutoIT DllCall", "Sinus : " &$ret[0] & @CRLF)

Calling DynaWrap from AutoIt using the VBScript Object give the same result 🙂

#AutoIt3Wrapper_UseX64=N

; Initialize COM error handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

Local $iVal = 1/2

; DynWrap Example (RegFree)
Local $oActCtx = ObjCreate("Microsoft.Windows.ActCtx")
$oActCtx.manifest = @ScriptDir & "\dynwrap.sxs.manifest"

$UserWrap = $oActCtx.CreateObject("DynamicWrapper")

Local $oActCtx = ObjCreate("Microsoft.Windows.ActCtx")
$oActCtx.manifest = @ScriptDir & "\dynwrap.sxs.manifest"

$UserWrap.Register("MSVCRT.DLL", "sin", "f=mc8", "i=d", "r=d")
$ret = $UserWrap.sin($iVal)
MsgBox(0, "DynWrap (RegFree)", "Sinus : " &$ret & @CRLF)

; VbScript Example (RegFree)
Local $Code = 'Option Explicit'
$code=$code & @CRLF & ''
$code=$code & @CRLF & 'Dim oActCtx'
$code=$code & @CRLF & 'Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")'
$code=$code & @CRLF & 'oActCtx.manifest = "dynwrap.sxs.manifest"'
$code=$code & @CRLF & ''
$code=$code & @CRLF & 'Dim UserWrap'
$code=$code & @CRLF & 'Set UserWrap = oActCtx.CreateObject("DynamicWrapper")'
$code=$code & @CRLF & ''
$code=$code & @CRLF & 'Dim ret, val'
$code=$code & @CRLF & 'val = 1/2'
$code=$code & @CRLF & ''
$code=$code & @CRLF & 'UserWrap.Register "MSVCRT.DLL", "sin", "f=mc8", "i=d", "r=d"'
$code=$code & @CRLF & 'ret = UserWrap.sin(val)'
$code=$code & @CRLF & 'msgbox "VBScript sin : " & ret'
$code=$code & @CRLF & 'UserWrap.Register "MSVCRT.DLL", "cos", "f=mc8", "i=d", "r=d"'
$code=$code & @CRLF & 'ret = UserWrap.cos(val)'
$code=$code & @CRLF & 'msgbox "VBScript cos : " & ret'
$code=$code & @CRLF & 'UserWrap.Register "MSVCRT.DLL", "sinh", "f=mc8", "i=d", "r=d"'
$code=$code & @CRLF & 'ret = UserWrap.sinh(val)'
$code=$code & @CRLF & 'msgbox "VBScript sinh : " & ret'
$code=$code & @CRLF & 'UserWrap.Register "MSVCRT.DLL", "cosh", "f=mc8", "i=d", "r=d"'
$code=$code & @CRLF & 'ret = UserWrap.cosh(val)'
$code=$code & @CRLF & 'msgbox "VBScript cosh : " & ret'

Local $vbs = ObjCreate("ScriptControl")
$vbs.language="vbscript"
$vbs.addcode($code)

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)   ; to check for after this function returns
Endfunc

 

Edited by ptrex
Link to post
Share on other sites
54 minutes ago, ptrex said:

; VbScript Example (Refgree)

Could you please be so kind as to format the VBScript examples in the second post as code? (There is a VBScript highlighter.) That would make it easier to read. :graduated:

-----------------------------------------

Hello ptrex.

I think it's amazing what you can do with a little brain power! What you share with us is impressive! Great work! 👍

I want to finish my current sub-project first before I delve deeper into the topic here. That should work out by next month, hopefully I'll have more time then.

Thanks for your work, the examples, and the documentation! 👍 (I skimmed through it all briefly).

Link to post
Share on other sites
5 minutes ago, ptrex said:

Changed it to vbscript code tags ... don't see much difference though

That's weird! For me it looks like this:

This is a test!

Capture KeyPressed

Option Explicit

' USE 32Bit SysWOW64 script host !!!

Dim fso, objShell, ScriptPath, ScriptDir

ScriptPath = WScript.ScriptFullName
Set fso = CreateObject("Scripting.FileSystemObject")
ScriptDir = fso.GetParentFolderName(ScriptPath)

Set objShell = CreateObject("Wscript.Shell")
' Msgbox objShell.CurrentDirectory      ' show WorkingDirectory
objShell.CurrentDirectory = ScriptDir ' set WorkingDirectory

Dim oActCtx
Set oActCtx = CreateObject("Microsoft.Windows.ActCtx")
oActCtx.manifest = "dynwrap.sxs.manifest"

Public Const VK_UP = &H26
Public Const VK_DOWN = &H28
Public Const VK_LEFT = &H25
Public Const VK_RIGHT = &H27
Public Const VK_DELETE = &H2E

Dim oDyn, ExcelApp
Set oDyn = oActCtx.CreateObject("DynamicWrapper")
oDyn.Register "User32.dll", "GetAsyncKeyState", "i=l", "r=t"

Set ExcelApp = WScript.CreateObject("EXCEL.application")
ExcelApp.Visible = True
ExcelApp.workbooks.Add
ExcelApp.sheets(1).Activate
ExcelApp.DataEntryMode = True

WScript.Echo "Start : Press UP / DOWN / LEFT / RIGHT or" & vbCr & "DELETE button to stop"

Dim continue
continue = True

While (continue)
    If (oDyn.GetAsyncKeyState(VK_UP) <> 0) Then
        WScript.Echo "UP"
    End If
    If (oDyn.GetAsyncKeyState(VK_DOWN) <> 0) Then
        WScript.Echo "DOWN"
    End If
    If (oDyn.GetAsyncKeyState(VK_LEFT) <> 0) Then
        WScript.Echo "LEFT"
    End If
    If (oDyn.GetAsyncKeyState(VK_RIGHT) <> 0) Then
        WScript.Echo "RIGHT"
    End If
    If (oDyn.GetAsyncKeyState(VK_DELETE) <> 0) Then
        continue = False
    End If
    WScript.Sleep(50)
Wend

ExcelApp.DisplayAlerts = False
ExcelApp.Quit
ExcelApp.DisplayAlerts = True

Set ExcelApp = Nothing

Set oActCtx = Nothing
Set oDyn = Nothing

 

Link to post
Share on other sites
  • Melba23 pinned this topic
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AXLE
      Hello to all  =)
      I am currently creating some Functions UDFs and examples using DllCall and other methods that interact with MS C runtime and Windows API.
      Many of the MSDN documents can be a little ambiguous and more so when converting to an AutoIt3 context, so for correctness or when I can't find conformation from within the forum or other documentation I would like to ask a number of questions with regards to the above topic. Even though some questions may not appear to relate to the same topic, they are all related to the same set of UDFs I am creating.
      The main purpose of the Function library is exemplify the use of Dll Calls from within AutoIt3 for other users and obviously a good learning and practice exercise for myself. Some Functions may resemble functions already supplied within the UDF library, and is purely a mater of process and coincidence to have arrived at a similar place. Where a UDF function already exists I will provide an example of the same method using the standard UDF , as the standard AutoIt UDFs will be more appropriate for most Users.
      The second purpose is to extend some of the current UDFs relating to AutoIt/Windows Dialog Metrics and Device Context. Although this is intended mostly for my own purposes It will offer a reasonable context for DllCall examples and hopefully a few additional functions that others may benefit from.
      Before posting any code or examples I would like to ensure that I am using the correct AutoIt and Win API measurements and methods so I will begin with those questions.
      (Mods, I would like to keep future code examples at the top of this thread, but if that is not convenient I can begin another thread. Basic layout top to bottom 1. Code examples with explanations  2.Standards, Measurements and Metrics 3.Questions and general discussions)
      For members who may feel that I am an unknown quantity, I am a very happy, easy going person and always approachable for questions or suggestions =)
      I do have a lot going on in the background most days between indentured study, Software Dev Startup, assisting local students with fundamental coding and robotics, time with my family etc.
      So If I don't reply to a question straight away, its just that I am busy elsewhere with other commitments.
    • By ufukreis1212
      Hello, I am new members. Help me please. I want vbs convert to au3 .
      This vbs code : 
      'deneme Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") strOSArch = GetObject("winmgmts:root\cimv2:Win32_OperatingSystem=@").OSArchitecture Set objNetwork = CreateObject("Wscript.Network") Set wshShell = CreateObject( "WScript.Shell" ) strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) Set oShell = WScript.CreateObject("WScript.Shell") proc_arch = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") Set oEnv = oShell.Environment("SYSTEM") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colMB = objWMIService.ExecQuery("Select * from Win32_BaseBoard") Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItemsx = objWMIService.ExecQuery( _ "SELECT * FROM Win32_VideoController",,48) '------------------------------------------------------------------- Set obj = GetObject("winmgmts:").InstancesOf("Win32_PhysicalMemory") i = 1 For Each obj2 In obj memTmp1 = obj2.capacity / 1024 / 1024 TotalRam = TotalRam + memTmp1 i = i +1 Next '-------------------------------------------------------------------- Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select Architecture from Win32_Processor") For Each objItem in colItems if objItem.Architecture = 0 then strArchitecture = "x86" end if if objItem.Architecture = 9 then strArchitecture = "x64" end if next '-------------------------------------------------------------------- strComputer = "." ' Local computer strMemory = "" i = 1 set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory") For Each objItem In colItems if strMemory <> "" then strMemory = strMemory & vbcrlf strMemory = strMemory & "Bank" & i & " : " & (objItem.Capacity /1024 /1024) & " Mb" i = i + 1 Next installedModules = i - 1 Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray") For Each objItem in colItems totalSlots = objItem.MemoryDevices Next '---------------------------------------------------------------------- Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" ) Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem" ) For Each objItem in colItems strComputerDomain = objItem.Domain Next for each System in SystemSet For Each objItem in colItemsx For Each objProcessor in colProcessors For Each bbType In colMB MbVendor = bbType.Manufacturer MbModel = bbType.Product MsgBox "İşletim Sistemi : " & System.Caption & vbNewLine & _ "İşletim Sistemi Versionu : " & + System.Version & vbNewLine & _ "Windows Mimari Yapısı: " & strOSArch & vbNewLine & _ "Kullanıcı isminiz: " & objNetwork.UserName & vbNewLine & _ "Bilgisayar ismi: " & strComputerName & vbNewLine & _ "Çalışma Grubu: " & strComputerDomain & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Anakart: " & MbVendor & " " & "[" & MbModel & "]" & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Grafik Kartı: " & objItem.Caption & vbNewLine & _ "Driver Version: " & objItem.DriverVersion & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "İşlemci Üreticisi: " & objProcessor.Manufacturer & vbNewLine & _ "İşlemci İsmi: " & objProcessor.Name & vbNewLine & _ "CPU Mimarisi: " & strArchitecture & vbNewLine & _ "İşlemci Çekirdek sayısı: " & oEnv("NUMBER_OF_PROCESSORS") & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Toplam RAM: " & TotalRam & " MB" & vbNewLine & _ "Toplam Slot: " & totalSlots & vbNewLine & _ "Boş Slot: " & (totalSlots - installedModules) & vbNewLine & _ "Ramlerin bulunduğu slotlar:" & vbcrlf & strMemory,0,"deneme" Next Next Next Next please help me , thanks.
    • By jdegraff
      I'm trying to add a bit of functionality to the FastStone File Rename dialog. I can access every control that I need to except the one that contains the files to be renamed. If I do some exploring in a vbScript shell I get
      :c  = "TTntTreeView.UnicodeClass1"
      :?aut.ControlTreeView(win,"",c,"GetItemCount","","")
      5
      You can see that the treeview control reports having five items, which is the number displayed. If I manually select (mouse) item #3 I can see the result by
      :?aut.ControlTreeView(win,"",c,"GetSelected","1","")
      #3
      But I do not know how to get the text for the selected item. If "#3" is the item reference then I should be able to
      :?aut.ControlTreeView(win,"",c,"GetText","1","#3")
      or
      :?aut.ControlTreeView(win,"",c,"GetText","1","#3")
      if I go strictly by the help file, but it returns nothing.
      :?aut.ControlTreeView(win,"",c,"Exists","","3")
      1
      So it appears that item 3 exists, but
      :?aut.ControlTreeView(win,"",c,"GetText","","3")
      does not have any text???
      :?aut.ControlTreeView(win,"",c,"Exists","","9")
      1
      and it also appears item 9 exists (it does not)
      :?aut.ControlTreeView(win,"",c,"Select","","")
      1
      causes the first item to be selected, as does
      :?aut.ControlTreeView(win,"",c,"Select","","3")
      1
      Here is the output from the Window Info tool
      >>>> Window <<<<
      Title:  Batch Image Convert / Rename
      Class:  TBatchConvert
      Position:   501, 83
      Size:   760, 520
      Style:  0x16CD0000
      ExStyle:    0x00010100
      Handle: 0x0000000001950796
      >>>> Control <<<<
      Class:  TTntTreeView.UnicodeClass
      Instance:   1
      ClassnameNN:    TTntTreeView.UnicodeClass1
      Name:   
      Advanced (Class):   [CLASS:TTntTreeView.UnicodeClass; INSTANCE:1]
      ID: 37030040
      Text:   
      Position:   354, 79
      Size:   378, 188
      ControlClick Coords:    108, 86
      Style:  0x54010039
      ExStyle:    0x00000200
      Handle: 0x0000000002350898
      >>>> Mouse <<<<
      Position:   970, 279
      Cursor ID:  0
      Color:  0xE1E1E1
      >>>> StatusBar <<<<
      >>>> ToolsBar <<<<
      >>>> Visible Text <<<<
      Batch Rename
      ...
      D:\temp\picsave\
      Images + Videos (*.jpg;*.jpe;*.jpeg;*.bmp;*.gif;*.tif;*.tiff;*.cur;*.ico;*.png;*.pcx;*.jp2;*.j2k;*.tga;*.ppm;*.wmf;*.psd;*.crw;*.nef;*.cr2;*.orf;*.raf;*.dng;*.mrw;*.pef;*.srf;*.arw;*.rw2;*.x3f;*.sr2;*.srw;*.nrw;*.rwl;*.eps;*.avi;*.mpeg;*.mpg;*.wmv;*.mov;*.mp4;*.mts;*.mkv;*.m4v)
      Search and Replace
      Use Filename Template
      No Sort
      Clear
      Remove
      Add All
      Add
      Preview
      Close
      Rename
      No Change
      ?
       
       


    • By vyperhand
      I'm struggling to launch a VBS file via autoit using RunWait.  Due to the nature of the deployment tool I am using for said script, I only know that the .vbs files will be in the same directory as my AutoIt-generated .exe, but not what that path will be.  The path will look something like this:
      c:\programdata\vendor\lots\of\folders\randomnumber
      This is generated during deployment and I have no way of predicting the path - therefore, I am not sure how to call back to "same directory" in order to successfully launch the .vbs.
      This line is as close as I have gotten - this fires off the cmd window, but it closes immediately with out information, and the .vbs is not launched.
      RunWait (@ComSpec & " /c" & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel') I thought /c might be the problem, but leaving out the /c element causes me not to even see the momentary CMD window flash by.  Any help will be greatly appreciated, and thanks in advance.
    • By ur
      I am maintaining all the reusable code in a separate file as library.au3.
      In that file I have referenced some dependent files using fileinstall, so that they will be extracted when necessary.
       
      Problem is, if I use a function in the library.au3 in another script which doesn't require this dependent file, as I am including the whole file using include tag, it is embedding that file also.
      Is there any way to exclude that.
       
×
×
  • Create New...