Ho un problema con un programma che perde lo stato attivo. Non è il mio programma. Come posso scrivere un secondo programma per impostare lo stato attivo su quella finestra ogni 1-2 secondi? È possibile farlo?Come impostare lo stato attivo su un'altra finestra?
7
A
risposta
8
È possibile utilizzare seguente API Win32 se si vuole portare qualche altro programma/processo
[DllImport("coredll.dll")]
static extern bool SetForegroundWindow (IntPtr hWnd);
private void BringToFront(Process pTemp)
{
SetForegroundWindow(pTemp.MainWindowHandle);
}
+11
Su Windows, dovresti usare 'user32.dll', perché' coredll.dll' è per Windows Mobile! –
2
utilizzare Spy ++ o altri strumenti di interfaccia utente per trovare il nome della classe della finestra che si desidera mettere a fuoco, dire la sua: focusWindowClassName . Quindi aggiungi le seguenti funzioni:
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern bool ShowWindow(IntPtr handle, int nCmdShow);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
Then:
IntPrt hWnd = FindWindow("focusWindowClassName", null); // this gives you the handle of the window you need.
// then use this handle to bring the window to focus or forground(I guessed you wanted this).
// sometimes the window may be minimized and the setforground function cannot bring it to focus so:
/*use this ShowWindow(IntPtr handle, int nCmdShow);
*there are various values of nCmdShow 3, 5 ,9. What 9 does is:
*Activates and displays the window. If the window is minimized or maximized, *the system restores it to its original size and position. An application *should specify this flag when restoring a minimized window */
ShowWindow(hWnd, 9);
//The bring the application to focus
SetForegroundWindow(hWnd);
// you wanted to bring the application to focus every 2 or few second
// call other window as done above and recall this window again.
Problemi correlati
- 1. Come impostare lo stato attivo su una finestra modale javascript?
- 2. Impostare lo stato attivo su un pulsante
- 3. Come impostare lo stato attivo su un materiale TextField?
- 4. Come impostare lo stato attivo su UserControl (renderlo selezionabile)?
- 5. Come impostare lo stato attivo su un elemento in Elm?
- 6. WPF: Impossibile impostare lo stato attivo
- 7. Impostare lo stato attivo sull'elemento contented div
- 8. Summernote: impostare lo stato attivo dopo l'inizializzazione
- 9. Come impostare lo stato attivo del widget Tkinter?
- 10. Impostare lo stato attivo su UITextField in tableCell
- 11. Esiste un modo affidabile per attivare/impostare lo stato attivo su una finestra usando C#?
- 12. come impostare lo stato attivo sulla casella di testo in una finestra di dialogo utilizzando C#
- 13. Come impostare lo stato attivo sull'elemento con associazione?
- 14. Come si imposta lo stato attivo su Textfield in Swing?
- 15. WPF: Rileva quando la finestra perde lo stato attivo
- 16. Impostare lo stato attivo sul campo in DIV dinamicamente caricato
- 17. Impostare lo stato attivo sull'ingresso successivo in jQuery?
- 18. verifica lo stato dell'utente (attivo, inattivo) su una pagina Web
- 19. Imposta lo stato attivo su un componente con Apache Wicket?
- 20. Come impostare lo stato attivo su qualsiasi oggetto in MS Access utilizzando VBA
- 21. Come impostare lo stato attivo su una particolare riga in un datagrid/gridview?
- 22. Come impostare lo stato attivo su un controllo all'interno di un controllo personalizzato?
- 23. Come impostare lo stato attivo su un TextView all'avvio di un'attività?
- 24. Come impostare lo stato attivo su un controllo in un'applicazione Windows Form?
- 25. Come posso impostare lo stato attivo su un'applicazione che è già in esecuzione?
- 26. Come impostare lo stato attivo su un widget del pulsante a livello di programmazione?
- 27. Come impostare lo stato attivo sulle finestre figlio e apri quando viene inserito il tabulatore
- 28. Impostare lo stato attivo su input JSF specifico sul caricamento della pagina
- 29. Come sapere quale finestra ha lo stato attivo e come modificarla?
- 30. Sposta lo stato attivo su un campo particolare
Stai dicendo che vorresti che lo stato attivo passasse tra il tuo programma e questo secondo secondo programma ogni secondo? O nella tua applicazione vorrebbe portare l'altro programma in primo piano ogni 2 secondi (nel caso in cui sia andato di nuovo sul retro)? – Faraday
È un programma (processo di programma diverso) o un modulo figlio? –
il suo programma diffrent e voglio che il mio programma lo porti solo a fuoco ... – Endiss