Jump to content

Problem with one drag and drop gui


Wollf
 Share

Recommended Posts

I made a small window with some buttons and with a drag and drop box but for some reason it doesnt work anyone know what i do wrong here?

second question is how i can put images at buttons?

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1) 
$hGUI = GUICreate("Form1", 685, 629, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Label1 = GUICtrlCreateLabel("Directories", 80, 24, 91, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100)
$Pic2 = GUICtrlCreatebutton("", 124, 68, 100, 100)
$Pic3 = GUICtrlCreatebutton("", 16, 176, 100, 100)
$Pic4 = GUICtrlCreatebutton("", 124, 176, 100, 100)
$Pic5 = GUICtrlCreatebutton("", 16, 284, 100, 100)
$Pic6 = GUICtrlCreatebutton("", 124, 284, 100, 100)
$Pic7 = GUICtrlCreatebutton("", 16, 392, 100, 100)
$Pic8 = GUICtrlCreatebutton("", 124, 392, 100, 100)
$Pic9 = GUICtrlCreatebutton("", 16, 500, 100, 100)
$Pic10 = GUICtrlCreatebutton("", 124, 500, 100, 100)

$Button1 = GUICtrlCreateButton("", 388, 452, 125, 45, 0)
GUICtrlSetOnEvent(-1, "b1")
$Label2 = GUICtrlCreateLabel("", 260, 32, 417, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$cListBox = GUICtrlCreateList("", 350, 100, 200, 200)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

Func b1 ()
    SoundPlay("dog_puppy_2.wav")
    msgbox(0, "Firefox", "Firefox willopen", 1)
    Run(@GUI_DRAGFILE)
EndFunc

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DRAGFILE & @CRLF, 1)
    EndSwitch
WEnd
Link to comment
Share on other sites

  • Moderators

Wollf,

Answer to second question:

Quote from help file:

A Button control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage to specify the picture to use.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_BUTTON, newstyle,...).

Search the forums if you cannot get it to work first time. There are plenty of examples out there if you look. ;-)

M23

Edited by Melba23

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

 

Link to comment
Share on other sites

Also, don't use Opt('GuiOnEventMode', 1) and a message loop. It doesn't work this way, just create a function that handle all the events on the listbox control and process it there, keep in mind that you'll get notified for all the events which each has to be handled differently so try to use GuiRegisterMsg and differentiate the control and event there...

Link to comment
Share on other sites

thanks for help it seemed that Opt('GuiOnEventMode', 1) was disabling drag and drop box, now it works fin but it cant run shortcuts or other files only exe files(how can i change it to run everything?

2)how can i move files dropped there to another folder? will it transfer all files i drop there if i move files with gui dragfile?

3)i want to put small images that i made for button, same pixels as button nut i need a bit more help

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Form1", 685, 629, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Label1 = GUICtrlCreateLabel("Directories", 80, 24, 91, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100)
$Pic2 = GUICtrlCreatebutton("", 124, 68, 100, 100)
$Pic3 = GUICtrlCreatebutton("", 16, 176, 100, 100)
$Pic4 = GUICtrlCreatebutton("", 124, 176, 100, 100)
$Pic5 = GUICtrlCreatebutton("", 16, 284, 100, 100)
$Pic6 = GUICtrlCreatebutton("", 124, 284, 100, 100)
$Pic7 = GUICtrlCreatebutton("", 16, 392, 100, 100)
$Pic8 = GUICtrlCreatebutton("", 124, 392, 100, 100)
$Pic9 = GUICtrlCreatebutton("", 16, 500, 100, 100)
$Pic10 = GUICtrlCreatebutton("", 124, 500, 100, 100)

$1 = GUICtrlCreateButton("Send", 388, 452, 125, 45, 0)

$Label2 = GUICtrlCreateLabel("Enter files", 260, 32, 417, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$cListBox = GUICtrlCreateList("", 350, 100, 200, 200)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DRAGFILE & @CRLF, 1)
        EndSwitch
        If $msg = $1 then
            SoundPlay("dog_puppy_2.wav")
            Run(@GUI_DRAGFILE)
            EndIf
WEnd
Link to comment
Share on other sites

  • Moderators

Wollf,

A1. From the Help file (you really should read it in more detail, you know!):

Why can I only use Run() to execute .exe files? What about .msi / .txt and others?

Only a few file extensions are usually "runable" - these are .exe, .bat, .com, .pif. Other file types like .txt and .msi are actually executed with another program. When you double click on a "myfile.msi" file what actually happens in the background is that "msiexec.exe myfile.msi" is executed. So to run a .msi file from AutoIt you would do:

RunWait("msiexec myfile.msi")

Or, run the command "start" which will automatically work out how to execute the file for you:

RunWait(@COMSPEC & " /c Start myfile.msi")

Or, use the ShellExecuteWait function which will automatically work out how to execute the file for you:

