Jump to content

Requesting Help With Terminate Function


Recommended Posts

Hi everyone, I'm still a beginner when it comes to AutoIT and I'm mostly using it with excel to analyze some data. I'm getting a little bit better and learning more and more each day, and I ran across an example of a terminate function that I've implemented into my script. The issue is it works sometimes, and other times it doesn't terminate the script (but I will see a new autoit icon show in my taskbar each time I attempt to terminate the script). Here is the function in question:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{q}", "Terminate") ;Press q to terminate program

;My script here

While 1
Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause

Func Terminate()
Exit 0
EndFunc ;==>Terminate

The script I'm using this in is 1692 lines and runs for about 75 seconds. The reason I want this terminate function is sometimes I'll make a change, and realize I screwed something up and the rest of the actions the script will take are wrong, so I need to cancel it instead of wasting the next 75 seconds. If I terminate or pause the script within about 30 seconds, it seems to always work then. If I try to pause or terminate the script after 30 seconds, it seems to stop working. Any ideas?

Link to comment
Share on other sites

  • Moderators

corvetteaustin24l,

Welcome to the AutoIt forum. :)

Without seeing the script you are running in detail it is impossible to give a complete answer, but I would think it likely that your script is running some form of external application which take some time to return - while this is happening the HotKey is unlikely to be honoured. If you could post the rest of your script than we might well be able to offer some better focused assistance. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Here's all 1628 lines (made some edits from previous versions)

;-------------------------------------------------------------------
;Match Scheduler Game 2 - Updated 11/18/2012
;-------------------------------------------------------------------
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{q}", "Terminate") ;Press q to terminate program

;Process
;1 - Away Team Scheduler
;2 - Away Team StatGrabber
;3 - Home Team Scheduler
;4 - Home Team StatGrabber
;5 - Result Tracker
;5 - Update Results

;Game 2 - Line 800

;-------------------------------------------------------------------
;Away Team Scheduler Game 1 - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(500);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Resets tab to top of the page
Send("{CTRLDOWN}")
Send("{HOME}")
Send("{CTRLUP}")
Sleep(50)

;Copies 1st Away Team - Cell d2
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("d2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Away Tab
MouseMove(89,1009,0) ;moves mouse to Away tab
sleep(50)
MouseClick("left")
sleep(50)

;Paste Away team into Away tab
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)

