Launching Betfair Trader From Excel??

Please post any questions regarding the program here.

Moderator: 2020vision

Launching Betfair Trader From Excel??

Postby The Gambling Monkey » Thu Jun 22, 2006 5:39 pm

Hello All,

I'm trying to launch Gary's program from excel using the following code:

Code: Select all
Sub OpenLayItBA()

    Dim ReturnValue As Double
   
    ReturnValue = Shell("C:\Program Files\Betfair Trader\BetfairTraderLauncher.exe")
    Call AppActivate(ReturnValue)

End Sub


But I keep getting this error from Gary's Betfair Trader Application:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at BetfairTraderLauncher.Form1.Form1_Activated(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnActivated(EventArgs e)
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
BetfairTraderLauncher
Assembly Version: 1.0.1953.25021
Win32 Version: 1.0.1953.25021
CodeBase: file:///C:/Program%20Files/Betfair%20Trader/BetfairTraderLauncher.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 7.0.5000.0
Win32 Version: 7.10.3052.4
CodeBase: file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.



Anyone know why?

Cheers.
The Gambling Monkey
 
Posts: 39
Joined: Fri Nov 18, 2005 9:22 pm
Location: St. Albans

Postby GeorgeUK » Fri Jun 23, 2006 12:32 am

Not sure if this is of use, but it may be the shell function not liking folders with more than one word ie "program files"

http://groups.google.co.uk/group/micros ... 73e6596563

Not sure if this is what's happening as you seem to be accessing the application.
I don't have the trader on this computer so can't test it.

It seems to be something to do with the shell function opening the trader, so i'm not sure if the above allows the dos comand to do it. Maybe also look at the ShellAPI commands.

Will try to have another look some other time, but hopefully this is on the right track.

George
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby GeorgeUK » Fri Jun 23, 2006 10:47 pm

8) YAAAY that was it - thank god for google

you just need this line of code

Code: Select all
x = Shell("cmd /k cd C:\Program Files\Betfair Trader&&BetfairTraderLauncher.exe")


Note - i have it as /k so you can see the cmd prompt. Change this to /c and it will close down after it has run the code.
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby The Gambling Monkey » Sat Jun 24, 2006 2:39 pm

Cheers for that George.

It doesn't work flawlessly for me as I get:

Run-Time Error '5'
Invalid procedure Call or argument.

BUT it launches the application. An On Error Resume Next statement should fix that.

Many thanks.
The Gambling Monkey
 
Posts: 39
Joined: Fri Nov 18, 2005 9:22 pm
Location: St. Albans

Postby Mitch » Mon Jun 26, 2006 11:31 pm

That's good stuff George.

I have another use for this, but the application I want to start has a space in the name of the file to launch. Is there a character(s) that I can replace the space with to make it work in a command window, because as it is now it only recognises up to the space in the name and obviously says it doesn't exist. I know I could rename the app without the space (which I've tried and it works) but it would make life a lot easier if I didn't have to.

Also, I'm just curious, but how can opening BA automatically help unless you can pick and load markets automatically as well?
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby GeorgeUK » Tue Jun 27, 2006 1:45 am

Took me ages to get this
Code: Select all
Sub test()
y = """Betfair Trader Launcher.exe"""
x = Shell("cmd /k cd C:\Program Files\Betfair Trader&&" & y)
End Sub


Not entirely sure why the double quotes before and after a quote/string makes a difference, but it seems to work.

Time for bed now
:shock: zzzzzzz

Edit: As for automatically opening the trader from excel, i think that's just for ease of use.
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby The Gambling Monkey » Tue Jun 27, 2006 10:55 am

Mitch,

As I open a new page for each market, using SendKeys I am going to try to automatically open the trader with 18 new pages. If I can I'm also going to set the refresh rates in each to 10 seconds and tick show place market. If it works I'll post the code here (bearing in mind I am just a novice at VBA).

George,

Thanks for the code, lovely!!

Cheers
The Gambling Monkey
 
Posts: 39
Joined: Fri Nov 18, 2005 9:22 pm
Location: St. Albans

Postby Mitch » Tue Jun 27, 2006 11:47 am

The double-quotes inside single-quotes means use " rather than end the first quotes. I tried that in the long string but never thought of assigning it to its' own string first, thanks very much George.

18 pages open! No wonder the site is slow if lots of people do that! I got told I use too much bandwidth and I only use 1 page and 1 instance of the program.
I tried to use 2 pages once (admittedly both at 1 sec refresh) but it made it far too slow - about 3 sec refresh.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby a1ehouse » Tue Jun 27, 2006 11:54 am

Great Stuff. I always open UK Win Markets when I open BA, so now I can use this code, thanks for the tips!! Just run OpenBA from Excel, or asign it to a button

Code: Select all
Sub OpenBA()
    Shell ("cmd /c cd C:\Program Files\Betfair Trader&&BetfairTraderLauncher.exe")
    PauseMe (2)
    LoadWinMkt
End Sub
Sub LoadWinMkt()
    SendKeys "%M"
    SendKeys "S"
    PauseMe (2)
    SendKeys "{TAB} "
    SendKeys "{TAB 5} "
    SendKeys "%{F4}"
End Sub
Sub PauseMe(iHowLong As Integer)
    Dim WAIT As Double
   
    WAIT = Timer
    While Timer < WAIT + iHowLong
       DoEvents  'do nothing
    Wend
End Sub
...it maekesh me do a shecks wee...
Image
User avatar
a1ehouse
 
Posts: 69
Joined: Wed Apr 05, 2006 9:06 pm
Location: The Playboy Mansion

Postby GeorgeUK » Tue Jun 27, 2006 1:07 pm

So all we need to do now is put in a scheduled task to open or close the workbook when required.

This way our other macros that automatically pick the selections can be run without any user interference and our automated stoploss and greening macros will enure we make millions.

All of this can take place on the old wireless laptop we can keep under the stairs. Just let it run for a year and reap the benefits.

Or maybe i'm simplifying too much :D
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland


Return to Help

Who is online

Users browsing this forum: No registered users and 48 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.