Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Read all tabs open in chrome for example.

Hey guys ^_^
So at the moment im working on this project i have so far... its almost done
But theres one thing that bothers me... my program does not read all the tabs i have open in chrome...
Code
Dim p() As Process = Process.GetProcessesByName("chrome")

        For Each procc As Process In p
            If Not ListBox1.Items.Contains(procc.MainWindowTitle) Then
                ListBox1.Items.Add(procc.MainWindowTitle)
            End If
        Next
This is one code im using at the moment. Wich is im having trouble at... i know im using the procc.MainWindowTitle wrong... i've tried to search anywhere to get all window names all currently window tabs... but im kinda losing hope in google ^-^
Code
Try
            Dim title As String = ListBox1.Items.Cast(Of String).First(Function(s) s.Contains("YouTube"))
            title = title.Replace("- YouTube - Google Chrome", "")
            Label2.Text = title
            Me.Text = ("♫♪ Song Playing ♪♫ : " + title)
        Catch ex As Exception

        End Try
And this is my second code, for the timer

//Edit: My goal is for the program to read all tabs i have open in chrome.
Check this out: https://stackoverflow.com/questions/7814...nd-firefox

They mention a library you can use to get URL's, so you should be able to get the window titles as well.
Quite hard for me since i only know some basics of VB.NET :/ im trying to get what they are trying to do there... but... its as good as my japanese :^|
(Nov 22, 2015 03:30 PM)pakalupapito Wrote:  Quite hard for me since i only know some basics of VB.NET :/ im trying to get what they are trying to do there... but... its as good as my japanese :^|

I guess don't bother from that example, because the comments mention it doesn't work on every major browser anymore...

But, doesn't chrome spawn a new process per window? Reading the mainwindowtitle property returns what?
(Nov 22, 2015 04:09 PM)He B TeMy Wrote:  I guess don't bother from that example, because the comments mention it doesn't work on every major browser anymore...

But, doesn't chrome spawn a new process per window? Reading the mainwindowtitle property returns what?

It returns the last active window ^-^ so if like... i have for example 1 window only youtube right... seperate from my other window with 6 tabs, it is still gonna read my last "chrome" window title, and not seperately
https://msdn.microsoft.com/en-us/library...s.85).aspx
[Image: irDbVUN.gif]
Yea i tried that too this morning @Agent Raigar... i've searched around and they mostly got it done till the EnumChildWindows function. I did not get further than that to be honest... My VB.NET knowledge/expectation isnt that amazing ^.^ but thanks :]
Well, p/invoke is usually helpful, that and some reading capabilities on the API documentation should be enough, i can't give you an example right now myself though.

http://www.pinvoke.net/default.aspx/user...ildwindows
Ya ill give it a go then^^ thanks man
To be honest im quite stuck with enumchildwindows... is there any example i could find somehow...
The link i posted has an example, but by looking at it it was written by some retard.

Anyway, it should be easy...

Code
EnumChildWindows(hwnd, ChildWindowsCallBack, IntPtr.Zero)

'ChildWindowsCallBack is where the child windows are enumerated, see https://msdn.microsoft.com/en-us/library/windows/desktop/ms633493%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

Private Shared Function ChildWindowsCallBack(hwnd As IntPtr, lParam As IntPtr) As Boolean
'Do what you need with the window parameters
Return True 'you must return true to keep enumerating the child windows.
End Function
I literally have been searching for 2 days now non-stop :/
for example... to add the childwindow of chrome right... to a listbox
should i be using Listbox1.items.add(childwindowscallback(hwnd:="chrome.exe"; 32))?


I found this aswell wich is quite interesting, but tbh... its so hard for me to understand... im just trying to get all window titles of chrome >-<
#edit nvm... can't post links... i found this if u google it "sendmessage notepad c#" first link, they work with childs aswell, but pretty hard to understand


/watch?v=9H8rQqy13Kk -> this might be interesting, but i get random numbers in my listbox now..
my god, do you even know what you're doing? Or how to read? Or how to... fml


EnumChildWindows, by the fucking name, it enumerates the child windows of ANOTHER window, the MainWindow for a process in your case, HWND is a type in c++, it has a meaning of 'handle to a window', which means you must pass the handle to the window (an IntPtr in .net) to the function that you want to get the child windows from, understood thus far?

the callback i declared above which you need in order to enumerate the child windows that i named 'ChildWindowsCallBack' has two parameters, the first one is another HWND (this time, the handle is retrieved for you to do what you need to do with it) the second one doesn't matter in this case.

So... if you want to get the window text from each HWND, you'll have to use the https://msdn.microsoft.com/en-us/library...owText API which this time it seems to have a nice example on p/invoke, http://www.pinvoke.net/default.aspx/user...windowtext
Then, if you still don't understand where's the text on the window, it's on the variable "sb" which is a stringbuilder in the example above.
Code
Private Shared Function ChildWindowsCallBack(hwnd As IntPtr, lParam As IntPtr) As Boolean
'Do what you need with the window parameters
Return True 'you must return true to keep enumerating the child windows.
End Function

Where 'Do what you need with the window parameters, is where i use the get text api right...?
(Nov 28, 2015 09:44 AM)pakalupapito Wrote:  
Code
Private Shared Function ChildWindowsCallBack(hwnd As IntPtr, lParam As IntPtr) As Boolean
'Do what you need with the window parameters
Return True 'you must return true to keep enumerating the child windows.
End Function

Where 'Do what you need with the window parameters, is where i use the get text api right...?

yes... you pass the 'hwnd' parameter (1st one) to the getwindowtext function.
p/invoke has an example.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by blackcoder00Oct 29, 2018 04:52 AM 4 273 Oct 29, 2018 04:52 AM
Last Post: wirelin3
[.NET] by PrillorFeb 6, 2017 10:25 AM 4 266 Feb 6, 2017 10:25 AM
Last Post: Prillor
[.NET] by Josh‎Jun 22, 2016 03:23 PM 2 207 Jun 22, 2016 03:23 PM
Last Post: Josh‎