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-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-05-09 - Version 1.2.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

    • rm4453
      Custom Stream GUI Using Autoit Gui Wrap
      By rm4453
      Hey guys! I need to find a way to wrap an autoit gui around a game. I am planning on making a custom gui overlay for interacting with my stream, which will allow me to run giveaways and stuff like that. But I need to find a way to force the steam games to run inside my autoit gui... I have the following code so far credit to those I took code from and modified to suite my needs "can't remember who u are pls post if i owe ty to u" If I select notepad and launch it then it works great! and the notepad window is wrapped inside my gui. However if I try it with teamfortress 2 it won't work...
       
      #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #include <GUIConstants.au3> Local $msg, $hwnd, $WinHwnd ;===> UDV Start $pid = 0 $Hidden = 0 $exe = 0 $sDrive = 0 $sDir = 0 $sFileName = 0 $sExtension = 0 ;===> UDV End $hwnd = GUICreate("hello") $Open = GUICtrlCreateButton("Launch Game", 10, 30, 75, 25) $Select = GUICtrlCreateButton("Select Game", 10,60,75,25) GUISetState() ;===> UDF START Func _GetWinHwnd($pid) $aWinlist = WinList() For $i = 1 To $aWinlist[0][0] If $pid = WinGetProcess($aWinlist[$i][0]) Then Return $aWinlist[$i][0] Next EndFunc ;==>_GetWinHwnd Func _SetParentWindow($pid) $WinInfo = _GetWinHwnd($pid) $WinHwnd = ControlGetHandle($WinInfo, "", "") _WinAPI_SetParent($WinHwnd, $hwnd) _WinAPI_SetWindowLong($WinHwnd, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) WinMove($WinHwnd, "", 0, 0) EndFunc ;==>_SetParentWindow Func RedrawGui($RedrawMe) If ProcessExists($pid) And $Hidden = 0 Then GUICtrlSetState($RedrawMe, @SW_HIDE) $Hidden = 1 sleep(50) _WinAPI_RedrawWindow($pid) Sleep(50) ElseIf $Hidden = 1 And Not ProcessExists($pid) Then GUICtrlSetState($RedrawMe, @SW_SHOW) $Hidden = 0 EndIf EndFunc ;===> UDF END While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If ProcessExists($pid) Then ProcessClose($pid) GUICtrlSetState($Open, @SW_SHOW) Else Exit EndIf Case $Open GUICtrlSetState($Open, @SW_HIDE) Sleep(100) $pid = Run('"' & $exe & '" -game tf -steam') #cs This RUN CMD is custom made for testing with TF2 change to just $exe to select any exe you want to test with -game tf specifies to launch tf2 and -steam gets rid of insecure mode error #ce RedrawGui($Open) ProcessWait($pid) Sleep(5500) _GetWinHwnd($pid) _SetParentWindow($pid) Case $Select $exe = FileOpenDialog("Please select your game!", @ScriptDir, "Executable File (*.exe)", "1", "Process Selection") Sleep(50) FileChangeDir(@ScriptDir) _PathSplit($exe, $sDrive, $sDir, $sFileName, $sExtension) EndSwitch WEnd  
    • ralph_ng
      How to append data (random) in Excel?
      By ralph_ng
      Hi everybody, I'm newbie to learn AutoIt, need some help... The process/ work that I'd like to automate is just for testing purpose for my job.
      Searching high and low, I found no script example for writing any random data into excel file. 
    • FrankSchneidewind
      [GUI] Drag&Drop files -> Get filename
      By FrankSchneidewind
      Hi all,
      I got a quick question regarding Drag&Drop with GUIs. I made a little script that does something with files and I need a way to get the name/path of the file when I drag&drop it into the GUI. Is there a quick way to do this?

      Tyvm in advance!
      Neo
    • Valnurat
      Several small issues
      By Valnurat
      I have put all my small issues into one thread hope that is fine.
      I have GUI with many GUICtrlCreateInput and it's working ok.
       
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=x86\Create Consultant.Exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <AD.au3> #include <Array.au3> Main() Func Main() _AD_Open() If @error Then Exit MsgBox(0x40010, "ERROR", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Local $sUsername = InputBox('OPTIONAL', 'Please enter the username.' & @CRLF & @CRLF & 'Exampel: '& @UserName) If @error = 1 Then Exit If $sUsername <> "" Then Local $sFQDN = _AD_SamAccountNameToFQDN($sUsername) if @error = 1 Then MsgBox(64, "Info", "User '" & $sUsername & "' does not exist") Exit EndIf ; MsgBox(64, "Info", "User '" & $sFQDN & @CRLF & _AD_GetObjectAttribute($sFQDN, 'department')) EndIf ; MsgBox(64, "Info", "User '" & $sFQDN & @CRLF & _AD_GetManager($sFQDN, 'department')) local $aObj = _AD_GetObjectsInOU("OU=Users,OU=so,OU=dk,OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=person)(sAMAccountName=" & $sUsername & "))",2,"department,physicalDeliveryOfficeName,company", "") _ArrayDisplay($aObj) _ArrayDelete($aObj,0) ; Create a GUI with various controls. Local $hGUI = GUICreate("Create Consultant") GUICtrlCreateLabel("First name:", 10, 13) Local $idFirst = GUICtrlCreateInput("", 90, 10, 150, 20) GUICtrlCreateLabel("Shortname:", 245, 13) Local $idShort = GUICtrlCreateInput("", 300, 10, 90, 20) GUICtrlCreateLabel("Last name:", 10, 43) Local $idLast = GUICtrlCreateInput("", 90, 40, 300, 20) GUICtrlCreateLabel("Display name:", 10, 73) Local $idDisplay = GUICtrlCreateInput("", 90, 70, 300, 20) GUICtrlCreateLabel("Description:", 10, 103) Local $idRadio1 = GUICtrlCreateRadio("Consultant", 90, 100) Local $idRadio2 = GUICtrlCreateRadio("Group Account", 190, 100) GUICtrlCreateLabel("Email:", 10, 133) Local $idEmail = GUICtrlCreateInput("", 90, 130, 300, 20) GUICtrlCreateLabel("Department:", 10, 163) If $sUsername <> "" Then Local $idDepart = GUICtrlCreateInput($aObj[0][0], 90, 160, 300, 20) Else Local $idDepart = GUICtrlCreateInput("", 90, 160, 300, 20) EndIf GUICtrlCreateLabel("Office:", 10, 193) If $sUsername <> "" Then Local $idOffice = GUICtrlCreateInput($aObj[0][1], 90, 190, 80, 20) Else Local $idOffice = GUICtrlCreateInput("", 90, 190, 80, 20) EndIf Local $idCheckBox = GUICtrlCreateCheckbox("End date", 330, 190, 80, 20) Local $idDate = GUICtrlCreateDate("", 200, 190, 120, 20) GUICtrlSetState($idDate,$gui_disable) GUICtrlCreateLabel("Manager:", 10, 223) Local $idComboBox = GUICtrlCreateCombo("", 90, 220, 150, 100) GUICtrlCreateLabel("Misal code:", 245, 223) If $sUsername <> "" Then Local $idMisalCode = GUICtrlCreateInput($aObj[0][2], 310, 220, 80, 20) Else Local $idMisalCode = GUICtrlCreateInput("", 310, 220, 80, 20) EndIf GUICtrlCreateLabel("Ticket no.:", 10, 253) Local $idTicketNo = GUICtrlCreateInput("", 90, 250, 150, 20) GUICtrlCreateLabel("Cost no.:", 245, 253) Local $idCostNo = GUICtrlCreateInput("", 290, 250, 100, 20) GUICtrlCreateLabel("Ext. Company:", 10, 283) Local $idExtComp = GUICtrlCreateInput("", 90, 280, 300, 20) GUICtrlCreateGroup("Optional, if no Email", 10, 310, 380, 55) GUICtrlCreateLabel("Ext. Email:", 20, 333) Local $idExtEmail = GUICtrlCreateInput("", 90, 330, 290, 20) local $aObject = _AD_GetObjectsInOU("OU=Users,OU=so,OU=dk,OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=person)(StaffManager=TRUE))",2,"sAMAccountName,distinguishedName,displayname", "displayname") ; _ArrayDisplay($aObject,"") If IsArray($aObject) Then Local $sFill = "" For $i = 1 To $aObject[0][0] $sFill &= $aObject[$i][2] & "|" Next $sFill = StringTrimRight($sFill,1) ; Add additional items to the combobox. GUICtrlSetData($idComboBox, $sFill, "") EndIf Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idOK MsgBox($MB_SYSTEMMODAL, "", "test") Global $sFirst = GUICtrlRead($idFirst) Global $sShort = GUICtrlRead($idShort) Global $sLast = GUICtrlRead($idLast) Global $sDisp = GUICtrlRead($idDisplay) If GUICtrlRead($idRadio1) = $GUI_CHECKED Then MsgBox($MB_SYSTEMMODAL, "test", "Consultants") EndIf Global $sEmail = GUICtrlRead($idEmail) Global $sDepart = GUICtrlRead($idDepart) Global $sOffice = GUICtrlRead($idOffice) Global $sManager = GUICtrlRead($idComboBox) If $sManager <> "" Then MsgBox($MB_SYSTEMMODAL, "test", $sManager) EndIf Global $sMisalCode = GUICtrlRead($idMisalCode) Global $sTicketNo = GUICtrlRead($idTicketNo) Global $sCostNo = GUICtrlRead($idCostNo) Global $sExtCompe = GUICtrlRead($idExtComp) Global $sExtEmail = GUICtrlRead($idExtEmail) ExitLoop Case $idCheckBox If _IsChecked($idCheckbox) Then GUICtrlSetState($idDate,$gui_enable) Else GUICtrlSetState($idDate,$gui_disable) EndIf EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) ; Create a new user #cs Global $iValue = _AD_CreateUser($sOU, $sShort, "Doe John") If $iValue = 1 Then MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' in OU '" & $sOU & "' successfully created") ElseIf @error = 1 Then MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' already exists") ElseIf @error = 2 Then MsgBox(64, "Active Directory Functions - Example 1", "OU '" & $sOU & "' does not exist") ElseIf @error = 3 Then MsgBox(64, "Active Directory Functions - Example 1", "Value for CN (e.g. Lastname Firstname) is missing") ElseIf @error = 4 Then MsgBox(64, "Active Directory Functions - Example 1", "Value for $sAD_User is missing") Else MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory") #ce EndIf _AD_Close() EndFunc Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Now I have to read all GUICtrlCreateInput and I want to be sure that all GUICtrlCreateInput is filled. Do I have to this for all of them:
      Global $sManager = GUICtrlRead($idComboBox) If $sManager <> "" Then MsgBox($MB_SYSTEMMODAL, "test", $sManager) Global $bManager = True EndIf Or is there a nice way of controlling that they all are filled out?
      And how can I be in the loop until all fields are filled out?
       
      I also have 2 radiobuttons. 1 with text "Consultants" and 1 with "Group account".
      How do I get the text from the 1 that's active? I tried this and it's working, but is there another way?
      If GUICtrlRead($idRadio1) = $GUI_CHECKED Then MsgBox($MB_SYSTEMMODAL, "test", "Consultants") EndIf