Jump to content



Photo

Problems with DllCall function


  • Please log in to reply
3 replies to this topic

#1 guillermoares

guillermoares

    Seeker

  • Normal Members
  • 9 posts

Posted 06 July 2012 - 07:33 PM

Hi!

I'm building some automated tests for Internet Explorer 9 with AutoIT. I'm currently using keyboard shortcuts to control IE9, but I need these tests to run under any language. Since the shortcuts vary through different languages, I'm trying not to hardcode the key combinations but to take them from the IE9 .mui (internationalization) files. The file I'm trying to use right now is ieframe.dll.mui (which is under %windows%\%system32%\En-us). Supposedly, I should be able to get the information I want from this file using Windows API functions such as LoadAccelerators (MSDN). I'm not very C nor C++ experienced, so I'm having trouble both with the Windows API and with the AutoIT function DllCall.

This what I have so far:

AutoIt         
Global $kernel32 = OpenDll("kernel32.dll") Global $user32 = OpenDll("user32.dll") Global $ieframe = OpenDll("ieframe.dll") Local $accelerators = LoadAccelerators($ieframe, "") ConsoleWrite($accelerators & @LF) ; ================= user32.dll functions ==================== Func LoadAccelerators($moduleHandle, $acceleratorTable) Local $result = DllCall($user32, "HANDLE", "LoadAccelerators", "HANDLE", $moduleHandle, "str", $acceleratorTable) CheckDllCallError(@error) ConsoleWriteIfNull($result, "The accelerator is null") Return $result EndFunc ; ================= kernel32.dll functions ==================== Func FindResource($moduleHandle, $resourceId, $resourceType) Local $result = DllCall($kernel32, "HANDLE", "FindResource", "HANDLE", $moduleHandle, "int", $resourceId, "int", $resourceType) CheckDLLCallError(@error) ConsoleWriteIfNull($result, "The resource handle is null") Return $result EndFunc Func LoadResource($moduleHandle, $resourceHandle) Local $result = DllCall($kernel32, "HANDLE", "LoadResource", "HANDLE", $ieframe, "HANDLE", $resourceHandle) CheckDLLCallError(@error) ConsoleWriteIfNull($resource, "The resource is null") Return $result EndFunc ; ================= Utils ==================== Func ConsoleWriteIfNull($var, $message) If not $var Then ConsoleWriteError($message & @LF) EndIf EndFunc Func CheckDLLCallError($error) Switch $error Case 1 ConsoleWriteError("Unable to use the DLL file" & @LF) Case 2 ConsoleWriteError("Unknown return type" & @LF) Case 3 ConsoleWriteError("Function not found in the DLL file" & @LF) Case 4 ConsoleWriteError("Bad number of parameters" & @LF) Case 5 ConsoleWriteError("Bad parameter" & @LF) Case Else EndSwitch EndFunc Func OpenDll($dllName) Local $dll = DllOpen($dllName) If ($dll = -1) Then ConsoleWriteError("Could not load " & $dllName & @LF) EndIf Return $dll EndFunc


It seems that LoadAccelerators is returning a null value. I guess that I'm not passing the right argument/argument types, but I already tried several things to no avail.

Any help would be appreciated!





#2 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,836 posts

Posted 06 July 2012 - 07:46 PM

What is it you're trying to accomplish with the shortcut keys? There is an Internet Explorer UDF that might help with this and eliminate using hotkeys all together.

Also, LoadAccelerators loads the accellerators, I don't believe it will give you anything back. Another thing, you're sending this a blank accelerator table, you're probably unsetting them with that. I'm not that familiar with what that does, so I could be guessing here. :)

How to ask questions the smart way!

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.

Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.

_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#3 guillermoares

guillermoares

    Seeker

  • Normal Members
  • 9 posts

Posted 06 July 2012 - 07:58 PM

We are making test scripts for IE9. The company in which I'm working is making compatibility layers for different versions of IE (i.e. these layers could let you run IE6 in Windows 7). We were also asked to ship a (weak) test suit in AutoIT. These test suit should try every possibility that the IE UI gives (i.e. Try doing File -> open, Try doing Edit -> Select all, etc, etc, etc). I'm using the hotkeys to simulate these user inputs.

You're right about that function. I'm pretty lost messing around with the Windows API :P. Anyway, I can't figure out how to translate the (darn confusing) data types I see in the WinAPI documentation to the data types specified in the DllCall function documentation.

Also, yes, I know that the arguments I used in the code for the LoadAccelerators are obviously wrong and will never ever work... I tried several other things before, that was just testing.

#4 guillermoares

guillermoares

    Seeker

  • Normal Members
  • 9 posts

Posted 10 July 2012 - 04:10 PM

Bump.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users