Jump to content

console write and send parameter to python


Recommended Posts

Hi everyone I have a script that gets two parameters. After AutoIt finishes,  I try to send a string to my python script with  ConsoleWrite (  ) but I get nothing. and when i send from cmd I get nothing.

Edited by gal9
Link to post
Share on other sites

Hello, Could you show a sample script about how you're doing it?

 

Saludos

Link to post
Share on other sites
23 hours ago, Danyfirex said:

Hello, Could you show a sample script about how you're doing it?

 

Saludos

#include <Constants.au3>
#include <Array.au3>

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win9x/NT
; Author:         Jonathan Bennett (jon at autoitscript dot com)
; Modified:       mLipok
;
; Script Function:
;   Opens Notepad, types in some text and then quits the application.
;

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

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

        Local $mtric =$CmdLine[1] 
;       "Allow Adobe Flash"
        Local $setting = $CmdLine[2]
        ;"disable"
 Local $settingValidation =_Validation($mtric,$setting)
 ConsoleWrite ( "data" )
ConsoleWrite ( $settingValidation  )
Exit(1)

; Finished!
Func _Validation($mtric,$setting)
    Run("c:\Windows\system32\mmc.exe C:\Users\gal.dahan\Desktop\script\gpedit_v1.msc /a")

    Sleep(2500)

    WinWaitActive("[CLASS:MMCMainFrame]")

    Sleep(500)

    Send("{ALT}{A}{O}")
    While ControlGetFocus("[TITLE:Filter Options]") = ""
        sleep(1)
    WEnd
    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
Send($mtric)
Sleep(3500)

Send("{ENTER}")
Sleep(5500)
                Send("{tab}{down 1}{ENTER}")
                Sleep(2000)
        Send("{down 2}{ENTER}")
        Sleep(4000)
    Sleep(1500)
        Local $sText = WinGetTitle("[ACTIVE]")
        Local $settingValidation= ""

If $setting = "disable"  Then
    $settingValidation=" not set to disable"
    If ControlCommand($mtric, "&Disabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad15", "Check", "") = 0 Then
$settingValidation=" set to disable"
Sleep(2000)
    EndIf
EndIf

If $setting = "enabled"  Then
    $settingValidation=" not set to enabled"

    If ControlCommand($mtric, "&Enabled", "WindowsForms10.BUTTON.app.0.297b065_r64_ad14", "Check", "") = 1 Then
    $settingValidation=" set to enabled"
EndIf
EndIf



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

WinWaitActive("[CLASS:MMCMainFrame]")
Send("{ALT down}{F4}{ALT up}")
Sleep(2000)
; Display the window title.
MsgBox(4096,  "", $sText& " Validation verified "&$settingValidation, 8)
Return $settingValidation

Exit(1)
EndFunc

after I call _Validation  ConsoleWrite ( "data" )
ConsoleWrite ( $settingValidation  ) try string or variable not work.... 

how I get this from python?

Edited by gal9
Link to post
Share on other sites
  • 2 weeks later...

When you run your AutoIt script from Scite, does the consolewrite data show up in the output box at the bottom?

If so, then the problem is with Python and i'd suggest doing some google searches for "Python Read STDOUT"

Link to post
Share on other sites
2 minutes ago, BigDaddyO said:

When you run your AutoIt script from Scite, does the consolewrite data show up in the output box at the bottom?

If so, then the problem is with Python and i'd suggest doing some google searches for "Python Read STDOUT"

but i dont see in cmd the STDOUT

Link to post
Share on other sites

I just put together a quick test, and you are correct.  consolewrite and consolewriteError don't display when running a script from cmdline.  I did output the return to a file using > output.txt and it did create the output.txt with the contents of the consolewrite line so the STDOUT is there it's just not displaying on the screen.

 

Link to post
Share on other sites
Just now, BigDaddyO said:

I just put together a quick test, and you are correct.  consolewrite and consolewriteError don't display when running a script from cmdline.  I did output the return to a file using > output.txt and it did create the output.txt with the contents of the consolewrite line so the STDOUT is there it's just not displaying on the screen.

 

I think I'll work with writing to a file. Can you help me on this topic 

 

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...