Sign in to follow this  
Followers 0
cheeseslice

help learning to use dll please

8 posts in this topic

hi,

I have only really started using autoit properly over the past week or so, I am learning it quickly enough but I was hoping that someone could either give me a quick crash course in dll's or point me towards a tutotial.

The dll I want to use is the user32.dll (http://msdn2.microsoft.com/en-us/library/ms633532.aspx)

The problem is I don't know how to put the information from msdn into the dllcall function.

I have been messing about with a test script just to try and lock the window but I'm not getting anywhere with it.

From the msdn am I right in thinking that the return value will be: int and the type will be: str. Paramater will be LSFW_LOCK ?

I really like to understand this.

#include <GUIConstants.au3>

$testWindow=guiCreate("test",200,200,200,200)

GUISetState(@SW_SHOW,$testWindow)

while 1

$guiMsg = GUIGetMsg()

Switch $guiMsg

case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

DllCall("user32.dll","int","uLockCode","str", "LSFW_LOCK")

Share this post


Link to post
Share on other sites



Func _LockSetFGWin($nLock = 0)
    Local Const $LSFW_LOCK      = 1
    Local Const $LSFW_ULOCK    = 2
    If $nLock Then 
        $nLock = $LSFW_LOCK
    Else
        $nLock = $LSFW_ULOCK
    EndIf
    Local $aDLLLock = DllCall("USER32.DLL", "int", "LockSetForegroundWindow", "uint", $nLock)
    If IsArray($aDLLLock) And $aDLLLock[0] > 0 Then Return 1
    Return SetError(1, 0, 0)
EndFunc
[


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Func _LockSetFGWin($nLock = 0)
    Local Const $LSFW_LOCK      = 1
    Local Const $LSFW_ULOCK    = 2
    If $nLock Then 
        $nLock = $LSFW_LOCK
    Else
        $nLock = $LSFW_ULOCK
    EndIf
    Local $aDLLLock = DllCall("USER32.DLL", "int", "LockSetForegroundWindow", "uint", $nLock)
    If IsArray($aDLLLock) And $aDLLLock[0] > 0 Then Return 1
    Return SetError(1, 0, 0)
EndFunc
[
sorry to be a nusance but could you explain this to me. I can't get it to work for the test window I'm trying it on.

thanks for replying so quickly

Share this post


Link to post
Share on other sites

sorry to be a nusance but could you explain this to me. I can't get it to work for the test window I'm trying it on.

thanks for replying so quickly

What test window? It disables or enables the ability of being able to set a foreground window.

_LockSetFGWin(1) To Disable

_LockSetFGWin() To Enable


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

What test window? It disables or enables the ability of being able to set a foreground window.

_LockSetFGWin(1) To Disable

_LockSetFGWin() To Enable

what i want to do is set my gui as the active window and then lock it so that nothing else can affect it. I'm currently using a loop something like:

while 1

if winexists("mygui") = 1 and winexists("my messsagebox") = 0 then

if winnotactive("mygui") then winactive("mygui")

winsetontop("mygui","",1)

endif

else if winexists("mygui") =1 and winexists("my messagebox") = 1 then

winsetontop("mygui","",0)

if winnotactive ("my messagebox") then winactive("my messagebox")

winsetontop("my messagebox")

endif

endif

wend

(there are probably a few mistakes in there, i just did that to give you an idea of what i'm trying to do)

winsetontop is causing a few problems becuase it keeps the gui window on top of message boxes that i need the user to interact with even when i change the winsetontop flags.

i was reading a few posts and using this dll to lock the window is supposed to do exactly what i am looking for.

Edited by cheeseslice

Share this post


Link to post
Share on other sites

i was reading a few posts and using this dll to lock the window is supposed to do exactly what i am looking for.

That's what I don't understand... you are not "locking" this window... you are "locking" them all so to speak. There is no parameter for you to send the handle of a specific window for this function.

You might be better off using the dllcall for your message box and just send the hwnd of your GUI to the message box that way (so it has the same on top style).


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

That's what I don't understand... you are not "locking" this window... you are "locking" them all so to speak. There is no parameter for you to send the handle of a specific window for this function.

You might be better off using the dllcall for your message box and just send the hwnd of your GUI to the message box that way (so it has the same on top style).

i knew it was too good to be true!!! i'll have a go at what you suggested. my loop isn't working at the minute so i'll have to work that out again now.

thanks for the help

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