Sign in to follow this  
Followers 0
jgq85

Error in GUI function script

5 posts in this topic

I have a GUI script and setup Case with Variables and then functions for each case.

The script runs fine with no errors until I add something into this one function (for a button on the GUI that when pushed, should simply launch a website).

Not sure if I need the entire code here or if someone can identify whether I'm just unable to accomplish this within a Func / EndFunc.

Syntax Check shows no errors in the script when this portion of the script is simply:

Func _OpenDIDButton()
EndFunc

But when I take that portion of the script, and add something inside of it, such as:

Func _OpenDIDButton()
#include <IE.au3>
_IECreate ( [$s_Url = "about:blank" [, $f_tryAttach = 0 [, $f_visible = 1 [, $f_wait = 1 [, $f_takeFocus = 1]]]]] )
EndFunc

Then I run Syntax Check and it reports:

C:\Program Files\AutoIt3\Include\WinAPIError.au3(29,1) : ERROR: syntax error

Func

^

Is that referencing line 29, character 1?

Line 29 is in this portion:

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $GenChecklistButton
   _GenCheckListButton()
  Case $EmailMgrsButton
   _EmailMgrsButton()
  Case $DisableADButton
   _DisableADButton()
  Case $OpenDIDButton
   _OpenDIDButton()
EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include "pastes" the file where the statement is, so what you are doing here is just no going to work. You can't declare a function inside of another (just like the error said). Why are you trying that anyway?

Just move the #include to the top of your script.

Edit:

Is that referencing line 29, character 1?

Something like that. Why don't you look at the two lines under that where it shows exactly where the problem is?

Func

^

It's not that hard if you think logically.

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

jgq85,

The #include directive adds the code at that point in the script - so you are putting all of IE.au3 inside your function. :oops:

Just add the #include line at the top of your script and see if that solves your problem. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

BTW: Your _IECreate statement is wrong. You inserted the syntax description.

Try something like:

_IECreate("www.google.com")
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2016-05-02 - Version 1.4.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-01-07 - Version 1.1.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

Thanks that works. I did try moving the # include to top, but had still left the wrong IECreate function (copy/paste from the reference website).

I do something beyond a few lines of code and start acting stupid.

Thanks again and SORRY!!!

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • Tumulus
      Help with Hash
      By Tumulus
      I am creating a script that changes important account information, including passwords and usernames, but I can't take the input from a user at runtime. I could get the script to work with the information included in variables, but that is a security risk we want to avoid. As far as I can tell, _Crypt_HashData or possible _Crypt_EncryptData are how I would go about this. I looked at the help file and I am struggling to understand the implementation. 
      Do I need an external document with the info? That would present the same issue. Do I need to create the variable and then run the function in another script and then add it in? I am quite lost.
      Could somone give me a basic step-by-step rundown? 
    • Tumulus
      Use Elevated CMD
      By Tumulus
      I need to create a new administrator account on a number of computers, so figured I would make a script to do it. 
      You can only add/modify admin profile from an elevated command prompt (administrator command prompt). So I tried writing that into my short script. I thought that my "RunAs" command below would do the trick, but it opens a standard cmd window through the admin profile.
      Anyone able to tell me how to get it to open the elevated cmd?
      RunAs("administrator",@ComputerName,$sAdminPassword,0,@ComSpec) Sleep (500) Send("net user /ADD " & $sUsername & " " & $sPassword) Send("{ENTER}") Send("Y") Send("{ENTER}") Send("net user " & $sUsername & " /passwordchg:no") Send("{ENTER}") Send("net localGroup administrators " & $sUsername & " /ADD") Send("{ENTER}") WinClose("C:\Windows\system32\cmd.exe")  
    • Valnurat
      Merge cvs file to excel file
      By Valnurat
      My goal is to have some info I got in a comma CVS file merged with a excel doc.
      In the excel.doc the search column is B and I need to do it from row 8, because 1-7 is locked.
      I really hope someone can help me.
      This is what I have tried:
      #include <Excel.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Select a single file of any type." ; Display an open dialog to select a file. Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "All (*.*)", $FD_FILEMUSTEXIST) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Exit Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Create application object and open an example workbook Local $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileOpenDialog) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf ; ***************************************************************************** ; Find all occurrences of string "=C10*10" in the formulas, exact match ; ***************************************************************************** Local $aResult = _Excel_RangeFind($oWorkbook, "Maskprov 7", "B8:B1739", Default, $xlWhole) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 2", "Error searching the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 2", "Find all occurrences of string '=C10*10' in the formulas, exact match." & @CRLF & "Data successfully searched.") _ArrayDisplay($aResult, "Excel UDF: _Excel_RangeFind Example 2", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment") EndIf This is my result:
      Row|Sheet|Name|Cell|Value [0]|Consultant OU - Questions - EME|$B$1573|Maskprov 7|Maskprov 7 But how do I use this info to add text into the excel doc?
       
    • Valnurat
      _Excel_RangeFind
      By Valnurat
      I'm trying to find a text in my excel with Excel_RangeFind, but I get an error.
      My code:
      #include <Excel.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Select a single file of any type." ; Display an open dialog to select a file. Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "All (*.*)", $FD_FILEMUSTEXIST) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Exit Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Create application object and open an example workbook Local $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileOpenDialog) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf ; ***************************************************************************** ; Find all occurrences of string "=C10*10" in the formulas, exact match ; ***************************************************************************** Local $aResult = _Excel_RangeFind($oWorkbook, "Maskprov 7", Default, Default, $xlWhole) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 2", "Error searching the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 2", "Find all occurrences of string 'Maskprov 7' in the formulas, exact match." & @CRLF & "Data successfully searched.") _ArrayDisplay($aResult, "") EndIf My error:
      --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop "C:\Program Files (x86)\AutoIt3\Include\Excel.au3" (656) : ==> The requested action with this object has failed.: $aResult[$iIndex][1] = $oMatch.Name.Name $aResult[$iIndex][1] = $oMatch^ ERROR ->21:10:04 AutoIt3.exe ended.rc:1 +>21:10:04 AutoIt3Wrapper Finished. >Exit code: 1 Time: 11.22 Do I something wrong?
    • Vivi
      Is it possible to post into the usenet with autoit ?
      By Vivi
      hey guys,
       
      is there a way to post into the "Usenet" with autoit ?
       
      I didn't found any resources about it online.