Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/24/2014 in all areas

  1. I was needing to enable and disable a network connection. I google and find a good C++ example using interfaces. so I ported to Autoit (ObjCreateInterface ) Global Const $NCME_DEFAULT = 0 Global Const $S_OK = 0 Global Const $sCLSID_ConnectionManager = '{BA126AD1-2166-11D1-B1D0-00805FC1270E}' Global Const $sIID_INetConnectionManager = '{C08956A2-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sIID_IEnumNetConnection = '{C08956A0-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sIID_INetConnection = '{C08956A1-1CD3-11D1-B1C5-00805FC1270E}' Global Const $sINetConnectionManager = "EnumConnections hresult(int;ptr*)" Global Const $sTag_IEnumNetConnection = "Next hresult(int;ptr*;ulong*)" Global Const $sTag_INetConnection = "Connect hresult();Disconnect hresult();Delete hresult();Duplicate hresult(wstr;ptr*);GetProperties hresult(ptr)" Global Const $sTag_NETCON_PROPERTIES = "byte guidId[16];ptr pszwName;ptr pszwDeviceName;dword Status;dword MediaType;dword dwCharacter;byte clsidThisObject[16];byte clsidUiObject[16]" Func NetWorkEnableDisable($sNetWorkName, $bEnable_Disable = true) Local $hResult = 0 Local $iCount = 0 Local $pIEnumNetConnection = 0 Local $oIEnumNetConnection = 0 Local $pConnection = 0 Local $tNETCON_PROPERTIES = 0 Local $tName = 0 Local $sNetName = "" Local $tDeviceName = 0 Local $oConnection = 0 Local $pPROPERTIES = 0 Local $tPtr = 0 Local $iState=0 Local $oNetCManager = ObjCreateInterface($sCLSID_ConnectionManager, $sIID_INetConnectionManager, $sINetConnectionManager) If IsObj($oNetCManager) Then ConsoleWrite("$oNetCManager:" & IsObj($oNetCManager) & @CRLF) $oNetCManager.EnumConnections($NCME_DEFAULT, $pIEnumNetConnection) If $pIEnumNetConnection Then ConsoleWrite("$pIEnumNetConnection: " & $pIEnumNetConnection & @CRLF) $oIEnumNetConnection = ObjCreateInterface($pIEnumNetConnection, $sIID_IEnumNetConnection, $sTag_IEnumNetConnection) If IsObj($oIEnumNetConnection) Then ConsoleWrite("$oIEnumNetConnection: " & IsObj($oIEnumNetConnection) & @CRLF) While ($oIEnumNetConnection.Next(1, $pConnection, $iCount) = $S_OK) ConsoleWrite("$pConnection: " & $pConnection & " $iCount: " & $iCount & @CRLF) $oConnection = ObjCreateInterface($pConnection, $sIID_INetConnection, $sTag_INetConnection) If IsObj($oConnection) Then $tNETCON_PROPERTIES = DllStructCreate($sTag_NETCON_PROPERTIES) $tPtr = DllStructCreate("ptr Pointer") ConsoleWrite("$oConnection: " & IsObj($oConnection) & @CRLF) $hResult = $oConnection.GetProperties(DllStructGetPtr($tPtr)) If SUCCEEDED($hResult) Then $tNETCON_PROPERTIES = DllStructCreate($sTag_NETCON_PROPERTIES, $tPtr.Pointer) $tName = DllStructCreate("wchar[260]", $tNETCON_PROPERTIES.pszwName) $sNetName = DllStructGetData($tName, 1) If $bEnable_Disable Then If $sNetName = $sNetWorkName Then If SUCCEEDED($oConnection.Connect()) Then DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) Return True EndIf EndIf Else If $sNetName = $sNetWorkName Then If SUCCEEDED($oConnection.Disconnect()) Then DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) Return True EndIf EndIf EndIf DllCall("netshell.dll", "none", "NcFreeNetconProperties", "ptr", DllStructGetPtr($tNETCON_PROPERTIES)) $tPtr = 0 $tName = 0 $tNETCON_PROPERTIES = 0 $oConnection = 0 Else Return False EndIf Else Return False EndIf WEnd Else Return False EndIf Else Return False EndIf Else Return False EndIf EndFunc ;==>NetWorkEnableDisable Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED Saludos
    1 point
  2. This issue should probably be noted in the remarks section of the help file.
    1 point
  3. I apologize. I'll move it the appropriate section. I've been looking at examples, but haven't figured out a couple of steps yet. Thanks for replying.
    1 point
  4. Do you have a leading backslash in your $date variable, at least? P.S. I cogitated too long and JLogan... beat me to it.
    1 point
  5. Your path has no : _ScreenCapture_CaptureWnd(@MyDocumentsDir & $date & "ÜKegyenleg.jpg", $Egyenleg) Should be more like _ScreenCapture_CaptureWnd(@MyDocumentsDir & "\" & $date & "\ÜKegyenleg.jpg", $Egyenleg)
    1 point
  6. SmOke_N

    Help !! ToUnicodeEx!

    Out of curiosity... Why not just the _WinAPI_* functions already done for you? Worse case, look at how they implemented their code for your functions versus yours. Edit: #1. You are trying to get the value of $pwszBuff exactly how? You didn't even make the param ByRef. #2. You have $pwszBuff setup to receive a wstr, when it states it's a ptr #3. Even if you had that setup right, you didn't pass a ptr. Func _User32_ToUnicodeEx($wVirtKey, $wScanCode, $lpKeyState, ByRef $pwszBuff, $cchBuff, $wFlags, $dwhkl) Local $vRetVal = DllCall("user32.dll", "int", "ToUnicodeEx", "UINT", $wVirtKey, "UINT", $wScanCode, "ptr", $lpKeyState, "wstr*", "", "int", $cchBuff, "UINT", $wFlags, "hwnd", $dwhkl) If @error Then Return SetError(1, 0, 0) $pwszBuff = $vRetVal[4] Return $vRetVal[0] EndFunc ;==>_User32_ToUnicodeEx See if that does what you're looking for.
    1 point
  7. Chimp, does this work for you on the 3.3.12.0/W7 x64? _IELoadWait($oIE) $oIE.document.parentwindow.focus()
    1 point
×
×
  • Create New...