Jump to content

send key tab jumps somewhere else


Go to solution Solved by ioa747,

Recommended Posts

4 minutes ago, ioa747 said:

show me the Autoit info for the control you want use ControlSend()

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>


;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $metric - The name of the policy setting to be changed.
;   $setting - The value to which the policy setting should be changed.
; RETURNS: None.
;==============================================================



If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable")

MsgBox(4096, "message", "The setting  "& $CmdLine[1] & " set to " & $CmdLine[2] & " This box will time out in 3 seconds", 3)
    Sleep(5000)

        Local $mtric =$CmdLine[1]
;       "Allow Adobe Flash"
        Local $setting = $CmdLine[2]
        ;"disable"
_Example($mtric,$setting)
MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 3 seconds", 3)
Exit(0)

; Finished!

Func _selectDisEna($setting)
    Sleep(200) ; we give some time until the window appears
    Local $sEditTitle = WinGetTitle("[ACTIVE]")
    ConsoleWrite("$sEditTitle=" & $sEditTitle & @CRLF)
    Local $hGPOedit = WinWaitActive($sEditTitle)
        ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16")

    For $i = 5 To 1 Step -1
 If $setting = "disable" Or $setting ="Disabled" Then
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
Sleep(3000)
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a")
EndIf
If $setting = "enabled" Or $setting ="Enabled"  Then
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
Sleep(3000)
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a")
EndIf
If $setting = "not configured" Or $setting ="Not configured"  Then
Send("{c}")
EndIf
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{p}")
Next
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}")
EndFunc


Func _Example($mtric,$setting)


    ; Run gpedit.msc
    ; Run("c:\Windows\system32\mmc.exe c:\Windows\system32\gpedit.msc /a")
    ;Run("c:\Windows\system32\mmc.exe C:\Users\" & @USERNAME &"\Desktop\script\gpedit_v1.msc /a")
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")

    Sleep(2500)


    Local $hGPO = WinWaitActive("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")


    Sleep(500)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT}{A}{O}")
    ControlFocus($hGPO, "", "[TITLE:Filter Options]")

    WinWaitActive("[TITLE:Filter Options]")

    Sleep(3500)

If ControlCommand("Filter Options", "Enable &Keyword Filters", "Button2", "IsChecked", "") = 0 Then
    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{K}{F}{ALT up}")
Else
    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{F}{ALT up}")
EndIf

Sleep(3500)
    ;;Type search

    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", $mtric)
Sleep(3500)
    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ENTER}")


    ControlFocus($hGPO, "", $hTreeView_1)
    ControlSend($hGPO, "", $hTreeView_1, "a")

    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
;~  Sleep(1000)

    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ControlFocus($hGPO, "", $hListView)

    ControlSend($hGPO, "", $hListView, "{HOME}")
    Sleep(2000)

    ControlSend($hGPO, "", $hListView, "{down 5}")
    Sleep(2000)

   Local $Item, $ItemCnt, $ItemTxt, $FindItem

    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)


    $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $mtric)
    ConsoleWrite("$FindItem=" & $FindItem & @CRLF)

    ControlListView($hGPO, "", $hListView, "Select", $FindItem)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)

    ControlSend($hGPO, "", $hListView, "{Enter}")



Sleep(3500)

_selectDisEna($setting)


;Send ("{Ctrl}{S}")
;Send("^s")
;_Validation($mtric,$setting)
Sleep(3500)

ControlFocus($hGPO, "", $hTreeView_1)
ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

Sleep(2000)
    Local $hGPO = WinWaitActive("Microsoft Management Console")

ControlSend($hGPO, "", "[CLASS:Static; INSTANCE:2]", "{N}")
;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10)

EndFunc

now all the code I use in ControlSend only all i have left it is to work on getting the path if you can help me 🙃

Link to comment
Share on other sites

31 minutes ago, gal9 said:

about the path did you succeed?

 

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator

If Not WinExists("Local Group Policy Editor") Then
    ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC")
    WinWait("Local Group Policy Editor", '', 5)
EndIf

;Retrieves the 'Local Group Policy Editor' window handle
Global $hGPO = WinActive("Local Group Policy Editor")
ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

;Retrieves the SysTreeView321 control handle
Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

Global $sPolicyPath, $sPolicyItem

$sPolicyPath = "\Computer Configuration\Administrative Templates\All Settings"
$sPolicyItem = "Allow Adobe Flash"

$sPolicyPath = "Local Computer Policy" & $sPolicyPath
ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

Global $aPath = StringSplit($sPolicyPath, "\", 1)
Global $tmpPath = ""
ConsoleWrite("" & @CRLF)
For $i = 1 To $aPath[0]
    $tmpPath &= $aPath[$i] & "|"
    ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
    ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
    ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
    Sleep(50)
Next


;at the bottom tabs we go right to the standard tab
ControlFocus($hGPO, "", "AMCCustomTab1")
ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
Sleep(50)

;Retrieves the SysListView321 control handle
Global $hListView = ControlGetHandle($hGPO, "", "SysListView321")

;Sets the focus to SysListView321
ControlFocus($hGPO, "", $hListView)

Global $Item, $ItemCnt, $ItemTxt, $FindItem

;Selects the first items.
ControlListView($hGPO, "", $hListView, "Select", 0)
;~ ControlSend($hGPO, "", $hListView, "{HOME}")

;Returns a string containing the item index of selected items
$SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)
Sleep(50)

;Returns the number of list items.
$ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)
Sleep(50)

;Returns the item index of the string. Returns -1 if the string is not found
$FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
ConsoleWrite("$FindItem=" & $FindItem & @CRLF)
Sleep(50)

For $x = 0 To $ItemCnt - 1
    ControlListView($hGPO, "", $hListView, "Select", $x)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
    ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

    If $x = $FindItem Then ExitLoop

    Sleep(100)
Next