;Copies Away team stat website link row number
Send("{RIGHT}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switch to Links tab
MouseMove(262,1009,0) ;moves mouse to Link tab
sleep(50)
MouseClick("left")
sleep(50)

;Resets link search to top of the Link tab
Send("{CTRLDOWN}")
Send("{HOME}")
Send("{CTRLUP}")
Sleep(50)
Send("{RIGHT}") ;Moves mouse to B1
Send("{RIGHT}") ;Moves mouse to C1
Sleep(50)

;Highlights Column C to search for row number
MouseMove(581,180,0) ;Highlights column C
sleep(50)
MouseClick("left")
sleep(50)

;Searches Column C for row number
Send("{CTRLDOWN}") ;Opens search
Send("f")
Send("{CTRLUP}")
Sleep(50)
Send("{CTRLDOWN}") ;Pastes row number
Send("v")
Send("{CTRLUP}")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{ESC}") ;Closes out of search window
Sleep(50)

;Copies Away team stat website
Send("{LEFT}") ;Moves mouse from column C to column B
Sleep(50)
Send("{LEFT}") ;Moves mouse from column B to column A
Sleep(100)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Away Tab
MouseMove(89,1009,0) ;moves mouse to Away tab
sleep(50)
MouseClick("left")
sleep(50)

;Pastes Away team stat website cell a2
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("a2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}") ;Pastes Away team's stat website
Send("v")
Send("{CTRLUP}")
Sleep(50)

;-------------------------------------------------------------------
;Team StatGrabber - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(250);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Opens team stats in Chrome
MouseMove(65,208,0)
sleep(200)
MouseClick("left")
sleep(2200);gives website time to load
;Makes Chrome maximized on the left monitor
Send("{ALTDOWN}")
Sleep(50)
Send("{SPACE}")
Sleep(50)
Send("{ALTUP}")
Sleep(50)
Send("x")
Sleep(50)

;Sends "/stats" to go to team stats page
Send("{F6}")
Sleep(50)
Send("{RIGHT}")
Sleep(50)
Send("/stats")
Sleep(50)
Send("{ENTER}")
Sleep(2500)


;Copy sections: Overall Statistics, Shooting Statistics, and Scoring Statistics
MouseMove(639,314,0);data start
MouseDown("left")
sleep(50)
MouseMove(667,314,0);moves mouse to the right a little bit to ensure text copies
sleep(50)
Send("{PGDN}")
sleep(50)
MouseMove(1445,744,0)
MouseUp("left")
sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Alt tab to excel
Send("{ALTDOWN}")
Send("{TAB}")
Send("{ALTUP}")
Sleep(50)

;Paste copied team stats data into excel
MouseMove(84,240,0) ;moves mouse to cell A3
Sleep(50)
MouseClick("left") ;Clicks to focus on cell A3
Sleep(50)
MouseClick("right") ;Paste copied team stats data into cell A3 as plain text
Send("s")
Sleep(50)
Send("t")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Remove rank #'s for each stat
Send("{CTRLDOWN}") ;Find and replace shortcut
Send("h")
Send("{CTRLUP}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("n")
Sleep(100)
Send("{(}{#}{*}{)}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Sleep(100)

;Remove % signs from each stat
Sleep(100)
Send("n") ;find and replace is already open from removing rank #'s, "n" is shortcut to the find option
sleep(100)
Send("{%}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Send("{ESC}")
Sleep(100)

;Make all cells general so random stats don't show up with percent signs
MouseMove(12,171,0) ;moves mouse to top left corner of excel spreadsheet
Sleep(50)
MouseClick("left") ;Clicks to focus corner to highlight whole page
Sleep(50)
MouseMove(752,69,0) ;moves mouse to cell type dropdown
Sleep(50)
MouseClick("left") ;Clicks to focus on dropdown menu
Send("g") ;selects general text option
Send("{ENTER}")
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left") ;Clicks on A1 to unfocus all cells
Sleep(50)

;-------------------------------------------------------------------
;Home Team Scheduler Game 1 - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(500);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Resets tab to top of the page
Send("{CTRLDOWN}")
Send("{HOME}")
Send("{CTRLUP}")
Sleep(50)

;Copies 1st Home Team - Cell f2
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("f2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Home Tab
MouseMove(142,1009,0) ;moves mouse to Home tab
sleep(50)
MouseClick("left")
sleep(50)

;Paste Home team into Home tab
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)

;Copies Home team stat website link row number
Send("{RIGHT}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switch to Links tab
MouseMove(262,1009,0) ;moves mouse to Link tab
sleep(50)
MouseClick("left")
sleep(50)

;Resets link search to top of the Link tab
Send("{CTRLDOWN}")
Send("{HOME}")
Send("{CTRLUP}")
Sleep(50)
Send("{RIGHT}") ;Moves mouse to B1
Send("{RIGHT}") ;Moves mouse to C1
Sleep(50)

;Highlights Column C to search for row number
MouseMove(581,180,0) ;Highlights column C
sleep(50)
MouseClick("left")
sleep(50)

;Searches Column C for row number
Send("{CTRLDOWN}") ;Opens search
Send("f")
Send("{CTRLUP}")
Sleep(50)
Send("{CTRLDOWN}") ;Pastes row number
Send("v")
Send("{CTRLUP}")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{ESC}") ;Closes out of search window

;Copies Home team stat website
Send("{LEFT}") ;Moves mouse from column C to column B
Sleep(50)
Send("{LEFT}") ;Moves mouse from column B to column A
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Home Tab
MouseMove(142,1009,0) ;moves mouse to Home tab
sleep(50)
MouseClick("left")
sleep(50)

;Pastes Home team stat website cell a2
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("a2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)

;-------------------------------------------------------------------
;Team StatGrabber - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(250);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Opens team stats in Chrome
MouseMove(65,208,0)
sleep(200)
MouseClick("left")
sleep(2200);gives website time to load
;Makes Chrome maximized on the left monitor
Send("{ALTDOWN}")
Sleep(50)
Send("{SPACE}")
Sleep(50)
Send("{ALTUP}")
Sleep(50)
Send("x")
Sleep(50)

;Sends "/stats" to go to team stats page
Send("{F6}")
Sleep(50)
Send("{RIGHT}")
Sleep(50)
Send("/stats")
Sleep(50)
Send("{ENTER}")
Sleep(2500)


;Copy sections: Overall Statistics, Shooting Statistics, and Scoring Statistics
MouseMove(639,314,0);data start
MouseDown("left")
sleep(50)
MouseMove(667,314,0);moves mouse to the right a little bit to ensure text copies
sleep(50)
Send("{PGDN}")
sleep(50)
MouseMove(1445,744,0)
MouseUp("left")
sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Alt tab to excel
Send("{ALTDOWN}")
Send("{TAB}")
Send("{ALTUP}")
Sleep(50)

;Paste copied team stats data into excel
MouseMove(84,240,0) ;moves mouse to cell A3
Sleep(50)
MouseClick("left") ;Clicks to focus on cell A3
Sleep(50)
MouseClick("right") ;Paste copied team stats data into cell A3 as plain text
Send("s")
Sleep(50)
Send("t")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Remove rank #'s for each stat
Send("{CTRLDOWN}") ;Find and replace shortcut
Send("h")
Send("{CTRLUP}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("n")
Sleep(100)
Send("{(}{#}{*}{)}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Sleep(100)

;Remove % signs from each stat
Sleep(100)
Send("n") ;find and replace is already open from removing rank #'s, "n" is shortcut to the find option
sleep(100)
Send("{%}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Send("{ESC}")
Sleep(100)

;Make all cells general so random stats don't show up with percent signs
MouseMove(12,171,0) ;moves mouse to top left corner of excel spreadsheet
Sleep(50)
MouseClick("left") ;Clicks to focus corner to highlight whole page
Sleep(50)
MouseMove(752,69,0) ;moves mouse to cell type dropdown
Sleep(50)
MouseClick("left") ;Clicks to focus on dropdown menu
Send("g") ;selects general text option
Send("{ENTER}")
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left") ;Clicks on A1 to unfocus all cells
Sleep(50)

;-------------------------------------------------------------------
;Result Tracker Game 1 - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(500);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Site Projected Winner - Cell h2/k2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies Site Projected Winner
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("h2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("k2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Site Spread - Cell i2/l2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies Site Projected Winner
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("i2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("l2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Away ML- Cell e2/o2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies Away ML
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("e2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("o2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Home ML- Cell g2/p2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies Home ML
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("g2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("p2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Home Court - Cell j2/r2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies Home ML
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("j2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("r2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;-------------------------------------------------------------------
;Update Results Game 1 - Updated 11/18/2012
;-------------------------------------------------------------------

;Switches to Schedule Results tab
MouseMove(464,1009,0) ;moves mouse Schedule Results Tab
Sleep(50)
MouseClick("left")
Sleep(50)

;Copy Current Matchup Results
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(200)
Send("f2:s2")
Sleep(100)
Send("{ENTER}")
Sleep(500)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Paste Current Matchup Results
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("f7:s7")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)
Send("{CTRLDOWN}")
Sleep(50)
Send("{CTRLUP}")
Send("e")
Sleep(50)
Send("{ESC}")
Sleep(50)

;Section not necessary for Match Scheduler Game 2
;Copies Current Matchup Results so they are easily transfered to results spreadsheet
;Send("{CTRLDOWN}")
;Send("c")
;Send("{CTRLUP}")


;-------------------------------------------------------------------
;BEGIN GAME 2
;-------------------------------------------------------------------

;-------------------------------------------------------------------
;Away Team Scheduler Game 2 - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(500);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies 2nd Away Team - Cell d3
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("d3")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Away Tab
MouseMove(89,1009,0) ;moves mouse to Away tab
sleep(50)
MouseClick("left")
sleep(50)

;Paste Away team into Away tab
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)

;Copies Away team stat website link row number
Send("{RIGHT}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switch to Links tab
MouseMove(262,1009,0) ;moves mouse to Link tab
sleep(50)
MouseClick("left")
sleep(50)

;Resets link search to top of the Link tab
Send("{CTRLDOWN}")
Send("{HOME}")
Send("{CTRLUP}")
Sleep(50)
Send("{RIGHT}") ;Moves mouse to B1
Send("{RIGHT}") ;Moves mouse to C1
Sleep(50)

;Highlights Column C to search for row number
MouseMove(581,180,0) ;Highlights column C
sleep(50)
MouseClick("left")
sleep(50)

;Searches Column C for row number
Send("{CTRLDOWN}") ;Opens search
Send("f")
Send("{CTRLUP}")
Sleep(50)
Send("{CTRLDOWN}") ;Pastes row number
Send("v")
Send("{CTRLUP}")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{ESC}") ;Closes out of search window

;Copies Away team stat website
Send("{LEFT}") ;Moves mouse from column C to column B
Sleep(50)
Send("{LEFT}") ;Moves mouse from column B to column A
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Away Tab
MouseMove(89,1009,0) ;moves mouse to Away tab
sleep(50)
MouseClick("left")
sleep(50)

;Pastes Away team stat website cell a2
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("a2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}") ;Pastes Away team's stat website
Send("v")
Send("{CTRLUP}")
Sleep(50)

;-------------------------------------------------------------------
;Team StatGrabber - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(250);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Opens team stats in Chrome
MouseMove(65,208,0)
sleep(200)
MouseClick("left")
sleep(2200);gives website time to load
;Makes Chrome maximized on the left monitor
Send("{ALTDOWN}")
Sleep(50)
Send("{SPACE}")
Sleep(50)
Send("{ALTUP}")
Sleep(50)
Send("x")
Sleep(50)

;Sends "/stats" to go to team stats page
Send("{F6}")
Sleep(50)
Send("{RIGHT}")
Sleep(50)
Send("/stats")
Sleep(50)
Send("{ENTER}")
Sleep(2500)


;Copy sections: Overall Statistics, Shooting Statistics, and Scoring Statistics
MouseMove(639,314,0);data start
MouseDown("left")
sleep(50)
MouseMove(667,314,0);moves mouse to the right a little bit to ensure text copies
sleep(50)
Send("{PGDN}")
sleep(50)
MouseMove(1445,744,0)
MouseUp("left")
sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Alt tab to excel
Send("{ALTDOWN}")
Send("{TAB}")
Send("{ALTUP}")
Sleep(50)

;Paste copied team stats data into excel
MouseMove(84,240,0) ;moves mouse to cell A3
Sleep(50)
MouseClick("left") ;Clicks to focus on cell A3
Sleep(50)
MouseClick("right") ;Paste copied team stats data into cell A3 as plain text
Send("s")
Sleep(50)
Send("t")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Remove rank #'s for each stat
Send("{CTRLDOWN}") ;Find and replace shortcut
Send("h")
Send("{CTRLUP}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("n")
Sleep(100)
Send("{(}{#}{*}{)}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Sleep(100)

;Remove % signs from each stat
Sleep(100)
Send("n") ;find and replace is already open from removing rank #'s, "n" is shortcut to the find option
sleep(100)
Send("{%}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Send("{ESC}")
Sleep(100)

;Make all cells general so random stats don't show up with percent signs
MouseMove(12,171,0) ;moves mouse to top left corner of excel spreadsheet
Sleep(50)
MouseClick("left") ;Clicks to focus corner to highlight whole page
Sleep(50)
MouseMove(752,69,0) ;moves mouse to cell type dropdown
Sleep(50)
MouseClick("left") ;Clicks to focus on dropdown menu
Send("g") ;selects general text option
Send("{ENTER}")
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left") ;Clicks on A1 to unfocus all cells
Sleep(50)

;-------------------------------------------------------------------
;Home Team Scheduler Game 2 - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(500);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies 2nd Home Team - Cell f3
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("f3")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Home Tab
MouseMove(142,1009,0) ;moves mouse to Home tab
sleep(50)
MouseClick("left")
sleep(50)

;Paste Home team into Home tab
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)

;Copies Home team stat website link row number
Send("{RIGHT}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switch to Links tab
MouseMove(262,1009,0) ;moves mouse to Link tab
sleep(50)
MouseClick("left")
sleep(50)

;Resets link search to top of the Link tab
Send("{CTRLDOWN}")
Send("{HOME}")
Send("{CTRLUP}")
Sleep(50)
Send("{RIGHT}") ;Moves mouse to B1
Send("{RIGHT}") ;Moves mouse to C1
Sleep(50)

;Highlights Column C to search for row number
MouseMove(581,180,0) ;Highlights column C
sleep(50)
MouseClick("left")
sleep(50)

;Searches Column C for row number
Send("{CTRLDOWN}") ;Opens search
Send("f")
Send("{CTRLUP}")
Sleep(50)
Send("{CTRLDOWN}") ;Pastes row number
Send("v")
Send("{CTRLUP}")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{ESC}") ;Closes out of search window

;Copies Home team stat website
Send("{LEFT}") ;Moves mouse from column C to column B
Sleep(50)
Send("{LEFT}") ;Moves mouse from column B to column A
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Home Tab
MouseMove(142,1009,0) ;moves mouse to Home tab
sleep(50)
MouseClick("left")
sleep(50)

;Pastes Home team stat website cell a2
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("a2")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)

;-------------------------------------------------------------------
;Team StatGrabber - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(250);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Opens team stats in Chrome
MouseMove(65,208,0)
sleep(200)
MouseClick("left")
sleep(2200);gives website time to load
;Makes Chrome maximized on the left monitor
Send("{ALTDOWN}")
Sleep(50)
Send("{SPACE}")
Sleep(50)
Send("{ALTUP}")
Sleep(50)
Send("x")
Sleep(50)

;Sends "/stats" to go to team stats page
Send("{F6}")
Sleep(50)
Send("{RIGHT}")
Sleep(50)
Send("/stats")
Sleep(50)
Send("{ENTER}")
Sleep(2500)


;Copy sections: Overall Statistics, Shooting Statistics, and Scoring Statistics
MouseMove(639,314,0);data start
MouseDown("left")
sleep(50)
MouseMove(667,314,0);moves mouse to the right a little bit to ensure text copies
sleep(50)
Send("{PGDN}")
sleep(50)
MouseMove(1445,744,0)
MouseUp("left")
sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Alt tab to excel
Send("{ALTDOWN}")
Send("{TAB}")
Send("{ALTUP}")
Sleep(50)

;Paste copied team stats data into excel
MouseMove(84,240,0) ;moves mouse to cell A3
Sleep(50)
MouseClick("left") ;Clicks to focus on cell A3
Sleep(50)
MouseClick("right") ;Paste copied team stats data into cell A3 as plain text
Send("s")
Sleep(50)
Send("t")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Remove rank #'s for each stat
Send("{CTRLDOWN}") ;Find and replace shortcut
Send("h")
Send("{CTRLUP}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("n")
Sleep(100)
Send("{(}{#}{*}{)}")
Sleep(100)
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Sleep(100)

;Remove % signs from each stat
Sleep(100)
Send("n") ;find and replace is already open from removing rank #'s, "n" is shortcut to the find option
sleep(100)
Send("{%}")
Send("{TAB}")
Send("{BACKSPACE}")
Send("{TAB}")
Send("{TAB}")
Send("a")
Send("{SPACE}")
Send("{ESC}")
Sleep(100)

;Make all cells general so random stats don't show up with percent signs
MouseMove(12,171,0) ;moves mouse to top left corner of excel spreadsheet
Sleep(50)
MouseClick("left") ;Clicks to focus corner to highlight whole page
Sleep(50)
MouseMove(752,69,0) ;moves mouse to cell type dropdown
Sleep(50)
MouseClick("left") ;Clicks to focus on dropdown menu
Send("g") ;selects general text option
Send("{ENTER}")
MouseMove(66,196,0) ;moves mouse to cell A1
Sleep(50)
MouseClick("left") ;Clicks on A1 to unfocus all cells
Sleep(50)

;-------------------------------------------------------------------
;Result Tracker Game 2 - Updated 11/18/2012
;-------------------------------------------------------------------

;Focuses screen on the excel file
MouseMove(796,0,0);Moves mouse to top of left monitor
sleep(50)
MouseClick("left") ;Clicks to unfocus everything
sleep(500);this pause is necessary to let go of mouse otherwise the team stats link will not open

;Site Projected Winner - Cell h3/k2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies value
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("h3")
Sleep(50)
Send("{ENTER}")
Sleep(100)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("k2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Site Spread - Cell i3/l2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies value
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("i3")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("l2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Away ML- Cell e3/o2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies value
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("e3")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("o2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Home ML- Cell g3/p2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies value
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("g3")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("p2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

;Home Court - Cell j3/r2
;-------------------------------------------------------------------

;Verifies Schedule tab is in focus
MouseMove(385,1009,0) ;Selects Schedule tab
sleep(50)
MouseClick("left")
sleep(50)

;Copies value
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("j3")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Switches to Results Tab
MouseMove(315,1009,0) ;moves mouse to Results tab
sleep(50)
MouseClick("left")
sleep(50)

;Types in cell in the cell search box
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("r2")
Sleep(50)
Send("{ENTER}")
Sleep(50)

;Pastes value
Send("{CTRLDOWN}")
Sleep(400)
Send("v")
Send("{CTRLUP}")
Send("{CTRLDOWN}")
Send("{CTRLUP}")
Sleep(50)
Send("v")
Sleep(50)

Send("{ESC}")
Sleep(50)

;-------------------------------------------------------------------
;Update Results Game 2 - Updated 11/18/2012
;-------------------------------------------------------------------

;Switches to Schedule Results tab
MouseMove(464,1009,0) ;moves mouse Schedule Results Tab
Sleep(50)
MouseClick("left")
Sleep(50)

;Copy Current Matchup Results
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(200)
Send("f2:s2")
Sleep(100)
Send("{ENTER}")
Sleep(500)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")
Sleep(50)

;Paste Current Matchup Results
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("f8:s8")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(50)
Send("{CTRLDOWN}")
Sleep(50)
Send("{CTRLUP}")
Send("e")
Sleep(50)
Send("{ESC}")
Sleep(50)

;Copies Current Matchup Results so they are easily transfered to results spreadsheet
MouseMove(80,149,0) ;moves mouse to cell search box
sleep(50)
MouseClick("left")
sleep(50)
Send("f7:s8")
Sleep(50)
Send("{ENTER}")
Sleep(50)
Send("{CTRLDOWN}")
Send("c")
Send("{CTRLUP}")

While 1
Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause

Func Terminate()
Exit 0
EndFunc ;==>Terminate
Link to comment
Share on other sites

  • Moderators

corvetteaustin24,

I can see nothing there which should prevent the Hotkey from working - when I run the code (obviously without the apps that you use open on the screen) pressing "q" exits the script regardless of how far through it has gone.

I wonder if after a certain time you are activating an element in one of those GUIs which somehow is "swallowing" the keypress and so preventing AutoIt from recognising that you have pressed it. Try changing the keypress you use to terminate the script into something more exotic like Ctrl-Alt-q:

HotKeySet("^!q", "Terminate")

Any better? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

corvetteaustin24,

The problem we have is that we have absolutely no idea what is happening in this script as it is just a list of Mouse*, Send and Sleep lines - we cannot tell what each action does to the environment in which the script is running. :(

All I can suggest is to add some error-checking to see if you can locate the point at which the script no longer honours the HotKey. Amend the "Terminate" function to pop up a MsgBox when you action it - then at least you can see if the HotKey is actioned. If you can locate a point after which it is not, then that might give a clue as to why. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...