Jump to content
sosimple

How can I send a variable with a shortcut, to a autoit executable created app?

Recommended Posts

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,

Share this post


Link to post
Share on other sites
48 minutes ago, Subz said:

Look at $CmdLineRaw and $CmdLine in the Help File which explains how to handle switches.

Thanks but I am note sure if I can do it by this. I don't want one compiled with autoit executable app to send a variable to another. 

I want a simple shortcut to sent variable to autoit executable app..

I am not very good in autoit, so an example could help if this can be done, if anyone knows.

Share this post


Link to post
Share on other sites

@sosimple did even you look at $CmdLine as was suggested? It does precisely what you are looking for, and has an example in the help file.

This forum is dedicated to helping people who want to improve their own scripts; it is not somewhere where you put in a request and someone barfs up the code for you. You need to show some effort if you would like assistance.

Edited by JLogan3o13

Share this post


Link to post
Share on other sites

Well I was bored and so wrote something simple up, to show you how you can create 3 shortcuts on the desktop named Option1, Option2 and Option3

Option1 Runs Notepad
Option2 Runs Wordpad
Option3 Delete the three shortcuts

You should be able to modify the code to suit, as JLogan3o13 mentioned the forum would like to see you write something first and we can give you help as required, but I have some spare time so have given you a working example.

Please remember read AutoIt Helpfile, it includes a large variety of examples you can test and base your own scripts on.

If FileExists(@DesktopDir & "\Option1.lnk") = 0 Then FileCreateShortcut(@ScriptFullPath, @DesktopDir & "\Option1.lnk", "", "-Option1")
If FileExists(@DesktopDir & "\Option2.lnk") = 0 Then FileCreateShortcut(@ScriptFullPath, @DesktopDir & "\Option2.lnk", "", "-Option2")
If FileExists(@DesktopDir & "\Option3.lnk") = 0 Then FileCreateShortcut(@ScriptFullPath, @DesktopDir & "\Option3.lnk", "", "-Option3")
If $CmdLine[0] >= 1 Then
    Switch $CmdLine[1]
        Case "-Option1"
            ShellExecute(@WindowsDir & "\Notepad.exe")
        Case "-Option2"
            ShellExecute("Wordpad.exe")
        Case "-Option3"
            FileDelete(@DesktopDir & "\Option1.lnk")
            FileDelete(@DesktopDir & "\Option2.lnk")
            FileDelete(@DesktopDir & "\Option3.lnk")
    EndSwitch
EndIf

 

Share this post


Link to post
Share on other sites

Thank you very much Subs!. I will work on your code . I think I can made it from here.. :)

@JLogan3o13: Sorry, as I told, I haven't much experience in autoit.. I did search but didn't understand how to do it. 

I understand what you say, but please understand that some users don't have many experience..

Thanks again both!

Share this post


Link to post
Share on other sites
33 minutes ago, sosimple said:

I understand what you say, but please understand that some users don't have many experience..

I do understand; everyone here was on "Day 1" at some point. The ones who succeed, however, are those that spend the time learning. That is why we operate on the "teach a man to fish" motto; simply being handed the code often does more harm than good for new scripters. Hopefully you will study the code and use it to learn more about the language. 

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 iAmNewbe
      I created an application to catch keyboard programmed keys.  Some of the keys open URL's via ShellExecute and then they open in the default browser.

      The problem I am having is that when the browser is opened in this manner 3rd party applications such as Logitech Setpoint for Logitech mouse and keyboards and programs like auto password form filling stop working with the browser.  In the mouse specific situation the Cruise Up and Cruise Down buttons, normally back and forward, do not work. If I open the browser manually via the browsers icon and then press the keyboard buttons to open the web page everything works normally.

      I have two questions:

      1:  Why does 
      ShellExecute("http://www.autoitscript.com") when the browser is not open and then is launched, via the above line, cause third party apps to not be able to interface with the browser?


      2:  What is a better way to launch URL's if not via ShellExecute?


      The application is NOT using #RequireAdmin and is not 64bit.
    • By rudi
      Hello,
      for a script to display PDF files I'd like to simply use the default program for PDF files, so I used "ShellExecute(<pdf-file-full-path>)" to open these files.
       
      The result for *SOME* of the workstations is, that the Adobe Reader starts up with asking for its language. (English/German). When starting AcroRd32.exe through "ShellExecute()", this "choose your language" dialog is showing up *ALWAYS*.
       
      Just to have mentioned it: Process Explorer is presenting this command line, it looks the same for both, PCs with and without that question "Choose Language? [English|German]"
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" --channel=4680.0.860715181 --type=renderer "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf"  
      The next approach I thought of was to use Foxit Portable (instead of Acrord32.exe), started from a Network Drive, but it's starting up ugly slowly...
      So I tried to "Run()" instead to "ShellExecute()" the Adobe Reader. Now the result looks more stange, the "select your language" dialog shows up every now and then, but not always for the Win7 installations affected.
       
      If I place a "msgbox()" just in front of the "run()" command, it seems never to show this "select your language" dialog.
      If I take out this MsgBox() the "select your language" dialog shows up sometimes.
      When I "ClipPut()" the run command prior the "Run()" and paste that one to a CMD box, then it seems to *NEVER* happen, that this "select your language" dialog shows up.
       
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf" $AcroRead='"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"' $PDF='"Y:\Temp\DRV_H\Daten\TIF\33\85\153385_Freigegeben.dwg.pdf"' MsgBox(0,"Values",$AcroRead & @CRLF & $PDF,1) $MyCommand=$AcroRead & " " & $PDF ClipPut($MyCommand) Run($MyCommand)  
      It looks like, that this "--channel=... --type=renderer" parameters are always fact for the AcroRd32.exe instance, that is opening the PDF to be displayed. The Instance opening the "PDF Display GUI" seems to always be a child process of another AcroRd32.exe process.
       
      Any clue, what's going on "backstage" here? How to avoid this "Choose your language" dialog? Or maybe someone can mention a different "portable" PDF viewer, I could use for this purpose?  
      Any suggestions appreciated, regards, Rudi.
    • By e45678mail
      Hi~
      I have some question about how to enable the test mode via "Run" or "shellexecute" of command,
      was to tried :
      -----
      Run("bcdedit.exe /-set testsinging on", "C:\Windows\System32")
      and
      shellexecute("bcdedit.exe /-set testsinging on", "C:\Windows\System32")
      -----
      since this command must to run through administrator competence,
      have any method can accomplish it?
       
       
    • By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian
    • 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 !
       
×
×
  • Create New...