Jump to content

como faço para fazer o autoit integrar com arquivo json?


Recommended Posts

  • Moderators

Hi,

Moved to the correct section.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

 

I have this code to automate sales, but I need to make autoit read a j.son file that will contain the sales information made in autoit. but I don't know what code to use, any ideas?

Global $hWnd
Global $titulo = "[REGEXPTITLE:myCommerce.+]"
Global $ListaProdutos[8] = [ "047100119391", "100119605", "047100119391", "100119605", "047100119391", "100119605", "047100119391", "100119605", ]
Global $cheque = 88595


Func esperaCampoVazio()
   ConsoleWrite("esperaCampoVazio"& @CRLF)
   If WinExists("Item Não Cadastrado", "") > 0 Then
      ConsoleWrite("tela aberta"& @CRLF)
      Send("{ESC}")
   EndIf
   While (ControlGetText($hWnd, "", "ThunderTextBox3") <> "")
      Sleep(100)
   WEnd
EndFunc

Func liberaCredito()
    ConsoleWrite("Libera Credito"&  @CRLF)
    Sleep(1000)
    Send("1")
    Sleep(1000)
    send("{ENTER}")
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    ConsoleWrite("Finaliza Libera Credito"&  @CRLF)
EndFunc

Func finalizaVenda_Dinheiro()
    ConsoleWrite("Inicia Dinheiro" & @CRLF)
    Sleep(2000)
    Send("d")
    Sleep(2000)
    ConsoleWrite("Finaliza Dinheiro" & @CRLF)
EndFunc

Func finalizaVenda_Crediario()
    ConsoleWrite("Inicia crediario" &  @CRLF)
    Sleep(2000)
    Send("k")
    Sleep(2000)
    Send("78")
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    liberaCredito()
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    send("{ENTER}")
    ConsoleWrite("Finaliza crediario " & @CRLF)
EndFunc

Func finalizaVenda_Cheque()
    ConsoleWrite("Inicia Cheque " & @CRLF)
    Sleep(1000)
    Send("r")
    Sleep(1000)
    Send("2")
    Sleep(1000)
    send("{ENTER}")
    Sleep(100)
    Send("1") ; comp
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    Send("1") ; banco
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    Send("1") ; agencia
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
    Send("1") ; conta corrente
    Sleep(100)
    send("{ENTER}")
    Sleep(100)
     $cheque = $cheque + 1
    Send($cheque) ; n cheque
    ConsoleWrite("N° cheque "& $cheque & @CRLF)
    Sleep(100)
    send("{ENTER}") ; data
    Sleep(100)
    Send("{ENTER}")  ; origem
    Sleep(100)
    Send("{ENTER}") ; descricao
    Sleep(100)
    Send("{ENTER}") ; cliente
    Sleep(100)
    Send("13")
    Sleep(100)
    Send("{ENTER}")
    Sleep(100)
    liberaCredito()
    Sleep(100)
    Send("13") ; não consulta
    ConsoleWrite("Finaliza cheque "&@CRLF)
EndFunc

Func finalizaVenda_Cartao()
    ConsoleWrite("Inicia Cartao "&@CRLF)
    Sleep(2000)
    Send("s")
    Sleep(1500)
    Send("{ENTER}")  ; BANDEIRA
    Sleep(100)
    Send("{ENTER}")  ; CARTAO
    Sleep(100)
    Send("321")
    Sleep(100)
    Send("{ENTER}")  ; N PARCELA
    Sleep(100)
    Send("{ENTER}")  ; SALVAR
    Sleep(100)
    Send("{ENTER}")  ; CONFIRMA SALVAR
    Sleep(100)
    ConsoleWrite("Finaliza Cartao "&@CRLF)
EndFunc

Func cdbarraAleatorio()
   ConsoleWrite("cdbarraAleatorio "& @CRLF)
   $cdbarra = ""
   If UBound($ListaProdutos) > 1 Then
      $Index = Random(0, UBound($ListaProdutos), 1)
      If $Index > UBound($ListaProdutos) - 1 Then $Index = UBound($ListaProdutos) - 1
      $cdbarra = $ListaProdutos[$Index]
   Else
      $cdbarra = $ListaProdutos[0]
   EndIf
   ConsoleWrite($cdbarra & @CRLF)
   Return $cdbarra
EndFunc

Func decideFinalizadora()
    $finCode = Random(1, 4, 1)
    ConsoleWrite("Selecionado finalizadora code: "& $finCode & @CRLF)
    Return $finCode
EndFunc

ConsoleWrite("INI"& @CRLF)
$hWnd=WinWait($titulo)
ConsoleWrite("INI2"& @CRLF)

$numVendas=120

For $i = 0 To $numVendas - 1 Step 1
   ConsoleWrite("FOR"& @CRLF)
   WinWaitActive($titulo, "")
   esperaCampoVazio()
   Send(cdbarraAleatorio())
   Sleep(100)
   send("{ENTER}")
      WinWaitActive($titulo, "")
   $a = 10 ;Random(20, 100, 1)
   For $j = 1 to $a -1 Step 1
      esperaCampoVazio()
      Send(cdbarraAleatorio())
      Sleep(500)
      Send("{ENTER}")
   Next
   esperaCampoVazio()
   Sleep(100)
   Send("{SPACE}")

    Sleep(2000)
    WinWaitActive("","")
   Switch decideFinalizadora()
        Case 1
            finalizaVenda_Dinheiro()
            ConsoleWrite("Switch Dinheiro"&  @CRLF)
        Case 2
            finalizaVenda_Cartao()
            ConsoleWrite("Switch Cartao"&  @CRLF)
        Case 3
            finalizaVenda_Cheque()
            ConsoleWrite("Switch Cheque"&  @CRLF)
        Case 4
            finalizaVenda_Crediario()
            ConsoleWrite("Switch Crediario"&  @CRLF)
   EndSwitch
   Sleep(1000)
   Send(2)
   Sleep(1000)
Next

 

Edited by Melba23
Added code tags and reduced font size
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...