Jump to content

DllCall


Recommended Posts

EDIT: the issues in this thread are solved until post #20

_____________________________________________________________

Im trying to pop my dllcall cherry an wondering if someone coul look at the state of it before I crash my PC

$uiAction = "SPI_GETMOUSECLICKLOCK"
$uiParam = 0 
$fWinIni = 0
$dll = "User32.dll"
$stct = "uint state"
$Structure = DllStructCreate($stct)
$pvParam = DllStructGetPtr($Structure,"state")

$aret = DllCall($dll, "uint", $uiAction, "uint", $uiParam, "ptr", $pvParam, "uint", $fWinIni)

I've never attemped it before and... well Im shitting myself, and it just dosent look right

SPI_GETMOUSECLICKLOCK is near the top of Accessibility parameters here

Any hints or tips warmly welcome.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Completely wrong :blink:

$SPI_GETMOUSECLICKLOCK = 4126

$aCall = DllCall("user32.dll", "bool", "SystemParametersInfo", _
        "dword", $SPI_GETMOUSECLICKLOCK, _
        "dword", 0, _
        "bool*", 0, _
        "dword", 0)
; ...chech for errors here...

ConsoleWrite("! Mouse ClickLock feature ")

If $aCall[3] Then
    ConsoleWrite("enabled." & @CRLF)
Else
    ConsoleWrite("disabled." & @CRLF)
EndIf
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

wow, thanks trancexx

Well i'm even more confused now with dword, I can see where the bool comes from I thing, I just thought it was int in autoit

EDIT:

hang on, they are both 32 bit unsigned intger ?

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Loking closer I see I totally got the function name wrong, using a parameter as it :blink:

EDIT:

Can you let me know where 4126 comes from?

I was thinking I may have had to use 0x101E somewhere as that was in the docs.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Loking closer I see I totally got the function name wrong, using a parameter as it :blink:

EDIT:

Can you let me know where 4126 comes from?

I was thinking I may have had to use 0x101E somewhere as that was in the docs.

Run this:
ConsoleWrite(0x101E & " is in fact 0x101E" & @CRLF)

Btw, uint is the same as dword (int is not).

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

That's just hex to decimal conversion, 0x101E = 4126. Either will work.

;)

Edit: Oops, redundant again!

:blink:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hmmm, talking about Hex<>Dec conversion... why is it, that some hex numbers are 4 digits long, and others 8 digits? Better, how do I know when to use which? Hope it's not a too noobish question :blink:

ConsoleWrite(Dec("101E") & @tab & 0x101E  & @tab & "0x101E" & @tab & Hex(4126) & @tab & "0x" & Hex(4126,4) & @CRLF)
; 4126  4126    0x101E  0000101E    0x101E
Link to comment
Share on other sites

The smallest internal representation of numbers is 32-bit, which is 8 hex characters long. You can shorten it by using the second operand for 'Hex' of course if you know the number can fit into less than 32-bits. Also, a shortcoming of both Hex() and Dec() is they both work on a max integer size of 32-bits. Of course, there are workarounds for 64-bit numbers :blink:

Link to comment
Share on other sites

Link to comment
Share on other sites

It depends on the use you have of the hex representation. As I see it Hex defaults to 8-char output, which is what your example shows.

Except for strictly formatted usage, having leading hex zeroes generally don't harm just like leading decimal zeroes. But sometimes the context forces zeroes truncation on not (Win 7 vs. agent 007).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Im back already, (cherry in tact)

Ive been trying other parameters of the function, and thought tedting for cleartype looked pretty simple.

I first tried checking for SPI_GETCLEARTYPE

Determines whether ClearType is enabled. The pvParam parameter must point to a BOOL variable that receives TRUE if ClearType is enabled, or FALSE otherwise.

which is pretty much the same as the last, but it just kept returning true, whether it was enabled or not.

I read down the page, and someone had commented that it didnt work in vista, and suggested checking for SPI_GETFONTSMOOTHING and SPI_GETFONTSMOOTHINGTYPE, so I tried that.

