Jump to content
Sign in to follow this  
xiaosongshu

AutoRegisterCourses

Recommended Posts

xiaosongshu

Hi,

I just started learning AutoIt two days ago (been a member for a while, just found out about AutoIt again) and wanted to create a bot that:

1) scans pixels at a specific section of the screen to see if the box changes from white to blue (closed to opened class) -> if it does, then drops 2 courses and then adds the course I want

2) clicks on a link on the left sidebar and then clicks on another link to the same site (in order to refresh the page; cannot manually refresh page or will default you to main site)

3) checks to see if timed out page is present (using another pixel search) and then enters login info and then goes back to the page with the class you're trying to add (page used in step 1)

So far I managed to implement 1) by itself, but I have now tried adding more If statements to make all three work. Would you guys mind checking my If Statements to see if it will do 1-3 correctly, and if there is anything else I need to fix? Thanks!

Edit: Updated!

;Auto Register Classes
HotKeySet("{F5}","BotOnOff")
HotKeySet("{F6}","ExitApp")

Tooltip("F5 = Activate Bot, F6 = Exit bot", 0, 0)
Dim $botting = False

Func BotOnOff()
   If $botting = False Then
      $botting = True
      ToolTip("Botting",0,0)
   Else
      $botting = False
      Tooltip("F5 = Bot, F6 = Exit bot", 0, 0)
   EndIf
EndFunc

Func ExitApp()
   Exit
EndFunc



While True
   
   If $botting = True Then
       ;If gray box turns blue
      $CoordsA = PixelSearch( 823, 296, 854, 313, 0x7794C9)
      
      If IsArray($CoordsA) Then
        ;drop Lecture and confirm
         MouseClick("left",665,409,1,0)
         Sleep(4000)
         MouseClick("left",603,418,1,0)
         Sleep(11000)
         
         ;drop Recitation and confirm
         MouseClick("left",665,409,1,0)
         Sleep(4000)
         MouseClick("left",603,418,1,0)
         Sleep(11000)
         
         ;add class and confirm
         MouseClick("left",836,303,1,0)
         Sleep(4000)
         MouseClick("left",757,330,3,100)
         
         ;end loop
         $botting = False
         
     Else
         ;refresh page
          MouseClick("left",79,356,1,0)
          Sleep(11000)
          MouseClick("left",135,372,1,0)
          Sleep(11000)
      EndIf
 EndIf
   
   If $botting = True Then
       ;If Session Timed Out
      $CoordsB = PixelSearch( 1036, 197, 1220, 232, 0x012169)
      
      If IsArray($CoordsB) Then
          ;Session Has Timed Out
          MouseClick("left",375,325,1,0)
          Sleep(11000)
          
          ;Enter Username
          MouseClick("left",156,492,1,0)
          Send("kjiang")
          Sleep(1000)
          
          ;Enter Password
          MouseClick("left",339,492,1,0)
          Send("Xiaoouxiaoou123~")
          Sleep(1000)
          
          ;login
          MouseClick("left",448,491,1,0)
          Sleep(11000)
          
          ;Register for course
          MouseClick("left",875,318,1,0)
          Sleep(11000)
          
          ;Select a Schedule
          MouseClick("left",938,279,1,0)
          Sleep(1000)
          
          ;Click on Schedule Choice (slow)
          MouseClick("left", 880,345,1,100)
          Sleep(4000)
      EndIf
  EndIf
   
WEnd
Edited by xiaosongshu

Share this post


Link to post
Share on other sites
xiaosongshu

Well I think I got everything working, except the small problem that sometimes even after I turn off the bot, it keeps running. But nobody has any suggestions to help a newcomer improve his first script?

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  

×