Franz135 Posted August 3, 2020 Share Posted August 3, 2020 Hello everyone, I want the programm to click two buttons (item_66029 and btn-add-to-cart) when I press the down key. It seems I do something wrong. Any ideas? Thanks for the help! #include <IE.au3> HotKeySet ( "{DOWN}","_start" ) HotKeySet ( "{UP}","_pause" ) HotKeySet ( "{END}","_exit" ) Global $go = 0 While(1) If($go) Then Local $button1 = _IEGetObjByName ($oIE,"item_66029") Local $button2 = _IEGetObjById ($oIE, "btn-add-to-cart") _IEAction ($button1,"click") Sleep(1) _IEAction ($button2,"click") $go=0 Else Sleep(1) EndIf WEnd Func _start() $go = 1 EndFunc Func _pause() $go = 0 EndFunc Func _exit() Exit EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted August 3, 2020 Share Posted August 3, 2020 Where do you define the $oIE variable? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Franz135 Posted August 3, 2020 Author Share Posted August 3, 2020 Thanks. I put the following definition in: Global $oIE = _IECreate ("https://xxx") But when I do this the website opens (even if the website is already open). I dont want that the programm to restart the explorer and the website. I just want the programm to click two buttons (item_66029 and btn-add-to-cart) when I press the down key (while I am on the website). Link to comment Share on other sites More sharing options...
Nine Posted August 3, 2020 Share Posted August 3, 2020 And how is it different from your other thread ? https://www.autoitscript.com/forum/topic/203517-how-to-pause-a-program/ Danp2 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 3, 2020 Moderators Share Posted August 3, 2020 @Franz135 I would second that, how is this thread any different? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Franz135 Posted August 4, 2020 Author Share Posted August 4, 2020 @Nine @JLogan3o13 It is nearly similiar but instead of mouse clicks I want to use a more "intelligent" version (by using things like IEGetObjByName). But right now the programm restarts the explorer and the website. I want the programm to only click the two buttons while I am on the website. Any ideas? Link to comment Share on other sites More sharing options...
Nine Posted August 4, 2020 Share Posted August 4, 2020 The problem with this thread (and like the other "similar" one) is that you ask us to tell you how to solve your issue but you do not provide the essential information of why is this an issue and what do you want to achieve at the end. I suggest you first start telling us the web site that you want to automate (or at least a screenshot of the pages), the end goal of the script, and a clear description of the issue. Unless you can adduce a more detailed documentation of your problem, I am afraid it is going to be hard to help you. Franz135 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Franz135 Posted August 4, 2020 Author Share Posted August 4, 2020 (edited) 3 hours ago, Nine said: The problem with this thread (and like the other "similar" one) is that you ask us to tell you how to solve your issue but you do not provide the essential information of why is this an issue and what do you want to achieve at the end. I suggest you first start telling us the web site that you want to automate (or at least a screenshot of the pages), the end goal of the script, and a clear description of the issue. Unless you can adduce a more detailed documentation of your problem, I am afraid it is going to be hard to help you. Ok, I try to explain what I want to achieve: 1) I want to make a reservation on this website (https://pretix.eu/dnb/reservierung-f/). Everyday 9 AM tickets will be released. At this time the website looks like in the attached picture. To make the reservation I have to click on one of the boxes and then click on the "anmelden"-button. And I have to do it really fast because the tickets are gone in 1-2 seconds. => I want a program that automatically opens the website and does this steps at 9 AM. So far I have this (imo only the feature that the program starts itself at 9 AM is missing) #include <IE.au3> Call ("SignIn") Func SignIn () Global $oIE = _IECreate ("https://pretix.eu/dnb/reservierung-f") Local $button1 = _IEGetObjByName ($oIE,"item_66932") Local $button2 = _IEGetObjById ($oIE, "btn-add-to-cart") _IEAction ($button1,"click") Sleep(100) _IEAction ($button2,"click") EndFunc 2) If I didnt manage to get a ticket sometimes someone cancels its ticket. To make sure that I get this ticket (and not someone else) I have to click the refresh button constantly until a "free" box is shown again. Then I have to click on the box and the "anmelden"-button. So far I made a program that presses the refresh button every 4 seconds (just a bunch of mouse click commands) and I tried to make a program that quickly clicks on the box and the "anmelden"-button (the topic is about this program). The current problem I have is that I cannot switch very fast from the reload program to the second program and that the second problem is a little bit slower when it always has to restart the explorer. Why is the program in 1) and the program I posted at the beginning of the thread different? Because right now I manually refresh and then activate program with the down key (which does not work): #include <IE.au3> HotKeySet ( "{DOWN}","_start" ) HotKeySet ( "{UP}","_pause" ) HotKeySet ( "{END}","_exit" ) Global $go = 0 Global $oIE = _IECreate ("https://pretix.eu/dnb/reservierung-f") While(1) If($go) Then Local $button1 = _IEGetObjByName ($oIE,"item_66932") Local $button2 = _IEGetObjById ($oIE, "btn-add-to-cart") _IEAction ($button1,"click") Sleep(1) _IEAction ($button2,"click") $go=0 Else Sleep(1) EndIf WEnd Func _start() $go = 1 EndFunc Func _pause() $go = 0 EndFunc Func _exit() Exit EndFunc I appreciate any help! Edited August 4, 2020 by Franz135 Link to comment Share on other sites More sharing options...
Danp2 Posted August 4, 2020 Share Posted August 4, 2020 13 hours ago, Franz135 said: Global $oIE = _IECreate ("https://xxx") RTFM (or the help file in this case). 😜 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted August 4, 2020 Share Posted August 4, 2020 (edited) Thank you for taking the time to describe your issue. Here one way you could do it : expandcollapse popup#include <Constants.au3> #include <IE.au3> ; should be started at 8h50 every day If Not @Compiled Then Exit MsgBox ($MB_SYSTEMMODAL,"Error", "You must compile this script and add it to task scheduler") MsgBox ($MB_SYSTEMMODAL,"", "Reservation manager started", 5) Local $oIE = _IECreate ("https://pretix.eu/dnb/reservierung-f") While Int(@HOUR) < 9 Sleep (100) WEnd If SignIn($oIE, 20, 0) Then ; perform initial reservation with no sleep MsgBox ($MB_SYSTEMMODAL,"","Successful reservation") ElseIf SignIn ($oIE, 500, 1000) Then ; reservation attempt with 1 sec sleep at each iteration MsgBox ($MB_SYSTEMMODAL,"","Reservation found because of cancellation") Else MsgBox ($MB_SYSTEMMODAL,"","Unable to make reservation") EndIf _IEQuit ($oIE) Func SignIn (ByRef $oIE, $iAttempt, $iPause) Local $button1, $button2 For $i = 1 to $iAttempt Sleep ($iPause) _IEAction ($oIE, "refresh") _IELoadWait ($oIE) $button1 = _IEGetObjByName ($oIE,"item_66932") If Not IsObj ($button1) Then ContinueLoop $button2 = _IEGetObjById ($oIE, "btn-add-to-cart") If IsObj ($button2) Then _IEAction ($button1,"click") Sleep(100) _IEAction ($button2,"click") Return True EndIf Next Return False EndFunc I would personally put this compiled script into task scheduler to start every day just before 9h00AM. Edit : I just saw that there is a different button to push for cancellation part, you will need to adjust the script accordingly. Edited August 4, 2020 by Nine Franz135 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Franz135 Posted August 4, 2020 Author Share Posted August 4, 2020 Thank you for your effort! I will definitely try this tomorrow. Link to comment Share on other sites More sharing options...
Franz135 Posted August 4, 2020 Author Share Posted August 4, 2020 Two other questions: 1) How can I set a time like 8h45? Is this correct? While Int(@HOUR) < 8.45 2) When will the program stop if it doesnt find a reservation (how does it jump to "unable to make reservation")? Link to comment Share on other sites More sharing options...
Nine Posted August 4, 2020 Share Posted August 4, 2020 1) Like this : While Number(@HOUR & "." & @MIN) < 8.45 2) The parameters that are passed to the function SignIn tell the function how many times it has to loop before returning False. If it finds a match with the button objects, it will return True. So you must adjust the $iAttempt accordingly, to cover the duration that you want (increase the $iAttempt for a longer duration). Franz135 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Franz135 Posted August 4, 2020 Author Share Posted August 4, 2020 (edited) 49 minutes ago, Nine said: 2) The parameters that are passed to the function SignIn tell the function how many times it has to loop before returning False. If it finds a match with the button objects, it will return True. So you must adjust the $iAttempt accordingly, to cover the duration that you want (increase the $iAttempt for a longer duration). Which value did you set? I am not sure which number represents the number of attempts. 500, correct? Edit: And where did you set the 1 sec sleep at each iteration? How would I set 2 sec sleep for example? Edited August 4, 2020 by Franz135 Link to comment Share on other sites More sharing options...
Nine Posted August 4, 2020 Share Posted August 4, 2020 @Franz135 You will need to make a little effort here ! What values do you think I did set ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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