[英]How to get process id of currently active tab on browser using JNI
我嘗試下面的代碼,
但是它給了我瀏覽器父線程id。我想知道使用jni當前活動的選項卡進程ID。
使用Example會非常有幫助。 提前致謝。
HWND hwnd = User32.INSTANCE.GetForegroundWindow();
IntByReference pId=new IntByReference();
int tmp= User32.INSTANCE.GetWindowThreadProcessId(hwnd, pId);
int processId=pId.getValue();
System.out.println("processId : "+processId);
您無法使用Win32 API獲取tab的進程ID,因為它取決於瀏覽器。 並非所有瀏覽器都在單獨的進程中執行選項卡。
對於谷歌瀏覽器,您可以為此使用它的API 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.