Sign in to follow this  
Followers 0
neogia

First stab at DllCall()

6 posts in this topic

Ok, so I did my homework by searching the forums, and I know a DLL is just a collection of functions, and I know how to find what functions are inside a DLL (ApiViewer), but I can't seem to figure out how to utilize DllCall().

My idea was to open the "Internet Properties" dialog (inetcpl.cpl), which I've done, and then select the fifth Tab, "Connections". I thought I would use the UDF GuiTab.au3, and the function _GUICtrlTabSetCurSel(), but it requires a "control id/control hWnd", and that's where I run into problems. At first I tried:

_GUICtrlTabSetCurSel("SysTabControl321", 4)

But I realized even before I ran that, that there was no reference to what window to do that in. So, since it's not an AutoIt3 GUI, and I didn't create the tab, I needed to use a dll to get the "control id/control hWnd". And here's that try:

$hWnd = WinGetHandle("Internet Properties", "")
$id = DllCall("user32.dll", "int", 'GetDlgCtrlID', 'hwnd', "SysTabControl321")
$id = $id[0]
_GUICtrlTabSetCurSel($id, 4)

As I'm sure is the case, I've done something horribly wrong, but I can't figure out what it is, and I haven't found anything that explains how to use DllCall() properly. I hope I've been clear in explaining my problem, and as always, any help is greatly appreciated. Thanks.

Fellow programmer in learning.


[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

...My idea was to open the "Internet Properties" dialog (inetcpl.cpl), which I've done,...

You can try this:
Run("rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4")
it opens to the tab you mentioned.

http://vbnet.mvps.org/index.html?code/system/controlpnl3.htm

...but keep chasing that hWnd...

edit - corrected link

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

You can try this:

Run("rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4")
it opens to the tab you mentioned.

http://vbnet.mvps.org/index.html?code/system/controlpnl2.htm

...but keep chasing that hWnd...

Awesome! I love how that works. But I have one question, how did you know that? Where do you find documentation for that type of a call? Also, is it even possible to do it the way I was doing it? I would like to know for future reference how to grab an hwnd or some type of pointer to a non-AutoIt GUI control. That would be handy. Thank you again though, this takes care of the messiness of Send("{RIGHT 4}") sending to the wrong window.

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Awesome! I love how that works. But I have one question, how did you know that? Where do you find documentation for that type of a call?...

A quote from this site: http://vbnet.mvps.org/index.html?code/system/controlpnl3.htm

Internet Explorer 4 Control Panel

module: INETCPL.CPL

command: rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl

result: displays Internet Properties, General Tab

command: rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,0

result: displays Internet Properties, General Tab (same as above)

command: rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,1

result: displays Internet Properties, Security Tab

command: rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,2

result: displays Internet Properties, Content Tab

command: rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,3

result: displays the Internet Control Panel, Connection Tab

command: rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4

result: displays the Internet Control Panel, Programs Tab

command: rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,5

result: displays the Internet Control Panel, Advanced Tab

There may be a better source, I stumbled on that site years ago. There are many more such "calls" on the site that you can just wrap an AutoIt "Run" around.

...Also, is it even possible to do it the way I was doing it? I would like to know for future reference how to grab an hwnd or some type of pointer to a non-AutoIt GUI control. That would be handy. Thank you again though...

You are welcome. Getting the handle might come in handy, but I don't have a handle on handles. (Pun fully intended.)

I read this in the help file under Controls:

This method of accessing controls is generally only designed for users who are familar with working with handles.

...and ran like the wind. Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I think I might be getting closer, but still with zero results:

$hwnd = WinGetHandle("Internet Properties")
$id = DllCall("user32.dll", "hwnd", "FindWindowExA", "hwnd", $hwnd, "hwnd", 0, "str", "SysTabControl32", "str", "")
_GUICtrlTabSetCurSel($id, 4)

I was thinking, is the result from WinGetHandle() in the same format as what is required by the DllCall()?


[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites

I think I might be getting closer, but still with zero results:

$hwnd = WinGetHandle("Internet Properties")
$id = DllCall("user32.dll", "hwnd", "FindWindowExA", "hwnd", $hwnd, "hwnd", 0, "str", "SysTabControl32", "str", "")
_GUICtrlTabSetCurSel($id, 4)

I was thinking, is the result from WinGetHandle() in the same format as what is required by the DllCall()?

I would not know - but I'll give you a free bump :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0