Wollf Posted February 2, 2009 Share Posted February 2, 2009 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? expandcollapse popup#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 More sharing options...
Moderators Melba23 Posted February 2, 2009 Moderators Share Posted February 2, 2009 (edited) 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 February 2, 2009 by Melba23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Authenticity Posted February 2, 2009 Share Posted February 2, 2009 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 More sharing options...
Wollf Posted February 2, 2009 Author Share Posted February 2, 2009 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 expandcollapse popup#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 More sharing options...
Moderators Melba23 Posted February 2, 2009 Moderators Share Posted February 2, 2009 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Wollf Posted February 2, 2009 Author Share Posted February 2, 2009 (edited) 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 February 2, 2009 by Wollf Link to comment Share on other sites More sharing options...
Authenticity Posted February 2, 2009 Share Posted February 2, 2009 The error is a syntax one, use two bracket - "))". Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2009 Moderators Share Posted February 2, 2009 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Wollf Posted February 2, 2009 Author Share Posted February 2, 2009 i tried using with 2 ) but it didnt worked it was saying variable used without being declared do i do something wrong here? Link to comment Share on other sites More sharing options...
Authenticity Posted February 2, 2009 Share Posted February 2, 2009 lol man, so what can it be? is the $BS_BITMAP is declared wither by your script or the included ones? Link to comment Share on other sites More sharing options...
Wollf Posted February 2, 2009 Author Share Posted February 2, 2009 $Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr($GUI_SS_DEFAULT_BUTTON, $BS_BITMAP) $Pic1 = GUICtrlCreatebutton("", 16, 68, 100, 100, BitOr(^ERROR error variable used without being declared Link to comment Share on other sites More sharing options...
Authenticity Posted February 2, 2009 Share Posted February 2, 2009 #include <ButtonConstants.au3> check this out... Link to comment Share on other sites More sharing options...
Wollf Posted February 2, 2009 Author Share Posted February 2, 2009 (edited) 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 February 2, 2009 by Wollf Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2009 Moderators Share Posted February 2, 2009 Wollf,$BS_BITMAP1.jpgDoes that give you a clue?M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Authenticity Posted February 2, 2009 Share Posted February 2, 2009 You can give .jpg format for this function, it's not the case... maybe the file path need to be included like @ScriptDir & '\1.jpg Link to comment Share on other sites More sharing options...
Wollf Posted February 2, 2009 Author Share Posted February 2, 2009 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 More sharing options...
Moderators Melba23 Posted February 2, 2009 Moderators Share Posted February 2, 2009 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Authenticity Posted February 2, 2009 Share Posted February 2, 2009 heh... Unless I have a special AutoIt designed just for my needs then yes. Link to comment Share on other sites More sharing options...
Wollf Posted February 2, 2009 Author Share Posted February 2, 2009 Ι 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. expandcollapse popup#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 More sharing options...
Authenticity Posted February 2, 2009 Share Posted February 2, 2009 You should carefully read what SciTE has found and search this place for a syntax error, some of your If statements doesn't have a matching EndIf. 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