kkk Posted April 19, 2006 Share Posted April 19, 2006 HiI have problem, probably it is very simple, but I started with autoit few days ago, and I tried to solve this problem ... but 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!kkkCode:WinActivate ("Microsoft Excel - Template-parallel")WinWaitActive ("Microsoft Excel - Template-parallel", "", 60); Select CellMouseClick ("", $CmdLine[2], $CmdLine[3])Sleep (2);Send the value in $CmdLine[1] to the selected cellSend (" " & $CmdLine[1]);ClipPut(& $CmdLine[1]) Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 19, 2006 Share Posted April 19, 2006 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 More sharing options...
kkk Posted April 20, 2006 Author Share Posted April 20, 2006 Thanks Mega! It works now Link to comment Share on other sites More sharing options...
d4vr0s Posted April 30, 2006 Share Posted April 30, 2006 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. 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 More sharing options...
Moderators SmOke_N Posted April 30, 2006 Moderators Share Posted April 30, 2006 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. 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 More sharing options...
d4vr0s Posted April 30, 2006 Share Posted April 30, 2006 (edited) Thanks, but I wasn't clear enough, sorry. 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 April 30, 2006 by d4vr0s Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 30, 2006 Moderators Share Posted April 30, 2006 (edited) Thanks, but I wasn't clear enough, sorry. 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 April 30, 2006 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 More sharing options...
d4vr0s Posted April 30, 2006 Share Posted April 30, 2006 (edited) Neater doesn't always mean more efficient, generally speaking you are (the scripter) the only one that ever sees the code anywayMakes 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. When I use this code every command is trimmed by 1 character regardless if there is an - or / in it. Edited April 30, 2006 by d4vr0s Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 30, 2006 Moderators Share Posted April 30, 2006 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 More sharing options...
herewasplato Posted April 30, 2006 Share Posted April 30, 2006 $var = "test-this/string" If StringInStr($var, '/') Or StringInStr($var, '-') Then $var = StringReplace(StringReplace($var, '-', ''), '/', '') MsgBox(0, "", $var) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
d4vr0s Posted April 30, 2006 Share Posted April 30, 2006 Excellent, That's exactly what I was trying to do. The obviousness of it makes me feel stupid. :"> Thank you SmOke_N Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 30, 2006 Moderators Share Posted April 30, 2006 Excellent, That's exactly what I was trying to do. The obviousness of it makes me feel stupid. :"> Thank you SmOke_N 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 More sharing options...
d4vr0s Posted April 30, 2006 Share Posted April 30, 2006 That's definitely simpler. But I'm glad I got the if stuff understood. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now