Sign in to follow this  
Followers 0
gouwzee

doubleclick a shortcut

11 posts in this topic

I have a rasdial (dial-up) connection that oftentimes will return an error when called programmatically. When launched manually, it will always run just fine. I am new at autoit, but I suspect this question must be straightforward:

I just want to emulate the manual launching by double-clicking a shortcut to the dial-up connection. Can anybody outline me how that would be written in autoit script?

Thanks!!

Share this post


Link to post
Share on other sites



This has no error checking but you script at a bare minimum would be like this:

#include <process.au3>

Run("rasdial C2")

Where C2 in the RAS DUN connection nmae you created in the Network Control panel.

CC

Share this post


Link to post
Share on other sites

I recomend shellexecute instade of run because run can be problematic with some prorams

Share this post


Link to post
Share on other sites

I recomend shellexecute instade of run because run can be problematic with some prorams

Can you explain these problems so we can learn from the statement made?

Share this post


Link to post
Share on other sites

Can you explain these problems so we can learn from the statement made?

Sure: when I use the shellexecute approach (ie. "radial <phonebookname>") I will often receive error 623: phonebook entry does not exist. The helpfile states this error may also occur when another process is using the phonebook entry.

I am using a Huawei E220 USB UMTS modem, which has a virtual CD-rom with software auto-installer included. This software often also auto-launches when invoking the RAS connection.

The peculiar thing is: when manually launching the dial-up the error never occurs.

Share this post


Link to post
Share on other sites

This has no error checking but you script at a bare minimum would be like this:

#include <process.au3>

Run("rasdial C2")

Thanks IvanCodin. May I assume the process.au3 include is part of the standard autoit libraries?

Share this post


Link to post
Share on other sites

This has no error checking but you script at a bare minimum would be like this:

#include <process.au3>

Run("rasdial C2")

Where C2 in the RAS DUN connection nmae you created in the Network Control panel.

CC

I now understand that this is actually a scripted shell command. That is not going to work unfortunately. I really want to simulate me hand starting that dial-up session. Auto-it really appears as an "XP GUI macro maker" so it should be easy (feasible at least) to simulate a doubleclick on a shortcut (ie. .lnk) file.

Share this post


Link to post
Share on other sites

I guess you could perhaps use ShellExecute on the shortcut? that should work

Share this post


Link to post
Share on other sites

I guess you could perhaps use ShellExecute on the shortcut? that should work

:)

not sure how that syntax would look like

Run("dialup.lnk") doesn't do the job

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Well here are some examples to try. Something may work. I have automated Rasphone OK before so you can see what is going on with it.

; Automate rasphone
FileCreateShortcut(@SystemDir & '\rasphone.exe', @DesktopDir & '\Dialup.lnk')
ShellExecute('"' & @DesktopDir & '\Dialup.lnk"')

; or perhaps run shortcut of rasdial
FileCreateShortcut(@SystemDir & '\rasdial.exe', @DesktopDir & '\Dialup.lnk', @SystemDir, 'C2')
ShellExecute('"' & @DesktopDir & '\Dialup.lnk"')

; or perhaps execute rasdial
Run('"' & @SystemDir & '\rasdial.exe" C2', @TempDir, @SW_HIDE)

; or perhaps shellexecute rasdial
ShellExecute('"' & @SystemDir & '\rasdial.exe"', 'C2', @TempDir)

Edit:

Replace "C2" with the connection name.

Edited by MHz

Share this post


Link to post
Share on other sites

Try this. Determine what the actual ras connection name is. I'll assume from your description it's called dialup. Then run this script:

CODE
#include <Process.au3>

$RET = _RunDOS("rasdial dialup")

Switch $RET

Case 720

MsgBox(16, "RAS Error", "Login script error", 3)

Case 680

MsgBox(16, "RAS Error", "No dialtone", 3)

Case 678

MsgBox(16, "RAS Error", "There was no answer", 3)

Case 677

MsgBox(16, "RAS Error", "A person answered instead of a modem", 3)

Case 676

MsgBox(16, "RAS Error", "Line is busy", 3)

Case 0

MsgBox(32, "RAS Info", "The RAS connection was successful", 3)

Case Else

MsgBox(16, "RAS Error", "An unknown error has occured", 3)

EndSwitch

Let me know if this does the trick for you.

CC

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  
Followers 0