grimta Posted July 26, 2017 Share Posted July 26, 2017 Hi everyone, I have not found anything related to my question, so will try to ask here, maybe someone will know. $GUI_DROPACCEPTED - Accept drag/drop function for selected field. My question is about separator. When I drop 2 files they separated by "|" (Pipe) and I need t will be separated by ";" any way of work around, or I have missed the simple solution for this? Link to comment Share on other sites More sharing options...
Developers Jos Posted July 26, 2017 Developers Share Posted July 26, 2017 Don't understand the question. What exactly do you need? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
grimta Posted July 27, 2017 Author Share Posted July 27, 2017 When I drag two files into the field, I have: " files1|file2" and what I need is: "file1;file2" Link to comment Share on other sites More sharing options...
Developers Jos Posted July 27, 2017 Developers Share Posted July 27, 2017 So simply do a StringReplace() function after you have received that Original string? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
grimta Posted July 27, 2017 Author Share Posted July 27, 2017 I do not know why (I have tried it already) , but it does not work, any possibility to show any sample for this solution? Link to comment Share on other sites More sharing options...
TheDcoder Posted July 27, 2017 Share Posted July 27, 2017 StringReplace('file1|file2', '|', ';') EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
grimta Posted July 27, 2017 Author Share Posted July 27, 2017 50 minutes ago, TheDcoder said: StringReplace('file1|file2', '|', ';') $filesSet_REP_BEFORE = GUICtrlCreateInput("", 30, 140, 400, 20) $filesSet_REP = StringReplace($filesSet_REP_BEFORE, '|', ';') Does not work Link to comment Share on other sites More sharing options...
TheDcoder Posted July 27, 2017 Share Posted July 27, 2017 Well... $filesSet_REP_BEFORE is a control ID so why would it work? You should be using something like @GUI_DragFile EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
grimta Posted July 27, 2017 Author Share Posted July 27, 2017 18 minutes ago, TheDcoder said: Well... $filesSet_REP_BEFORE is a control ID so why would it work? You should be using something like @GUI_DragFile Sorry, I have like this $filesSet_REP_BEFORE = GUICtrlCreateInput("", 30, 140, 400, 20)$filesSet_REP = StringReplace($filesSet_REP_BEFORE, '|', ';') GUICtrlSetState($filesSet_REP_BEFORE, $GUI_DROPACCEPTED) Link to comment Share on other sites More sharing options...
Developers Jos Posted July 27, 2017 Developers Share Posted July 27, 2017 3 hours ago, grimta said: but it does not work, any possibility to show any sample for this solution? What about you show what you tried that isn't working... sound much simpler to me! Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
grimta Posted July 27, 2017 Author Share Posted July 27, 2017 31 minutes ago, Jos said: What about you show what you tried that isn't working... sound much simpler to me! Jos This is what I have tried: $filesSet_REP_BEFORE = GUICtrlCreateInput("", 30, 140, 400, 20) GUICtrlSetState($filesSet_REP_BEFORE, $GUI_DROPACCEPTED)$filesSet_REP = StringReplace($filesSet_REP_BEFORE, '|', ';') Ideally I need that when client will drag files to the field it will be display already with ";" and not with "|" Link to comment Share on other sites More sharing options...
mikell Posted July 27, 2017 Share Posted July 27, 2017 (edited) 33 minutes ago, grimta said: Ideally I need that when client will drag files to the field it will be display already with ";" and not with "|" OK, the only way I can - currently - think of is this one expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> OnAutoItExitRegister('OnAutoItExit') ; Create GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 500, 100) Global $input = GUICtrlCreateInput("", 10, 40, 480, 20) $hInput = GuiCtrlGetHandle($input) _WinAPI_DragAcceptFiles($hInput) ; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later) #cs If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hInput, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hInput, $WM_DROPFILES, $MSGFLT_ALLOW) EndIf #ce ; Register input window proc Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') Global $g_pDll = DllCallbackGetPtr($g_hDll) Global $g_hProc = _WinAPI_SetWindowLong($hInput, $GWL_WNDPROC, $g_pDll) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_DROPFILES Local $aFileList = _WinAPI_DragQueryFileEx($wParam) If not @error Then Local $list For $i = 1 To $aFileList[0] $list &= $aFileList[$i] & ";" Next GuiCtrlSetData($input, StringTrimRight($list, 1)) _WinAPI_DragFinish($wParam) Return 0 EndIf EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func OnAutoItExit() _WinAPI_SetWindowLong($hInput, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit Edited July 27, 2017 by mikell Melba23 and grimta 2 Link to comment Share on other sites More sharing options...
TheSaint Posted July 27, 2017 Share Posted July 27, 2017 (edited) 3 hours ago, grimta said: $filesSet_REP_BEFORE = GUICtrlCreateInput("", 30, 140, 400, 20)$filesSet_REP = StringReplace($filesSet_REP_BEFORE, '|', ';') GUICtrlSetState($filesSet_REP_BEFORE, $GUI_DROPACCEPTED) $filesSet_REP_BEFORE is not the content of the Input field, it is the ID of the input field. You need to read the content of that control (field) using the ID. i.e. $filesSet_REP = GUICtrlRead($filesSet_REP_BEFORE) Then you can work with the value. i.e. $filesSet_REP = StringReplace($filesSet_REP, "|", ";") Altogether, you should have. $filesSet_REP_BEFORE = GUICtrlCreateInput("", 30, 140, 400, 20) $filesSet_REP = GUICtrlRead($filesSet_REP_BEFORE) $filesSet_REP = StringReplace($filesSet_REP, "|", ";") But if you are wanting to work with $GUI_DROPACCEPTED you are doing it all wrong anyway. TheDcoder gave you a clue to go on with, using the Help file .... @GUI_DragFile But I really think you could benefit from doing some simple AutoIt tutorials, before learning to fly, as the concepts of reading and setting data are not evident in your understanding as displayed. Edited July 27, 2017 by TheSaint 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...
grimta Posted July 27, 2017 Author Share Posted July 27, 2017 OK, the only way I can - currently - think of is this one expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> OnAutoItExitRegister('OnAutoItExit') ; Create GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 500, 100) Global $input = GUICtrlCreateInput("", 10, 40, 480, 20) $hInput = GuiCtrlGetHandle($input) _WinAPI_DragAcceptFiles($hInput) ; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later) #cs If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hInput, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) _WinAPI_ChangeWindowMessageFilterEx($hInput, $WM_DROPFILES, $MSGFLT_ALLOW) EndIf #ce ; Register input window proc Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') Global $g_pDll = DllCallbackGetPtr($g_hDll) Global $g_hProc = _WinAPI_SetWindowLong($hInput, $GWL_WNDPROC, $g_pDll) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_DROPFILES Local $aFileList = _WinAPI_DragQueryFileEx($wParam) If not @error Then Local $list For $i = 1 To $aFileList[0] $list &= $aFileList[$i] & ";" Next GuiCtrlSetData($input, StringTrimRight($list, 1)) _WinAPI_DragFinish($wParam) Return 0 EndIf EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func OnAutoItExit() _WinAPI_SetWindowLong($hInput, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit This way does work, thank you very much for this. I thought initially, it should simpler solution for this kind of things O_o 1 hour ago, TheSaint said: $filesSet_REP_BEFORE is not the content of the Input field, it is the ID of the input field. You need to read the content of that control (field) using the ID. i.e. $filesSet_REP = GUICtrlRead($filesSet_REP_BEFORE) Then you can work with the value. i.e. $filesSet_REP = StringReplace($filesSet_REP, "|", ";") Altogether, you should have. $filesSet_REP_BEFORE = GUICtrlCreateInput("", 30, 140, 400, 20) $filesSet_REP = GUICtrlRead($filesSet_REP_BEFORE) $filesSet_REP = StringReplace($filesSet_REP, "|", ";") But if you are wanting to work with $GUI_DROPACCEPTED you are doing it all wrong anyway. TheDcoder gave you a clue to go on with, using the Help file .... @GUI_DragFile But I really think you could benefit from doing some simple AutoIt tutorials, before learning to fly, as the concepts of reading and setting data are not evident in your understanding as displayed. I have tried to look for some help related to @GUI_DragFile , but I'm not sure where exactly take information from. This is only things I have found: https://www.autoitscript.com/trac/autoit/ticket/1870https://www.autoitscript.com/forum/topic/90806-gui_dragfile/ If you have any good source to read, will be appreciated. Link to comment Share on other sites More sharing options...
TheDcoder Posted July 27, 2017 Share Posted July 27, 2017 1 minute ago, grimta said: If you have any good source to read, will be appreciated. Surprising that you didn't know about the help file! Just press F1 in SciTE EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
mikell Posted July 27, 2017 Share Posted July 27, 2017 (edited) @GUI_DragFile will not bring more benefit for the desired action than a simple GuiCtrlRead, as reading @GUI_DragFile gives file names also separated by a pipe OTOH , setting Opt(GUIDataSeparatorChar, ";") doesn't work for this So for an instant display in the input using ";" as separator, the only way is to intercept the message before writing in the input Edited July 27, 2017 by mikell tie paw grimta 1 Link to comment Share on other sites More sharing options...
TheSaint Posted July 30, 2017 Share Posted July 30, 2017 On 28/7/2017 at 0:02 AM, grimta said: I thought initially, it should simpler solution for this kind of things The simpler way, is to treat the result from drag & drop as an array, either from GUICtrlRead or the @GUI_DragFile, and separate out the elements that way. Mikell has provided you a beautiful example of the clever way, that is understandably more complex for beginners to understand. If however, you want to get down and dirty and understand/learn/grow more easily from a simpler approach, then investigate arrays and probably the StringSplit command in particular. 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...
mikell Posted July 30, 2017 Share Posted July 30, 2017 @grimta On 27/7/2017 at 4:32 PM, grimta said: I thought initially, it should simpler solution for this kind of things And in fact you were not totally wrong My code above does the modification before writing in the input. Pretty nice correct and all, but as TheSaint pointed out, not so easy to handle. So the easiest workaround is to make the modification in the input just after writing, so fast than you can't see Example #1, using $GUI_EVENT_DROPPED : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $hForm = GUICreate('Test', 500, 100, -1, -1, -1, $WS_EX_ACCEPTFILES) Global $input = GUICtrlCreateInput("", 10, 40, 480, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED If @GUI_DropId = $input Then GuiCtrlSetData($input, StringReplace(GUICtrlRead($input), "|", ";") ) EndIf EndSwitch WEnd Example #2 using GUIRegisterMsg : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Local $hForm = GUICreate('Test', 500, 100, -1, -1, -1, $WS_EX_ACCEPTFILES) Global $input = GUICtrlCreateInput("", 10, 40, 480, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) Local $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $input Switch $iCode Case $EN_UPDATE ;$EN_CHANGE GuiCtrlSetData($input, StringReplace(GUICtrlRead($input), "|", ";") ) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND grimta 1 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