Thing is it returns true than font smoothing is enabled but dosent return what is used, Ive tried a few variations of this code. (basically the code from trancexx)

#include <Array.au3>
$SPI_GETFONTSMOOTHING = 0x004A

$aCall = DllCall("user32.dll", "bool*", "SystemParametersInfo", _
        "dword", $SPI_GETFONTSMOOTHING, _
        "dword",0 , _
        "bool*",0, _
        "dword",0 )
If @error Then
    MsgBox(0, "error", @error)
EndIf
_ArrayDisplay($aCall)
ConsoleWrite("! FONTSMOOTHING feature ")
If $aCall[3] Then

    ConsoleWrite("enabled." & @CRLF)
Else
    ConsoleWrite("disabled." & @CRLF)
EndIf
;#ce
sleep(1000)
$SPI_GETFONTSMOOTHINGTYPE = 0x200A
$aCall = DllCall("user32.dll", "bool*", "SystemParametersInfo", _
        "dword", $SPI_GETFONTSMOOTHINGTYPE, _
        "dword", 0, _
        "dword", "FE_FONTSMOOTHINGCLEARTYPE", _
        "dword", 0)
If @error Then
    MsgBox(0, "error", @error)
EndIf
_ArrayDisplay($aCall)
ConsoleWrite("! smoothing type ")
If $aCall[3] Then

    ConsoleWrite($aCall[3] & @CRLF)
Else
    ConsoleWrite("disabled." & @CRLF)
EndIf

If anyone has the time and patience, Id appreciated any guidance.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • 1 month later...

I've been trying to set this system param for some time now, to change the type of font smoothing used, but unfortunately Autoit crashes during the dllcall, I' love someone to see if my code is wrong.

#include <WinAPI.au3>

$string = "Environment"

$struct = DllStructCreate($string)

$pointer = DllStructGetPtr($struct)

$WM_WININICHANGE = 0x001A
$SPI_SETFONTSMOOTHINGTYPE = 0x200B
$aCall = DllCall("user32.dll", "bool*", "SystemParametersInfo", _
        "uint", $SPI_SETFONTSMOOTHINGTYPE, _
        "uint", 0, _
        "uint*",1, _
        "uint", $WM_WININICHANGE, "dword", 0, "ptr", $pointer)

If @error Then
    ConsoleWrite(_WinAPI_GetLastErrorMessage())
EndIf
ConsoleWrite(_WinAPI_GetLastErrorMessage())

MSDN INFO

http://msdn.microsoft.com/en-us/library/ms724947%28VS.85%29.aspx

BOOL WINAPI SystemParametersInfo(

__in UINT uiAction,

__in UINT uiParam,

__inout PVOID pvParam,

__in UINT fWinIni

);

__________________________________________________

uiAction [in]

UINT

The system-wide parameter to be retrieved or set.

SPI_SETFONTSMOOTHINGTYPE

0x200B

Sets the font smoothing type. The pvParam parameter is either FE_FONTSMOOTHINGSTANDARD, if standard anti-aliasing is used, or FE_FONTSMOOTHINGCLEARTYPE, if ClearType is used. The default is FE_FONTSMOOTHINGSTANDARD.

SPI_SETFONTSMOOTHING must also be set.

Windows 2000: This parameter is not supported.

----------------------------------------------------

uiParam [in]

UINT

A parameter whose usage and format depends on the system parameter being queried or set. For more information about system-wide parameters, see the uiAction parameter. If not otherwise indicated, you must specify zero for this parameter.

-----------------------------------------------------

pvParam [in, out]

PVOID

A parameter whose usage and format depends on the system parameter being queried or set. For more information about system-wide parameters, see the uiAction parameter. If not otherwise indicated, you must specify NULL for this parameter.

------------------------------------------------------

fWinIni [in]

UINT

If a system parameter is being set, specifies whether the user profile is to be updated, and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to notify them of the change.

This parameter can be zero if you don't want to update the user profile or broadcast the WM_SETTINGCHANGE message, or it can be one or more of the following values.

http://msdn.microsoft.com/en-us/library/ms725497%28v=VS.85%29.aspx

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...