Nine Posted March 27, 2020 Share Posted March 27, 2020 I spent few hours trying to figure out how to get results from the _WinAPI_DragQueryPoint when the script runs on elevated rights with a WM_DROPFILES registered message. I searched everywhere but I wasn't able to find the right message to allow on my GUI. So I finally decided to allow all messages under 0x400, to finally find THE ONE that makes it work. It was really a surprise to find out that it is $WM_NCHITTEST !!! To test you start Windows Explorer and you simply Drag & Drop anywhere into the GUI. If you remove any of the _WinAPI_ChangeWindowMessageFilterEx it will not fully work. Anyway since I was not able to find it on the Web may as well document it here. expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <WindowsConstants.au3> #RequireAdmin Global $hGUI = GUICreate('WM_DROPFILES', 400, 200, -1, -1, -1, $WS_EX_ACCEPTFILES) GUISetState() GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_NCHITTEST, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_DROPFILES, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) ;_WinAPI_ChangeWindowMessageFilterEx ($hGUI, $WM_COPYDATA, $MSGFLT_ALLOW) ; useless ? While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $aFileList Switch $hWnd Case $hGUI $tPoint = _WinAPI_DragQueryPoint($wParam) $iXpos = DllStructGetData($tPoint, 1) $iYpos = DllStructGetData($tPoint, 2) ConsoleWrite ($iXpos & "/" & $iYpos & @CRLF) $aFileList = _WinAPI_DragQueryFileEx($wParam) If IsArray($aFileList) Then For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) Next EndIf _WinAPI_DragFinish($wParam) Return 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES Tested on Win7. TheSaint and argumentum 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
argumentum Posted March 31, 2020 Share Posted March 31, 2020 Tested as X64/86 compiled with and without #RequireAdmin on Win10. All good. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
TheSaint Posted March 31, 2020 Share Posted March 31, 2020 Thanks for sharing. Had to remove #RequireAdmin for it to write to the console for me - Win 7 32 bit. Shows up in my added msgbox though, with or without. If I recall rightly, drag & drop with the usual function does not work when #RequireAdmin is used, so very good that it can with your function/code. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
argumentum Posted March 31, 2020 Share Posted March 31, 2020 16 minutes ago, TheSaint said: Had to remove #RequireAdmin for it to write to the console for me Spoiler expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate('WM_DROPFILES', 400, 200, -1, -1, -1, $WS_EX_ACCEPTFILES) Global $edit = GUICtrlCreateEdit("", 0, 100, 400, 100) ; I cheat it TheSaint =P GUISetState() GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_NCHITTEST, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_DROPFILES, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) ;_WinAPI_ChangeWindowMessageFilterEx ($hGUI, $WM_COPYDATA, $MSGFLT_ALLOW) ; useless ? While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $aFileList, $sFileList Switch $hWnd Case $hGUI $tPoint = _WinAPI_DragQueryPoint($wParam) $iXpos = DllStructGetData($tPoint, 1) $iYpos = DllStructGetData($tPoint, 2) ConsoleWrite($iXpos & "/" & $iYpos & @CRLF) $aFileList = _WinAPI_DragQueryFileEx($wParam) If IsArray($aFileList) Then For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) $sFileList &= $aFileList[$i] & @CRLF Next GUICtrlSetData($edit, $sFileList) EndIf _WinAPI_DragFinish($wParam) Return 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
TheSaint Posted March 31, 2020 Share Posted March 31, 2020 I suspected as much. argumentum 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) 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