![]() |
Auto Execute Bets-VBA-NZ TAB-Project
1 Attachment(s)
Hi Guys
I would like help to create a Macro that looks at an Excel Spreadsheet. Accomplishes 1/ Logging into NZ TAB using A1 (User name) and A2 (Password) 2/ Looks at Cells B2 (Horse Number) and B2 ($ Bet Amount) and enters Values into appropriate box's on Web Page 3/ Then completes the Submit process That's it. I have found Code that fills in Username and Password for https://www.tab.co.nz/racing/?action=schedule# Bit clunky but the only one I could find that actually works, message box's disappear after 1 second but sometimes on first call I need to click 1st one, sure there's a better code. And still can't get it to Actually Login "Click" / "Submit". Things to look at A/ Clicking correct Radio Button for selected horse B2 (Horse Number) B/ Clicking Win or Place C/ Entering Bet Amount in Bet Amount box B2 ($ Bet Amount) D/ Clicking Login E/ Clicking Submit Bet 8/ Clicking the final "OK" I think that's about it All that is needed is Tenacity knowledge and Skill : ) I will of course help where I can One may need a NZ TAB account really, to go through whole process. Regards Mike |
Mike
You might also post this in the General forum as there are people there who don't visit this forum who have excel knowledge. |
1 Attachment(s)
Hiya,
Part of the way there with this attachment. Attempts to login (and fails if you're already logged in or the Try Again button is active due to a previously unsuccessful attempt). Specifies a Win bet, clicks the appropriate horse (without handling the error if it were scratched), enters a bet amount and....that's it. Couldn't figure out how to click the Submit Bet button. They've hidden that one well. Or I'm tired. Pretty sure it might be both. And probably something to do with my lapsed coding skills. I don't have an NZ TAB account, so my attempt to log in fails and it just fills out everything else anyway. I don't know if the source code would change on a successful log in. You'll undoubtedly want to add another field to the spreadsheet indicating which race it is you want to bet on. Otherwise it just seems to go to the next race - which there isn't this time of night, in case anyone uses it before they click over until tomorrow. (Effort somewhat due to SpeedyBen's earlier benevolence - it's a caring, sharing forum... :) ) |
Hi SpeedyBen
Ok will post in General Forum too will fix B2 to C2 as well Cheers : ) Hi WalkerMac Tried spreadsheet As is worked great Put in real Username and Password, i'm 100% sure it worked first time but then tried again and now comes up with "Object Doesn't Support This Property Or Method" Mucked about with it but it didn't help, ha ! But very promising cool Error checking to see if one is Logged in or not first, is a good idea i think. Great stuff so far Mike : ) |
Hey
Calling WalkerMac : ) Been mucking around with your code all weekend : ) all good learning a bit i suppose but can't get it to do what oi want : ( Any chance you could get the Code to just Fill in Username Pw Win Selection number Bet Amount Then i will click Login and Submit manually If ya could that would be great my main man i owe ya : ) Respec Mike : ) Sorry Mr Moderator I didn't Know : ( |
1 Attachment(s)
Hiya,
I've rewritten it properly, and commented liberally - so it should give you a better idea of what's going on (or how to fix it if I've stuffed it up). Now it logs on if the username/password fields are visible, fills in the bet type and amount, selects the horse (so long as it isn't scratched - tried a couple of things but couldn't get it to work out automatically whether the horse was scratched or not) and then leaves you to click the Submit bet button. |
Hi walkermac
Thanks matey Gave that a Whirl But : ) When i use my actual Username and Password it Logs in OK but doesn't select Win or Horse number or fill in Bet Amount. Could you get it to only fill in the page as above and I'll click Login then Submit manually Filling in the page is the pain : ) Hope that's OK Know it would be a hassle to suss out whats going on without actually logging in and seeing process I would be happy with that : ) Appreciate all process descriptions and time You da man Great stuff Mike : ) |
Heya,
Since it works fine with an invalid username/password pair, I presume that a successful login alters the contents of the betting area (if not the actual layout, then the name/address of items on the page). Unfortunately it won't let me create an account so that I can check whether this is the case. So, you have 2 options. 1. - Run the code while you're logged out and put a bogus username/password pair in your spreadsheet. This is what I can test and I can see that it works (at least until they change their code). It selects Win bet, it clicks on the horse checkbox (so long as it is running), and fills in the bet amount. When you click on the Submit Bet button manually, it gives you the opportunity to login, etc. Make your bet and click Log out afterwards. Not such a terrible way of doing things as it's probably not a good idea to leave a plaintext copy of your login details of your tab account lying around. 2. - I've commentated my code pretty heavily and explained how I was able to determine the names of items on the screen. Time for you to flap those wings and fly! ;) Log in to the NZ TAB site using the Google Chrome browser (it's easier) then right-click on the items you want to manipulate and select Inspect Element from the resulting pop-up menu. Then update the code to refer to the "name" parameter of these items instead of the existing ones (again, this is presuming that the names change dependent on whether the user is in a logged in or logged out state - if this isn't the case then I don't know how to fix it for you anyway! ;) ) Incidentally, after "horseSelection.click" in the code, add the following to click the Submit Bet button: i = 0 While i < htmldoc.Links.Length If htmldoc.Links(i).innerText = "Submit bet" Then htmldoc.Links(i).Click i = htmldoc.Links.Length End If i = i + 1 Wend I'm positive I tried the exact same thing before but, with the javascript running it's a dynamic environment. Perhaps I tried it earlier than I should have - or I just made a typo or something. Anywho, all that should be enough to get you over the line. Good luck! :D ...is what I wrote first. But I couldn't leave it alone. Try changing all occurences of "htmldoc.forms(0).elements" to "htmldoc.forms(1).elements". It looks like the stuff we want to update is on forms(0) if we have made an unsuccessful login, and on forms(1) if we are yet to log in! Maybe it's the same for a successful login. Just keep incrementing that figure until it complains about it, I guess :) |
Hi WM
Thanks for looking at it again Will give those pointers a go, trial error type thing Shall report soon be long Cheers matey Mike : ) |
Just curious here Keen2xL.
Are you trying to place bets unattended depending on odds or other variables before jump or just want to place bets via Excel for other reasons? |
All times are GMT +10. The time now is 09:18 AM. |
Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.