Jump to content
jantograaf

Issues with WS_EX_ACCEPTFILES and GUI_DROPACCEPTED

Recommended Posts

Hi all,

I've been looking around the forum and testing different ways of getting a 'drop zone' to work in my script, but I can't seem to get any response from the event listener. Code compiles perfectly. Chaning the control from a label to an input- or edit-field doesn't change its behaviour, still no response when a file is dropped on there...

It might just be that I am overlooking a simple detail, so I'm hoping for an extra pair of eyes here or there who can spot why this isn't working as it should. 

I have another 3500+ lines script where I have basically the same bit of code, and it seems to work in there without problems.

So, here it goes:

Global $DD_GUI = GUICreate("DicomDrop",200,200,-1,-1,BitOR($WS_SYSMENU,$WS_POPUP),$WS_EX_ACCEPTFILES)
GUISetBkColor(0x030303,$DD_GUI)

$DD_GUI_DRAGLABEL = GUICtrlCreateLabel("",0,0,32,32,-1, $GUI_WS_EX_PARENTDRAG)
$DD_GUI_DRAGIMAGE = GUICtrlCreateIcon(@ScriptFullPath,201,0,0,32,32)

$DD_GUI_TITLELABEL = GUICtrlCreateLabel("DicomDrop",50,10,100,20,$SS_CENTER)
GUICtrlSetFont($DD_GUI_TITLELABEL,8,$FW_SEMIBOLD,$GUI_FONTNORMAL,"Verdana")
GUICtrlSetColor($DD_GUI_TITLELABEL,0xFFFFFF)

$DD_GUI_CLOSE = GUICtrlCreateButton("X",174,4,24,24,$BS_FLAT)
GUICtrlSetBkColor($DD_GUI_CLOSE,0x030303)
GUICtrlSetColor($DD_GUI_CLOSE,0xFFFFFF)

Global $DD_GUI_DROPZONE = GUICtrlCreateLabel("",10,42,180,148)
GUICtrlSetState(-1,8)
GUICtrlSetBkColor($DD_GUI_DROPZONE,0x181818)

GUISetState(@SW_SHOW,$DD_GUI)

Local $DD_MSG = 0
While 1
    $DD_MSG = GUIGetMsg()
    Select
        Case $DD_MSG = $GUI_EVENT_CLOSE
            ConsoleWrite(@CRLF & "Debug -- Closed by GUI_EVENT_CLOSE")
            DD_EXIT()
        Case $DD_MSG = $GUI_EVENT_DROPPED
                If @GUI_DropId = $DD_GUI_DROPZONE Then
                    Local $DroppedFile = @GUI_DragFile
                    GUIDelete()
                    ConsoleWrite(@CRLF & "Debug -- Dropped file : " & $DroppedFile)
                EndIf
        Case $DD_MSG = $DD_GUI_CLOSE
            ConsoleWrite(@CRLF & "Debug -- Closed by DD_GUI_CLOSEIMAGE")
            DD_EXIT()
    EndSelect
WEnd

Func DD_EXIT()
    GUIDelete($DD_GUI)
    Exit
EndFunc

If anyone has any idea whatsoever, please let me know 🙂

Thanks in advance and kind regards,

Jan

Share this post


Link to post
Share on other sites

jantograaf,

Your script as posted runs (when the required includes are added) without problem for me - I get the dropped filename written to the console for every drop.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi @Melba23,

Thanks for the quick reply! 🙂 

This was the scenario I was afraid of (since my code seemed correct). So, just to be 'complete', I have included all the includes I'm using right now. Overkill, I know, but I included all includes from the other script as the drop zone works in that one...

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=DicomDrop.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Icon_Add=drag.ico,201
#AutoIt3Wrapper_Res_Icon_Add=close.ico,202
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <MsgBoxConstants.au3>
#include <GuiEdit.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>
#include <Array.au3>
#include <FontConstants.au3>
#include <AutoItConstants.au3>
#include <ColorConstants.au3>
#include <InetConstants.au3>
#include "WinHttp.au3"
#include <Network.au3>
#include <StringConstants.au3>
#include <File.au3>
#include <Misc.au3>
#include <GuiComboBox.au3>
#include <GUIComboBoxEx.au3>
#include <FileConstants.au3>
#include <GUIListView.au3>
#include <GUITab.au3>
#include <GUIListBox.au3>
#include <GuiButton.au3>
#include <XML.au3>
#include <SliderConstants.au3>
#include <json.au3>