ConsoleWrite("" & @CRLF)
$ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
ConsoleWrite("--> found " & $ItemTxt & @CRLF)
ConsoleWrite("" & @CRLF)

look at console out

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

18 minutes ago, ioa747 said:

 

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator

If Not WinExists("Local Group Policy Editor") Then
    ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC")
    WinWait("Local Group Policy Editor", '', 5)
EndIf

;Retrieves the 'Local Group Policy Editor' window handle
Global $hGPO = WinActive("Local Group Policy Editor")
ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

;Retrieves the SysTreeView321 control handle
Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

Global $sPolicyPath, $sPolicyItem

$sPolicyPath = "\Computer Configuration\Administrative Templates\All Settings"
$sPolicyItem = "Allow Adobe Flash"

$sPolicyPath = "Local Computer Policy" & $sPolicyPath
ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

Global $aPath = StringSplit($sPolicyPath, "\", 1)
Global $tmpPath = ""
ConsoleWrite("" & @CRLF)
For $i = 1 To $aPath[0]
    $tmpPath &= $aPath[$i] & "|"
    ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
    ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
    ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
    Sleep(50)
Next


;at the bottom tabs we go right to the standard tab
ControlFocus($hGPO, "", "AMCCustomTab1")
ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
Sleep(50)

;Retrieves the SysListView321 control handle
Global $hListView = ControlGetHandle($hGPO, "", "SysListView321")

;Sets the focus to SysListView321
ControlFocus($hGPO, "", $hListView)

Global $Item, $ItemCnt, $ItemTxt, $FindItem

;Selects the first items.
ControlListView($hGPO, "", $hListView, "Select", 0)
;~ ControlSend($hGPO, "", $hListView, "{HOME}")

;Returns a string containing the item index of selected items
$SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)
Sleep(50)

;Returns the number of list items.
$ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)
Sleep(50)

;Returns the item index of the string. Returns -1 if the string is not found
$FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
ConsoleWrite("$FindItem=" & $FindItem & @CRLF)
Sleep(50)

For $x = 0 To $ItemCnt - 1
    ControlListView($hGPO, "", $hListView, "Select", $x)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
    ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

    If $x = $FindItem Then ExitLoop

    Sleep(100)
Next

ConsoleWrite("" & @CRLF)
$ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
ConsoleWrite("--> found " & $ItemTxt & @CRLF)
ConsoleWrite("" & @CRLF)

look at console out

image.thumb.png.dd76d5100a7fd3644c13f1a01098ee98.png
it is not running for me maybe you can try on https://file.io/QldDUja24Qng and if i change for gpedit_v1 it not focus 

Link to comment
Share on other sites

2 hours ago, ioa747 said:

 

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator

If Not WinExists("Local Group Policy Editor") Then
    ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC")
    WinWait("Local Group Policy Editor", '', 5)
EndIf

;Retrieves the 'Local Group Policy Editor' window handle
Global $hGPO = WinActive("Local Group Policy Editor")
ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

;Retrieves the SysTreeView321 control handle
Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

Global $sPolicyPath, $sPolicyItem

$sPolicyPath = "\Computer Configuration\Administrative Templates\All Settings"
$sPolicyItem = "Allow Adobe Flash"

$sPolicyPath = "Local Computer Policy" & $sPolicyPath
ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

Global $aPath = StringSplit($sPolicyPath, "\", 1)
Global $tmpPath = ""
ConsoleWrite("" & @CRLF)
For $i = 1 To $aPath[0]
    $tmpPath &= $aPath[$i] & "|"
    ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
    ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
    ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
    Sleep(50)
Next


;at the bottom tabs we go right to the standard tab
ControlFocus($hGPO, "", "AMCCustomTab1")
ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
Sleep(50)

;Retrieves the SysListView321 control handle
Global $hListView = ControlGetHandle($hGPO, "", "SysListView321")

;Sets the focus to SysListView321
ControlFocus($hGPO, "", $hListView)

Global $Item, $ItemCnt, $ItemTxt, $FindItem

;Selects the first items.
ControlListView($hGPO, "", $hListView, "Select", 0)
;~ ControlSend($hGPO, "", $hListView, "{HOME}")

;Returns a string containing the item index of selected items
$SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)
Sleep(50)

;Returns the number of list items.
$ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)
Sleep(50)

;Returns the item index of the string. Returns -1 if the string is not found
$FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
ConsoleWrite("$FindItem=" & $FindItem & @CRLF)
Sleep(50)

For $x = 0 To $ItemCnt - 1
    ControlListView($hGPO, "", $hListView, "Select", $x)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
    ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

    If $x = $FindItem Then ExitLoop

    Sleep(100)
Next

ConsoleWrite("" & @CRLF)
$ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
ConsoleWrite("--> found " & $ItemTxt & @CRLF)
ConsoleWrite("" & @CRLF)

look at console out

now i try to run on my pc https://streamja.com/zBl9M
image.png.40265c3dee78bff3b3d71e42fb9190c3.png

when I try to merge your code and my code i get 
https://streamja.com/GGMyQ
this is the code
 

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>


;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $metric - The name of the policy setting to be changed.
;   $setting - The value to which the policy setting should be changed.
; RETURNS: None.
;==============================================================



If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable")

MsgBox(4096, "message", "The setting  "& $CmdLine[1] & " set to " & $CmdLine[2] & " This box will time out in 3 seconds", 3)
    Sleep(5000)

        Local $mtric = "Allow Basic Authentication"
;       "Allow Adobe Flash"
        Local $setting = "disable"
        ;"disable"
_Example($mtric,$setting)
MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 3 seconds", 3)
Exit(0)

; Finished!

