started making the native interfaces
This commit is contained in:
parent
a6b50d9e6b
commit
5bf0e4c226
@ -4,7 +4,7 @@
|
|||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="openjdk-19" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="openjdk-19" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@ -13,6 +13,8 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0")
|
testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0")
|
||||||
|
|
||||||
|
implementation("net.java.dev.jna:jna:latest.release")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import game_logic.runescape.RunescapeRoutines
|
import game_logic.runescape.RunescapeRoutines
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
RunescapeRoutines.fullRunIncense(0, 500, 500, 500)
|
// RunescapeRoutines.fullRunIncense(0, 4514, 4870, 308)
|
||||||
|
RunescapeRoutines.processInventoryAtFurnace(6888)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
|
import com.sun.jna.Native
|
||||||
|
import com.sun.jna.Pointer
|
||||||
|
import com.sun.jna.win32.StdCallLibrary
|
||||||
import params.MouseWiggleParams
|
import params.MouseWiggleParams
|
||||||
import java.awt.MouseInfo
|
import java.awt.MouseInfo
|
||||||
import java.awt.Point
|
import java.awt.Point
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for controllers that interact with the desktop.
|
* Interface for controllers that interact with the desktop.
|
||||||
*
|
*
|
||||||
@ -78,4 +82,34 @@ interface DesktopController {
|
|||||||
}
|
}
|
||||||
return Point(point.x + (xDel * xDir), point.y + (yDel * yDir))
|
return Point(point.x + (xDel * xDir), point.y + (yDel * yDir))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WindowsDesktopController : DesktopController {
|
||||||
|
|
||||||
|
internal interface User32 : StdCallLibrary {
|
||||||
|
interface WNDENUMPROC : StdCallLibrary.StdCallCallback {
|
||||||
|
fun callback(hWnd: Pointer?, arg: Pointer?): Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
fun EnumWindows(lpEnumFunc: WNDENUMPROC?, userData: Pointer?): Boolean
|
||||||
|
fun GetWindowTextA(hWnd: Pointer?, lpString: ByteArray?, nMaxCount: Int): Int
|
||||||
|
|
||||||
|
fun GetForegroundWindow(): Pointer?
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val INSTANCE = Native.load("user32", User32::class.java) as User32
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentlyActiveWindowName(): String {
|
||||||
|
val user32 = User32.INSTANCE
|
||||||
|
|
||||||
|
val windowText = ByteArray(512)
|
||||||
|
val hWnd = user32.GetForegroundWindow()
|
||||||
|
user32.GetWindowTextA(hWnd, windowText, 512)
|
||||||
|
val wText = Native.toString(windowText).trim { it <= ' ' } //i have no idea what this does
|
||||||
|
return wText
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -81,30 +81,38 @@ object RunescapeRoutines {
|
|||||||
// Loop to clean grimy herbs:
|
// Loop to clean grimy herbs:
|
||||||
// Withdraw herb preset, clean without dialog at bank
|
// Withdraw herb preset, clean without dialog at bank
|
||||||
if (volHerbs > 0) {
|
if (volHerbs > 0) {
|
||||||
|
println("\rCleaning herbs")
|
||||||
cleanHerbs(volHerbs, agent, bankPoint)
|
cleanHerbs(volHerbs, agent, bankPoint)
|
||||||
|
println("\rHerbs cleaned")
|
||||||
}
|
}
|
||||||
println("\rHerbs cleaned")
|
|
||||||
|
|
||||||
// Loop to cut magic logs into sticks:
|
// Loop to cut magic logs into sticks:
|
||||||
// Withdraw log preset, cut logs using hotkey at bank
|
// Withdraw log preset, cut logs using hotkey at bank
|
||||||
if (volLogs > 0) {
|
if (volLogs > 0) {
|
||||||
|
println("\rCutting logs into sticks")
|
||||||
cutIncenseSticks(volLogs, agent, bankPoint)
|
cutIncenseSticks(volLogs, agent, bankPoint)
|
||||||
|
println("\rLogs cut into sticks")
|
||||||
}
|
}
|
||||||
println("\rLogs cut into sticks")
|
|
||||||
|
|
||||||
// Loop to coat sticks in ashes:
|
// Loop to coat sticks in ashes:
|
||||||
// Withdraw ash preset, coat sticks using hotkey at bank
|
// Withdraw ash preset, coat sticks using hotkey at bank
|
||||||
if (volAshes > 0) {
|
if (volAshes > 0) {
|
||||||
|
println("\rCoating sticks in ashes")
|
||||||
coatIncenseSticks(volAshes, agent, bankPoint)
|
coatIncenseSticks(volAshes, agent, bankPoint)
|
||||||
|
println("\rSticks coated in ashes")
|
||||||
}
|
}
|
||||||
println("\rSticks coated in ashes")
|
|
||||||
|
|
||||||
// Loop to infuse clean herbs into sticks:
|
// Loop to infuse clean herbs into sticks:
|
||||||
// Withdraw herb preset, infuse sticks using hotkey at bank
|
// Withdraw herb preset, infuse sticks using hotkey at bank
|
||||||
if (volCleanHerbs > 0) {
|
if (volCleanHerbs > 0) {
|
||||||
|
println()
|
||||||
|
println("\rInfusing sticks with clean herbs")
|
||||||
infuseIncenseSticks(volCleanHerbs, agent, bankPoint)
|
infuseIncenseSticks(volCleanHerbs, agent, bankPoint)
|
||||||
|
println("\rClean herbs infused")
|
||||||
}
|
}
|
||||||
println("\rClean herbs infused")
|
|
||||||
|
|
||||||
val finish = System.currentTimeMillis()
|
val finish = System.currentTimeMillis()
|
||||||
agent.drawStar()
|
agent.drawStar()
|
||||||
|
|||||||
@ -60,4 +60,10 @@ class DesktopControllerTest {
|
|||||||
assertNotEquals(100, wiggly.x)
|
assertNotEquals(100, wiggly.x)
|
||||||
assertNotEquals(200, wiggly.y)
|
assertNotEquals(200, wiggly.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun devTest(){
|
||||||
|
val c = WindowsDesktopController()
|
||||||
|
println("TEXT: ${ c.getCurrentlyActiveWindowName()}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user