Jump to content
Sign in to follow this  
jorgeng

Send sms

Recommended Posts

jorgeng

I am trying to send sms by a program we in sweden call telia sms i datorn.

i have got a string from supplier about what to send and i am trying to do this in autoit with expressions after send

but it doesn't work.

Here it the autoit string i am trying to send but it doesn't work:

Run("C:\Program Files (x86)\Sms och mms i datorn Desktop\mw.exe -NewMMS -Number +46111111111 -Text 'hej' -Silent", @SW_HIDE)

The program mw.exe is locally installed on my computer.

The suppliers description:

-------------------------------------------------------------------------------------------------------------

Command-line interface

It is possible to interact with the desktop client with a command-line interface (CLI).

To use the CLI the end-user first needs to install the client and register with a supported MSISDN. Registration is done using the normal GUI wizard.

After that the end-user can send SMS by running the desktop messaging client executable with some arguments.

Example: mw.exe -NewSMS -Number +1234567890,+9876543210 -Text "testing testing testing" -Silent

Option

Description

-NewSMS

Create a new message

-Number

Comma separated list of recipient numbers

-Text

The text for the SMS

-Silent

Do not show the new SMS window, immediately send the message.

--------------------------------------------------------------------------------------------

Can someone help me get the send string to work?

:idea:

Share this post


Link to post
Share on other sites
Tvern

What error are you getting?

if I look at your run command I notice 3 things:

1. "C:\Program Files (x86)\Sms och mms i datorn Desktop\mw.exe" seems like a strange path. are you sure there is a folder called "Sms och mms i datorn Desktop"?

2. The example uses 2 numbers seperated by a comma, but I can't imagine that's a problem.

3. -Text "testing testing testing" uses double quotation thingies -Text 'hej' uses single ones.

If autoit doesn't give an error then this isn't realy autoit help as much as "telia sms i datorn help".

I'd advise you to try and get some more information on why it is not working by removeing the -Silent and @SW_HIDE option to see what is failing.

Share this post


Link to post
Share on other sites
jorgeng

What error are you getting?

if I look at your run command I notice 3 things:

1. "C:\Program Files (x86)\Sms och mms i datorn Desktop\mw.exe" seems like a strange path. are you sure there is a folder called "Sms och mms i datorn Desktop"?

2. The example uses 2 numbers seperated by a comma, but I can't imagine that's a problem.

3. -Text "testing testing testing" uses double quotation thingies -Text 'hej' uses single ones.

If autoit doesn't give an error then this isn't realy autoit help as much as "telia sms i datorn help".

I'd advise you to try and get some more information on why it is not working by removeing the -Silent and @SW_HIDE option to see what is failing.

The path under 1 is ok, it's a 64 bit it system.

I shall test remove silent and sw_hide.

Edited by jorgeng

Share this post


Link to post
Share on other sites
jorgeng

You can't skip optional parameters! You probably want the apps path as the working dir.

I tried that but no success.

I tried with:

Run("mw.exe -NewMMS -Number +46111111111 -Text 'hej' -Silent","C:\Program Files (x86)\Sms och mms i datorn Desktop")

I want to have double quotes in text "hej" but i am not allowed to do that in the compilation

and then

