Hey guys,
i'd lyk to bind the area of GuiDropFiles. I want this to happen to a specific area. For example, i'd lyk the area to be left half of my GUI. Other than that, U cant drop files anywhere else. I thought i can bind using mousegetpos, but the problem is that, the-drag-n-drop-icon still appears in the "no dropzone" area. Any help?

[SOLVED] Binding area of GuiDropFiles
Started by
Ronins
, May 20 2012 08:03 PM
12 replies to this topic
#1
-
Posted 20 May 2012 - 08:03 PM
![[SOLVED] Binding area of GuiDropFiles: post #1](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
#Persistent #SingleInstance, Force [color=#40BF00]; Top Left Corner of region[/color] RegionX = 100 RegionY = 100 [color=#40BF00];Bottom Right Corner of region [/color]RegionW = 300 RegionH = 300 Gui, Add, Text, x%RegionX% y%RegionY% w%RegionW% h%RegionH% Border Center, Drop Files Here Gui, Show, w800 h600 Return GuiDropFiles: If ( (A_GuiX >= RegionX) && (A_GuiX <= RegionX+RegionW) && (A_GuiY >= RegionY) && (A_GuiY <= RegionY+RegionH) ) { MsgBox, File dropped: %A_GuiEvent% } Else { MsgBox, File dropped outside of the region specified } Return
#2
-
Posted 21 May 2012 - 03:55 PM
![[SOLVED] Binding area of GuiDropFiles: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Ahk_L (Unicode 32-bit)
#Persistent #SingleInstance, Force [color=#40BF00]; Top Left Corner of region[/color] RegionX = 100 RegionY = 100 [color=#40BF00];Bottom Right Corner of region [/color]RegionW = 300 RegionH = 300 Gui, Add, Text, x%RegionX% y%RegionY% w%RegionW% h%RegionH% Border Center, Drop Files Here Gui, Show, w800 h600 Return GuiDropFiles: If ( (A_GuiX >= RegionX) && (A_GuiX <= RegionX+RegionW) && (A_GuiY >= RegionY) && (A_GuiY <= RegionY+RegionH) ) { MsgBox, File dropped: %A_GuiEvent% } Else { MsgBox, File dropped outside of the region specified } Return
That i know, but there is sort of cursor problem. If u bring file to the outside area, cursor still shows "droppable" zone. In normal window, where guidropfiles is not specified, when u dragdrop file, "invalid" cursor is shown. I want that cursor thingy
#3
-
Posted 21 May 2012 - 04:12 PM
![[SOLVED] Binding area of GuiDropFiles: post #3](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Can you post your code then I could try and understand better and debug it. Also are you using AHK basic or Ahk_L?
#4
-
Posted 21 May 2012 - 04:17 PM
![[SOLVED] Binding area of GuiDropFiles: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Ahk_L (Unicode 32-bit)
Using same code as urs. M using ahk l. I'll post screenshots of kind of result that i want
#5
-
Posted 21 May 2012 - 04:35 PM
![[SOLVED] Binding area of GuiDropFiles: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
The code above works in both AHK and AHK_L - I tried it in both. The code works flawlessly for me.
#6
-
Posted 21 May 2012 - 04:38 PM
![[SOLVED] Binding area of GuiDropFiles: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Ahk_L (Unicode 32-bit)
Code is flawless, i know, i made more or less the same code. But right now, m talking about cursor. Observe the difference in cursors when u drop files on gui(s) with n without guidropfile
#7
-
Posted 21 May 2012 - 04:50 PM
![[SOLVED] Binding area of GuiDropFiles: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
...the problem is not really the code, it's the fact that once you use GuiDropFiles, AutoHotkey will show the "yes you can drop files here" mouse cursor all the time, even if you use extra code to "detect" where the drop occurred & take different action in the script, the user still gets the feedback (mouse pointer icon) that they can drop anywhere, even if you don't want them to.The code above works in both AHK and AHK_L...
AutoHotkey needs to be changed, to allow more control over GuiDropFiles...we need to be able to specify an exact area that is "droppable", so that AutoHotkey can tell the OS that, so the mouse cursor can change to indicate "droppableness".
You could probably remove GuiDropFiles & then use an entire DllCall/OnMessage approach & get more control over the file drop notifications. But the bottom line is, that currently, in regards to mouse pointer indications of being able to drop, GuiDropFiles is "all or nothing"...either the entire Gui will "look droppable" or "look non-droppable".
I did a some searching, it may be a little easier than I thought, it could be as simple as calling DragAcceptFiles, as the mouse is moved over the Gui...(this is a WinAPI function, not an AutoHotkey function, so you need DllCall).
I will do some testing & post code, if I get somewhere.
#8
-
Posted 21 May 2012 - 05:19 PM
![[SOLVED] Binding area of GuiDropFiles: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Useful forum links: New content since: Last visit ■ Past week ■ Past 2 weeks (links will show YOUR posts, not mine)
OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...
Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".
I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?
OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...
Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".
I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?
Yeh I figured that out little while ago
Take a look at this on changing the cursor and see if you can put together a code. I have to go unfortunately. Can't play around with it right now.
http://www.autohotke...opic.php?t=6107
This is also under the Ahk_L Documentation under "DllCall" section. Go to the bottom where there are examples.
Good luck!

http://www.autohotke...opic.php?t=6107
This is also under the Ahk_L Documentation under "DllCall" section. Go to the bottom where there are examples.
Good luck!
#9
-
Posted 21 May 2012 - 05:25 PM
![[SOLVED] Binding area of GuiDropFiles: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Ahk_L (Unicode 32-bit)
ok, i got a workaround here. I can use 2 seperate GUIs, stick them one above another. So if the file is over base one, it'll show "dont drop here" cursor, while on above GUI, it will show "drop here" cursor. Will work on code tomorrow. Any other ideas?
#10
-
Posted 21 May 2012 - 05:31 PM
![[SOLVED] Binding area of GuiDropFiles: post #10](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Once again:
#NoEnv WM_DROPFILES := 0x0233 ; window message WS_EX_ACCEPTFILES := [color=#BF0000]0x10[/color] ; extended window style Gui, Margin, 0, 0 Gui, Add, Text, w300 h300 [color=#BF0000]+E0x10[/color] HwndHDROP +Border, Files can be dropped within the borders! Gui, Add, Edit, x50 y50 w200 h200 HwndHEDIT, Drop target! Gui, Add, Button, xp y+10, Just a button! Gui, Add, Edit, x320 y50 w160 h200, Don't accept files! Gui, Show, w500 h350, Drag&Drop DropTarget := HEDIT OnMessage(WM_DROPFILES, "On_WM_DROPFILES") Return On_WM_DROPFILES(WParam, LParam, Msg, HWND) { ; http://msdn.microsoft.com/en-us/library/bb774303(v=vs.85) ; WParam contains a handle to an internal structure describing the dropped files. ; Pass this handle DragFinish, DragQueryFile, or DragQueryPoint to retrieve information about the dropped files. Static DragQueryFile := "Shell32.dll\DragQueryFile" . (A_IsUnicode ? "W" : "A") Global DropTarget ; Global variable containing the target control's HWND Dropped := "" Files := DllCall(DragQueryFile, "Ptr", WParam, "UInt", -1, "Ptr", 0, "UInt", 0, "UInt") Loop, % Files { Length := DllCall(DragQueryFile, "Ptr", WParam, "UInt", A_Index - 1, "Ptr", 0, "UInt", 0, "UInt") + 1 VarSetCapacity(File, Length * (A_IsUnicode ? 2 : 1), 0) DllCall(DragQueryFile, "Ptr", WParam, "UInt", A_Index - 1, "Str", File, "UInt", Length, "UInt") Dropped .= File . "`r`n" } DllCall("Shell32.dll\DragFinish", "Ptr", WParam) GuiControl, , % DropTarget, % RTrim(Dropped, "`r`n") Return 0 }
#11
-
Posted 22 May 2012 - 05:38 AM
![[SOLVED] Binding area of GuiDropFiles: post #11](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Prefer ahkscript.org for the time being.
Once again:
#NoEnv WM_DROPFILES := 0x0233 ; window message WS_EX_ACCEPTFILES := [color=#BF0000]0x10[/color] ; extended window style Gui, Margin, 0, 0 Gui, Add, Text, w300 h300 [color=#BF0000]+E0x10[/color] HwndHDROP +Border, Files can be dropped within the borders! Gui, Add, Edit, x50 y50 w200 h200 HwndHEDIT, Drop target! Gui, Add, Button, xp y+10, Just a button! Gui, Add, Edit, x320 y50 w160 h200, Don't accept files! Gui, Show, w500 h350, Drag&Drop DropTarget := HEDIT OnMessage(WM_DROPFILES, "On_WM_DROPFILES") Return On_WM_DROPFILES(WParam, LParam, Msg, HWND) { ; http://msdn.microsoft.com/en-us/library/bb774303(v=vs.85) ; WParam contains a handle to an internal structure describing the dropped files. ; Pass this handle DragFinish, DragQueryFile, or DragQueryPoint to retrieve information about the dropped files. Static DragQueryFile := "Shell32.dll\DragQueryFile" . (A_IsUnicode ? "W" : "A") Global DropTarget ; Global variable containing the target control's HWND Dropped := "" Files := DllCall(DragQueryFile, "Ptr", WParam, "UInt", -1, "Ptr", 0, "UInt", 0, "UInt") Loop, % Files { Length := DllCall(DragQueryFile, "Ptr", WParam, "UInt", A_Index - 1, "Ptr", 0, "UInt", 0, "UInt") + 1 VarSetCapacity(File, Length * (A_IsUnicode ? 2 : 1), 0) DllCall(DragQueryFile, "Ptr", WParam, "UInt", A_Index - 1, "Str", File, "UInt", Length, "UInt") Dropped .= File . "`r`n" } DllCall("Shell32.dll\DragFinish", "Ptr", WParam) GuiControl, , % DropTarget, % RTrim(Dropped, "`r`n") Return 0 }
Works perfectly awesome... thanx

#12
-
Posted 22 May 2012 - 06:23 AM
![[SOLVED] Binding area of GuiDropFiles: post #12](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
brilliant, thanks for that, just me. I'm sure I'll need that in a script eventually.
#13
-
Posted 22 May 2012 - 06:55 AM
![[SOLVED] Binding area of GuiDropFiles: post #13](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)