Anything obvious missing as far as you can see?

Kind regards,

Jan

Share this post


Link to post
Share on other sites
1 minute ago, Nine said:

Shouldn't you exit after GUIDelete ?

Haha, I missed that line, since it came from the other program (where the drop zone does work). But actually that GuiDelete() should be erased there and will be replaced by the call to the function that will process the dropped file. Thanks anyway 😉 

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

So, meanwhile, I've tested it here on multiple PC's, and it seems to work on some and not work on others. All of them are Windows 10 x64 however, and they should be configured basically in the same way. Could it be that it has something to do with usernames/permissions? I'm completely baffled right now, this should work without a problem and it doesn't. 😪

Share this post


Link to post
Share on other sites

jantograaf,

My machine is also Win10 x64 and as I said earlier, the script ran perfectly for me.

But searching for "Win10 drag and drop problem" shows that this a relatively common event, possibly linked to Explorer becoming corrupted during Windows updates.  Various sites listed propose fixes - none of those I investigated appear to be likely to damage your machine or your data - so it might be worth trying some of them and seeing if you can resolve your problem. Please let us know if you do find a solution.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

The script works fine

Global $DD_GUI = GUICreate("DicomDrop",200,200,-1,-1,0x00CF0000,0x00000018)
GUISetBkColor(0x030303,$DD_GUI)
$DD_GUI_DRAGLABEL = GUICtrlCreateLabel("",0,0,32,32,-1, 0x00100000)
$DD_GUI_DRAGIMAGE = GUICtrlCreateIcon(@ScriptFullPath,201,0,0,32,32)
$DD_GUI_TITLELABEL = GUICtrlCreateLabel("DicomDrop",50,10,100,20,0x1)
GUICtrlSetFont($DD_GUI_TITLELABEL,8,600,0,"Verdana")
GUICtrlSetColor($DD_GUI_TITLELABEL,0xFFFFFF)
$DD_GUI_CLOSE = GUICtrlCreateButton("X",174,4,24,24,0x8000)
GUICtrlSetBkColor($DD_GUI_CLOSE,0x030303)
GUICtrlSetColor($DD_GUI_CLOSE,0xFFFFFF)
Global $DD_GUI_DROPZONE = GUICtrlCreateLabel("",10,42,180,148)
GUICtrlSetState(-1,8)
GUICtrlSetBkColor($DD_GUI_DROPZONE,0xC8C9D2)
GUISetState(@SW_SHOW)
Local $DD_MSG = 0
While 1
$DD_MSG = GUIGetMsg()
Select
Case $DD_MSG = -3
ConsoleWrite(@CRLF & "Debug -- Closed by GUI_EVENT_CLOSE")
DD_EXIT()
Case $DD_MSG = -13
If @GUI_DropId = $DD_GUI_DROPZONE Then
Local $DroppedFile = @GUI_DragFile
GUICtrlSetData($DD_GUI_DROPZONE,$DroppedFile)
MsgBox(262144, '', $DroppedFile & @CR & '' & @CR & '' & @CR & '')
;GUIDelete()
ConsoleWrite(@CRLF & "Debug -- Dropped file : " & $DroppedFile)
EndIf
Case $DD_MSG = $DD_GUI_CLOSE
ConsoleWrite(@CRLF & "Debug -- Closed by DD_GUI_CLOSEIMAGE")
DD_EXIT()
EndSelect
WEnd
Func DD_EXIT()
GUIDelete($DD_GUI)
Exit
EndFunc

 

Share this post


Link to post
Share on other sites

Every time I had a drag/drop problem it came from elevation issues. 

If the GUI was running as admin and the explorer process was not then it would not have enough permissions to drag a file.

