Fazer Posted March 2, 2020 Share Posted March 2, 2020 Hi guys, I'm absolutly new to AutoIT and programming at all. Nevertheless I find it pretty exiting to solve a repetetive problem by coding a script. Unfortunately, I have just reached a point where I don't know what to do. The aim of the program is to perform mouse clicks on a certain website fully automatically at certain times. The script should be executed after the start of a virtual machine and should be structured as follows (please see figure): 1. Examine, if it shall either register or deregister, depending on the day of the week and the time of day, i.e. there are two different procedures 2. Establishing a VPN tunnel to a specific network (via Cisco Anyconnect Secure Mobility Client) 3. Carry out registration or deregistration (after previously examined) 4. End VPN 5. Shut down the VM As I understand, the code runs from the first line. Unfortunately, I don't quite know how to structure it for the script to work. I thought about packing individual program components into functions and then only executing them when they were needed. Some functions like the VPN should always be carried out, some only if they meet my conditions. Unfortunately, the code has not yet worked. expandcollapse popupAutoItSetOption('MouseCoordMode', 0) Global $WDAY, $HOUR $WDAY = @WDAY $HOUR= @HOUR If $WDAY = 3 OR 4 Then examination() EndIf Func examination() If $HOUR = 07 or 08 Then registration() ElseIf $HOUR = 12 or 13 Then deregistration() EndIf EndFunc Func registration() ShellExecute('C:\Program Files\Mozilla Firefox\firefox.exe', '-new-window website.com') WinWait('website title') WinActivate('website title') Sleep (3000) MouseClick('primary', 135, 342, 1, 0) Send('username') MouseClick('primary', 138, 377, 1, 0) Send('password') MouseClick('primary', 82, 408, 1, 0) Sleep (3000) MouseClick('primary', 93, 591, 1, 0) Sleep (3000) MouseClick('primary', 652, 520, 1, 0) Sleep (3000) MouseClick('primary', 728, 625, 1, 0) Sleep (3000) MouseClick('primary', 92, 246, 1, 0) MouseClick('primary', 1006, 21, 1, 0) EndFunc Func deregistration() MsgBox(0,0,0) EndFunc (MsgBox is just for testing, if my approach works out..., but it didn't) Please rate my approach. I would be very happy to receive a hint to solve the problem. Thank you in advance for your support. Greetings Fazer Link to comment Share on other sites More sharing options...
Nine Posted March 2, 2020 Share Posted March 2, 2020 (edited) Your if are badly formatted. It should be : If $WDAY = 3 OR $WDAY = 4 Then Also @HOUR returns a string not a numeric. Finally you should consider using a Web Browser UDF, instead of mouseClicks (WebDriver for Firefox). Edited March 2, 2020 by Nine Fazer 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...
Fazer Posted March 3, 2020 Author Share Posted March 3, 2020 19 hours ago, Nine said: Your if are badly formatted. It should be : If $WDAY = 3 OR $WDAY = 4 Then Also @HOUR returns a string not a numeric. Finally you should consider using a Web Browser UDF, instead of mouseClicks (WebDriver for Firefox). It's working now. Thank you @Nine for this great advice! Really appreciate it! 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