Jump to content

Simple Problem: Command Line Parameter Value


kkk
 Share

Recommended Posts

Hi

I have problem, probably it is very simple, but I started with autoit few days ago, and I tried to solve this problem ... but :think:

Simple description:

3 Command line parameter exist: $CmdLine[1] - $CmdLine[3]

An excel-file is selected by the script.

The $CmdLine[1] ist a parameter which shall be written to the selected excel cell.

Problem: the string "$CmdLine[1]" is written into the cell, but not the value of $CmdLine[1].

Can some please help me?

Thanks in advance!

kkk

Code:

WinActivate ("Microsoft Excel - Template-parallel")

WinWaitActive ("Microsoft Excel - Template-parallel", "", 60)

; Select Cell

MouseClick ("", $CmdLine[2], $CmdLine[3])

Sleep (2)

;Send the value in $CmdLine[1] to the selected cell

Send (" " & $CmdLine[1])

;ClipPut(& $CmdLine[1])

Link to comment
Share on other sites

Hi,

works fine for me.

If $CmdLine[0] > 0 Then
Send (" " & $CmdLine[1])
Else
    MsgBox(0,"Error", "Wrong parameter count!")
EndIf

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 2 weeks later...

I don't intend to hijack this thread, but the topic is a good one for this question as well. :(

I want to look for and remove "/" or "-" from the command line if they exist.

This has probably been asked before but I'm out of ideas on how to find it.

This is what I'm trying to do:

If $CmdLine[0] <> 0 Then _CmdLine($CmdLine[1])
Func _CmdLine($Param)
If StringLeft($Param,1) = "-" OR "/" Then $Param=StringTrimLeft($Param,1)
MsgBox(64,"",$Param)

Of course there is more to the function, but this is just for experimentation. :think:

Now my theory here is based on the help file saying that you can use boolean operators as well as logical.

I've tried different parentheses options with no avail.

Link to comment
Share on other sites

  • Moderators

I don't intend to hijack this thread, but the topic is a good one for this question as well. :(

I want to look for and remove "/" or "-" from the command line if they exist.

This has probably been asked before but I'm out of ideas on how to find it.

This is what I'm trying to do:

If $CmdLine[0] <> 0 Then _CmdLine($CmdLine[1])
Func _CmdLine($Param)
If StringLeft($Param,1) = "-" OR "/" Then $Param=StringTrimLeft($Param,1)
MsgBox(64,"",$Param)

Of course there is more to the function, but this is just for experimentation. :think:

Now my theory here is based on the help file saying that you can use boolean operators as well as logical.

I've tried different parentheses options with no avail.

StringReplace()?

If StringInStr($CmdLine[1], '/') Then 
    $SomeVar = StringReplace($CmdLine[1], '/', '')
ElseIf StringInStr($CmdLine[1], '-') Then
    $SomeVar = StringReplace($CmdLine[1], '-', '') 
Else
    $SomeVar = $CmdLine[1]
EndIf

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks, but I wasn't clear enough, sorry. :think:

I can get it to work if I do a multi-line if then else statement, but I'm trying to do it with an if (this or that) statement.

Partially just to learn how to do this and partially because I think the code is neater. :(

Edit:

Or is this even possible?

Edited by d4vr0s
Link to comment
Share on other sites

  • Moderators

Thanks, but I wasn't clear enough, sorry. :think:

I can get it to work if I do a multi-line if then else statement, but I'm trying to do it with an if (this or that) statement.

Partially just to learn how to do this and partially because I think the code is neater. :(

Edit:

Or is this even possible?

Sorry, don't even understand what you mean... why don't you type of a pseudo code of what you want and comment next to it.

Edit:

(Neater doesn't always mean more efficient, generally speaking you are (the scripter) the only one that ever sees the code anyway)

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Neater doesn't always mean more efficient, generally speaking you are (the scripter) the only one that ever sees the code anyway

Makes sense, primarily it's to learn how to do stuff for me. :(

Trying again with comments. :)

If $CmdLine[0] <> 0 Then _CmdLine($CmdLine[1])
Func _CmdLine($Param)
; Check for - or / in one statement and remove the leftmost character if they exist
If StringLeft($Param,1) = "-" OR "/" Then $Param=StringTrimLeft($Param,1)
Select
Case $Param = "logon"
If @OSTYPE = "Win32_NT" Then _AdminLogon()
; Other cases continue with future commands
EndSelect
EndFunc

Mainly I just want to know if and how I can do an If statement based on 2 possibilities without nesting statements.

Edit:

I should tell you what the issue I'm having is too. :think:

When I use this code every command is trimmed by 1 character regardless if there is an - or / in it.

Edited by d4vr0s
Link to comment
Share on other sites

  • Moderators

Ok, let's take a look at your syntax for a second:

If StringLeft($Param,1) = "-" OR "/" Then $Param=StringTrimLeft($Param,1)

If StringLeft($Param,1) = "-" OR StringLeft($Param,1) = "/" Then $Param=StringTrimLeft($Param,1)

You have to do another comparison for the Or.

Is the first Character always either the "-" or "/" or correct?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Excellent, That's exactly what I was trying to do.

The obviousness of it makes me feel stupid. :">

Thank you SmOke_N :think:

No worries, actually after looking at it, I probably would have done it like:
If Not StringIsAlNum(StringLeft($Param,1)) Then $Param = StringTrimLeft($Param, 1)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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