Jump to content

send key tab jumps somewhere else


Go to solution Solved by ioa747,

Recommended Posts

  • Developers

:) Was just playing a little and sort-off suggesting to show how things should be done by tidying code when posting an answer. ;) 

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

31 minutes ago, ioa747 said:
#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)

it is now showing me the counter but:image.thumb.png.964e09173f26cb4a8a18031c18e90362.png
and after the message box i get
image.thumb.png.f0a744d43a5eea737717bbc056d422b8.png

Link to comment
Share on other sites

1 minute ago, ioa747 said:

and for me, there must be items for the filter to appear, for example I must first go to all settings, or where settings appear and then is the filter available

for to filter to appear you need to be in admintriv template /all setting 

Link to comment
Share on other sites

8 minutes ago, ioa747 said:

and for me, there must be items for the filter to appear, for example I must first go to all settings, or where settings appear and then is the filter available

I tried on another machine i get the same error Microsoft management console has stopped working

Link to comment
Share on other sites

that's why I asked because your script didn't work for me, and I had to modify it

here is calls {ALT}{A}{O} before he goes to all setting

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)

 

I know that I know nothing

Link to comment
Share on other sites

@gal9

You didn't respond to my question in your previous topic about reading GPO settings, so let me ask it again.  Why are you doing all of this GUI automation in order to simply read & write registry entries?  You are aware that all of these policies are stored in the registry right?

 

Link to comment
Share on other sites

8 minutes ago, ioa747 said:

that's why I asked because your script didn't work for me, and I had to modify it

here is calls {ALT}{A}{O} before he goes to all setting

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)

 

yes but i want to search and after go over all results 

Link to comment
Share on other sites

5 minutes ago, TheXman said:

@gal9

You didn't respond to my question in your previous topic about reading GPO settings, so let me ask it again.  Why are you doing all of this GUI automation in order to simply read & write registry entries?  You are aware that all of these policies are stored in the registry right?

 

I write automation for a product and write  a registry it is not will be work After consulting with kernel people

Link to comment
Share on other sites

small question if you can help me again with send and ControlSend

22 minutes ago, ioa747 said:

that's why I asked because your script didn't work for me, and I had to modify it

here is calls {ALT}{A}{O} before he goes to all setting

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)

 

small question if you can help me again with send and ControlSend 

Send("{ALT down}{F4}{ALT up}")
Sleep(2000)
Send ("{N}")

at the end of the code

Link to comment
Share on other sites

1 hour ago, gal9 said:

small question if you can help me again with send and ControlSend 

you can send it to  $hTreeView_1

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

but after that, for me,  that  closes Group Policy Editor window , where to send the {N} ?

if not for you then try  ControlSend($hGPO, "", $hTreeView_1, "{N}")

I know that I know nothing

Link to comment
Share on other sites

On 3/15/2023 at 6:25 PM, ioa747 said:

you can send it to  $hTreeView_1

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

but after that, for me,  that  closes Group Policy Editor window , where to send the {N} ?

if not for you then try  ControlSend($hGPO, "", $hTreeView_1, "{N}")

send n for this :
image.thumb.png.f0527be5f899e3d4cb9ce681928dca27.png
ControlSend($hGPO, "", $hTreeView_1, "{N}")  it is not work 
this work for me 
 

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

ControlSend($hGPO, "", "[CLASS:Static; INSTANCE:2]", "{N}")

about the path did you succeed?

Edited by gal9
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...