Func _selectDisEna($setting)
    Sleep(200) ; we give some time until the window appears
    Local $sEditTitle = WinGetTitle("[ACTIVE]")
    ConsoleWrite("$sEditTitle=" & $sEditTitle & @CRLF)
    Local $hGPOedit = WinWaitActive($sEditTitle)
        ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16")

    For $i = 5 To 1 Step -1
 If $setting = "disable" Or $setting ="Disabled" Then
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
Sleep(3000)
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a")
EndIf
If $setting = "enabled" Or $setting ="Enabled"  Then
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
Sleep(3000)
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a")
EndIf
If $setting = "not configured" Or $setting ="Not configured"  Then
Send("{c}")
EndIf
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{p}")
Next
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}")
EndFunc


Func _Example($mtric,$setting)


    ; Run gpedit.msc
    ; Run("c:\Windows\system32\mmc.exe c:\Windows\system32\gpedit.msc /a")
    ;Run("c:\Windows\system32\mmc.exe C:\Users\" & @USERNAME &"\Desktop\script\gpedit_v1.msc /a")
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")

    Sleep(2500)


    Local $hGPO = WinWaitActive("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")


    Sleep(500)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT}{A}{O}")
    ControlFocus($hGPO, "", "[TITLE:Filter Options]")

    WinWaitActive("[TITLE:Filter Options]")

    Sleep(3500)

If ControlCommand("Filter Options", "Enable &Keyword Filters", "Button2", "IsChecked", "") = 0 Then
    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{K}{F}{ALT up}")
Else
    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{F}{ALT up}")
EndIf

Sleep(3500)
    ;;Type search

    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", $mtric)
Sleep(3500)
    ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ENTER}")

$sPolicyPath = "\Windows Components\Windows Remote Management (WinRM)\WinRM Service"
$sPolicyItem = "Allow Basic Authentication"

$sPolicyPath = "Local Computer Policy" & $sPolicyPath
ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

Global $aPath = StringSplit($sPolicyPath, "\", 1)
Global $tmpPath = ""
ConsoleWrite("" & @CRLF)
For $i = 1 To $aPath[0]
    $tmpPath &= $aPath[$i] & "|"
    ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
    ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
    ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
    Sleep(50)

Next


    ControlFocus($hGPO, "", $hTreeView_1)
    ControlSend($hGPO, "", $hTreeView_1, "a")

    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
;~  Sleep(1000)

    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ControlFocus($hGPO, "", $hListView)

    ControlSend($hGPO, "", $hListView, "{HOME}")
    Sleep(2000)

    ControlSend($hGPO, "", $hListView, "{down 5}")
    Sleep(2000)

   Local $Item, $ItemCnt, $ItemTxt, $FindItem

    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)


    $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $mtric)
    ConsoleWrite("$FindItem=" & $FindItem & @CRLF)

    ControlListView($hGPO, "", $hListView, "Select", $FindItem)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)
For $x = 0 To $ItemCnt - 1
    ControlListView($hGPO, "", $hListView, "Select", $x)

    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
    ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

    If $x = $FindItem Then    
        ControlSend($hGPO, "", $hListView, "{Enter}")
        _selectDisEna($setting)
EndIf


    Sleep(100)
Next

    ControlSend($hGPO, "", $hListView, "{Enter}")



Sleep(3500)



;Send ("{Ctrl}{S}")
;Send("^s")
;_Validation($mtric,$setting)
Sleep(3500)

ControlFocus($hGPO, "", $hTreeView_1)
ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

Sleep(2000)
    Local $hGPO = WinWaitActive("Microsoft Management Console")

ControlSend($hGPO, "", "[CLASS:Static; INSTANCE:2]", "{N}")
;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10)

EndFunc

 

Edited by gal9
Link to comment
Share on other sites

On 3/19/2023 at 11:39 AM, gal9 said:

when I try to merge your code and my code i get 
https://streamja.com/GGMyQ
this is the code

I couldn't see that, Sorry I had to go

i have try on  https://file.io/QldDUja24Qng and working to me, I also found the control to send {N}

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
Global $sTestPath, $sTestItem

$sTestPath = "\Computer Configuration\Administrative Templates\All Settings"
$sTestItem = "Allow Adobe Flash"

_Example9($sTestPath, $sTestItem)

Func _Example9($sPolicyPath, $sPolicyItem)

    If Not WinExists("Local Group Policy Editor") Then
;~      ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC")
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
        WinWait("Local Group Policy Editor", '', 5)
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Global $hGPO = WinActivate("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

    Global $aPath = StringSplit($sPolicyPath, "\", 1)
    Global $tmpPath = ""
    ConsoleWrite("" & @CRLF)
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next


    ;at the bottom tabs we go right to the standard tab
    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Global $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;Sets the focus to SysListView321
    ControlFocus($hGPO, "", $hListView)

    Global $Item, $ItemCnt, $ItemTxt, $FindItem

    ;Selects the first items.
    ControlListView($hGPO, "", $hListView, "Select", 0)
;~ ControlSend($hGPO, "", $hListView, "{HOME}")

    ;Returns a string containing the item index of selected items
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)

    ;Returns the number of list items.
    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)
    Sleep(50)

    ;Returns the item index of the string. Returns -1 if the string is not found
    $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    ConsoleWrite("$FindItem=" & $FindItem & @CRLF)
    Sleep(50)

    ;Selects the $FindItem items.
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)

    ;Returns the text of a given item/subitem.
    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)

    Local $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(4097, "-->  " & $sPolicyItem, "$FindItem=" & $FindItem & @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF & "Pres ok to go step by step")
    Select
        Case $iMsgBoxAnswer = 1 ;OK

        Case $iMsgBoxAnswer = 2 ;Cancel
            Exit
    EndSelect

    For $x = 0 To $ItemCnt - 1
        ControlListView($hGPO, "", $hListView, "Select", $x)

        $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
        ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

        $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
        ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

        If $x = $FindItem Then ExitLoop

        Sleep(100)
    Next

    ConsoleWrite("" & @CRLF)
    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
    ConsoleWrite("--> found " & $ItemTxt & @CRLF)
    ConsoleWrite("" & @CRLF)

    $iMsgBoxAnswer = MsgBox(4097, "-->  " & $sPolicyItem, "$FindItem=" & $FindItem & @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF & "Pres ok to find where to send the {N} ? ")
    Select
        Case $iMsgBoxAnswer = 1 ;OK

        Case $iMsgBoxAnswer = 2 ;Cancel
            Exit
    EndSelect

    ControlFocus($hGPO, "", $hTreeView_1)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
    ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")

