Jump to content
imitto

Script not working if run from shortcut

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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. 

Share this post


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

  • Similar Content

    • By lonardd
      Hi,
      I have a very strange problem concerning MouseClick function.
      I need to start Control Panel, navigate it on the Display Section (Adjust screen resolution link), click on it, and from the next Dialog choose Intel Graphic tool tab and navigate into it when it opens. 
      I wasn't using MouseClick() at first when I tried to use Control IDs, but I was fed up with the Autoit Window Info poor and inaccurate info (It flickers and the moment I click on the control the control ID and class disappear) so I ended up choosing the easiest way.
      The code I'm posting worked OK until two weeks ago, the mouse clicks were accurately performed and the Script reached the end with no errors...and I was happy.
      All of a sudden, between one try and the other, I noticed the cursor not flying exactly where it was supposed to, namely to the Control Panel ->Display->Adjust screen resolution link   but it clicked some 30 pixels below and some 30 pixels to the left, choosing obviously and undesired function and from that point it screwed the whole thing up. And from that moment onward, it seems I can no longer regain the mouse to click on that sequence.
      Could it be because my Control Panel ->Display form moved slightly from one test to another and therefore I got that small offside?
      If you believe this is the reason, I should then re position the Control Panel ->Display window to 0,0 and recalculate all the clicks. 
      do you have a suggestion?
       
      Thanks a lot
      Dave
       
       
       
      RotateDisplays.au3
    • By lonardd
      I need to open an INTEL Graphic Tool clicking on a Win7 Tray Icon. This icon is not shown on the Win7 Tray but it is shown once you click on a button that shows a little  arrow-up. This button opens up an extension of the tray and there is my INTEL Graphic Tool Icon. 
      The first ControlClick('[Class:Shell_TrayWnd]', '', 1502 ) at line 26 of my source code (Rotatedisplays.au3) works fine as it clicks on the up-arrow shown on the uparrowfirst Menu.jpg  picture and opens up an extension of the tray. Then I'm trying to click on the INTEL Graphic Tool Icon which is the first blue icon (up-left) of the tray extension but I failed all my attempts. Can somebody help me out?
      Thanks 
      Dave


      RotateDisplays.au3
    • By sosimple
      Is this possible with autoit?
      What I want to do:
      Create a Desctop windows shortcut to run an executable application created with autoit, which shortcut would have some parameters which will send as a variable to the aplicagion .
      For example:
      Create an app : ExampleAppCreatedByAutoit.exe
      Run this with a shortcut which has:  "C:/ExampleAppCreatedByAutoit.exe" -option1
      What I want to do is the ExampleAppCreatedByAutoit.exe take the option1 and do something like this: Shellexecute("c:\myfolder\option1.exe")
      Can I do that?
      Thanks,
    • By satanico64
      hi guys, how are you ??  fine? good...
      Here is a little question: is it possible to know whish shortcut has been used to launch my autoit app ?
      i'm quite sure that there's nothing to do with autoit, but mostly windows ...
       
      My context: i have an app accessed from the network by my user.
      In my app i use FileCreateShortcut to point to \\myfileserver\myapp.exe
      Soon, in october, they are going to change my fileserver, so my app will be on \myNEWfileserver\myapp.exe
      So in my code, i just rewrite my shortcut on the desktop's user. Everything works fine.
      BUT..some users have several shortcut for my app (they just manually create another shortcut which i don't know the name).
      So maybe they don't use my shortcut but their own ...
      => i know I could list all file on desktop, and for all the .lnk i check if destination is myapp.exe and modify the path but do you see another way ?
       
      thanks
      have fun !
       
    • By ur
      I am trying to launch the shortcut through autoit, but I am getting below error.
      [Window Title] C:\Windows\system32\cmd.exe /c start "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\erwin\erwin Mart Server r9.8 (64-bit)\Create MartServer Service.lnk" [Content] Windows cannot find 'C:\Windows\system32\cmd.exe /c start "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\erwin\erwin Mart Server r9.8 (64-bit)\Create MartServer Service.lnk"'. Make sure you typed the name correctly, and then try again. [OK] Launching the target directly is not feasible as it is dynamic.
      I tried.
      $r = ShellExecute(@ComSpec & " /c " & "start """& @ProgramsCommonDir & "\erwin\erwin Mart Server r9.8 (64-bit)\Create MartServer Service.lnk""")
       
      and also Run and RUnwait
       
       
×
×
  • Create New...