Leaderboard
Popular Content
Showing content with the highest reputation on 01/16/2021 in all areas
-
@Professor_Bernd / @argumentum Here I posted some examples and documentation on how to use the DynaWrap object to do DLLCalls https://www.autoitscript.com/forum/topic/204903-dllcalls-using-vbscripts-possible/ Enjoy !3 points
-
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.pdf2 points
-
DLLCalls using VBScripts Possible
Professor_Bernd and one other reacted to ptrex for a topic
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 Endfunc2 points -
A little late. Sorry. I've been busy. I'm also very busy all next week. These are comments to the discussion in this and the following posts. The Running Object Table (ROT) has something to do with COM clients and servers. The program that registers an object in the ROT plays the role of server. One or more programs that access the ROT object with the ObjGet() function or a similar function play the role of clients. The ROT object is only available as long as the server program is running or until the server program deletes the object with the ROT_Revoke() function. Since client and server code run in separate processes, ROT objects usually also have something to do with code running in different processes. You do not normally use ROT objects in connection with code that all runs in the same process. An obvious use of ROT objects is therefore in connection with IPC techniques. These can be IPC techniques between programs implemented in the same language, and IPC techniques between programs implemented in different languages. It'll work as long as the languages are COM compatible languages. Another possible use of ROT objects is in connection with the execution of object methods that for one reason or another do not work in AutoIt. Then one can create a ROT object to pass the problem object along with any data to another scripting language, and maybe successfully execute the object method in that language. This use of ROT objects is demonstrated here. There are plenty of other uses of ROT objects limited only by fantasy and imagination. mLipok, So in terms of making a regsvr32 free registration of the Chilkat objects I don't immediately think ROT objects are of any benefit. Maybe if it's possible to make a regsvr32 free registration of the Chilkat objects in another language, and then pass the objects to AutoIt through a ROT object.1 point
-
DLLCalls using VBScripts Possible
Professor_Bernd reacted to ptrex for a topic
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 Sub1 point -
Eigen4AutoIt - Matrix computing with Eigen
argumentum reacted to RTFC for a topic
E4A version 5,2 is available for download: the "2020 Hindsight" release. This is a maintenance upgrade, fixing many small issues (and the odd catastrophic bug ), filling some consistency gaps in the function library, streamlining the environment functions, and updating Eigen's source to stable release 3.3.9. Full details can be found in the ChangeLog as per usual. Hope it helps! EDIT: as every mission has at least one glitch, it's no surprise that the updated MatrixFileConverter.au3 script did not get copied to the bundle subdir before packing it into the setup. So since it's tiny, I'm providing it separately here: EDIT2: as every mission apparently has at least two glitches, I Just discovered a potential issue in _Eigen_StartUp when calling _Eigen_DefineWorkspace repeatedly in x64-mode (luckily this is not a common scenario). See spoiler for a quick patch. EDIT3: the aforementioned patches have now been incorporated into v5.2a (setup re-uploaded). Apologies for any inconvenience caused.1 point -
How do I Format my computer with AutoIt
argumentum reacted to InclusiveExclusion for a topic
AutoIT might be a little bit of a difficult way to do that task. Try this. Explains it better than i can. https://www.windowscentral.com/how-create-unattended-media-do-automated-installation-windows-101 point -
I am assuming that there is only one user for that computer at a time. Here how I would do it : 1- Get list of users with WMI Win32_LoggedOnUser 2- Get _Timer_GetIdleTime() 3- if Idle Time > xy minutes and User is a child then ShutDown ($SD_REBOOT+$SD_FORCE) If that makes sense and need help to convert this pseudo-code into real code, let me know...1 point
-
Write Section and Key
FrancescoDiMuro reacted to Jos for a topic
@YuChan, Unfortunately the code you posted/requested is essentially a keylogger (and before you start I accept that is not what you intended, but that is what it was). Please read This Keyloggers Announcement before you post again and then you will understand why you will get no help and this thread will now be locked. Jos1 point -
Query and sign off disconnected users (Win10)
therks reacted to FrancescoDiMuro for a topic
@therks Didn't have spare time to build an example, but you can definitely have a look at PsLoggedOn from SysInternals suite. Just execute the command, get the result, and use the logoff command with the specified users. Hope it helps. Cheers1 point -
No quick or easy way around some things, especially if you want to display processing etc. Sometimes it is just better to get AutoIt to run a batch file ... not that I am likely to do that with a batch file than contains a GoTo line. But usually I am just quickly playing around with a Batch file, testing, before I then build an AutoIt alternative ... and troubleshooting can be easier in a batch.1 point
-
EasyCodeIt - cross-platform AutoIt implementation
TheDcoder reacted to JockoDundee for a topic
See what happens with GOTO? If we only had used GOSUB we could RETURN to Easy-CodeIt - A Cross Platform Autoit Implementation...1 point -
Find the last line of text entered from GUI
Emanoel reacted to JockoDundee for a topic
I have no idea what the code actually does, it should however do whatever the old code did1 point -
You can use "Ubound($a)-1" to get the last row number, personally I would do something like the following: Global $g_sString = "First Line" & @CRLF & "Second Line" & @CRLF & "" & @CRLF & "Third Line" Write($g_sString) Func Write ($datafromuser) Local $sDatafromUser = StringRegExpReplace($datafromuser, "(?:\r?\n|\r)+", @CRLF) ;~ Removes empty lines from the string Local $aDatafromUser = StringSplit($sDatafromUser, @CRLF, 1) ;~ Creates an array without empty lines For $i = 1 To $aDatafromUser[0] MsgBox(4096, "Title", $i & " of " & $aDatafromUser[0] & @CRLF & "$aDatafromUser[" & $i & "] = " & $aDatafromUser[$i]) Next EndFunc1 point
-
EasyCodeIt - cross-platform AutoIt implementation
TheDcoder reacted to seadoggie01 for a topic
Wait, y'all still use them? Wasn't that what AutoIt replaced?1 point -
Silent Installation (To software there is no silent switch)
PHAK reacted to Earthshine for a topic
look here to move the window off screen Function WinMove (autoitscript.com)1 point -
mm i suppose you wanna create a Macro , for work with your site , for my best opinion is much stable if you use a REST API in wordpress , or work directly with database of site ,if you want create macro in site full of javascript , is much better if you use , webdriver , but is only my opinion good luck1 point
-
Here's a different calculation method for brightness that sounds reasonable too: Sqrt( .241 * $R ^ 2 + .691 * $G ^ 2 + .068 * $B ^ 2 ) / 2.551 point
-
Non-focusable GUI does not give focus after calling "evil" functions
Professor_Bernd reacted to jpm for a topic
it always good to see an happy people nice catch 😍1 point