EndFunc   ;==>_Example9

<image>

Edited by ioa747
del image

I know that I know nothing

Link to comment
Share on other sites

18 hours ago, ioa747 said:

I couldn't see that, Sorry I had to go

i have try on  https://file.io/QldDUja24Qng and working to me, I also found the control to send {N}

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
Global $sTestPath, $sTestItem

$sTestPath = "\Computer Configuration\Administrative Templates\All Settings"
$sTestItem = "Allow Adobe Flash"

_Example9($sTestPath, $sTestItem)

Func _Example9($sPolicyPath, $sPolicyItem)

    If Not WinExists("Local Group Policy Editor") Then
;~      ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC")
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
        WinWait("Local Group Policy Editor", '', 5)
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Global $hGPO = WinActivate("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

    Global $aPath = StringSplit($sPolicyPath, "\", 1)
    Global $tmpPath = ""
    ConsoleWrite("" & @CRLF)
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next


    ;at the bottom tabs we go right to the standard tab
    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Global $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;Sets the focus to SysListView321
    ControlFocus($hGPO, "", $hListView)

    Global $Item, $ItemCnt, $ItemTxt, $FindItem

    ;Selects the first items.
    ControlListView($hGPO, "", $hListView, "Select", 0)
;~ ControlSend($hGPO, "", $hListView, "{HOME}")

    ;Returns a string containing the item index of selected items
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)

    ;Returns the number of list items.
    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)
    Sleep(50)

    ;Returns the item index of the string. Returns -1 if the string is not found
    $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    ConsoleWrite("$FindItem=" & $FindItem & @CRLF)
    Sleep(50)

    ;Selects the $FindItem items.
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)

    ;Returns the text of a given item/subitem.
    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)

    Local $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(4097, "-->  " & $sPolicyItem, "$FindItem=" & $FindItem & @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF & "Pres ok to go step by step")
    Select
        Case $iMsgBoxAnswer = 1 ;OK

        Case $iMsgBoxAnswer = 2 ;Cancel
            Exit
    EndSelect

    For $x = 0 To $ItemCnt - 1
        ControlListView($hGPO, "", $hListView, "Select", $x)

        $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
        ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

        $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
        ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

        If $x = $FindItem Then ExitLoop

        Sleep(100)
    Next

    ConsoleWrite("" & @CRLF)
    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
    ConsoleWrite("--> found " & $ItemTxt & @CRLF)
    ConsoleWrite("" & @CRLF)

    $iMsgBoxAnswer = MsgBox(4097, "-->  " & $sPolicyItem, "$FindItem=" & $FindItem & @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF & "Pres ok to find where to send the {N} ? ")
    Select
        Case $iMsgBoxAnswer = 1 ;OK

        Case $iMsgBoxAnswer = 2 ;Cancel
            Exit
    EndSelect

    ControlFocus($hGPO, "", $hTreeView_1)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
    ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")

EndFunc   ;==>_Example9

 

hP6H16.thumb.png.b5b2a1fe614b96ad69323246d84cb1b1.png

sorry it is not work for me....
image.png.35a4f64858aae778163115b489502845.png


i have another question i try to run AutoIt but i don't in with a screen on and AutoIt doesn't run... and use controlsend 

Link to comment
Share on other sites

15 hours ago, gal9 said:

sorry it is not work for me....

does it need more time? try from Sleep (50) to Sleep (100)

my console output:

Spoiler
$hGPO=0x00000000007805E6
$sPolicyPath=Local Computer Policy\Computer Configuration\Administrative Templates\All Settings
$sPolicyItem=Allow Adobe Flash

