Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/07/2018 in all areas

  1. Hello What a beautiful question, Initially I thought it was a data alignment problem. But after many tests I have the problem. The problem is IsHWnd. It would seem that this is not the problem but it is. Probably we have all been using this function without being aware of its internal structure. Or perhaps we are very used to using it for any data of handle type. That's where the problem lies. We says IsHWnd (SomeHandle) but we do not worry about the true data type, in this case the handle returned by NMTREEVIEW-> NewhItem will not match. You also need to check inside _GUICtrlTreeView_GetItemHandle It sometimes make all work as we would expect due to same issue with IsHWnd. So You structure is correctly. Here is an Example where you can check the IsHwnd is not working as we expect. #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() Local $idItem, $idTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("TreeView Get First Item", 400, 300) $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) _GUICtrlTreeView_BeginUpdate($idTreeview) For $x = 1 To 10 $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView) Next _GUICtrlTreeView_EndUpdate($idTreeview) Local $hItem = _GUICtrlTreeView_GetFirstItem($idTreeview) Local $sText = "" Local $hItem7=0 ;sometimes show correct values sometimes no. same IsHWnd issue. For $i = 0 To _GUICtrlTreeView_GetCount($idTreeview) - 1 $sText = _GUICtrlTreeView_GetText(($idTreeview), $hItem) ConsoleWrite($sText & @TAB & @TAB & @TAB & $hItem & @CRLF) $hItem = _GUICtrlTreeView_GetNext(($idTreeview), $hItem) If $i=5 Then $hItem7=$hItem Next Local $tStruct = DllStructCreate("handle item") DllStructSetData($tStruct, 1, $hItem7) Local $hItem = DllStructGetData($tStruct, 1) If Not IsHWnd($hItem) Then MsgBox(0, "I'm not a Window Handle :(", "TreeView Item Handle: " & $hItem & @CRLF & "IsHWnd(" & $hItem & ")=" & IsHWnd($hItem) & @CRLF & _ "Value 7: " & _GUICtrlTreeView_GetText($idTreeview, $hItem) & @CRLF & @CRLF & _ "The Value must be wrong sometimes. " & @CRLF & @CRLF & "Make sure to run many times to get the issue." & @CRLF) Else MsgBox(0, "this will not be shown", $hItem & @CRLF & "Value: " & _GUICtrlTreeView_GetText($idTreeview, $hItem)) EndIf ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Here is a example removing IsWnd verification of _GUICtrlTreeView_GetText2 that makes work all right. #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiTreeView.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $g_hImage, $g_hStateImage Example() Func Example() Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $idTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) GUICreate("TreeView Get Text", 400, 300) $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) _GUICtrlTreeView_BeginUpdate($idTreeView) For $x = 0 To 9 $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5) Next _GUICtrlTreeView_EndUpdate($idTreeView) _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0]) _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2) Local $iRand = 7 MsgBox($MB_SYSTEMMODAL, "It Fails sometimes", StringFormat("Text for Item %d: \n %-40s", $iRand, _GUICtrlTreeView_GetText($idTreeView, $ahItem[$iRand]))) MsgBox($MB_SYSTEMMODAL, "This Always Fine", StringFormat("Text for Item %d: \n %-40s", $iRand, _GUICtrlTreeView_GetText2($idTreeView, $ahItem[$iRand]))) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func _GUICtrlTreeView_GetText2($hWnd, $hItem = 0) ;~ If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem) ;remove this to make work all correctly If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If $hItem = 0x00000000 Then Return SetError(1, 1, "") Local $tTVITEM = DllStructCreate($tagTVITEMEX) Local $tText Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd) If $bUnicode Then $tText = DllStructCreate("wchar Buffer[4096]") ; create a text 'area' for receiving the text Else $tText = DllStructCreate("char Buffer[4096]") ; create a text 'area' for receiving the text EndIf DllStructSetData($tTVITEM, "Mask", $TVIF_TEXT) DllStructSetData($tTVITEM, "hItem", $hItem) DllStructSetData($tTVITEM, "TextMax", 4096) If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then DllStructSetData($tTVITEM, "Text", DllStructGetPtr($tText)) _SendMessage($hWnd, $TVM_GETITEMW, 0, $tTVITEM, 0, "wparam", "struct*") Else Local $iItem = DllStructGetSize($tTVITEM) Local $tMemMap Local $pMemory = _MemInit($hWnd, $iItem + 4096, $tMemMap) Local $pText = $pMemory + $iItem DllStructSetData($tTVITEM, "Text", $pText) _MemWrite($tMemMap, $tTVITEM, $pMemory, $iItem) If $bUnicode Then _SendMessage($hWnd, $TVM_GETITEMW, 0, $pMemory, 0, "wparam", "ptr") Else _SendMessage($hWnd, $TVM_GETITEMA, 0, $pMemory, 0, "wparam", "ptr") EndIf _MemRead($tMemMap, $pText, $tText, 4096) _MemFree($tMemMap) EndIf Return DllStructGetData($tText, "Buffer") EndFunc ;==>_GUICtrlTreeView_GetText Saludos
    2 points
  2. @Alliri or should I say Sillyre.... bye bye
    1 point
  3. You could do it this way: #RequireAdmin While 1 $Ping = Ping("8.8.8.8") If $Ping > 0 Then $Reset = 0 Else $Reset += 1 EndIf If $Reset = 4 Then RunWait(@ComSpec & " /c netsh interface set interface name=Wi-Fi admin=disabled") Sleep(3000) RunWait(@ComSpec & " /c netsh interface set interface name=Wi-Fi admin=enabled") $Reset = 0 Sleep(5000) EndIf Sleep(1000) WEnd This will ping 8.8.8.8 in a loop every 1 second. If it fails to ping it 4 times in a row, it disables the wifi, waits until the command has ended, waits another 3 seconds, then reenables it and waits 5 seconds after that to give your computer time to reconnect to the network. You can play around with the sleep commands to accommodate your environment.
    1 point
  4. water

    Ethernet/IP

    According to Wikipedia Ethernet/IP uses UDP on layer 4. So you would need to use UDP* functions.
    1 point
  5. @mLipok I found this -- https://support.google.com/youtube/answer/7060842?hl=en
    1 point
  6. careca

    AutoIt software licensing

    I'd say that would be hard to do, im no expert, but since we can admit the source code can be extracted, nothing would impede someone getting your code, remove the parts that check for a licence on a server, and run it without any check.
    1 point
  7. @ufukreis1212 I think you should read better Forum Etiquette, especially the 1st, 2nd, 3rd, 4th ones, and the note: Usually asking for a script is not taken too well, within reason. Keep in mind that this is a support forum, so please acknowledge that. We are here to help you with your scripts, not to spoon-feed code to you.
    1 point
  8. Hello. this works for me. #include <Array.au3> #include <String.au3> Local $URLSteam = "https://steamdb.info/app/264710/info/" Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHttp.Open("GET", $URLSteam, False) $oHttp.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)") $oHttp.Send() Local $sData = $oHttp.ResponseText ConsoleWrite($sData & @CRLF) Local $aArray_32bit_Icons = _StringBetween($sData, 'avatar" src=', '" alt=') _ArrayDisplay($aArray_32bit_Icons) Saludos
    1 point
  9. Unsure why your prior code stopped working. Have you recently updated the Windows install? FWIW, the following works for me -- #include <String.au3> #include <Array.au3> #include <WinHttp.au3> ; https://www.autoitscript.com/forum/topic/84133-winhttp-functions/ Local $sResponseText, $iResult = 0 Local $sURL = "https://steamdb.info/app/264710/info/" Local $Array_32bit_Icons Local $aURL = _WinHttpCrackUrl($sURL) Local $hOpen = _WinHttpOpen() ; Get connection handle Local $hConnect = _WinHttpConnect($hOpen, $aURL[2], $aURL[3]) If @error Then $iResult = 1 Else $sResponseText = _WinHttpSimpleSSLRequest($hConnect, "GET", $aURL[6]) If @error Then $iResult = 2 Else $Array_32bit_Icons = _StringBetween($sResponseText, 'avatar" src=', '" alt=') _ArrayDisplay($Array_32bit_Icons) EndIf EndIf _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ConsoleWrite("$iResult=" & $iResult & @CRLF) ConsoleWrite("$sResponseText=" & $sResponseText & @CRLF)
    1 point
  10. Here is a combination of my script and your script: Const $SE_DACL_PRESENT = 0x4 Const $ACCESS_ALLOWED_ACE_TYPE = 0x0 Const $ACCESS_DENIED_ACE_TYPE = 0x1 Const $FILE_ALL_ACCESS = 0x1f01ff Const $FOLDER_ADD_SUBDIRECTORY = 0x000004 Const $FILE_DELETE = 0x010000 Const $FILE_DELETE_CHILD = 0x000040 Const $FOLDER_TRAVERSE = 0x000020 Const $FILE_READ_ATTRIBUTES = 0x000080 Const $FILE_READ_CONTROL = 0x020000 Const $FOLDER_LIST_DIRECTORY = 0x000001 Const $FILE_READ_EA = 0x000008 Const $FILE_SYNCHRONIZE = 0x100000 Const $FILE_WRITE_ATTRIBUTES = 0x000100 Const $FILE_WRITE_DAC = 0x040000 Const $FOLDER_ADD_FILE = 0x000002 Const $FILE_WRITE_EA = 0x000010 Const $FILE_WRITE_OWNER = 0x080000 ;Retrieve shares $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_LogicalShareSecuritySetting', "WQL", 48) For $objItem in $colItems $strShareName = $objItem.name $wmiFileSecSetting = ObjGet("winmgmts:{impersonationLevel=impersonate}!//" & $strComputer & "/root/cimv2:Win32_LogicalShareSecuritySetting.Name='" & $strShareName & "'") ;Retrieve security descriptor by reference Dim $wmiSecurityDescriptor $RetVal = $wmiFileSecSetting.GetSecurityDescriptor($wmiSecurityDescriptor) If @Error Then ConsoleWrite("GetSecurityDescriptor failed on " & $strShareName & @CRLF) Else ConsoleWrite( "-----------------------" & @CRLF) ConsoleWrite("Share name: " & $strShareName & @CRLF) ConsoleWrite( "-----------------------" & @CRLF) EndIf ; Retrieve the DACL array of Win32_ACE objects. $DACL = $wmiSecurityDescriptor.DACL For $wmiAce in $DACL $strMsg = "" $strMsg &= "Access Mask: " & $wmiAce.AccessMask & @CRLF $strMsg &= "ACE Type: " & $wmiAce.AceType & @CRLF ; Get Win32_Trustee object from ACE $Trustee = $wmiAce.Trustee $strMsg &= "Trustee Domain: " & $Trustee.Domain & @CRLF $strMsg &= "Trustee Name: " & $Trustee.Name & @CRLF ; Get SID as array from Trustee $SID = $Trustee.SID $strsid = "" For $i = 0 To UBound($SID) - 1 $strsid &= $SID[$i] & "," Next If $wmiAce.AccessMask And $FILE_ALL_ACCESS Then $strMsg &= @TAB & "FILE_ALL_ACCESS " & @CRLF If $wmiAce.AccessMask And $FOLDER_ADD_SUBDIRECTORY Then $strMsg &= @TAB & "FOLDER_ADD_SUBDIRECTORY " & @CRLF If $wmiAce.AccessMask And $FILE_DELETE Then $strMsg &= @TAB & "FILE_DELETE " & @CRLF If $wmiAce.AccessMask And $FILE_DELETE_CHILD Then $strMsg &= @TAB & "FILE_DELETE_CHILD " & @CRLF If $wmiAce.AccessMask And $FOLDER_TRAVERSE Then $strMsg &= @TAB & "FOLDER_TRAVERSE " & @CRLF If $wmiAce.AccessMask And $FILE_READ_ATTRIBUTES Then $strMsg &= @TAB & "FILE_READ_ATTRIBUTES " & @CRLF If $wmiAce.AccessMask And $FILE_READ_CONTROL Then $strMsg &= @TAB & "FILE_READ_CONTROL " & @CRLF If $wmiAce.AccessMask And $FOLDER_LIST_DIRECTORY Then $strMsg &= @TAB & "FOLDER_LIST_DIRECTORY " & @CRLF If $wmiAce.AccessMask And $FILE_READ_EA Then $strMsg &= @TAB & "FILE_READ_EA " & @CRLF If $wmiAce.AccessMask And $FILE_SYNCHRONIZE Then $strMsg &= @TAB & "FILE_SYNCHRONIZE " & @CRLF If $wmiAce.AccessMask And $FILE_WRITE_ATTRIBUTES Then $strMsg &= @TAB & "FILE_WRITE_ATTRIBUTES " & @CRLF If $wmiAce.AccessMask And $FILE_WRITE_DAC Then $strMsg &= @TAB & "FILE_WRITE_DAC " & @CRLF If $wmiAce.AccessMask And $FOLDER_ADD_FILE Then $strMsg &= @TAB & "FOLDER_ADD_FILE " & @CRLF If $wmiAce.AccessMask And $FILE_WRITE_EA Then $strMsg &= @TAB & "FILE_WRITE_EA " & @CRLF If $wmiAce.AccessMask And $FILE_WRITE_OWNER Then $strMsg &= @TAB & "FILE_WRITE_OWNER " & @CRLF $strMsg &= "Trustee SID: {" & $strsid & "}" & @CRLF ConsoleWrite($strMsg & @CRLF) Next Next I'm not sure if its just me, if a user is Read Only it shows the same thing as a user with Full Control.
    1 point
×
×
  • Create New...