satanttin Posted May 18, 2015 Share Posted May 18, 2015 Hello all,I was wondering if it's possible to make a gui that lets me drag and drop files/programs in it and open it from there.Also is this possible with an option to right click and delete an file/program from there?Haven't wrote any code yet since i have no clue on how to start. So any help and tips are very welcome Greetings. Link to comment Share on other sites More sharing options...
mikell Posted May 18, 2015 Share Posted May 18, 2015 You could use a listviewTry this to start#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> GUICreate("listview items", 420, 150, 100, 200, -1, $WS_EX_ACCEPTFILES) $listview = GUICtrlCreateListView("|column1|column2 ", 10, 10, 400, 130) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 1, 300) GUICtrlCreateListViewItem("|" & @Autoitexe & "|" & FileGetVersion(@Autoitexe ), $listview) GUICtrlSetImage(-1, @Autoitexe, -1) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED GUICtrlCreateListViewItem("|" & @GUI_DragFile & "|" & FileGetVersion(@GUI_DragFile), $listview) GUICtrlSetImage(-1, @GUI_DragFile, -1) EndSwitch Wend Link to comment Share on other sites More sharing options...
MikahS Posted May 18, 2015 Share Posted May 18, 2015 (edited) Have a look at this example by Melba23: Link Edited May 18, 2015 by MikahS cleanup Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
satanttin Posted May 18, 2015 Author Share Posted May 18, 2015 @Mikell Could be my second choice rather have icons like u have on your desktop. Btw once i added a file with your script i can't open it or remove it. @MikahS Thanks for the link i shall check this out! Link to comment Share on other sites More sharing options...
mikell Posted May 18, 2015 Share Posted May 18, 2015 Btw once i added a file with your script i can't open it or remove it.Hmm I said "to start" ... unless you want people make the complete script for you ? Link to comment Share on other sites More sharing options...
satanttin Posted May 19, 2015 Author Share Posted May 19, 2015 Think i missed that part. And no i prefer writing everything myself actually.I will take another look and hope i can do it Link to comment Share on other sites More sharing options...
satanttin Posted May 19, 2015 Author Share Posted May 19, 2015 M'kay so i've put everything in oneventmode so it's easier for me to code with. So far i've tried a couple of things to make sure i can open the files from the gui without success.The code i have so far is:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> Global $listview, $Main, $test Opt("GUIOnEventMode", 1) Main() Func Main() $Main = GUICreate("listview items", 420, 150, 100, 200, -1, $WS_EX_ACCEPTFILES) $listview = GUICtrlCreateListView("|column1 ", 10, 10, 400, 130) GUICtrlSetState($listview, $GUI_DROPACCEPTED) GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 1, 365) GUICtrlCreateListViewItem("|" & @Autoitexe & "|" , $listview) GUICtrlSetImage(-1, @Autoitexe, -1) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "stop") GUISetOnEvent($GUI_EVENT_DROPPED, "Dropped") GUISetOnEvent($test, "stop") EndFunc Func Dropped() $test = GUICtrlCreateListViewItem("|" & @GUI_DragFile & "|" , $listview) GUICtrlSetImage(-1, @GUI_DragFile, -1) EndFunc Func stop() MsgBox(0,"",@GUI_DragFile) Exit EndFunc While 1 Sleep(50) WEndNever worked with treeview before so sorry if the things i've tried are wrong. But as you see i've tried to make an guisetonevent for $test and the msgbox works it shows me the path of the file i dragged into my gui. altho if i put in multiple files it only shows me the last one i dragged into it. even if i selected the first on i dragged into.And another thing is it doesn't work if i click on the treeviewitem just if i make an extra button like i used the X button for as a test.is there another way so i can click the treeviewitem or do i really need to use some sort of a button? Sorry if this wasn't clear i tried my best Link to comment Share on other sites More sharing options...
MikahS Posted May 19, 2015 Share Posted May 19, 2015 Here is an example of multiple file drag & drop by guinness: linkOtherwise, you are actually working with a ListView control and you'll have to register the WM_NOTIFY event to open something on clicking an item. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
satanttin Posted May 19, 2015 Author Share Posted May 19, 2015 Thanks for the information:) i will check this out^^ Link to comment Share on other sites More sharing options...
MikahS Posted May 19, 2015 Share Posted May 19, 2015 My pleasure. Let us know if you hit any snags. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ 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