$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|All Settings
$SelectedItem=0
$ItemCnt=2527
$FindItem=66
$SelectedItem=0  $ItemTxt=\Windows Components\Delivery Optimization
$SelectedItem=1  $ItemTxt=\Windows Components\Microsoft User Experience Virtualization\Applications
$SelectedItem=2  $ItemTxt=\Windows Components\Microsoft User Experience Virtualization\Applications
$SelectedItem=3  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Internet Zone
$SelectedItem=4  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Intranet Zone
$SelectedItem=5  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Local Machine Zone
$SelectedItem=6  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Internet Zone
$SelectedItem=7  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Intranet Zone
$SelectedItem=8  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Local Machine Zone
$SelectedItem=9  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Restricted Sites Zone
$SelectedItem=10  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Trusted Sites Zone
$SelectedItem=11  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Restricted Sites Zone
$SelectedItem=12  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Trusted Sites Zone
$SelectedItem=13  $ItemTxt=\Network\Offline Files
$SelectedItem=14  $ItemTxt=\Printers
$SelectedItem=15  $ItemTxt=\System
$SelectedItem=16  $ItemTxt=\Windows Components\Internet Explorer
$SelectedItem=17  $ItemTxt=\Windows Components\Internet Explorer\Accelerators
$SelectedItem=18  $ItemTxt=\Windows Components\Internet Explorer\Accelerators
$SelectedItem=19  $ItemTxt=\Windows Components\Search
$SelectedItem=20  $ItemTxt=\Printers
$SelectedItem=21  $ItemTxt=\Printers
$SelectedItem=22  $ItemTxt=\Windows Components\Search
$SelectedItem=23  $ItemTxt=\System\User Profiles
$SelectedItem=24  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Add-on Management
$SelectedItem=25  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Binary Behavior Security Restriction
$SelectedItem=26  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Add-on Management
$SelectedItem=27  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Binary Behavior Security Restriction
$SelectedItem=28  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Consistent Mime Handling
$SelectedItem=29  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Local Machine Zone Lockdown Security
$SelectedItem=30  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Mime Sniffing Safety Feature
$SelectedItem=31  $ItemTxt=\Windows Components\Internet Explorer\Security Features\MK Protocol Security Restriction
$SelectedItem=32  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Network Protocol Lockdown
$SelectedItem=33  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Notification bar
$SelectedItem=34  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Object Caching Protection
$SelectedItem=35  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Protection From Zone Elevation
$SelectedItem=36  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Restrict ActiveX Install
$SelectedItem=37  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Restrict File Download
$SelectedItem=38  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Scripted Window Security Restrictions
$SelectedItem=39  $ItemTxt=\System\Removable Storage Access
$SelectedItem=40  $ItemTxt=\System\Removable Storage Access
$SelectedItem=41  $ItemTxt=\Windows Components\Internet Explorer
$SelectedItem=42  $ItemTxt=\Windows Components\Remote Desktop Services\Remote Desktop Connection Client
$SelectedItem=43  $ItemTxt=\Windows Components\Remote Desktop Services\Remote Desktop Connection Client
$SelectedItem=44  $ItemTxt=\Windows Components\Microsoft Edge
$SelectedItem=45  $ItemTxt=\Windows Components\App Package Deployment
$SelectedItem=46  $ItemTxt=\Windows Components\BitLocker Drive Encryption\Fixed Data Drives
$SelectedItem=47  $ItemTxt=\Windows Components\BitLocker Drive Encryption\Removable Data Drives
$SelectedItem=48  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Advanced Page
$SelectedItem=49  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Internet Zone
$SelectedItem=50  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Intranet Zone
$SelectedItem=51  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Local Machine Zone
$SelectedItem=52  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Restricted Sites Zone
$SelectedItem=53  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Trusted Sites Zone
$SelectedItem=54  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Internet Zone
$SelectedItem=55  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Intranet Zone
$SelectedItem=56  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Local Machine Zone
$SelectedItem=57  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Internet Zone
$SelectedItem=58  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Intranet Zone
$SelectedItem=59  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Local Machine Zone
$SelectedItem=60  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Restricted Sites Zone
$SelectedItem=61  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Trusted Sites Zone
$SelectedItem=62  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Restricted Sites Zone
$SelectedItem=63  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Trusted Sites Zone
$SelectedItem=64  $ItemTxt=\Windows Components\Microsoft Edge
$SelectedItem=65  $ItemTxt=\System\Device Installation\Device Installation Restrictions
$SelectedItem=66  $ItemTxt=\Windows Components\Microsoft Edge

--> found Allow Adobe Flash

 

show me yours

 

15 hours ago, gal9 said:

i have another question i try to run AutoIt but i don't in with a screen on and AutoIt doesn't run... and use controlsend 

 

I don't understand what you mean

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

On 3/21/2023 at 5:10 AM, ioa747 said:

does it need more time? try from Sleep (50) to Sleep (100)

my console output:

  Reveal hidden contents
$hGPO=0x00000000007805E6
$sPolicyPath=Local Computer Policy\Computer Configuration\Administrative Templates\All Settings
$sPolicyItem=Allow Adobe Flash

$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|All Settings
$SelectedItem=0
$ItemCnt=2527
$FindItem=66
$SelectedItem=0  $ItemTxt=\Windows Components\Delivery Optimization
$SelectedItem=1  $ItemTxt=\Windows Components\Microsoft User Experience Virtualization\Applications
$SelectedItem=2  $ItemTxt=\Windows Components\Microsoft User Experience Virtualization\Applications
$SelectedItem=3  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Internet Zone
$SelectedItem=4  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Intranet Zone
$SelectedItem=5  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Local Machine Zone
$SelectedItem=6  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Internet Zone
$SelectedItem=7  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Intranet Zone
$SelectedItem=8  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Local Machine Zone
$SelectedItem=9  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Restricted Sites Zone
$SelectedItem=10  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Trusted Sites Zone
$SelectedItem=11  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Restricted Sites Zone
$SelectedItem=12  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Trusted Sites Zone
$SelectedItem=13  $ItemTxt=\Network\Offline Files
$SelectedItem=14  $ItemTxt=\Printers
$SelectedItem=15  $ItemTxt=\System
$SelectedItem=16  $ItemTxt=\Windows Components\Internet Explorer
$SelectedItem=17  $ItemTxt=\Windows Components\Internet Explorer\Accelerators
$SelectedItem=18  $ItemTxt=\Windows Components\Internet Explorer\Accelerators
$SelectedItem=19  $ItemTxt=\Windows Components\Search
$SelectedItem=20  $ItemTxt=\Printers
$SelectedItem=21  $ItemTxt=\Printers
$SelectedItem=22  $ItemTxt=\Windows Components\Search
$SelectedItem=23  $ItemTxt=\System\User Profiles
$SelectedItem=24  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Add-on Management
$SelectedItem=25  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Binary Behavior Security Restriction
$SelectedItem=26  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Add-on Management
$SelectedItem=27  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Binary Behavior Security Restriction
$SelectedItem=28  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Consistent Mime Handling
$SelectedItem=29  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Local Machine Zone Lockdown Security
$SelectedItem=30  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Mime Sniffing Safety Feature
$SelectedItem=31  $ItemTxt=\Windows Components\Internet Explorer\Security Features\MK Protocol Security Restriction
$SelectedItem=32  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Network Protocol Lockdown
$SelectedItem=33  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Notification bar
$SelectedItem=34  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Object Caching Protection
$SelectedItem=35  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Protection From Zone Elevation
$SelectedItem=36  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Restrict ActiveX Install
$SelectedItem=37  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Restrict File Download
$SelectedItem=38  $ItemTxt=\Windows Components\Internet Explorer\Security Features\Scripted Window Security Restrictions
$SelectedItem=39  $ItemTxt=\System\Removable Storage Access
$SelectedItem=40  $ItemTxt=\System\Removable Storage Access
$SelectedItem=41  $ItemTxt=\Windows Components\Internet Explorer
$SelectedItem=42  $ItemTxt=\Windows Components\Remote Desktop Services\Remote Desktop Connection Client
$SelectedItem=43  $ItemTxt=\Windows Components\Remote Desktop Services\Remote Desktop Connection Client
$SelectedItem=44  $ItemTxt=\Windows Components\Microsoft Edge
$SelectedItem=45  $ItemTxt=\Windows Components\App Package Deployment
$SelectedItem=46  $ItemTxt=\Windows Components\BitLocker Drive Encryption\Fixed Data Drives
$SelectedItem=47  $ItemTxt=\Windows Components\BitLocker Drive Encryption\Removable Data Drives
$SelectedItem=48  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Advanced Page
$SelectedItem=49  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Internet Zone
$SelectedItem=50  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Intranet Zone
$SelectedItem=51  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Local Machine Zone
$SelectedItem=52  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Restricted Sites Zone
$SelectedItem=53  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Trusted Sites Zone
$SelectedItem=54  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Internet Zone
$SelectedItem=55  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Intranet Zone
$SelectedItem=56  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Local Machine Zone
$SelectedItem=57  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Internet Zone
$SelectedItem=58  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Intranet Zone
$SelectedItem=59  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Local Machine Zone
$SelectedItem=60  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Restricted Sites Zone
$SelectedItem=61  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Locked-Down Trusted Sites Zone
$SelectedItem=62  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Restricted Sites Zone
$SelectedItem=63  $ItemTxt=\Windows Components\Internet Explorer\Internet Control Panel\Security Page\Trusted Sites Zone
$SelectedItem=64  $ItemTxt=\Windows Components\Microsoft Edge
$SelectedItem=65  $ItemTxt=\System\Device Installation\Device Installation Restrictions
$SelectedItem=66  $ItemTxt=\Windows Components\Microsoft Edge