ShellExecuteWait("myfile.msi")

A2. Get the file name into the edit, read the edit and then do what you want with the result.

A3. Do this for each button:

$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP)

GUICtrlSetImage ($Pic1, "image.bmp")

Again: Read the help file - it gives most of the answers if you look hard enough!

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

 

Link to comment
Share on other sites

Thanks for help i tried to use what u said about picture and i have some problems

$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP)

$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP^ERROR

ERROR PARSING FUNCTION CALL

Also what the order for tranfering files arond directories because i didnt undearstand a2

should i use filemove and how exactly i can use it with gui dragfile?

i could use help file but after the basics its very difficult find what u need

Edited by Wollf
Link to comment
Share on other sites

  • Moderators

Wollf,

Sorry, I missed off the final ")". It should read:

$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))

As to the Help file being hard - so is life! You will get much more help here if you have tried something yourself first. People do not like helping those who have made no attempt to help themselves.

There are 2 very good tutorials on Autoit here and here. I really think you would gain as an Autoit programmer from reading them.

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

 

Link to comment
Share on other sites

yes it works thanks

$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic1, "1.jpg")

but i still cant see the picture it is the same pixels as buttons but i dont know what i am doing wrong here?

sry for nonstop questions

Edited by Wollf
Link to comment
Share on other sites

  • Moderators

Wollf,

$BS_BITMAP

1.jpg

Does that give you a clue?

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

 

Link to comment
Share on other sites

i changed icon to bmp and it worked.

i want to write something at $1 an input by pressing a box i know i could use tabs to reach input but there should be a more simple way, what could i use to write something at an input?

Link to comment
Share on other sites

  • Moderators

Wollf,

Go and read the Help file and those tutorials I told you about.

We are not going to write your whole script for you. Come back when you have some code that you have written yourself.

"Click"

Authenticity,

Are you sure? It did not work for me when I used a .jpg file - and I did try before posting ;-)

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

 

Link to comment
Share on other sites

Ι have a problem with that code a get error of while and wend not matching i dont have any idea what i do wrong here.

also i did it so it can write some text at input but this is very way is very time consuming and since i dont know i asked if there was any other way i can do it since i dont know and i can learn.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

$hGUI = GUICreate("Form1", 685, 629, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Label1 = GUICtrlCreateLabel("Directories", 80, 24, 91, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic1, "images/1.bmp")
$Pic2 = GUICtrlCreatebutton("", 124, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic2, "images/1.bmp")
$Pic3 = GUICtrlCreatebutton("", 16, 176, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic3, "images/1.bmp")
$Pic4 = GUICtrlCreatebutton("", 124, 176, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic4, "images/1.bmp")
$Pic5 = GUICtrlCreatebutton("", 16, 284, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic5, "images/1.bmp")
$Pic6 = GUICtrlCreatebutton("", 124, 284, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic6, "images/1.bmp")
$Pic7 = GUICtrlCreatebutton("", 16, 392, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic7, "images/1.bmp")
$Pic8 = GUICtrlCreatebutton("", 124, 392, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic8, "images/1.bmp")
$Pic9 = GUICtrlCreatebutton("", 16, 500, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic9, "images/1.bmp")
$Pic10 = GUICtrlCreatebutton("", 124, 500, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP))
GUICtrlSetImage($Pic10, "images/1.bmp")

$1 = GUICtrlCreateButton("Send", 388, 452, 125, 45, 0)
GUICtrlCreateInput("C:\LESSONS\...",370,70,155,25)
$Label2 = GUICtrlCreateLabel("Enter files in the box below", 365, 32, 417, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$cListBox = GUICtrlCreateList("", 350, 150, 200, 200)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            GUICtrlSetData($cListBox, @GUI_DRAGFILE & @CRLF, 1)
        EndSwitch
        If $msg = $1 then
            SoundPlay("dog_puppy_2.wav")
            Run(@GUI_DRAGFILE)
        if $msg = $pic1 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 11}")
            send("c:\lessons\maths")
            if $msg = $pic2 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 10}")
            send("c:\lessons\Direction maths")
            if $msg = $pic3 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 9}")
            send("c:\lessons\Geography")
            if $msg = $pic4 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 8}")
            send("c:\lessons\biology")
            if $msg = $pic5 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 7}")
            send("c:\lessons\Ancient Greek")
            if $msg = $pic6 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 6}")
            send("c:\lessons\New greek")
            if $msg = $pic7 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 5}")
            send("c:\lessons\Geometry")
            if $msg = $pic8 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 4}")
            send("c:\lessons\Programming tools")
            if $msg = $pic9 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 3}")
            send("c:\lessons\Programming")
            if $msg = $pic10 then
            SoundPlay("dog_puppy_2.wav")
            send("{TAB 2}")
            send("c:\lessons\Physic")
            EndIf
WEnd
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...