Skip to content

✨ Writing Your First LuaHook Script

Step 1: Choose a Target App

First, select a target application you want to Hook.

Step 2: Enable LuaHook in Lsposed and Check the Target App

  1. Open Lsposed and enable the LuaHook module.
  2. In the module settings, check the target app you want to Hook: Enable Module

Step 3: Add Target App in LuaHook

  1. Go back to LuaHook and navigate to the "Apps" page.
  2. Click the "+" button in the bottom right corner to expand the menu: Expand Add App
  3. Select "Add App": Click Add App
  4. Find the target app, check it, and click the "✔" in the bottom right corner to save: Save Selection
  5. Return to the app page, and you will see the app has been successfully added. Click it to enter the script management interface: Click App

Step 4: Create a Script

  1. Enter the "Multi-Script Management" page and click the "+" in the bottom right corner to create a new script: Create Script
  2. Give your script a name: Name Script
  3. After naming, click confirm to enter the script editing page.

Step 5: Write Script Code

Enter the following example code in the editor, which will pop up a Toast when the target app starts:

lua
imports "android.widget.Toast"

hook {
    class = "android.app.Activity",
    method = "onCreate",
    params = {"android.os.Bundle"},
    before = function(it) 

    end,
    after = function(it)
        Toast.makeText(it.thisObject, "Hello LuaHook!", Toast.LENGTH_SHORT).show()
    end
}

Step 6: Run and Test

  1. Click the "Triangle" button at the top to launch the target app: Launch App
  2. If you see a Toast message "LuaHook" popup at the bottom of the target app, Success Tip

✅ Summary

You have completed your first LuaHook Hook operation and successfully ran a simple script. Next, you can try:

Made with ❤️