Sign in to follow this  
Followers 0
WSCPorts

have trouble with GUI's and API

4 posts in this topic

#1 ·  Posted (edited)

investigate using Dll's and structures in autoit... so with my test id like to actually help ppl by showing them good programming skills but i dont got em... here my problem i cant get SetWindowTextA to work on a GuiCtrlInput im using a test method for runtime access to API.. any suggestions on how to program ARE GREATLY appreciated as being a newb to autoit but not to Coding, i miss certain nuanences.. this is my first time using Dllstructures period so dont critisize my use of them for structured-oriented programming ... :/

#include <GUIConstants.au3>
Dim $Krnl32 = ("Kernal32.Dll")
Dim $User32 = ("USER32.Dll")

Func LibFree($hLibModule)
$hKrnl = DllOpen($Krnl32)
DllCall($hKrnl, "long", "FreeLibrary", "long", $hLibModule) 
$ClnKrnl = DllClose($hKrnl)
EndFunc;==>End func LibFree

Func LibLoad( $lpLibFileName )
$hKrnl = DllOpen($Krnl32)
DllCall($hKrnl, "long", "LoadLibraryA", "str", $lpLibFileName)
$ClnKrnl = DllClose($hKrnl)
EndFunc;==>End Func LibLoad

Func GetProcAddress($hModule, $lpProcName)
$hKrnl = DllOpen($Krnl32)
DllCall($hKrnl, "long", "GetProcAddress", "long", $hModule, "str", $lpProcName)
$ClnKrnl = DllClose($hKrnl)
EndFunc;==>End Func GetProcAddress

Func CallWindowProc($lpPrecWndFunc, $hWnd, $Msg, $wParam, $iParam)
$hUser = DllOpen($User32)
DllCall($hUser, "long", "CallWindowProcA", "long", $lpPrecWndFunc, _
"hwnd", $hWnd, "str", $Msg, "int", $wParam, "long", $iParam)
$ClnUser = DllClose($hUser)
EndFunc;==>EndFunc CallWindowProc

Dim $RECT = "int;int;int;int";Rectangle or square
$Wnd = DllStructCreate($RECT)
;define elements of the structure
 DllStructSetData($Wnd,1,50)
 DllStructSetData($Wnd,2,50)
 DllStructSetData($Wnd,3,200)
 DllStructSetData($Wnd,4,200)

Dim $Left = DllStructGetData($Wnd, 1)
Dim $Top = DllStructGetData($Wnd,2)
Dim $Bottom = DllStructGetData($Wnd, 3)
Dim $Right = DllStructGetData($Wnd, 4)
 GuiCreate("TESTING", $Right, $Bottom, $Left, $Top)
$input = GUICtrlCreateInput ( "test1", 10,  5, 300, 20)
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)
GUISetState (@SW_SHOW)

Const $WM_SYSCOMMAND = 274
Const $WM_UPDATE = 1025

Func Test()
$tHandle = WinGetHandle("TESTING", "test1")
Dim $lib = LibLoad($User32) 
Dim $ProcAddy = GetProcAddress($lib, "SetWindowTextA")
CallWindowProc($ProcAddy, $tHandle, "Hello !", $WM_UPDATE, 0)
LibFree($lib)
EndFunc;==>End FUNC TEST

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $btn
               Test()
       EndSelect
Wend

hopefully this doesnt qualify as obfuscated Code :/ prolly will to some ppl

Edited by WSCPorts

http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]

Share this post


Link to post
Share on other sites



your functions dont return anything exept 0

take this for ex:

Func GetProcAddress($hModule, $lpProcName)
$hKrnl = DllOpen($Krnl32)
DllCall($hKrnl, "long", "GetProcAddress", "long", $hModule, "str", $lpProcName)
$ClnKrnl = DllClose($hKrnl)
EndFunc;==>End Func GetProcAddress

should be

Func GetProcAddress($hModule, $lpProcName)
$hKrnl = DllOpen($Krnl32)
$return = DllCall($hKrnl, "long", "GetProcAddress", "long", $hModule, "str", $lpProcName)
$ClnKrnl = DllClose($hKrnl)
return $return[0]
EndFunc;==>End Func GetProcAddress

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

When you are setting text to controls in YOUR AutoIt GUI

there is simple way: GUICtrlSetData ($input ,"Hello!")

And with possibility od DllCall in AutoIt your code

LoadLibraryA
GetProcAddress
CallWindowProcA
FreeLibraryA

is OBSOLETE.

Look at HelpFile and search forum for examples of using

DllCall and GUICtrlSetData ...

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