13lack13lade Posted August 21, 2013 Posted August 21, 2013 Hey Guys!!! Hope everyones well on this fine Wednesday morning! So im starting to take my automation skills with vba/autoit further and start setting up GUI's Dashboards etc... However i cant seem to get the simplest "click button 1 = run(thisfile)" I have read through the help file however cant figure it out(self taught) I thought it was like this, just from going off the example and using Koda GUI creator, Loads up fine but the buttons just dont wanna do anything! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\webbth\Desktop\Automation\GUI\Form1.kxf $Form1 = GUICreate("Form1", 196, 279, 373, 211) $Button1 = GUICtrlCreateButton("South Pacific Landline", 16, 136, 161, 33) $Button2 = GUICtrlCreateButton("Asia Landline", 16, 184, 161, 33) $Button3 = GUICtrlCreateButton("Europe Landline", 16, 232, 161, 33) $Progress1 = GUICtrlCreateProgress(16, 96, 161, 17) $Pic1 = GUICtrlCreatePic("C:\Users\webbth\Pictures\Untitled1111.jpg", 0, 0, 193, 73) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Case $nmsg = $Button1 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\SouthPacLandline.au3") ; Will run SouthPac Landline Case $nmsg = $Button2 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\AsiaLandline.au3") ; Will run Asia Landline Case $nmsg = $Button3 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\EuropeLandline.au3") ; Will run Europe Landline Exit EndSwitch Thanks in advance and apologies for my totally noob question!
BrewManNH Posted August 21, 2013 Posted August 21, 2013 Your switch statements are written wrong, look in the help file to how it should be done. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Realm Posted August 21, 2013 Posted August 21, 2013 (edited) Hello 13lack13lade, First, Welcome to the AutoIt Forums Your Case statement is written wrong. Your Case statements do not need the variable the switch is check listed again. Also you don't end the While loop which will result in a fatal error. Take a look at this example and the comments I added. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;Needs to be placed here or outside of the loop. Case $Button1 ;in Switch loop the variable is already been declared to be checked int he Switch handle. Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\SouthPacLandline.au3") ; Will run SouthPac Landline Case $Button2 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\AsiaLandline.au3") ; Will run Asia Landline Case $Button3 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\EuropeLandline.au3") ; Will run Europe Landline EndSwitch WEnd ;Need to end a While loop If you choose to place Exit outside of your loop, include a way to exit the loop as in this example: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 ;in Switch loop the variable is already been declared to be checked int he Switch handle. Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\SouthPacLandline.au3") ; Will run SouthPac Landline Case $Button2 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\AsiaLandline.au3") ; Will run Asia Landline Case $Button3 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\EuropeLandline.au3") ; Will run Europe Landline EndSwitch WEnd ;Need to end a While loop Exit Edited August 21, 2013 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.
13lack13lade Posted August 21, 2013 Author Posted August 21, 2013 Thanks guys that makes more sense! I thought that this code below is saying 'if button 3 is pressed run that script' Case $Button3 Run("\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\EuropeLandline.au3") ; Will run Europe Landline However the buttons still dont do anything.. i am using the help file however to no avail. again sorry for the noob questions =[
Realm Posted August 21, 2013 Posted August 21, 2013 (edited) I did not originally notice that your attempting to run scripts. There are a few ways to remedy this. ShellExecute( "\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\EuropeLandline.au3" ) Or if you need the program ID, you could compile the other three scripts and call them in application form with the .exe extension. However, if you wish to run then as script for testing purpose while still obtaining a program ID, you could run AutoIt3.exe passing the script in parameter as such: Run('AutoIt3.exe "\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\EuropeLandline.au3"') Notice that in this last Example there are quotation marks wrapping the path. Paths with spaces need to be enclosed in quotation marks. I do apologize for not recognizing the scripts originally. Realm Edited August 21, 2013 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.
13lack13lade Posted August 21, 2013 Author Posted August 21, 2013 Hey Realm, Thats all good, thanks again for responding. I have tried both shellexecute and the other run however both did nothing.. From my understanding i thought the easiest way to create the GUI would be to have the premade scripts and then just have a button run the appropriate script. Is the way im trying to do it incorrect or not the best? Should i be changing my GUI to be OnEvents rather than Loop? Completely lost just when i thought i had it all figured out! lol
13lack13lade Posted August 21, 2013 Author Posted August 21, 2013 (edited) anyone? seems like something really simple that im missing. Have tried everything ! cannot get this to work at all. Edited August 22, 2013 by 13lack13lade
BrewManNH Posted August 22, 2013 Posted August 22, 2013 Do you have autoit installed on the target computer? Is a file with an au3 extension associated to AutoIt? Have you tried running the second script using the first script and the command line parameter? Run a script using another compiled script: Compiled.exe [/ErrorStdOut] /AutoIt3ExecuteScript file [params ...] Execute another AutoIt script file from a compiled AutoIt3 executable. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
13lack13lade Posted August 22, 2013 Author Posted August 22, 2013 Yes, Yes scripts automatically run when opened. Script is not complied just in .au3 format but that shouldnt make a difference should it if im using Run ? Sorry but im not too sure what you mean about running the second script using the first script and command line parameter
BrewManNH Posted August 22, 2013 Posted August 22, 2013 Yes, Yes scripts automatically run when opened. Script is not complied just in .au3 format but that shouldnt make a difference should it if im using Run ?It makes all the difference in the world, because you can't use the command line parameter to run the second script.Sorry but im not too sure what you mean about running the second script using the first script and command line parameterSeriously? I posted the way to do that, quoted directly from the help file, in my post. How was that not clear? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
13lack13lade Posted August 22, 2013 Author Posted August 22, 2013 (edited) It makes all the difference in the world, because you can't use the command line parameter to run the second script. Seriously? I posted the way to do that, quoted directly from the help file, in my post. How was that not clear? I didnt know you had to compile a script in order for that script to be run from another script, and seeing how i was just going off the help file to create a GUI and just wanted to run a script at the click of a button it didnt say anything about 'Compiled.exe [/ErrorStdOut] /AutoIt3ExecuteScript file [params ...]' I am only a beginner i do not have the knowledge of Autoit like you do and i apologize if my questions seem stupid but ive been using the help file and i didnt see anywhere that you needed to have a script compiled to run that script within a script or from a button(would make sense to have an example like that in the help file for something as simple as running a script from a click of a button in a GUI made in autoit). - Not saying its not there just saying i havn't come across it for what im trying to do. And also looking at the commandline straight from the help file im taking from the very first syntax here that i CAN run a script without it being compiled? Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...] Execute an AutoIt3 Script File which looks similar to what Realm was trying to show me: Run('AutoIt3.exe "\\fbnecl3\inzb\Documents\Load Support\Tom\Automation\GUI\EuropeLandline.au3"') Im not a programmer and im not trying to waste anyones time BrewManNH - But if i dont understand something throwing some code at me that i ALSO do not understand isnt going to help me so im sorry if you took that iwas just being lazy from the way i replied. Edited August 22, 2013 by 13lack13lade
shaadisan Posted August 26, 2013 Posted August 26, 2013 Your all statement is not write. Take the search on the Google or use any book for accurate decisions.
Moderators Melba23 Posted August 26, 2013 Moderators Posted August 26, 2013 shaadisan,Either post sensibly or do not post at all - the above added precisely nothing to the thread. 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
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