Jump to content

Boy needs help with his script :-)


Recommended Posts

I think this would be useful for all the girls too!

Please advise on how to fix this dllcall to return a handle to the desktop window.

Func GetDeskTopWindowHWND()
;Get a window handle for the Desktop window
;WINAPI describes as HWND GetDesktopWindow(void)
;The GetDesktopWindow function retrieves the handle of the desktop window. 
;The desktop window covers the entire screen and is the area on top of which all icons and other windows are painted. 
$DskTp = DllCall("user32.dll", "none", "GetDesktopWindow", "hwnd", 0)
Return $DskTp
EndFunc

I am familiar with using dlls in other languages. At first, that appears to be a handicap while trying to do the same in AutoIt! Please advise how to knock this function into shape.

Many thanks,

DW

PS No offence to Sandra, I just need some TLC from the Wise Ones too!

Link to comment
Share on other sites

I think I know a solution.

I'm doing 2 things at once so it may take a while.

Edit:

The DllCall wasn't working that's for sure.

I know that the title of the desktop is "Program Manager".

But I'm not sure if that's for all Windows versions or only Win2000+.

Quote from http://www.commandline.co.uk/cmdow/

.. by default its caption is "Program Manager ..

From CodeGuru.com:

The desktop, as you see it, is just a big ListView. So, we can use the FindWindow() and FindWindowEx() APIs to get the handle of the ListView. First, we use FindWindow() to find the window with the title "Program Manager;"

That's all I found.

And now a working solution.

What this script does:

Won't let you click any icon on your desktop until you click on "OK".

$DeskTopHandle = GetDeskTopWindowHWND()
WinSetState($DeskTopHandle, "", @SW_DISABLE)
MsgBox(64, "Debug", "$DeskTopHandle:" & @CRLF & $DeskTopHandle)
WinSetState($DeskTopHandle, "", @SW_ENABLE)

Func GetDeskTopWindowHWND()
   $DskTp = WinGethandle("Program Manager", "")
   Return $DskTp
EndFunc
Edited by SlimShady
Link to comment
Share on other sites

Thank you for this reply and all this info. Your method does return a handle and it may well be useful to move ahead with the anti-flashing problem I posted yesterday.

BTW did my dllcall not work because of an error on my part or something else?

Thanks again for this.

DW

I think I know a solution.

I'm doing 2 things at once so it may take a while.

Edit:

The DllCall wasn't working that's for sure.

I know that the title of the desktop is "Program Manager".

But I'm not sure if that's for all Windows versions or only Win2000+.

Quote from http://www.commandline.co.uk/cmdow/

From CodeGuru.com:

That's all I found.

And now a working solution.

What this script does:

Won't let you click any icon on your desktop until you click on "OK".

$DeskTopHandle = GetDeskTopWindowHWND()
WinSetState($DeskTopHandle, "", @SW_DISABLE)
MsgBox(64, "Debug", "$DeskTopHandle:" & @CRLF & $DeskTopHandle)
WinSetState($DeskTopHandle, "", @SW_ENABLE)

Func GetDeskTopWindowHWND()
   $DskTp = WinGethandle("Program Manager", "")
   Return $DskTp
EndFunc

<{POST_SNAPBACK}>

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...