question

Zaug-0766 avatar image
0 Votes"
Zaug-0766 asked Zaug-0766 edited

findwindow

I have a question with findwindow: I said findwindow a find VALORANT window, but even anywhere it triggers events under findwindow, I want it to run only in VALORANT window
code this :
int hwnd = FindWindow(null, "VALORANT");
SetForegroundWindow(hwnd);
SendKeys.SendWait("+{ENTER}iyi oyunlar...{ENTER}");

windows-forms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered Zaug-0766 edited

Are you sure "VALORANT" is the right title ?
Have you checked if hwnd is not null ?

A test with Notepad shows it works :

 // Class = "Notepad"
 IntPtr hWnd = FindWindow("Notepad", null);
 if (hWnd != IntPtr.Zero)
 {                    
     SwitchToThisWindow(hWnd, true);
     SendKeys.SendWait("+{ENTER}iyi oyunlar...{ENTER}");                   
 }

with :

 [DllImport("User32.dll", SetLastError = true)]
 public static extern bool SwitchToThisWindow(IntPtr hWnd, bool fAltTab);
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

i make this , but only make once

0 Votes 0 ·

you write if hwnd != intptr.zero , write once , because this???
i make a keydown event (with keyboard hook) and i want wwhen i press f7, make this

0 Votes 0 ·

I don't understand what you mean
I just test if the window has been found
(in this case, if Notepad is already launched to find its main window, then send keys on this window, after it has been set to foreground)

0 Votes 0 ·
Show more comments