How to send a flag/data as an input to installed android app?
Yes, this is exactly what ADB is for. Part of the Android SDK, it's designed for developers but useful for any user. After you turn on "USB Debugging" in the device's developer options, it can connect to the device via Wi-Fi or USB. Depending on the particular app you want to control, you might control it by:


sending an intent the app understands, using am start
copying a file to the device using adb push
sending fake keyboard or touch-screen inputs using adb input


Find out more about ADB on the official site or the tag on this site: adb.

Another option is to use an automation app such as tasker or automate. With these tools, you can visually create something like a "script" of actions: changing system settings, and sending intents to apps. Many apps integrate with these tools, offering special intents to control them and even a nice menu to choose them from. You can set this script to be triggered directly by a single touch on the screen, or indirectly by a change in some other state: e.g. when the phone sees a particular Wi-Fi network, when it's in a geofence, or when it connects to a Bluetooth device.