Jump to content

What is wrong here?


Aarstad
 Share

Recommended Posts

Hello.

When I try to run a program on a computer without autoit installed i get the following error reported:

Line 32 (File "C:pathxxx"):

Error: Incorrect number of parameters in function call.

However, when I install autoit on the machine and run the script manually it executes just fine. Here's the code:

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author:         Patrick

Script Function: Get registry file for CAS.


#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Func _Language()
Select

    Case StringInStr("0409 0809 0c09 1009 1409 1809 1c09 2009 2409 2809 2c09 3009 3409", @OSLang)
        Return "English"

    Case StringInStr("0414 0814", @OSLang)
        Return "Norwegian"

    Case StringInStr("040a 080a 0c0a 100a 140a 180a 1c0a 200a 240a 280a 2c0a 300a 340a 380a 3c0a 400a 440a 480a 4c0a 500a", @OSLang)
        Return "Spanish"

    EndSelect
EndFunc


Global $Datanavn = FileRead ("C:\IGS\AutoKey\Datanavn.ini")
Global $DatanavnDir = ("C:\IGS\AutoKey\Datanavn.ini")
Global $DropKeyGet = ("C:\IGS\Dropbox\Autokey\Keys\Getcheck\Hent.txt")
Global $DropKeyNew = ("C:\IGS\Dropbox\Autokey\Patricktest\" & $Datanavn & "new.txt")
Global $CAS = ("C:\IGS\CAS\ControleCaixa1.exe")
Global $Cashcontrol = ("C:\IGS\CAS\cashcontrol.dll")
Global $Tempcash = ("C:\cashcontrol.dll")
Global $CASdropboxget = ("C:\IGS\Dropbox\Autokey\Keys\CASget")
Send ("#d")


 If FileExists ($DropKeyNew) = 1 Then
Run ($CASload)
Exit
ElseIf FileExists ($DropKeyGet) = 0 Then
Exit
 EndIf


;sjekker om CAS er oppe, hvis den er det så logger den ut - gjelder innlogging skjermen også.
If ProcessExists("ControleCaixa1.exe") Then
ProcessClose ("ControleCaixa1.exe")
 EndIf
  
 ;henter ut navn på CAS-admin ;;OBS! UKRYPTERT!;;
If FileExists ($DatanavnDir) = 0 Then
   Run ($CAS)
   Sleep (20000)
   If WinExists ("", "Bekreftelse") = 1 Then
 ControlClick ("", "", "[NAME:btnNao]")
   EndIf
   WinWaitActive ("frmLoginMexico")
   Sleep (1000)
   ControlSend ("frmLoginMexico", "", "[NAME:txtUsuario]", "USER")
   Sleep (1000)
   ControlSend   ("frmLoginMexico", "", "[NAME:txtSenha]", "PASSWORD")
   Sleep (500)
   ControlClick ("frmLoginMexico", "", "[NAME:btnOk]")
   Sleep (10000)
   $husnavn = ControlGetText ("Menu", "", "[NAME:lblMexBingo]")
   FileWrite ($DatanavnDir, $husnavn)
   Sleep (200)
   ProcessClose ("ControleCaixa1.exe")
EndIf

;etter at CAS er lukket så starter den overføring og automasjon.
FileMove ($Cashcontrol, $Tempcash, 9)
Run($CAS)
ConsoleWrite ("Navnet på datamaskinen er " & $Datanavn & @CRLF)
Do
$bekreftelse = ControlGetText ("", "Bekreftelse", "[NAME:lblTitulo]")
Sleep(1000)
Until $bekreftelse = "Bekreftelse"
ControlClick ("", "" & $bekreftelse, "[NAME:btnSim]")
WinWaitActive ("Register")
Sleep (600)
ControlClick ("", "", "[NAME:GenerateKey]")

ConsoleWrite ("Sjekker språk.." & @crlf)
if _Language() = "Norwegian" Then
   ConsoleWrite ("Norsk versjon!" & @CRLF)
   WinWaitActive ("Lagre som")
   Sleep(500)
   $Datanavn = FileRead ("C:\IGS\AutoKey\Datanavn.ini")
   ControlSend("", "", "[CLASS:Edit; INSTANCE:1]", "C:\" & $Datanavn & ".txt")
   Sleep(200)
   Send ("{enter}")
   Sleep(200)
   ControlClick("", "", "Button1")
   Sleep(200)
   WinClose("Register")
   Sleep(200)
   FileMove($Tempcash, $Cashcontrol, 0)
   WinWaitClose ("C:\WINDOWS\system32\cmd.exe")
   Sleep(500)
   Run($CAS)
ElseIf _Language() = "Spanish" Then
   ConsoleWrite ("Spansk versjon!" & @CRLF)
   WinWaitActive ("Guardar como")   
   Sleep(500)
   $Datanavn = FileRead ("C:\IGS\AutoKey\Datanavn.ini")
   ControlSend("", "", "[CLASS:Edit; INSTANCE:1]", "C:\" & $Datanavn & ".txt")
   Sleep(200)
   Send ("{enter}")
   Sleep(200)
   ControlClick("", "", "Button1")
   Sleep(200)
   WinClose("Register")
   Sleep(200)
   FileMove($Tempcash, $Cashcontrol, 0)
   WinWaitClose ("C:\WINDOWS\system32\cmd.exe")
   Sleep(500)
   Run("C:\IGS\CAS\ControleCaixa1.exe")
ElseIf _Language() = "English" Then
     ConsoleWrite ("Engelsk versjon!" & @CRLF)
   WinWaitActive ("Save As")
   Sleep(500)
   $Datanavn = FileRead ("C:\IGS\AutoKey\Datanavn.ini")
   ControlSend("", "", "[CLASS:Edit; INSTANCE:1]", "C:\" & $Datanavn & ".txt")
   Sleep(200)
   Send ("{enter}")
   Sleep(200)
   ControlClick("", "", "Button1")
   Sleep(200)
   WinClose("Register")
   Sleep(200)
   FileMove($Tempcash, $Cashcontrol, 0)
   WinWaitClose ("C:\WINDOWS\system32\cmd.exe")
   Sleep(500)
   Run($CAS)
EndIf




;Overføring fra skrivebord til dropbox.
FileMove("C:\"  & $Datanavn & ".txt", $CASdropboxget, 1)
Sleep (5000)
Exit

This error has been boggling my mind for about an hour now. How can I know what is wrong when I can debug the error because it's gone when I install autoit?

Thanks for the (possible) replies.

Link to comment
Share on other sites

What is on line 32 in your script?

BTW, don't put the strings inside parentheses, there's no need for it.

Also, what is in your INI file, and why are you reading the whole thing into a variable instead of using the Ini* functions?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I think I know the error now. I tried to remove all of the _func commands and now it works without it. Is there any way to make functions work without having to install autoit on the machine?

Line 32 is nothing but air and space in the script, but I think the line parameter disregards comments etc. in the script when counting.

I didn't know there was any other way to read ini files, I see now that I have been misusing the function. However, the .ini file is only meant for 1 line anyway.

Any feedback on the horrible coding I am making is greatly appreciated. This is my first language and I have no prior experience with programming/scripting.

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