Jump to content

open an application and file name


julia
 Share

Recommended Posts

Dear all,

I'm learning how to use AutoIt so I'm asking very basic questions. I have 2 problems:

1. I'd like to open an application to download periodically and automatically data stored in a device which is connected to the PC. I'm running the following script as test to verify that the function "Run" is working, but the command after Run is not being executed (maximize window). Do you know why?

$Kestrel_Title = "[CLASS:WindowsForms10.Window.8.app.0.378734a]"
$Kestrel_Text = ""

Run("c:\Program Files (x86)\Nielsen-Kellerman\Kestrel Communicator\KestrelCommunicator.exe")

WinActivate($Kestrel_Title, $Kestrel_Text) ; I tested the version without this command too.

; Maximize KestrelĀ® Tracker - Communicator
WinSetState($Kestrel_Title, $Kestrel_Text, @SW_MAXIMIZE)

2. After opening a window to save downloaded data in a file, I would like to change the default name of the file. I'm using the suggested command ControlSetText and I see that the name is being changed. However, when clicking on the control "Save", a Message Box appears informing about the fact that the file (with the default name) already exists. Do you know what is incorrect in the script? I don't know why after clicking "Save" the name of the file is not kept as the selected one.

;......

; Save the Kestrel data log - Filename (Box)
   $kOriginal = Opt("MouseCoordMode", 2)
   $kTitle = "Save the Kestrel data log"
   $kText = ""
   $kControl = "[ID:1001]"

      ; Filename according to current date
      $tCur_sys = _Date_Time_GetLocalTime()
      $tCur =_Date_Time_SystemTimeToDateTimeStr($tCur_sys)
      $Mo = StringMid ($tCur, 1, 2)
      $DD = StringMid ($tCur, 4, 2)
      $YY = StringMid ($tCur, 7, 4)
      $hh = StringMid ($tCur, 12, 2)
      $mm = StringMid ($tCur, 15, 2)
      $ss = StringMid ($tCur, 18, 2)
      $FileName = "Kestrel_" & $YY & $Mo & $DD & $hh & $mm & $ss

   ControlSetText($kTitle, $kText, $kControl,$FileName)

 ;Save the Kestrel data log - Save (Button)
   $lOriginal = Opt("MouseCoordMode", 2)
   $lTitle = "Save the Kestrel data log"
   $lText = "&Guardar"
   $lControl = "[ID:1]"
   ControlClick($lTitle, $lText, $lControl,$Button, $Clicks)

Thanks very much for your help.

Link to comment
Share on other sites

I'd suspect your first issue is a timing problem.

Your script has already executed the command(s) following the Run() statement before your hard drive has finished loading the requested program. Look into WinWait(), WinWaitActive(), or ProcessWait().

As to issue 2... Have you tried ControlSend()?

edit: typo

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