Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
Add function to close package advertisement modal
Browse files Browse the repository at this point in the history
In addition, the interact function is rewritten for clarity and now
assures the image to be searched exists locally on the filesystem before
attempting a search.

This new package ad close is bound to <key>Esc</key> by default.

Closes #26
  • Loading branch information
Nightfirecat committed Jul 23, 2016
1 parent 99f68a6 commit 9305f15
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ most customization features*!
up)
* <kbd>shift</kbd> + scroll-wheel-down : <kbd>Page Down</kbd>
(for scrolling chat down)
* <kbd>Esc</kbd> : Close the package advertisement modal window that appears
on login

##Features

Expand Down
5 changes: 5 additions & 0 deletions hotkeys.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ Return
interact()
Return

; close advertisement with Esc
Esc::
closeAd()
Return

; shift+scroll through the chat log with the in-game keybinds
+WheelUp::
scrollChat("up")
Expand Down
Binary file added img/close-low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 50 additions & 11 deletions realmscript.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ STARTUP:
FileInstall, img/change-high.png, img/change-high.png, 1
FileInstall, img/change-med.png, img/change-med.png, 1
FileInstall, img/change-low.png, img/change-low.png, 1
FileInstall, img/choose-low.png, img/choose-low.png, 1
FileInstall, img/enter-high.png, img/enter-high.png, 1
FileInstall, img/enter-med.png, img/enter-med.png, 1
FileInstall, img/enter-low.png, img/enter-low.png, 1
Expand Down Expand Up @@ -237,6 +238,33 @@ interact() {
stretched := false
}

closeAd() {
MouseGetPos, mousePosX, mousePosY
WinGetPos, , , winSizeX, winSizeY, A
stretched := !imageQualitySearch("close", imageLocX, imageLocY)
if (stretched) {
clientButtonX := 637
clientButtonY := 104
stretchedWindowPosition(clientButtonX, clientButtonY, stretchedX, stretchedY)
windowPosToClientPos(stretchedX, stretchedY, buttonCenterX, buttonCenterY)
} else {
imageSearchSizeX := 24
imageSearchSizeY := 25
windowPosToClientPos(imageLocX, imageLocY, posX, posY)
buttonCenterX := posX + Floor(imageSearchSizeX / 2)
buttonCenterY := posY + Floor(imageSearchSizeY / 2)
}
BlockInput, on
CoordMode, Mouse, Client
MouseMove, buttonCenterX, buttonCenterY
SendEvent {LButton Down}
SendEvent {LButton Up}
CoordMode, Mouse, Window
MouseMove, mousePosX, mousePosY
BlockInput, off
stretched := false
}

; item swap function
; move the mouse to the correct slot, double-click, and move it back
invSwap(slot) {
Expand Down Expand Up @@ -299,18 +327,29 @@ invSwap(slot) {
; imageLocX and imageLocY will not be set.
imageQualitySearch(imageName, byref imageLocX, byref imageLocY) {
WinGetPos, , , winSizeX, winSizeY, A ; winSizeX/Y have window size
ImageSearch, imageLocX, imageLocY, 0, 0, %winSizeX%, %winSizeY%
, img\%imageName%-low.png
if ErrorLevel {
ImageSearch, imageLocX, imageLocY, 0, 0, %winSizeX%, %winSizeY%
, img\%imageName%-high.png
if ErrorLevel {

; start with lowest quality level, and work up to high
imageQuality := "low"
ErrorLevel := 1
while ErrorLevel {
IfExist, img\%imageName%-%imageQuality%.png
{
ImageSearch, imageLocX, imageLocY, 0, 0, %winSizeX%, %winSizeY%
, img\%imageName%-med.png
if ErrorLevel {
; stretched screen or image not found
return false
}
, img\%imageName%-%imageQuality%.png
}
IfNotExist, img\%imageName%-%imageQuality%.png
{
return false
}

; increment quality for potential future image searches
if (imageQuality == "low"){
imageQuality := "med"
} else if (imageQuality == "med") {
imageQuality := "high"
} else if (imageQuality == "high") {
; stretched screen
return false
}
}
return true
Expand Down

0 comments on commit 9305f15

Please sign in to comment.