Jump to content

send key tab jumps somewhere else


Go to solution Solved by ioa747,

Recommended Posts

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:
 

#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

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

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

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:
image.png.ecdc14949b2b9ac5f6431da37510c0b9.png

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:
image.thumb.png.d9e9eb8f31193b6c2ea203f829dbaa5f.png

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

 

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

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

Please help me to catch the "Path" with a variable.

#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

1 hour ago, ioa747 said:

Please help me to catch the "Path" with a variable.

#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

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 by ioa747

I know that I know nothing

Link to comment
Share on other sites

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

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 by ioa747

I know that I know nothing

Link to comment
Share on other sites

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

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?

image.thumb.png.0a315a911e0d2fce661008795fdc95f4.png
If I understand correctly itemcount counter of setting but it is zero

Link to comment
Share on other sites

1 minute ago, ioa747 said:

show me the script you are running

#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

#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 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...