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 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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

    • Valnurat
      By Valnurat
      I have a mainform with a ListviewControl. The ListView contains data from my SQL Server. My idea is that when you find what you are looking for, in the listview, I pick it by pressing the enter button and then show the content on a child window with some control.
      So my questions are:
      How do you pick the content in the listview with either enter button or the mouse?
      How do you create a child windows with control?
      Global $idListview, $idOKay _FormCreate() _Main() Func _FormCreate() ; Create GUI GUICreate("Computer Asset", 1027, 400) $idListview = GUICtrlCreateListView("", 2, 2, 1024, 268,Default, BitOR($LVS_SHOWSELALWAYS, $LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT)) ; Add columns _GUICtrlListView_AddColumn($idListview, "Computername", 100,2) _GUICtrlListView_AddColumn($idListview, "Tkt No.", 100,2) _GUICtrlListView_AddColumn($idListview, "Req No.", 100,2) _GUICtrlListView_AddColumn($idListview, "Order Date", 100,2) _GUICtrlListView_AddColumn($idListview, "Costcenter", 100,2) _GUICtrlListView_AddColumn($idListview, "Username", 100,2) _GUICtrlListView_AddColumn($idListview, "Model", 100,2) _GUICtrlListView_AddColumn($idListview, "Current Location", 100,2) _GUICtrlListView_AddColumn($idListview, "Option", 100,2) _GUICtrlListView_AddColumn($idListview, "Shipdate", 100,2) $idOKay = GUICtrlCreateButton("OK", 310, 290, 85, 25) GUISetState(@SW_SHOW) EndFunc Func _Main() Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & $sUser & ';PWD=' & $sPassword & ';' Local $oConnection = _ADO_Connection_Create() _ADO_Connection_OpenConString($oConnection, $sConnectionString) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) Local $sTableName = 'StaffMemberUser.ComputerAsset' Local $sQUERY = "Select Computername, TktNo, ReqNo, OrderDate, CostCenter, Username, Model, CurrentLocation, Note, Shipdate from " & $sTableName Local $oRecordset = _ADO_Execute($oConnection, $sQUERY) Local $aRecordsetArray = _ADO_Recordset_ToArray($oRecordset, False) Local $aRecordset_inner = _ADO_RecordsetArray_GetContent($aRecordsetArray) _GUICtrlListView_SetItemCount($idListview, UBound($aRecordset_inner) - 1) _GUICtrlListView_AddArray($idListview, $aRecordset_inner) ; CleanUp $oRecordset = Null _ADO_Connection_Close($oConnection) $oConnection = Null ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idOKay MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead($idListview), 2) Case $idListview MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2) EndSwitch WEnd GUIDelete() EndFunc  
    • drapdv
      By drapdv
      I have a GUI with a parent window that has a menu and shortcut buttons at the top, and a child window which displays a list which is scrolled vertically.
      When the list is relatively small, like no more than 100 or so lines then it scrolls fine.  As the list gets larger, scrolling begins to slow, and if you start mixing up the scroll method (mousewheel, left-clicking the scrollbar box, etc) then it begins to hang.  When it hangs, dwm.exe CPU usage maxes out, and I can't even switch to another window.  Each line in the list is 1000px wide X 30px tall, and the lines alternate between a gray background and a white background, in case that matters.
      When a non-Aero theme is active, everything works fine.  So, I could disable DWM every time someone fires it up, but changing a client's color scheme is not ideal.
      I tried to utilize _WinAPI_DwmSetWindowAttribute($oGui_Parent,  $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED), and although it succeeds in disabling DWM for that window, it doesn't seem to make any difference as far as the scrolling lag is concerned.
      The code is several thousand lines long and contains proprietary information, so I'm trying to avoid posting that, but these are the lines which are creating the GUIs.  Is there anything that anyone can think of off the top of their heads, or is there anything jumping out at you from this snippet of code?  Any help is appreciated!
      $oGui_Parent = GUICreate("Data Viewer", 700, 500, Default, Default, BitOR($WS_CAPTION, $WS_MINIMIZEBOX, $WS_POPUPWINDOW)) WinSetTrans($oGui_Parent, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Parent, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF) $oGui_Child = GUICreate("", 700, 400, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $oGui_Parent) WinSetTrans($oGui_Child, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Child, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF)  
    • tcox8
      By tcox8
      Hello,
      Currently I am running a script that calls a powershell script. To read the results of that I am reading StdOut. I am parsing things accordingly but unfortunately it doesn't parse correctly all the time and I end up missing parts of the string or other problems. My question then is, what is the best results for reading what is returned when running a powershell script or something similar?
    • siva1612
      By siva1612
      I would like to create a window like the one shown below. The requirements are as below
      1. The title bar should be opaque.
      2. The parent window/Main screen will be below the side menu/child window
      3. The left side of the side menu window should be opaque.
      4. The right side should be semi-transparent. 

       
      Any idea to help?
    • Valnurat
      By Valnurat
      I hope my title is good enough.
      I'm using the ADO UDF and I have question regarding editing SQL records with this UDF.
      The owner of the UDF suggested an idea, but maybe there is another trix.