you are most likely returning pointer to non existent data, if you construct std::string and return the char* of that string, the string deallocated once it leaves the function, making the returned pointer points to deallocated memoryauto get_text = (Il2CppString*(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_text(0)"); return get_text(this)->c_str();
i have used that but i have problems with getting the text after the user submits/entersIf your game is unity, you can try to invoke
TouchScreenKeyboard_InternalConstructorHelper on TouchScreenKeyboard class
class TouchScreenKeyboard {
public:
// Static Methods
static boolean isSupported() {
auto get_isSupported = (boolean(*)())Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_isSupported(0)");
return get_isSupported();
}
static TouchScreenKeyboard* Open(const char* value, int type, boolean autocorrection, boolean multiline){
auto open = (TouchScreenKeyboard*(*)(Il2CppString*,int,boolean,boolean))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>Open(4)");
return open(Il2CppString::Create(value), type, autocorrection, multiline);
}
// Other methods
const char* getText(){
auto get_text = (Il2CppString*(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_text(0)");
return get_text(this)->c_str();
}
void setText(const char* value){
auto set_text = (void(*)(void*,Il2CppString*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>set_text(1)");
set_text(this, Il2CppString::Create(value));
}
boolean isActive(){
auto get_active = (boolean(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_active(0)");
return get_active(this);
}
boolean isDone(){
auto get_done = (boolean(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_done(0)");
return get_done(this);
}
boolean isCanceled(){
auto get_wasCanceled = (boolean(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_wasCanceled(0)");
return get_wasCanceled(this);
}
};
TouchScreenKeyboard input;
if(ImGui::Button("Click me!")){
input = TouchScreenKeyboard::Open("", 0, false, true);
}
if (input->IsDone()) {
ImGui::Text("%s", input->getText());
}
get_text(this)->c_str();
while (true) {
bool active = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_active")) -> Invoke < bool > ();
if (!active) {
break; // exit loop
}
m_Text = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_text")) -> Invoke < UnityResolve::UnityType::String * > ();
usleep(100000); // sleep for 100ms to reduce cpu usage
}
It's seem your code are correct, however you can try to log your
C++:get_text(this)->c_str();
Is it showing some text or not, this is my code, idk it's good or not, but it's work like a charm
C++:while (true) { bool active = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_active")) -> Invoke < bool > (); if (!active) { break; // exit loop } m_Text = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_text")) -> Invoke < UnityResolve::UnityType::String * > (); usleep(100000); // sleep for 100ms to reduce cpu usage }
hey is there any way we could talk outisde this forum, discord.
basically every property works and it captures the input but the string itself comes as empty characters, although the strlen says its length is for example 5 but the string is empty
Sure, you can dm me here and I'll give you my discord.hey is there any way we could talk outisde this forum, discord.
you are most likely returning pointer to non existent data, if you construct std::string and return the char* of that string, the string deallocated once it leaves the function, making the returned pointer points to deallocated memoryauto get_text = (Il2CppString*(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_text(0)"); return get_text(this)->c_str();