ioa747 Posted March 15, 2023 Share Posted March 15, 2023 11 minutes ago, gal9 said: 1. In Func _selectDisEna($setting) I want to use controlsend not use send for i can use for this in which control, do you want to set what? I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 31 minutes ago, ioa747 said: you have changed it ;~ Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC") I get very weird bug https://streamja.com/w3wNz this code works for me well only problem I want to solve is the controlsend and path problems: expandcollapse popup#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) WinActivate($mtric) For $i = 5 To 1 Step -1 If $setting = "disable" Or $setting ="Disabled" Then Send("{d}") Sleep(3000) Send("{a}") EndIf If $setting = "enabled" Or $setting ="Enabled" Then Send("{e}") Sleep(3000) Send("{a}") EndIf If $setting = "not configured" Or $setting ="Not configured" Then Send("{c}") EndIf Send("{p}") Next Send("{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 Send("{ALT down}{K}{F}{ALT up}") Else Send("{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) WinWaitActive("[CLASS:MMCMainFrame]") Send("{ALT down}{F4}{ALT up}") Sleep(2000) Send ("{N}") ;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10) EndFunc and run cmd in admin and call ' exmple.au3 "Allow Adobe Flash" "enabled" ' Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 29 minutes ago, ioa747 said: in which control, do you want to set what? i want to send key with contrelsend function. I don't know how to get information about the window that opens. and send correct parameters to the controlsend function Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 48 minutes ago, gal9 said: 1. In Func _selectDisEna($setting) I want to use controlsend not use send for i can use for this 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) Switch $setting Case "disable", "Disabled" ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad15") ;~ Send("d") Case "enabled", "Enabled" ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ;~ Send("e") Case "not configured", "Not configured" ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad13") ;~ Send("c") EndSwitch ConsoleWrite("$setting=" & $setting & @CRLF) Sleep(100) ;Apply ;~ Send("a") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad17") ;~ Send("{n}") ; <----- I didn't understand what he was doing Sleep(100) ; Ok ;~ Send("{ENTER}") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") EndFunc ;==>_selectDisEna I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 26 minutes ago, gal9 said: I get very weird bug where does he send e -enable a - apply that is not active I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 24 minutes ago, ioa747 said: 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) Switch $setting Case "disable", "Disabled" ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad15") ;~ Send("d") Case "enabled", "Enabled" ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ;~ Send("e") Case "not configured", "Not configured" ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad13") ;~ Send("c") EndSwitch ConsoleWrite("$setting=" & $setting & @CRLF) Sleep(100) ;Apply ;~ Send("a") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad17") ;~ Send("{n}") ; <----- I didn't understand what he was doing Sleep(100) ; Ok ;~ Send("{ENTER}") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") EndFunc ;==>_selectDisEna Please, 1) I need\want to use ControlSend because it will be more stable. If the [X] button of the window is outside the border of the screen the ControlClick won't able to function. Help to catch the "Edit" window, for example: So I will be able to use ControlSend. Which parameter i need to send when i use ControlSend. 2) The "Send ("{n}")" is a temp workaround. Because I can search by "Setting" and not by "Path". Example: In that case, there is few "Path" for the same "setting", So when I open the edit window from a specific setting, I am changing the configuration for all of them by clicking "n" I move to the next setting. Please help me to catch the "Path" with a variable. If I will be able to catch the Setting and the variable it will be unique, and then I will delete the "Send ("{n}")". Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 (edited) 1) I need\want to use ControlSend because it will be more stable. expandcollapse popupFunc _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 Edited March 15, 2023 by ioa747 gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 Please help me to catch the "Path" with a variable. expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC") ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinWaitActive("Local Group Policy Editor") ConsoleWrite("$hGPO=" & $hGPO & @CRLF) ;Retrieves the SysTreeView321 control handle Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321") ControlTreeView($hGPO, "", $hTreeView_1, "Expand", "#0|#0|#2") ControlTreeView($hGPO, "", $hTreeView_1, "Select", "#0|#0|#2") ControlFocus($hGPO, "", $hTreeView_1) ControlSend($hGPO, "", $hTreeView_1, "a") ;at the bottom tabs we go right to the standard tab ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(300) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Local $Item, $ItemCnt, $ItemTxt, $FindItem ControlSend($hGPO, "", $hListView, "{HOME}") $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount") ConsoleWrite("$ItemCnt=" & $ItemCnt & @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) Sleep(1000) Next I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 1 hour ago, ioa747 said: Please help me to catch the "Path" with a variable. expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator ShellExecute("C:\WINDOWS\SYSTEM32\MMC.EXE", "C:\WINDOWS\SYSTEM32\GPEDIT.MSC") ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinWaitActive("Local Group Policy Editor") ConsoleWrite("$hGPO=" & $hGPO & @CRLF) ;Retrieves the SysTreeView321 control handle Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321") ControlTreeView($hGPO, "", $hTreeView_1, "Expand", "#0|#0|#2") ControlTreeView($hGPO, "", $hTreeView_1, "Select", "#0|#0|#2") ControlFocus($hGPO, "", $hTreeView_1) ControlSend($hGPO, "", $hTreeView_1, "a") ;at the bottom tabs we go right to the standard tab ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(300) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Local $Item, $ItemCnt, $ItemTxt, $FindItem ControlSend($hGPO, "", $hListView, "{HOME}") $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount") ConsoleWrite("$ItemCnt=" & $ItemCnt & @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) Sleep(1000) Next ok so did you succeed? sorry, i didn't see if you succeed If you succeeded, what variable did you put it in? Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 (edited) 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) Sleep(1000) Next Edited March 15, 2023 by ioa747 gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 10 minutes ago, ioa747 said: 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) Sleep(1000) Next so Which parameter catches for me the path? Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 (edited) the $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3) which, however, takes value from $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") look at help for the ControlListView() the first return which one is selected, and the second , what is the text of the selected one Edited March 15, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 2 minutes ago, ioa747 said: the $ItemTxt = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, 3) which, however, takes value from $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") look at help for the ControlListView() ok I try to print and i getting nothing 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) Sleep(1000) MsgBox(4096, "Test", "path "& $ItemTxt , 15) Next Thank you very much for your patience and help! Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 3 minutes ago, gal9 said: ok I try to print and i getting nothing in order to function, it also needs the rest what is the $ItemCnt ? what is the $hGPO ? what is the $hListView? gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 14 minutes ago, ioa747 said: in order to function, it also needs the rest what is the $ItemCnt ? what is the $hGPO ? what is the $hListView? If I understand correctly itemcount counter of setting but it is zero Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 (edited) show me the script you are running here you can see that the $hListView has no focus Edited March 15, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 15, 2023 Author Share Posted March 15, 2023 1 minute ago, ioa747 said: show me the script you are running expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #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 Send("{ALT down}{K}{F}{ALT up}") Else Send("{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) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Local $Item, $ItemCnt, $ItemTxt, $FindItem ControlSend($hGPO, "", $hListView, "{HOME}") $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount") ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF) Sleep(50) MsgBox(4096, "$ItemCnt", "$ItemCnt "& $ItemCnt , 15) 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) Sleep(1000) MsgBox(4096, "$ItemCnt", "$ItemTxt "& $ItemTxt , 15) Next ;Send ("{Ctrl}{S}") ;Send("^s") ;_Validation($mtric,$setting) Sleep(3500) WinWaitActive("[CLASS:MMCMainFrame]") Send("{ALT down}{F4}{ALT up}") Sleep(2000) Send ("{N}") ;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10) EndFunc Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 (edited) expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #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 Send("{ALT down}{K}{F}{ALT up}") Else Send("{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) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Sleep(50) Local $Item, $ItemCnt, $ItemTxt, $FindItem ControlSend($hGPO, "", $hListView, "{HOME}") Sleep(50) $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) Sleep(50) $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount") ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF) Sleep(50) MsgBox(4096, "$ItemCnt", "$ItemCnt "& $ItemCnt , 15) 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) Sleep(1000) MsgBox(4096, "$ItemCnt", "$ItemTxt "& $ItemTxt , 15) Next ;Send ("{Ctrl}{S}") ;Send("^s") ;_Validation($mtric,$setting) Sleep(3500) WinWaitActive("[CLASS:MMCMainFrame]") Send("{ALT down}{F4}{ALT up}") Sleep(2000) Send ("{N}") ;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10) EndFunc he wanted some Sleep(50) Edited March 15, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
Developers Jos Posted March 15, 2023 Developers Share Posted March 15, 2023 @ioa747, is your Tidy.exe not functioning? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ioa747 Posted March 15, 2023 Share Posted March 15, 2023 (edited) 5 minutes ago, Jos said: @ioa747, is your Tidy.exe not functioning? I'm sorry, @Jos I just didn't save it, it was a quote from a transport it's working fine, thanks to you Edited March 15, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now