--> found Allow Adobe Flash

 

show me yours

 

 

I don't understand what you mean

 

https://usaupload.com/6UWN/aaa.mp4
you can see after the Popup it is close the GPO you can see the video 

image.png

image.png

Link to comment
Share on other sites

On 3/15/2023 at 11:17 AM, ioa747 said:

 

1) I need\want to use ControlSend because it will be more stable.

Func _selectDisEna($setting)
    Sleep(200) ; we give some time until the window appears
    Local $sEditTitle = WinGetTitle("[ACTIVE]")
    ConsoleWrite("$sEditTitle=" & $sEditTitle & @CRLF)
    Local $hGPOedit = WinWaitActive($sEditTitle)


    ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16")

    Switch $setting
        Case "disable", "Disabled"
            ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
;~          Send("d")

        Case "enabled", "Enabled"
            ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
;~          Send("e")

        Case "not configured", "Not configured"
            ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c")
;~          Send("c")

    EndSwitch
    ConsoleWrite("$setting=" & $setting & @CRLF)


    ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112")
    Sleep(100)

    ;Apply
;~  Send("a")
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a")

;~  Send("{n}") ; <----- I didn't understand what he was doing
    Sleep(100)

    ; Ok
;~  Send("{ENTER}")
    ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}")

EndFunc   ;==>_selectDisEna

 

One more thing this code you can help me with this line 

   Local $sEditTitle = WinGetTitle("[ACTIVE]")

i want to replace this line without ACTIVE

Link to comment
Share on other sites

about the path did you succeed?

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
Global $sTestPath, $sTestItem

$sTestPath = "\Computer Configuration\Administrative Templates\All Settings"
$sTestItem = "Allow Adobe Flash"

_Example10($sTestPath, $sTestItem)

Func _Example10($sPolicyPath, $sPolicyItem)

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
        WinWait("Local Group Policy Editor", '', 5)
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinActivate("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""
    ConsoleWrite("" & @CRLF)
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next


    ;at the bottom tabs we go right to the standard tab
    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;Sets the focus to SysListView321
    ControlFocus($hGPO, "", $hListView)

    Local $Item, $ItemCnt, $ItemTxt, $FindItem

    ;Selects the first items.
    ControlListView($hGPO, "", $hListView, "Select", 0)

    ;Returns a string containing the item index of selected items
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    Sleep(50)
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)

    ;Returns the number of list items.
    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    Sleep(50)
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)

    ;Returns the item index of the string. Returns -1 if the string is not found
    $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(1000)
    ConsoleWrite("$FindItem=" & $FindItem & @CRLF)

    ;Selects the $FindItem items.
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)

    ;Returns the text of a given item/subitem.
    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)

    Local $iMsgBox = ""

    If $FindItem >= 0 Then

        $iMsgBox &= "$FindItem=" & $FindItem & @CRLF
        $iMsgBox &= @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF
        $iMsgBox &= @CRLF & "Pres ok to go step by step" & @CRLF
        $iMsgBox &= @CRLF & "Pres cancel to open it"

        $iMsgBox = MsgBox(4097, "*** " & $sPolicyItem & " ***", $iMsgBox)
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                ControlSend($hGPO, "", $hListView, "{ENTER}")
                Exit
        EndSelect

        For $x = 0 To $ItemCnt - 1
            ControlListView($hGPO, "", $hListView, "Select", $x)

            $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
            ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

            $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
            ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

            If $x = $FindItem Then ExitLoop

            Sleep(50)
        Next

        ConsoleWrite("" & @CRLF)
        $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
        ConsoleWrite("--> found " & $ItemTxt & @CRLF)
        ConsoleWrite("" & @CRLF)

        $iMsgBox = MsgBox(4097, "-->  " & $sPolicyItem, "$FindItem=" & $FindItem & @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF & "Pres ok to find where to send the {N} ? ")
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                Exit
        EndSelect

    Else
        $iMsgBox &= "$FindItem= <not found>" & @CRLF
        $iMsgBox &= @CRLF & "for this reson i make 10 steps" & @CRLF
        $iMsgBox &= "to show you the 10 first paths" & @CRLF
        $iMsgBox &= @CRLF & "Pres ok to start   or   Pres Cancel to Exit"

        $iMsgBox = MsgBox(4097, "*** " & $sPolicyItem & " ***", $iMsgBox)
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                ControlFocus($hGPO, "", $hTreeView_1)
                ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

                WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
                ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")
                Exit
        EndSelect

        For $x = 0 To 9
            ControlListView($hGPO, "", $hListView, "Select", $x)

            $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
            ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

            $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
            ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

            Sleep(500)
        Next

        $iMsgBox = "finish the 10 steps" & @CRLF
        $iMsgBox &= "$SelectedItem=" & $SelectedItem & @CRLF & @CRLF
        $iMsgBox &= "Setting=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0) & @CRLF
        $iMsgBox &= "State=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 1) & @CRLF
        $iMsgBox &= "Comment=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 2) & @CRLF
        $iMsgBox &= "Path=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3) & @CRLF & @CRLF
        $iMsgBox &= "Pres OK to Exit"
        $iMsgBox = MsgBox(4096, "*** Exit ***", $iMsgBox)

    EndIf

    ControlFocus($hGPO, "", $hTreeView_1)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
    ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")

