Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/15/2022 in all areas

  1. Look at page #1 where dany discussed how to declare the callback and star shows where to insert its ptr in the dllcall
    2 points
  2. jpm

    <snip>

    Yes, it is committed for the next beta even 3.3.16.1 Cheers WinAPIReg.au3
    1 point
  3. Parameters of a method are separated with ; not ,
    1 point
  4. I sure did read it before starting all this, at least twice That's the reason why I did set $i_Key_Height to 32 in the script above (32 being 2*16, and 16 is the line height on my computer) I think the key for trying to have no vertical gap and controls fully visible is to use multiples of line height, that means buttons/labels having a height of 16 or 32 (on my computer) * First I noticed that value of 16 in your function _GUIScrollbars_Size() ; Determine GUI text size $aRet = _GSB_Size_Text($hWnd) ... $iX_Char = $aRet[0] ; 7  on my computer $iY_Char = $aRet[1] ; 16 "  "     " * It seems possible to retrieve that line height with a short code placed at the beginning of the script, something like this : ; Get line height Global $iLineHeight = _GSB_Size_Text(GUICreate(""))[1] GUIDelete() ; ConsoleWrite($iLineHeight & @crlf) ; 16 on my computer * Finally (and this should also help to solve taurus905 issue) 16 is also found in a global array declared in... GuiScrollBars.au3 : Global $__g_aSB_WindowInfo[1][8] ; 0 = hwnd;1 = xClientMax;2 cxChar;3 = cyChar;4 cxClient;5 = cyClient,6 = iHMax;7 = iVMax This is the content of this array during taurus905's script (which deletes the GUI and recreates it each time new rows are added, this explains why there are several rows in the array) : 7 & 16 in Col 2 & 3, I guess these values depend on the OS and may vary from a computer to the other. Now let's focus on that constant of 27 found in Col 7. That's why we are stuck with a phantom horizontal scrollbar appearing when $aRet[2] = 28, then a growing gap at the bottom of the Gui, because of the following line found in _GUIScrollBars_Init() : If $iMaxV = -1 Then $__g_aSB_WindowInfo[$iIndex][7] = 27 If we increase that value, not by changing directly 27 in the function, but by passing a 3rd parameter when calling _GUIScrollBars_Init(), then there will be no phantom horizontal scrollbar and no gap at the bottom of the GUI : The code that led to the pic above : ; Resizing Gui with Vertical Scrollbar Example.au3 #include <Array.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPISys.au3> #include "GUIScrollbars_Size.au3" Opt("MustDeclareVars", 1) HotKeySet("{PAUSE}", "_Increment") ; Increment HotKeySet("{ESC}", "_Exit") ; Exit ; Get 1 character height & width (before creating GUI, as it will be used to calculate controls size) Global $aCharSize = _GSB_Size_Text(GUICreate("")) ; M23's internal function in GUIScrollbars_Size.au3 GUIDelete() Global $iCharWidth = $aCharSize[0], $iCharHeight = $aCharSize[1] ; ConsoleWrite($iCharWidth & " " & $iCharHeight & @crlf) ; 7 & 16 on my PC ; _Create_Gui() ; Create Gui Global $h_Gui Global $i_Increment = 2 Global $i_Rows = 24 Global $i_Cols = 4 Global $i_Key_Width = $iCharWidth * 6 ; 42 on my PC (7 * 6) Global $i_Key_Height = $iCharHeight * 2 ; 32 on my PC (16 * 2) Global $i_Gui_Width = $i_Key_Width * $i_Cols Global $i_Gui_Height Global $nV_Pos, $iIncMini = 0 ; _Create_Schrollbars() ; Create Schrollbars Global $iScroll_Width = _WinAPI_GetSystemMetrics(2) ; Width of VScrollbar: SM_CXVSCROLL Global $iScroll_Height = _WinAPI_GetSystemMetrics(3) ; Height of HScrollbar: SM_CYHSCROLL ; ConsoleWrite($iScroll_Width & " " & $iScroll_Height & @crlf) ; 17 & 17 on my PC ; _Create_Keys() ; Create Keys Global $s_Key_Name MsgBox(262208, _ ; $MB_TOPMOST + $MB_ICONINFORMATION "Resizing Gui with Vertical Scrollbar Example", _ "Use the 'Pause' key to increment Gui rows" & @CRLF & @CRLF & _ "and the 'Escape' key to exit script." & @CRLF & @CRLF & _ "Scroll to end of Gui to see row of keys" & @CRLF & _ "which shows consistent spacing.") GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _Increment() ; Increment While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If BitAND(WinGetState($h_GUI), $WIN_STATE_MINIMIZED) Then ; Minimize button, Win-D, hide all $iIncMini += 1 If $iIncMini = 1 Then _GUIScrollBars_ShowScrollBar($h_GUI, $SB_VERT, False) $nV_Pos = _GUIScrollBars_GetScrollPos($h_GUI, $SB_VERT) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_VERT, 0) EndIf Else ; not Minimized If $iIncMini Then $iIncMini = 0 _GUIScrollBars_ShowScrollBar($h_GUI, $SB_VERT, True) _GUIScrollBars_SetScrollInfoPos($h_GUI, $SB_VERT, $nV_Pos) _GUIScrollBars_ShowScrollBar($h_GUI, $SB_HORZ, False) ; keep that line EndIf EndIf WEnd ;======================================================== Func _Increment() ; Increment GUIDelete($h_Gui) ; As the script deletes the GUI for each increment, no need to keep useless rows... ; ... in the GLOBAL array $__g_aSB_WindowInfo[][] declared in GuiScrollBars.au3 ; But it's also a good idea to keep the "useless" rows to check the changed values. ; Global $__g_aSB_WindowInfo[1][8] ; reset, exactly as found in GuiScrollBars.au3 ; _ArrayDisplay($__g_aSB_WindowInfo, "$__g_aSB_WindowInfo", Default, $ARRAYDISPLAY_NOROW) $i_Rows += $i_Increment $i_Gui_Height = $i_Key_Height * $i_Rows _Create_Gui() ; Create Gui _Create_Schrollbars() ; Create Schrollbars _Create_Keys() ; Create Keys GUISetState(@SW_SHOW, $h_Gui) EndFunc ; ==> _Increment ;======================================================== Func _Create_Gui() ; Create Gui $h_Gui = GUICreate("Resizing Gui", _ $i_Gui_Width + $iScroll_Width, _ $i_Gui_Height / 2, _ Default, _ Default, _ Default, _ $WS_EX_TOPMOST) EndFunc ; ==> _Create_Gui ;======================================================== Func _Create_Schrollbars() ; Create Schrollbars Local $aRet = _GUIScrollbars_Size(0, $i_Gui_Height - $iScroll_Height / 2, _ $i_Gui_Width + $iScroll_Width, $i_Gui_Height / 2) ; ConsoleWrite("$aRet[2] = " & $aRet[2] & " $aRet[3] = " & $aRet[3] & @crlf) ;~ _GUIScrollBars_Init($h_GUI) ; phantom scrollbar + gap when no 2nd / 3rd param. _GUIScrollBars_Init($h_GUI, -1, 100) ; 3rd parameter to bypass the constant of 27 _GUIScrollBars_ShowScrollBar($h_GUI, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($h_GUI, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($h_GUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($h_GUI, $SB_VERT, $aRet[3]) EndFunc ; ==> _Create_Schrollbars ;======================================================== Func _Create_Keys() ; Create Keys For $row = 0 To $i_Rows - 1 For $col = 0 To $i_Cols - 1 $s_Key_Name = $row + 1 & "." & $col + 1 GUICtrlCreateLabel($s_Key_Name, _ ($col) * $i_Key_Width, _ ($row) * $i_Key_Height, _ $i_Key_Width, _ $i_Key_Height, _ BitOr($SS_CENTERIMAGE, $SS_CENTER, $SS_SUNKEN), _ $GUI_WS_EX_PARENTDRAG) GUICtrlSetTip(-1, _ $i_Key_Width & "w x " & _ $i_Key_Height & "h x " & _ $i_Rows & " rows") GUICtrlSetBkColor(-1, _ 0xFFFFFF) ; White GUICtrlSetFont(-1, _ Default, _ 900) ; Bold Next Next EndFunc ; ==> _Create_Keys ;======================================================== Func _Exit() ; Exit Exit EndFunc ; ==> _Exit ;======================================================== Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_VSCROLL I was lucky to find that global array $__g_aSB_WindowInfo[1][8] and its constant of 27, even if it took a long time. I hope the explanations above are correct and it may help @taurus905 to achieve his goal
    1 point
  5. @hudsonhock StringRegExpReplace acts differently from StringRegExp. When you specify surrounding characters, they are also replaced, but only the captured part can be back-referenced. So in order to make it work, you will need to repeat the surroundings in the replacement string. For example : FileWrite("NewConEmu.xml", StringRegExpReplace(FileRead("ConEmu.xml"), '(name="AnsiLogPath" type="string" data=)".*"', '$1"NewValueHere"')) But you could also use the XMLDOM object, which give you more control over an xml file : Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load("ConEmu.xml") Local $oNode = $oXML.SelectSingleNode("//value[@name='AnsiLogPath']") ConsoleWrite($oNode.xml & @CRLF) $oNode.setAttribute("data", "testpath") ConsoleWrite($oNode.xml & @CRLF) $oXml.save("NewConEmu.xml")
    1 point
  6. You need to use FileClose after the first FileOpen (in read mode) or use something like: #include <File.au3> _EditFileWithRegex('"AnsiLogPath" type="string" data=(.*)\/', '"TestFilePath"') Func _EditFileWithRegex($sFindPattern, $sStrReplace) Local $sFile = "C:\Temp\ConEmu\Data\settings\ConEmu.xml" Local $sReplaceText = StringRegExpReplace(FileRead($sFile), $sFindPattern, $sStrReplace) Local $hFile = FileOpen($sFile, $FO_OVERWRITE) FileWrite($hFile, $sReplaceText) FileClose($hFile) EndFunc
    1 point
  7. Good to see you again active on the forum. As to ATCmd.au3 I must check it again and make some guideline how use them, as this is strongly related to the device you choose, and to GSM operator you have.
    1 point
  8. Bilgus

    CallByName on COM Objects

    Here is a bit faster/cleaner version It should be a bit easier to understand too #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Au3CallByName, Bilgus Global $Au3_CallByName = 0 Global $hKernel32 = DllOpen("Kernel32.dll") OnAutoItExitRegister(__CallByNameCleanup) Func __CallByNameCleanup() Au3_CallByName_Init(False) ;Unload DllClose($hKernel32) EndFunc ;==>__CallByNameCleanup ; Takes a pointer to the v-table in a class and replaces specified member Id in it to a new one. Func __HookVTableEntry($pVtable, $iVtableOffset, $pHook, ByRef $pOldRet) ;;https://www.autoitscript.com/forum/topic/107678-hooking-into-the-idispatch-interface/ Local Const $PAGE_READWRITE = 0x04 Local $tpVtable = DllStructCreate("ptr", $pVtable) Local $szPtr = DllStructGetSize($tpVtable) Local $pFirstEntry, $pEntry, $tEntry, $aCall, $flOldProtect, $bStatus ; Dereference the vtable pointer $pFirstEntry = DllStructGetData($tpVtable, 1) $pEntry = $pFirstEntry + ($iVtableOffset * $szPtr) ;vtable is a big array of pointers ; Make the memory free for all. Yay! $aCall = DllCall($hKernel32, "int", "VirtualProtect", "ptr", $pEntry, "long", $szPtr, "dword", $PAGE_READWRITE, "dword*", 0) If @error Or Not $aCall[0] Then ConsoleWriteError("Error: Failed To hook vTable" & @CRLF) Return False EndIf $flOldProtect = $aCall[4] $tEntry = DllStructCreate("ptr", $pEntry) $pOldRet = DllStructGetData($tEntry, 1) If $pOldRet <> $pHook Then DllStructSetData($tEntry, 1, $pHook) $bStatus = True Else ;Already Hooked ConsoleWriteError("Error: vTable is already hooked" & @CRLF) $bStatus = False EndIf ;put the memory protect back how we found it DllCall($hKernel32, "int", "VirtualProtect", "ptr", $pEntry, "long", $szPtr, "dword", $flOldProtect, "dword*", 0) Return $bStatus EndFunc ;==>__HookVTableEntry ; Everytime autoit wants to call a method, get or set a property in a object it needs to go to ; IDispatch::GetIDsFromNames. This is our version of that function, note that by defining this ourselves ; we can fool autoit to believe that the object supports a lot of different properties/methods. Func __IDispatch_GetIDsFromNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local Const $DISP_E_UNKNOWNNAME = 0x80020006, $DISPID_UNKNOWN = -1 Local Static $pGIFN = __Pointer_GetIDsFromNames() Local $hRes ;Call the original GetIDsFromNames $hRes = DllCallAddress("LRESULT", $pGIFN, "ptr", $pSelf, "ptr", $riid, _ "struct*", $rgszNames, "dword", $cNames, "dword", $lcid, "ptr", $rgDispId) If @error Then ConsoleWriteError("Error: GetIDsFromNames: " & @error & @CRLF) Return $DISP_E_UNKNOWNNAME EndIf ; Autoit didnt find the name now its our turn If $DISPID_UNKNOWN = DllStructGetData(DllStructCreate("long[" & $cNames & "]", $rgDispId), 1, 1) Then ;$rgszNames is a pointer to an array[$cNames] of names -- Autoit only asks for one member $cNames = 1 Local $tName = DllStructCreate("wchar[64]", DllStructGetData(DllStructCreate("ptr[" & $cNames & "]", $rgszNames), 1, 1)) Local $sName = DllStructGetData($tName, 1) ;We just prepend CBN_CB_ to the function name and try to call it $hRes = Call("CBN_CB_" & $sName, $sName, $pGIFN, $pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) If Not @error And $hRes <> Default Then Return $hRes ; User handled the function ;Call the original GetIDsFromNames $hRes = DllCallAddress("LRESULT", $pGIFN, "ptr", $pSelf, "ptr", $riid, _ "struct*", $rgszNames, "dword", $cNames, "dword", $lcid, "ptr", $rgDispId) If @error Then ConsoleWrite("Error: GetIDsFromNames: " & @error & @CRLF) Return $DISP_E_UNKNOWNNAME EndIf EndIf Return $hRes[0] EndFunc ;==>__IDispatch_GetIDsFromNames Func __Pointer_GetIDsFromNames($ptr = 0) ;Stores pointer to the original 'GetIDsFromNames' Local Static $pOldGIFN = $ptr If $ptr <> 0 Then $pOldGIFN = $ptr Return $pOldGIFN EndFunc ;==>__Pointer_GetIDsFromNames Func Au3_CallByName_Init($bHook = True, $classname = "shell.application") Local Const $iOffset_GetIDsFromNames = 5 ;vtable index Local Static $IDispatch_GetIDsFromNames_Callback = 0 Local $oObject, $pObject, $pHook, $pOldGIFN If $bHook Then If $IDispatch_GetIDsFromNames_Callback = 0 Then $IDispatch_GetIDsFromNames_Callback = DllCallbackRegister("__IDispatch_GetIDsFromNames", _ "LRESULT", "ptr;ptr;ptr;dword;dword;ptr") EndIf $pHook = DllCallbackGetPtr($IDispatch_GetIDsFromNames_Callback) Else $pHook = __Pointer_GetIDsFromNames() If $pHook <= 0 Then Return ;Already Unloaded EndIf $oObject = ObjCreate($classname) $pObject = DllStructSetData(DllStructCreate("ptr"), 1, $oObject) If __HookVTableEntry($pObject, $iOffset_GetIDsFromNames, $pHook, $pOldGIFN) Then __Pointer_GetIDsFromNames($pOldGIFN) ;Save the original pointer to GetIDsFromNames If Not $bHook Then DllCallbackFree($IDispatch_GetIDsFromNames_Callback) $IDispatch_GetIDsFromNames_Callback = 0 EndIf Else ;Error EndIf $oObject = 0 EndFunc ;==>Au3_CallByName_Init ;|||||||||===========||||||||| ;||||||||| CallBacks ||||||||| Func CBN_CB_Au3_CallByName($sName, $pGIFN, $pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local Const $DISP_E_UNKNOWNNAME = 0x80020006 ConsoleWrite(">Call By Name: " & $sName & " -> " & $Au3_CallByName & @crlf) Local Static $tpMember = DllStructCreate("ptr") If $Au3_CallByName Then Local $hRes, $tMember ;ConsoleWrite("CallByName: " & $Au3_CallByName & @CRLF) $tMember = DllStructCreate("wchar[" & StringLen($Au3_CallByName) + 1 & "]") DllStructSetData($tMember, 1, $Au3_CallByName) DllStructSetData($tpMember, 1, DllStructGetPtr($tMember)) $rgszNames = $tpMember $Au3_CallByName = 0 ;Call the original GetIDsFromNames $hRes = DllCallAddress("LRESULT", $pGIFN, "ptr", $pSelf, "ptr", $riid, _ "struct*", $rgszNames, "dword", $cNames, "dword", $lcid, "ptr", $rgDispId) If @error Then ConsoleWrite("Error: Call By Name: " & @error & @CRLF) Return $DISP_E_UNKNOWNNAME EndIf Return $hRes[0] EndIf Return Default ;Default handler EndFunc ;||||||||| CallBacks ||||||||| ;|||||||||===========||||||||| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;TESTS; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Global $oDictionary = ObjCreate("Scripting.Dictionary") Au3_CallByName_Init() Sleep(1000) For $i = 1 To 3 $Au3_CallByName = "Add" $oDictionary.Au3_CallByName("test1:" & $i, "Dictionary Item: " & $i) Next $Au3_CallByName = "keys" For $sKey In $oDictionary.Au3_CallByName() For $j = 0 To 1 $Au3_CallByName = ($j = 0) ? "Item" : "Exists" ConsoleWrite($sKey & "[" & $Au3_CallByName & "] -> " & $oDictionary.Au3_CallByName($sKey) & @CRLF) Next Next Au3_CallByName_Init(False) ;Unload (Not Strictly Needed, Done on Script Close) Same Idea but now we only go looking for our function if Autoit indicates that it doesn't exist
    1 point
  9. ;Danyfirex Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 ;Danyfirex Local Const $DNLEN =15 ​;Danyfirex Global $tagRASCONNSTATUS = "dword dwSize;dword rasconnstate;wchar szDeviceType[" & $RAS_MaxDeviceType & "];wchar szDeviceName[" & $RAS_MaxDeviceName & "];" & _ "wchar szPhoneNumber[" & $RAS_MaxPhoneNumber & "];dword localEndPoint;byte[16];word[8];dword remoteEndPoint;byte[16];word[8];dword rasconnsubstate" ​;Danyfirex Global Const $tagRASDIALPARAMS = "dword dwSize;wchar szEntryName["& $RAS_MaxDnsSuffix +1 &"];wchar szPhoneNumber["& $RAS_MaxDeviceName +1 &"];wchar szCallbackNumber["& $RAS_MaxDeviceName +1 & "];wchar szUserName[" & $RAS_MaxDnsSuffix +1 & "];wchar szPassword["& $RAS_MaxDnsSuffix + 1 & "];wchar szDomain["&$DNLEN +1 &"];dword dwSubEntry;ULONG_PTR dwCallbackId;dword dwIfIndex" ; Only structure By Starstar ​;Danyfirex Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS) $tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS) DllStructSetData($tRASDIALPARAMS, "szEntryName", "HM-LINK") DllStructSetData($tRASDIALPARAMS, "szPhoneNumber", "") DllStructSetData($tRASDIALPARAMS, "szCallbackNumber", "") DllStructSetData($tRASDIALPARAMS, "szUserName", "PPP455") DllStructSetData($tRASDIALPARAMS, "szPassword", "455") DllStructSetData($tRASDIALPARAMS, "szDomain", "") Local $FilePath=@AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk" Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr",$FilePath, "ptr",DllStructGetPtr($tRASDIALPARAMS), "dword", 0, "ptr", Null, "handle*", NULL) MsgBox(0,"",$iRet[0]) If $iRet[0] Then Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256) ConsoleWrite( $Ret[2] & @CRLF) $hConection = $iRet[6] Else ConsoleWrite("Rasdial OK" & @CRLF) $hConection = $iRet[6] EndIf ​;Danyfirex Special Thanks to Danyfirex. I could never solve it without your help Danyfirex...........Thanks a lot of you. May God Bless you....
    1 point
  10. Global Const $RAS_MaxAreaCode = 10 Global Const $RAS_MaxPhoneNumber = 128 Global Const $RAS_MaxDeviceType = 16 Global Const $RAS_MaxDeviceName = 128 Global Const $RAS_MaxPadType = 32 Global Const $RAS_MaxX25Address = 200 Global Const $RAS_MaxFacilities = $RAS_MaxX25Address Global Const $RAS_MaxUserData = $RAS_MaxFacilities Global Const $RAS_MaxDnsSuffix = 256 Global Const $RAS_MaxEntryName = 256 Global Const $WM_RASDIALEVENT = 0xCCCD Global Const $RASCS_DONE = 0x2000 Global Const $WAIT_OBJECT_0 = 0 Global $hConection = 0 Global $tagRASCONNSTATUS = "dword dwSize;dword rasconnstate;wchar szDeviceType[" & $RAS_MaxDeviceType & "];wchar szDeviceName[" & $RAS_MaxDeviceName & "];" & _ "wchar szPhoneNumber[" & $RAS_MaxPhoneNumber & "];dword localEndPoint;byte[16];word[8];dword remoteEndPoint;byte[16];word[8];dword rasconnsubstate" Global Const $tagRASDIALPARAMS = "dword dwSize;wchar szEntryName[256];wchar szPhoneNumber[128];wchar szCallbackNumber[128];wchar szUserName[256];wchar szPassword[256];wchar szDomain[15];dword dwSubEntry;ULONG_PTR dwCallbackId;dword dwIfIndex" Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS) $tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS) DllStructSetData($tRASDIALPARAMS, "szEntryName", "HM-LINK") DllStructSetData($tRASDIALPARAMS, "szPhoneNumber", "") DllStructSetData($tRASDIALPARAMS, "szCallbackNumber", "") DllStructSetData($tRASDIALPARAMS, "szUserName", "PPP455") DllStructSetData($tRASDIALPARAMS, "szPassword", "455") DllStructSetData($tRASDIALPARAMS, "szDomain", "") Local $FilePath=@AppDataDir & "\Microsoft\Network\Connections\Pbk\rasphone.pbk" Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr",$FilePath, "ptr", DllStructGetPtr($tRASDIALPARAMS), "dword", 0, "ptr", Null, "handle*", NULL) MsgBox(0,"",$iRet[0]) If $iRet[0] Then Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256) ConsoleWrite( $Ret[2] & @CRLF) $hConection = $iRet[6] Else ConsoleWrite("Rasdial OK" & @CRLF) $hConection = $iRet[6] EndIf When i run script after few seconds i got error 691. But after dialing manually script run correctly and i got 0. Special Thanks to Danyfirex.
    1 point
×
×
  • Create New...