Mat Posted October 3, 2009 Share Posted October 3, 2009 I can't get this to work and I have no idea how Unfortunately this is one of my first real attempts at putting togethor DLL call and structs, and it took me a long time to find all the variables etc, so now i'm really annoyed that it didn't work! The other thing is that its not even returning an @Error code for me, I presume that means the Dll code itself has failed, not my calling of it, although its probably bad params. expandcollapse popup#include-once #include <StructureConstants.au3> ; WinUser.h Global Const $SPI_SETWORKAREA = 0x002F Global Const $SPI_GETWORKAREA = 0x0030 Global Const $SPIF_UPDATEINIFILE = 0x0001 Global Const $SPIF_SENDWININICHANGE = 0x0002 Global Const $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE MsgBox (0, _SetWorkArea (0, 0, 800, 800), @Error) Func _SetWorkArea ($iLeft = -1, $iTop = -1, $iRight = -1, $iBottom = -1) Local $aResult, $rect = DllStructCreate ($tagRECT) ; Change -1's If $iLeft = -1 Then $iLeft = 0 If $iTop = -1 Then $iTop = 0 If $iRight = -1 Then $iLeft = @DesktopWidth If $iBottom = -1 Then $iTop = @DesktopHeight ; Set struct data DllStructSetData ($rect, "Left", $iLeft) DllStructSetData ($rect, "Top", $iTop) DllStructSetData ($rect, "Right", $iRight) DllStructSetData ($rect, "Bottom", $iBottom) ; Set the area $aResult = DllCall("user32.dll", _ "int", "SystemParametersInfo", _ "int", $SPI_SETWORKAREA, _ "int", 0, _ "int", $rect, _ "int", $SPIF_SENDWININICHANGE) If @error Then Return SetError(@error, 1, False) Return $aResult[0] <> 0 EndFunc ; ==> _SetWorkArea $aResult is returning [0, 47, 0, 0, 2]. I don't know what this means, but $aResult[0] is supposed to return 1 on success isn't it? I think its just returning my input params back to me though (47 = $SPI_SETWORKAREA, 2 = $SPIF_SENDWININICHANGE). Thanks for any help! Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
martin Posted October 3, 2009 Share Posted October 3, 2009 I can't get this to work and I have no idea how Unfortunately this is one of my first real attempts at putting togethor DLL call and structs, and it took me a long time to find all the variables etc, so now i'm really annoyed that it didn't work! The other thing is that its not even returning an @Error code for me, I presume that means the Dll code itself has failed, not my calling of it, although its probably bad params. expandcollapse popup#include-once #include <StructureConstants.au3> ; WinUser.h Global Const $SPI_SETWORKAREA = 0x002F Global Const $SPI_GETWORKAREA = 0x0030 Global Const $SPIF_UPDATEINIFILE = 0x0001 Global Const $SPIF_SENDWININICHANGE = 0x0002 Global Const $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE MsgBox (0, _SetWorkArea (0, 0, 800, 800), @Error) Func _SetWorkArea ($iLeft = -1, $iTop = -1, $iRight = -1, $iBottom = -1) Local $aResult, $rect = DllStructCreate ($tagRECT) ; Change -1's If $iLeft = -1 Then $iLeft = 0 If $iTop = -1 Then $iTop = 0 If $iRight = -1 Then $iLeft = @DesktopWidth If $iBottom = -1 Then $iTop = @DesktopHeight ; Set struct data DllStructSetData ($rect, "Left", $iLeft) DllStructSetData ($rect, "Top", $iTop) DllStructSetData ($rect, "Right", $iRight) DllStructSetData ($rect, "Bottom", $iBottom) ; Set the area $aResult = DllCall("user32.dll", _ "int", "SystemParametersInfo", _ "int", $SPI_SETWORKAREA, _ "int", 0, _ "int", $rect, _ "int", $SPIF_SENDWININICHANGE) If @error Then Return SetError(@error, 1, False) Return $aResult[0] <> 0 EndFunc ; ==> _SetWorkArea $aResult is returning [0, 47, 0, 0, 2]. I don't know what this means, but $aResult[0] is supposed to return 1 on success isn't it? I think its just returning my input params back to me though (47 = $SPI_SETWORKAREA, 2 = $SPIF_SENDWININICHANGE). Thanks for any help! Mat I haven't spent the time to see what's wrong, but instead here is an example I made when I wanted to play with SPI_SETWORKAREA. If you try it be warned that it will completely mess up your desktop icons positions when it resizes the working area. expandcollapse popupConst $SPI_SETWORKAREA = 47,$SPI_GETWORKAREA = 48 Const $SPIF_SENDCHANGE = 11 $newWid = @DesktopWidth ;- 500 $newHt = @DesktopHeight $DtopRect = DllStructCreate("int[4]") ;WinMove("Chat", "", 797, 0, 482, 361, 2) DllStructSetData($DtopRect,1,797,1);left DllStructSetData($DtopRect,1,0,2);top DllStructSetData($DtopRect,1,1280,3);right DllStructSetData($DtopRect,1,361,4);bottom $PRect = DllStructGetPtr($DtopRect) $DNowRect = DllStructCreate("int[4]") $PNowRect = DllStructGetPtr($DNowRect) $StartRect = DllStructCreate("int[4]") $PStartRect = DllStructGetPtr($StartRect) $res = DllCall("user32.dll","int","SystemParametersInfo","int",$SPI_GETWORKAREA,"int",0,"ptr",$PStartRect,"int",0) MsgBox(0,'work area starts at',DllStructGetData($StartRect,1,1) & ', ' & DllStructGetData($StartRect,1,2) & _ ' x ' & DllStructGetData($StartRect,1,3) & ', ' & DllStructGetData($StartRect,1,4)) $res = DllCall("user32.dll","int","SystemParametersInfo","int",$SPI_SETWORKAREA,"int",0,"ptr",$PRect,"int",$SPIF_SENDCHANGE) $res = DllCall("user32.dll","int","SystemParametersInfo","int",$SPI_GETWORKAREA,"int",0,"ptr",$PNowRect,"int",0) MsgBox(0,'work area is now',DllStructGetData($DNowRect,1,1) & ', ' & DllStructGetData($DNowRect,1,2) & _ ' x ' & DllStructGetData($DNowRect,1,3) & ', ' & DllStructGetData($DNowRect,1,4) & @cr & _ "better have a look" & @CR & "Eg run notepad and maximize it." & _ "(After you have played with it click OK.)") ;set things back to how they started $res = DllCall("user32.dll","int","SystemParametersInfo","int",$SPI_SETWORKAREA,"int",0,"ptr",$PStartRect,"int",$SPIF_SENDCHANGE) $res = DllCall("user32.dll","int","SystemParametersInfo","int",$SPI_GETWORKAREA,"int",0,"ptr",$PNowRect,"int",0) MsgBox(0,'work area is back to',DllStructGetData($DNowRect,1,1) & ', ' & DllStructGetData($DNowRect,1,2) & _ ' x ' & DllStructGetData($DNowRect,1,3) & ', ' & DllStructGetData($DNowRect,1,4)) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Mat Posted October 3, 2009 Author Share Posted October 3, 2009 Thanks, I'll see if I can compare whats different. This could be very useful to get working! Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Mat Posted October 3, 2009 Author Share Posted October 3, 2009 (edited) I saw it the instant I looked in depth at your code, and managed to escape messing up my desktop!! and should have known!! pvParam requires a pointer, not an int input. So my DllCall was claiming to input an int instead of a pointer if that makes sense... "int", $rect, _ should be "ptr", $rect, _ Thanks a lot martin Mat Edit: That wasn't the only error either, one was very much autoit related! ; WinUser.h Global Const $SPI_SETWORKAREA = 0x002F Global Const $SPI_GETWORKAREA = 0x0030 Global Const $SPIF_UPDATEINIFILE = 0x0001 Global Const $SPIF_SENDWININICHANGE = 0x0002 Global Const $SPIF_SENDCHANGE = $SPIF_SENDWININICHANGE MsgBox (0, _SetWorkArea (-1, -1, -1, -1), @Error) Func _SetWorkArea ($iLeft = -1, $iTop = -1, $iRight = -1, $iBottom = -1) Local $aResult, $rect = DllStructCreate ("int[4]"), $pRect = DllStructGetPtr ($rect) ; Change -1's If $iLeft = -1 Then $iLeft = 0 If $iTop = -1 Then $iTop = 0 If $iRight = -1 Then $iRight = @DesktopWidth + 0 If $iBottom = -1 Then $iBottom = @DesktopHeight + 0 ; Set struct data DllStructSetData ($rect, 1, $iLeft , 1) ;left DllStructSetData ($rect, 1, $iTop , 2) ;top DllStructSetData ($rect, 1, $iRight , 3) ;right DllStructSetData ($rect, 1, $iBottom, 4) ;bottom ; Set the area $aResult = DllCall("user32.dll", _ "int", "SystemParametersInfo", _ "int", $SPI_SETWORKAREA, _ "int", 0, _ "ptr", $pRect, _ "int", $SPIF_SENDCHANGE) If @error Then Return SetError(@error, 0, False) Return $aResult[0] <> 0 EndFunc ; ==> _SetWorkArea Edited October 3, 2009 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now