If it is working on some machines and not others I wonder if it may be a UAC setting or some other process creating a difference in the rights.

 

You can go so far as to run the GUI as admin, and manually run a file explorer process as admin and it will work, but when they are mixed it creates issues. 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By paw
      I use SetSoundDevice to control my audio devices but the UI was either
       
      blurry like this:
      or unusable like this:

      so I made this horrible thing to add scaling to the GUI:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> ;~ _convertGUI("") If $CmdLine[0] <> 0 Then _convertGUI($CmdLine[1]) Func _convertGUI($sFilePath) If $sFilePath <> "" Then Local $aArray = FileReadToArray($sFilePath) Else ;TEST DATA Local $aArray[6] = ['$H_Res_Language = GUICtrlCreateProgress(5, 120, 210 + 25, 480, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; $CBS_DROPDOWNLIST)', _ 'Local $h_Ok = GUICtrlCreateButton("Ok", 72, 224, 81, 33, 0)', _ 'GUICreate($Warning_TiTle, 700, 310, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX)', _ 'GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)', _ '$H_FieldNameEdit = GUICtrlCreateEdit($INP_FieldNameEdit, 100,260+25, 500, 150 - 25) ;comment', 'Local $H_CANCEL = GUICtrlCreateGraphic("Cancel", 224, 224, 97, 33, 0)'] EndIf Local $hTimer = TimerInit(), $iGUIElementCount = 0, $sResult = "", $sFileName = "", $sDrive = "", $sDir = "", $sExtension = "" If @Compiled Then _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) $sFileName = StringRegExpReplace($sFilePath, "^.*\\", "") EndIf For $i = 0 To (UBound($aArray) - 1) If StringRegExp($aArray[$i], "GUICtrlCreate|GUICreate") Then $sResult = _splitComma($aArray[$i]) If Not @error Then $aArray[$i] = $sResult $iGUIElementCount += 1 EndIf Next ConsoleWrite("t = " & TimerDiff($hTimer) & " GUI elements = " & $iGUIElementCount & " lines = " & (UBound($aArray) - 1) & @CRLF) If $sFileName <> "" Then Local $hFile = FileOpen("edited." & $sFileName, 2) _FileWriteFromArray("edited." & $sFileName, $aArray) FileClose($hFile) EndIf Exit EndFunc ;==>_convertGUI Func _splitComma($sString) Local $sSplitResult = "", $sTrimmedR = "", $sTrimmedL = "" Local $aSplit = StringSplit($sString, ',') If Not @error Then $sTrimmedR = "" $sTrimmedL = "" For $j = 1 To $aSplit[0] If StringRegExp($aSplit[1], "(?:.GUICtrlCreateGraphic|GUICtrlCreateProgress|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTreeView)") Then If $j = 1 Then While StringLeft($aSplit[$j], 1) <> '(' $sTrimmedL &= StringLeft($aSplit[$j], 1) $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) EndIf EndIf If $j = $aSplit[0] Then While StringRight($aSplit[$j], 1) <> ')' $sTrimmedR &= StringRight($aSplit[$j], 1) $aSplit[$j] = StringTrimRight($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimRight($aSplit[$j], 1) EndIf If StringRegExp($aSplit[$j], "[0-9]") And $aSplit[$j] <> -1 And $aSplit[$j] <> 0 And $aSplit[$j] <> 1 And Not StringInStr($aSplit[$j], ')') Then If StringRegExp($aSplit[$j], "\-|\+") Then ;put parenthesis around + or - $aSplit[$j] = '(' & $aSplit[$j] & ")*$g_DPI" Else $aSplit[$j] = $aSplit[$j] & "*$g_DPI" EndIf EndIf If $j < $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ',' ElseIf $j = $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ')' Else $sSplitResult &= $aSplit[$j] EndIf Next If $sTrimmedR <> "" Then $sSplitResult &= StringReverse($sTrimmedR) If $sTrimmedL <> "" Then $sSplitResult = $sTrimmedL & '(' & $sSplitResult Else SetError(1) Return EndIf ConsoleWrite($sSplitResult & @CRLF) Return $sSplitResult EndFunc ;==>_splitComma
      And now it looks good: 
      but it doesn't work on everything, for example the "GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)" (from the autoit3wrapper gui)
      because the comment contains a parenthesis and it would break completely if there were variables as parameters..
      Is there some kind of parser around that I could use instead or maybe someone who has already done something like this?
    • By TXTechie
      Hello Everyone,
      I've developed my own GUI using AutoIt and I'm allowing users to minimize the GUI, but I also want to include some kind of timer so that it will automatically restore the GUI after something like 30 minutes or an hour. However, I also want them to be able to manually restore the GUI by clicking the application's icon in the taskbar.
      I've searched through the forums, but I'm not sure how to get started.
      Any ideas or functions to research are appreciated!
      Regards,
      TX Techie
    • By Rskm
      Hi, recently i created a GUI for some calculations in AutoIT.  The GUI has 2 tabs and on the first tab, it has few inputboxes where i use to click with mouse and start entering the inputs. i recently made some changes in the position of these textboxes. I made this by changing the autoit code file instead of making changes in KODA. Now i cannot click inside these textboxes with mouse. However, i can use TAB key to cycle through/enter input in these input boxes. what could have made the inputboxes not responding to mouseclicks. thanks
    • By TheDcoder
      Hi everyone,
      I am bit stumped as to why I am not able to set the time in the Date control
      #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI get date", 200, 200, 800, 200) Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20, $DTS_TIMEFORMAT) ; to select a specific default format Local $sStyle = "HH:mm:ss" GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle) ; Set time Local $iRet = GUICtrlSetData($idDate, '13:33:37') ConsoleWrite('GUICtrlSetData returned ' & ($iRet = 1 ? 'success' : 'failure') & @CRLF) GUISetState(@SW_SHOW) ; Loop until the user exits. While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate)) EndFunc ;==>Example The documentation for GUICtrlSetData clearly mentions that it uses the same format as GUICtrlRead:
      But I get failure
      What gives?
      Thanks for the help in advance!
    • By thedemons
      Introduction
      ImGui is a popular library written by ocornut, it can make awesome user interface based on directx. It is being used by many big apps/games.  The UI is nice and flexible, easy to use because of frame-by-frame drawing. So I decided to convert the entire ImGui library to AutoIt
      At first it's just an experiment, i converted some basic draw functions of imgui, compile to a dll, then using DllCall in autoit to call the functions. I was testing to see how much FPS i can get in autoit, and i was expected a low FPS, since autoit is slow. Suprisingly, the FPS turned out to be so high, it works really fast, even when drawing 1000 buttons at the same time. Features
      More than +270 functions converted from ImGui (compiled dll). Has 90% of the capability of what you can do in C++; Usable ImGuiIO and ImGuiStyle, so you can set whatever configurations you like. Preview
          
      Usage
      #include <WinAPI.au3> #include "ImGui.au3" ; Create a window Local $hwnd = _ImGui_GUICreate("AutoIt ImGui", 1024, 768) _WinAPI_ShowWindow($hwnd) ; Set style color _ImGui_StyleColorsLight() ;~ _ImGui_StyleColorsDark() Local $f_value = 5 While 1 ; when the user click close button on the window, this will return false if Not _ImGui_PeekMsg() Then Exit ; must call _ImGui_BeginFrame() _ImGui_Begin("Another window") _ImGui_Text("Hello there..") If _ImGui_Button("click me") Then $f_value = 5 _ImGui_SliderFloat("slider", $f_value, 2, 20) If _ImGui_IsItemHovered() Then _ImGui_ToolTip("what r u doing?") _ImGui_End() ; must call _ImGui_EndFrame() Wend  
      Remark
      Most of the functions were converted automatically. I haven't tested all of them yet, if some function doesn't work for you, please tell me. Still missing some features of ImGui, please tell me if you needed any. Run \tools\imgui-au3-setup.au3 to add _ImGui functions to SciTE auto-complete. Source Code
      Require: DirectX GitHub: imgui-autoit
×
×
  • Create New...