EndFunc   ;==>_Example10

 

I know that I know nothing

Link to comment
Share on other sites

5 minutes ago, ioa747 said:

about the path did you succeed?

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
Global $sTestPath, $sTestItem

$sTestPath = "\Computer Configuration\Administrative Templates\All Settings"
$sTestItem = "Allow Adobe Flash"

_Example10($sTestPath, $sTestItem)

Func _Example10($sPolicyPath, $sPolicyItem)

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
        WinWait("Local Group Policy Editor", '', 5)
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinActivate("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""
    ConsoleWrite("" & @CRLF)
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next


    ;at the bottom tabs we go right to the standard tab
    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;Sets the focus to SysListView321
    ControlFocus($hGPO, "", $hListView)

    Local $Item, $ItemCnt, $ItemTxt, $FindItem

    ;Selects the first items.
    ControlListView($hGPO, "", $hListView, "Select", 0)

    ;Returns a string containing the item index of selected items
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    Sleep(50)
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)

    ;Returns the number of list items.
    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    Sleep(50)
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)

    ;Returns the item index of the string. Returns -1 if the string is not found
    $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(1000)
    ConsoleWrite("$FindItem=" & $FindItem & @CRLF)

    ;Selects the $FindItem items.
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)

    ;Returns the text of a given item/subitem.
    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)

    Local $iMsgBox = ""

    If $FindItem >= 0 Then

        $iMsgBox &= "$FindItem=" & $FindItem & @CRLF
        $iMsgBox &= @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF
        $iMsgBox &= @CRLF & "Pres ok to go step by step" & @CRLF
        $iMsgBox &= @CRLF & "Pres cancel to open it"

        $iMsgBox = MsgBox(4097, "*** " & $sPolicyItem & " ***", $iMsgBox)
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                ControlSend($hGPO, "", $hListView, "{ENTER}")
                Exit
        EndSelect

        For $x = 0 To $ItemCnt - 1
            ControlListView($hGPO, "", $hListView, "Select", $x)

            $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
            ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

            $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
            ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

            If $x = $FindItem Then ExitLoop

            Sleep(50)
        Next

        ConsoleWrite("" & @CRLF)
        $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
        ConsoleWrite("--> found " & $ItemTxt & @CRLF)
        ConsoleWrite("" & @CRLF)

        $iMsgBox = MsgBox(4097, "-->  " & $sPolicyItem, "$FindItem=" & $FindItem & @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF & "Pres ok to find where to send the {N} ? ")
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                Exit
        EndSelect

    Else
        $iMsgBox &= "$FindItem= <not found>" & @CRLF
        $iMsgBox &= @CRLF & "for this reson i make 10 steps" & @CRLF
        $iMsgBox &= "to show you the 10 first paths" & @CRLF
        $iMsgBox &= @CRLF & "Pres ok to start   or   Pres Cancel to Exit"

        $iMsgBox = MsgBox(4097, "*** " & $sPolicyItem & " ***", $iMsgBox)
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                ControlFocus($hGPO, "", $hTreeView_1)
                ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

                WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
                ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")
                Exit
        EndSelect

        For $x = 0 To 9
            ControlListView($hGPO, "", $hListView, "Select", $x)

            $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
            ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

            $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
            ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

            Sleep(500)
        Next

        $iMsgBox = "finish the 10 steps" & @CRLF
        $iMsgBox &= "$SelectedItem=" & $SelectedItem & @CRLF & @CRLF
        $iMsgBox &= "Setting=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0) & @CRLF
        $iMsgBox &= "State=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 1) & @CRLF
        $iMsgBox &= "Comment=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 2) & @CRLF
        $iMsgBox &= "Path=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3) & @CRLF & @CRLF
        $iMsgBox &= "Pres OK to Exit"
        $iMsgBox = MsgBox(4096, "*** Exit ***", $iMsgBox)

    EndIf

    ControlFocus($hGPO, "", $hTreeView_1)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
    ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")

EndFunc   ;==>_Example10

 

image.thumb.png.2edc36cb146c9fe41d9bd7d85d8bf7ef.png

but it is close to the GPO 
image.thumb.png.50cfd29f4fbfe9f9a91ed38fd0aba130.png