ShellExecute("mw.exe", "-NewMMS -Number +46111111111 -Text 'hej' -Silent","C:\Program Files (x86)\Sms och mms i datorn Desktop"

This fires up the sms client but doesn't put in phone-number and text,

It seems that it isn't possible to put in additional parameters in the run command.

:idea:

Edited by jorgeng

Share this post


Link to post
Share on other sites
jorgeng

I managed to send the sms manually by opening a dos prompt box and put in next commands:

When i open dos-prompt it opens in:

C:\Users\Dator1

i had to put in dos commands:

cd..

cd..

to get to c:\ and then beginning to walk around in directory and put in:

cd program files (x86)

cd sms och mms i datorn Desktop

and then the string:

mw.exe -NewSMS -Number +46111111111 -Text 'hej' -Silent

with single quotes on 'hej' and it works

How do i do this automatic with:

#include <Process.au3>

$rc = _RunDos("mw.exe -NewSMS -Number +46111111111 -Text 'hej' -Silent")

I have to get in the switch directory in the run dos command...

:idea:

Edited by jorgeng

Share this post


Link to post
Share on other sites
jorgeng

I tried this but nothing happened:

#include <Process.au3>

$dir = ("C:\Program Files (x86)\Sms och mms i datorn Desktop\")

$rc = _RunDos($dir & "mw.exe -NewSMS -Number +411111111111 -Text 'hej' -Silent")

How do i put in a directory so rundos can find the mw.exe?

:idea:

Edited by jorgeng

Share this post


Link to post
Share on other sites
jorgeng

I tried this:

$rc = _RunDos("C:\Program Files (x86)\Sms och mms i datorn Desktop\mw.exe -NewSMS -Number +461111111111 -Text 'hej2' -Silent")

It doesn't work neither.

Anyone knowing why it doesn't work?

:idea:

Share this post


Link to post
Share on other sites
SmOke_N

No idea on the program you're trying to utilize or if you're calling it with the right command lines.

However, keep in mind, it's best to test in a command console before putting your string in Run().

At first glance, I'd say you're not escaping the spaces in the directory string:

Global $s_folder = @ProgramFilesDir & "\Sms och mms i datorn Desktop"
Global $s_exe = "mw.exe"
Global $s_what_to_say = "hej2"
Global $s_phone_number = "+461111111111"
Global $s_commandline = "-NewSMS -Number " & $s_phone_number & " -Text " & '"' & $s_what_to_say & '" -Silent'

Global $i_pid = Run('"' & $s_folder & "\" & $s_exe & '" "' & $s_commandline & '"')
If Not $i_pid Then
    MsgBox(16, "Error", "Chances are your command line is wrong")
Else
    MsgBox(64, "Success", "Ok")
EndIf
I'm not sure if that will work for you, but the point was more for you to see how I escaped the spaces in the path name. 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.

Share this post


Link to post
Share on other sites
jorgeng

No idea on the program you're trying to utilize or if you're calling it with the right command lines.

However, keep in mind, it's best to test in a command console before putting your string in Run().

At first glance, I'd say you're not escaping the spaces in the directory string:

Global $s_folder = @ProgramFilesDir & "\Sms och mms i datorn Desktop"
Global $s_exe = "mw.exe"
Global $s_what_to_say = "hej2"
Global $s_phone_number = "+461111111111"
Global $s_commandline = "-NewSMS -Number " & $s_phone_number & " -Text " & '"' & $s_what_to_say & '" -Silent'

Global $i_pid = Run('"' & $s_folder & "\" & $s_exe & '" "' & $s_commandline & '"')
If Not $i_pid Then
    MsgBox(16, "Error", "Chances are your command line is wrong")
Else
    MsgBox(64, "Success", "Ok")
EndIf
I'm not sure if that will work for you, but the point was more for you to see how I escaped the spaces in the path name.

Thanks for great coding.

Unfortunately i only got ""Error", "Chances are your command line is wrong"

:idea:

Share this post


Link to post
Share on other sites
jorgeng

I did:

MsgBox(4096,"Box",$i_pid)

after your code and got i_pid to 0.

Strange that i can put in commands in dos prompt box and send sms and not being able to do the same by rundos in autoit.

:idea:

Edited by jorgeng

Share this post


Link to post
Share on other sites
jorgeng

I did:

MsgBox(4096,"Box",$i_pid)

after your code and got i_pid to 0.

Strange that i can put in commands in dos prompt box and send sms and not being able to do the same by rundos in autoit.

:idea:

What's wrong??

Share this post


Link to post
Share on other sites
SmOke_N

Show the exact string you put in the command prompt that works.


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.

Share this post


Link to post
Share on other sites
jorgeng

Show the exact string you put in the command prompt that works.

When i open dos-prompt it opens in:

C:\Users\Dator1

i had to put in dos commands:

cd..

cd..

to get to c:\ and then beginning to walk around in directory and put in:

cd program files (x86)

cd sms och mms i datorn Desktop

and then the string:

mw.exe -NewSMS -Number +46111111111 -Text 'hej' -Silent

with single quotes on 'hej' and it works

-----------------------------------------------------------------

So the answer to your question is several strings beginning with

cd..

Edited by jorgeng

Share this post


Link to post
Share on other sites
jorgeng

I tried this but it doesn't work neither:

#include <Process.au3>

$rc = _RunDos("cd..")

$rc = _RunDos("cd..")

$rc = _RunDos("cd Program Files (x86)")

$rc = _RunDos("cd Sms och mms i datorn Desktop")

$rc = _RunDos("mw.exe -NewSMS -Number +46111111111 -Text 'hej2'")

Is there any way to command stacking the cd commands?

:idea:

Share this post


Link to post
Share on other sites
99ojo

Hi,

jumping on SmOke_N code and did some changes in the command line and the Run Call. I guess there are to much ":

Try:

Global $s_folder = @ProgramFilesDir & "\Sms och mms i datorn Desktop"
Global $s_exe = "mw.exe"
Global $s_what_to_say = "hej2"
Global $s_phone_number = "+461111111111"
;add a blank before -NewSMS
Global $s_commandline = " -NewSMS -Number " & $s_phone_number & " -Text " & '"' & $s_what_to_say & '" -Silent'
;origin: Global $i_pid = Run('"' & $s_folder & "\" & $s_exe & '" "' & $s_commandline & '"')
Global $i_pid = Run('"' & $s_folder & "\" & $s_exe & '"'  & $s_commandline)

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites
jorgeng

Hi,

jumping on SmOke_N code and did some changes in the command line and the Run Call. I guess there are to much ":

Try:

Global $s_folder = @ProgramFilesDir & "\Sms och mms i datorn Desktop"
Global $s_exe = "mw.exe"
Global $s_what_to_say = "hej2"
Global $s_phone_number = "+461111111111"
;add a blank before -NewSMS
Global $s_commandline = " -NewSMS -Number " & $s_phone_number & " -Text " & '"' & $s_what_to_say & '" -Silent'
;origin: Global $i_pid = Run('"' & $s_folder & "\" & $s_exe & '" "' & $s_commandline & '"')
Global $i_pid = Run('"' & $s_folder & "\" & $s_exe & '"'  & $s_commandline)

;-))

Stefan

Thanks.

I tired it, and did a messagebox about programfiles and maybe it is that that is wrong.

Msgbox says programfiles is:

c:\Program Files\Sms och Mms i Datorn

in reality the programfiles is

C:\Program Files (x86)

so how do i change to correct program files in code?

:idea:

Share this post


Link to post
Share on other sites
99ojo

Hi,

change Global $s_folder = @ProgramFilesDir & "\Sms och mms i datorn Desktop"

to

Global $s_folder = "C:\Program Files (x86)\Sms och mms i datorn Desktop"

or

Global $s_folder = EnvGet ("ProgramFiles(x86)") & "\Sms och mms i datorn Desktop"

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites
jorgeng

Hi,

change Global $s_folder = @ProgramFilesDir & "\Sms och mms i datorn Desktop"

to

Global $s_folder = "C:\Program Files (x86)\Sms och mms i datorn Desktop"

or

Global $s_folder = EnvGet ("ProgramFiles(x86)") & "\Sms och mms i datorn Desktop"

;-))

Stefan

Thanks you did it and it now works...

I can now send sms to my phone from autoit script.

:idea:

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.