Jump to content

Recommended Posts

Posted

Hello all!

I was in read-only until today, started to use Autoit 3 weeks ago. It can really make things easy, I really love it :)

I have some script now that works and make our job effective, but I have problems with the latest. It works if I open the script's folder and run the exe directly. If I use the shortcut that I created on the desktop, it's not working properly. Activates the window, but not opening/exporting my files, just opens the last msgbox. I use ftp becouse the PC and the destination PC is not on the same network.

Here's the script:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\microsoft_excel.ico
#AutoIt3Wrapper_Res_Comment=send file over ftp
#AutoIt3Wrapper_Res_Description=send file over ftp for process
#AutoIt3Wrapper_Res_Language=1038
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         imitto

 Script Function:
    Rename and put playlist file on ftp

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

#RequireAdmin
#include <File.au3>
#include <FileConstants.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <FTPEx.au3>



; Script Start

Global $playlistname=@YEAR&@MON&@MDAY&"-playlist.pll"
BlockInput($BI_DISABLE)
Opt ("WinTitleMatchMode", 2)
WinActivate("MAIN SCHED")
WinWaitActive("MAIN SCHED")
;Opt ("WinTitleMatchMode", 1)
Send("!fo")
WinWaitActive("Open")
Send("Z:\playlist\"&$playlistname&"{ENTER}")
Sleep(2000)
Send("!fe")
WinWaitActive("MCon")
Send("{ENTER}")
WinWaitActive("Save")
Send("C:\sendFileForXLS\lista.txt{ENTER}")
Sleep(500)
Send("!fc")
BlockInput($BI_ENABLE)
Sleep(50)
Opt ("WinTitleMatchMode", 1)
Local $hOpen = _FTP_Open('MyFTP Control')
$ftp=_FTP_Connect($hOpen, "**********", "******", "******")
If @error Then
    MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error)
Else
_FTP_FilePut($ftp, @ScriptDir&"\lista.txt", "/lista.txt")
EndIf
Local $iFtpc = _FTP_Close($hOpen)
FileDelete(@ScriptDir&"\lista.txt")
MsgBox(0, "", "Playlist exported", 2)
Exit

 

Posted

I think I got it. We have to try it with "Run as admin" checked. I think it's not running in admin mode, so after I disable input devices, autoit can't send the keystrokes. I check it tomorrow morning :)

Posted

Not working from the shortcut (I set it to run as administrator). It stops in the middle of the first send command, after sending the ALT key, before send "fo" keys. If I run the exe, it works. Any idea?

Posted

I do not see why it wont work, have you tried to turn off blockinput maybe that is the issue, that or its waiting for a window and holding up the script.

 

You can enable the debug modes and see what line the script is actually pausing on. 

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
×
×
  • Create New...