Link to comment
Share on other sites

13 minutes ago, ioa747 said:

about the path did you succeed?

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
Global $sTestPath, $sTestItem

$sTestPath = "\Computer Configuration\Administrative Templates\All Settings"
$sTestItem = "Allow Adobe Flash"

_Example10($sTestPath, $sTestItem)

Func _Example10($sPolicyPath, $sPolicyItem)

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
        WinWait("Local Group Policy Editor", '', 5)
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinActivate("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""
    ConsoleWrite("" & @CRLF)
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next


    ;at the bottom tabs we go right to the standard tab
    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;Sets the focus to SysListView321
    ControlFocus($hGPO, "", $hListView)

    Local $Item, $ItemCnt, $ItemTxt, $FindItem

    ;Selects the first items.
    ControlListView($hGPO, "", $hListView, "Select", 0)

    ;Returns a string containing the item index of selected items
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    Sleep(50)
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)

    ;Returns the number of list items.
    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    Sleep(50)
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)

    ;Returns the item index of the string. Returns -1 if the string is not found
    $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(1000)
    ConsoleWrite("$FindItem=" & $FindItem & @CRLF)

    ;Selects the $FindItem items.
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)

    ;Returns the text of a given item/subitem.
    $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)

    Local $iMsgBox = ""

    If $FindItem >= 0 Then

        $iMsgBox &= "$FindItem=" & $FindItem & @CRLF
        $iMsgBox &= @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF
        $iMsgBox &= @CRLF & "Pres ok to go step by step" & @CRLF
        $iMsgBox &= @CRLF & "Pres cancel to open it"

        $iMsgBox = MsgBox(4097, "*** " & $sPolicyItem & " ***", $iMsgBox)
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                ControlSend($hGPO, "", $hListView, "{ENTER}")
                Exit
        EndSelect

        For $x = 0 To $ItemCnt - 1
            ControlListView($hGPO, "", $hListView, "Select", $x)

            $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
            ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

            $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
            ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

            If $x = $FindItem Then ExitLoop

            Sleep(50)
        Next

        ConsoleWrite("" & @CRLF)
        $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0)
        ConsoleWrite("--> found " & $ItemTxt & @CRLF)
        ConsoleWrite("" & @CRLF)

        $iMsgBox = MsgBox(4097, "-->  " & $sPolicyItem, "$FindItem=" & $FindItem & @CRLF & "with Path:" & @CRLF & $ItemTxt & @CRLF & "Pres ok to find where to send the {N} ? ")
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                Exit
        EndSelect

    Else
        $iMsgBox &= "$FindItem= <not found>" & @CRLF
        $iMsgBox &= @CRLF & "for this reson i make 10 steps" & @CRLF
        $iMsgBox &= "to show you the 10 first paths" & @CRLF
        $iMsgBox &= @CRLF & "Pres ok to start   or   Pres Cancel to Exit"

        $iMsgBox = MsgBox(4097, "*** " & $sPolicyItem & " ***", $iMsgBox)
        Select
            Case $iMsgBox = 1 ;OK

            Case $iMsgBox = 2 ;Cancel
                ControlFocus($hGPO, "", $hTreeView_1)
                ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

                WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
                ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")
                Exit
        EndSelect

        For $x = 0 To 9
            ControlListView($hGPO, "", $hListView, "Select", $x)

            $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
            ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

            $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
            ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

            Sleep(500)
        Next

        $iMsgBox = "finish the 10 steps" & @CRLF
        $iMsgBox &= "$SelectedItem=" & $SelectedItem & @CRLF & @CRLF
        $iMsgBox &= "Setting=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 0) & @CRLF
        $iMsgBox &= "State=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 1) & @CRLF
        $iMsgBox &= "Comment=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 2) & @CRLF
        $iMsgBox &= "Path=" & ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3) & @CRLF & @CRLF
        $iMsgBox &= "Pres OK to Exit"
        $iMsgBox = MsgBox(4096, "*** Exit ***", $iMsgBox)

    EndIf

    ControlFocus($hGPO, "", $hTreeView_1)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    WinWait("[TITLE:Microsoft Management Console; CLASS:#32770]")
    ControlSend("[TITLE:Microsoft Management Console; CLASS:#32770]", "", "Button2", "{N}")

EndFunc   ;==>_Example10

 

You can see in the video in 0.10 it is close the gpo 
https://usaupload.com/6UXj/aaa_(2).mp4

Link to comment
Share on other sites

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
Global $sTestPath, $sTestItem

$sTestPath = "\Computer Configuration\Administrative Templates\All Settings"
$sTestItem = "Allow Adobe Flash"

_Example10($sTestPath, $sTestItem)

Func _Example10($sPolicyPath, $sPolicyItem)

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
        WinWait("Local Group Policy Editor", '', 5)
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinActivate("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""
    ConsoleWrite("" & @CRLF)
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next


    ;at the bottom tabs we go right to the standard tab
    ControlFocus($hGPO, "", "AMCCustomTab1")
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;Sets the focus to SysListView321
    ControlFocus($hGPO, "", $hListView)

    Local $Item, $ItemCnt, $ItemTxt, $FindItem

    ;Selects the first items.
    ControlListView($hGPO, "", $hListView, "Select", 0)

    ;Returns a string containing the item index of selected items
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    Sleep(50)
    ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF)

    ;Returns the number of list items.
    $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount")
    Sleep(50)
    ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF)


    For $x = 0 To 9
        ControlListView($hGPO, "", $hListView, "Select", $x)
        Sleep(50)

        $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
        Sleep(50)
        ConsoleWrite("$SelectedItem=" & $SelectedItem & "  ")

        $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3)
        Sleep(50)
        ConsoleWrite("$ItemTxt=" & $ItemTxt & @CRLF)

        Sleep(300)
    Next

edit i give more time between steps

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...