Jump to content

General Query


Recommended Posts

Just a general query, I did not want to create another thread for it but couldn't help it. Why does the AutoIt icon still appear in the notification area even after the application has run its course and closed but disappears when mouse is hovered on? Because, the script is set as a scheduled task, I collect a pile of them and then when I hover mouse on them, they disappear except for the last one. Then the last one shows that the script is paused. For some unknown reason then, we right-click the icon and click on exit.

Another query would be that what is $CmdLine[0], $CmdLine[1] and so on... I'm studying someone's script and I don't see these variable defined anywhere. But when I debug it, the script exits because it is set to check if $CmdLine[0] has a certain value or not. I haven't worked with AutoItX and do not understand how it works but for some reason I guess there is a .vbs script that passes some parameters to this script that define the values for these variables.

Link to comment
Share on other sites

18 minutes ago, pranaynanda said:

Another query would be that what is $CmdLine[0], $CmdLine[1] and so on... I'm studying someone's script and I don't see these variable defined anywhere. But when I debug it, the script exits because it is set to check if $CmdLine[0] has a certain value or not.

https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine

 

18 minutes ago, pranaynanda said:

I haven't worked with AutoItX and do not understand how it works but for some reason I guess there is a .vbs script that passes some parameters to this script that define the values for these variables.

Look here:
c:\Program Files (x86)\AutoIt3\AutoItX\AutoItX.chm
c:\Program Files (x86)\AutoIt3\AutoItX\Examples\

 

19 minutes ago, pranaynanda said:

Just a general query, I did not want to create another thread for it but couldn't help it. Why does the AutoIt icon still appear in the notification area even after the application has run its course and closed but disappears when mouse is hovered on? Because, the script is set as a scheduled task, I collect a pile of them and then when I hover mouse on them, they disappear except for the last one. Then the last one shows that the script is paused. For some unknown reason then, we right-click the icon and click on exit.

Please wait for other members answer.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 hour ago, pranaynanda said:

Just a general query, I did not want to create another thread for it but couldn't help it. Why does the AutoIt icon still appear in the notification area even after the application has run its course and closed but disappears when mouse is hovered on? Because, the script is set as a scheduled task, I collect a pile of them and then when I hover mouse on them, they disappear except for the last one. Then the last one shows that the script is paused. For some unknown reason then, we right-click the icon and click on exit.

This is not an AutoIt problem, is a Windows problem, look like Windows Systray does not refresh properly the icons hidden when the programs exit.
I have this issue on Windows 7 x64 with multiples programs, like Video Codecs and so, so is not an AutoIt problem.

Regards
Alien.

Link to comment
Share on other sites

1 hour ago, alien4u said:

This is not an AutoIt problem, is a Windows problem, look like Windows Systray does not refresh properly the icons hidden when the programs exit.
I have this issue on Windows 7 x64 with multiples programs, like Video Codecs and so, so is not an AutoIt problem.

Isn't there any way to refresh it?

1 hour ago, mLipok said:
2 hours ago, pranaynanda said:

Another query would be that what is $CmdLine[0], $CmdLine[1] and so on... I'm studying someone's script and I don't see these variable defined anywhere. But when I debug it, the script exits because it is set to check if $CmdLine[0] has a certain value or not.

https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine

I found the documentation a bit hard to understand. Could you just put it in simple language for me please?

Link to comment
Share on other sites

I'm not english native speakers, and after re reading this documentation I agree that there is indeed not quite well writen for such member like you and me ;)

If you want to help make it better: Please quote here each sentence which is dificult to understand for you, and ask a questions.

 



But for now I try to focus your attention and give you a little help:

Quote

The special array $CmdLine is initialized at the start of the script with the command line parameters passed to your AutoIt script. If running your script instead of the executable, then the ScriptName.au3 willl be ignored as a parameter.

You do not must declare it . This is done automaticaly by AutoIt.

Here is my quick example:

#include <MsgBoxConstants.au3>
ConsoleWrite("! Paramters count = " & $CmdLine[0] & @CRLF)
For $iParameter_idx = 1 To $CmdLine[0]
    MsgBox($MB_OK, "Paramter #" & $iParameter_idx, $CmdLine[$iParameter_idx])
Next

 


EDIT:

I changed this example a little.

First: Just copy this example to new (empty) au3 file and run it to see whats happend.
Next: compile it to exe and run from CMD   with Parameters 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Yeah maybe it's the language difference but I always thought I had sufficient.

I can't understand what parameters and what values do these array actually hold? I ran your code. It produced an output in green than the regular blue one and ended with end of AutoIt wrapper. If that isn't something different for you, I think my previous installation of AutoIt was flawed. I also ran the exe from command prompt but that produced no output. It says 0 parameters. I simply cant understand what to give.

Link to comment
Share on other sites

How you run this exe ?
 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

To prevent the tray icon from appearing for your own scripts, just add directive #NoTrayIcon.

Link to comment
Share on other sites

  • 2 weeks later...

Again, I'm trying to continue in this thread because I did not want to create a new thread for such a small trouble. How do I manage errors in AutoIt? Also, how do I call that windows dialog box that lets you sign in as another user? How do I work with it

Link to comment
Share on other sites

  • Moderators

@pranaynanda we have this wonderful wiki set up, which answers frequently asked questions. In fact, if you look under the Wiki's FAQ, you will see that your question on debugging is the very first one:

https://www.autoitscript.com/wiki/FAQ

I bet if you spend some time reading, you'll find the answers to other questions as well ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Maybe I can't make anything out of it. I've tried putting it at the beginning of the function, at the end of the function and also like this:

Func Function()
If @error Then
    MsgBox("0,"Error", "You did this wrong")
    DoThis()
Else
 <code>
 <code>
 <code>
 <code>
 <code>
 <code>
 <code>
 EndFunc()

Also, the point in code, where I have written DoThis(), I want to call the dialog box that lets me sign in as another user and execute the function further as is. In the message box, I'll put the values as 4096 instead of 0, So then I know how to compare the values. If the person clicks on Yes i.e. Value of MsgBox=6 then I want to call that user control dialog box. Hell! I don't even know what do you call it.

Link to comment
Share on other sites

Like this?
 

#include <MsgBoxConstants.au3>

Function()

Func Function()
;~  <code>
    If @error Then
        Local $respon = MsgBox($MB_ICONWARNING + $MB_YESNO, "Error", " You did this wrong")
        If $respon = $IDYES Then DoThis();$IDYES (6) $IDNO (7)
    Else
;~  <code>
;~  <code>
;~  <code>
;~  <code>
;~  <code>
;~  <code>
;~  <code>
    EndIf
EndFunc   ;==>Function

 

#include <MsgBoxConstants.au3>

Global $ServerList = Function(@ComputerName)
For $i = 0 To UBound($ServerList) - 1
    ConsoleWrite("Service " & $i & " Name: " & $ServerList[$i] & @CRLF)
Next

Func Function($Computer = ".")
    Local $i = 0, $iService, $rList
    Local $objWMG = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2")
    If @error Then
        Local $respon = MsgBox($MB_ICONWARNING + $MB_YESNO, "Error", " You did this wrong!" & @CRLF & "Try again?")
        If $respon = $IDYES Then Function($Computer)
    Else
        Local $objWQL = $objWMG.ExecQuery("SELECT * FROM Win32_Service", "WQL", 0x30)
        For $Obj_Item In $objWQL
            $i += 1
            $iService = $Obj_Item.Name
            $rList &= $iService & @CR
;~          ConsoleWrite("Service " & $i & " Name: " & $iService & @CRLF)
        Next
    EndIf
    If StringRight($rList, 1) = @CR Then $rList = StringTrimRight($rList, 1)
    If StringInStr($rList, @CR) Then Return StringSplit($rList, @CR)
    Return SetError(1, 0, 0)
EndFunc   ;==>Function

 

Edited by Trong

Regards,
 

Link to comment
Share on other sites

Does not work. I tried that already. The script exits. I do not want it to exit. Instead I want it to stay and send a message box.

This is how it is right now:

Func _populate($computer)

   If @error Then
       MsgBox(4096,"Error", "This user account is not authorised for access to the remote machine")
   Else

   Switch $computer
   ;code
   ;code
   ;code
   ;code
   ;code
   ;code
   
   EndSwitch
   EndIf
   If IsObj($ServicesList) then
        _GUICtrlListView_BeginUpdate($ListView1)
        _GUICtrlListView_BeginUpdate($ListView2)
        _GUICtrlListView_DeleteAllItems($ListView1)
        _GUICtrlListView_DeleteAllItems($ListView2)
        For $Services in $ServicesList
            if $Services.State = "Running" Then
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView1)
            Else
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView2)
            EndIf
         Next
         _GUICtrlListView_EndUpdate($ListView1)
        _GUICtrlListView_EndUpdate($ListView2)
    EndIf
EndFunc

Sorry. Can't give you what's in Switch statement because that is sensitive. But I can assure you that the code works once proper user rights are there for the remote machine. Basically the error is that when $computer is read, the code cannot create an object out of it because the user account trying to access remote system does not have proper rights. I can say that because it works correctly on my local machine though.

2016-05-18 11_34_14-AutoIt Error.png

Edited by pranaynanda
More editing.
Link to comment
Share on other sites

18 hours ago, pranaynanda said:

I'm trying to continue in this thread because I did not want to create a new thread for such a small trouble

if you continue a thread with unrelated topic, it becomes harder and harder for anyone else to follow. i just had to ramble thru 12 posts just to figure out where your current issue begins. when you have a new (issue) topic, please start a new (forum) topic.

18 hours ago, pranaynanda said:

How do I manage errors in AutoIt?

that is new topic #1. there are many kinds of errors in AutoIt, you need to specify what kind of error are you talking about, and what is the error origin. then we can offer a more specific help. for general help, as suggested, AutoIt has a great help file and a great wiki with plenty of resources - use them.

18 hours ago, pranaynanda said:

how do I call that windows dialog box that lets you sign in as another user?

that is new topic #2. if you are talking about the "Run As Another User" dialog that pops when you right-click an executable and select "Run As", then this is something that have no place in a script, as it cannot be automated. if you need to start an executable as another user, then AutoIt RunAs/RunAsWait functions are your friends.

1 hour ago, pranaynanda said:

I want to call the dialog box that lets me sign in as another user and execute the function further as is.

you cannot change security context at run time.

what you can do is ask the user for the new credentials (username, password, and - optionally - domain) with a simple GUI with two (or three, for the domain) Input controls. then your script needs either to restart itself with the new credentials, or connect to a remote computer with the new credentials. that depends on what you want to do, which you did not bother to mention, or i missed due to the length of this topic.

P.S. about the return value of MsgBox - @Trong got it right in post #14, and that is also documented in the help file for MsgBox. but if i understand correctly, that is not your issue - your issue is how to combine the "Run As" dialog, which was discussed above.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

@orbs You're somewhat right, but my trouble is that on encountering error, the script quits. I don't want it to quit. I want it to stay and give me a message about what's wrong. As you can see my code above, even if I've used a conditional statement for @error, even then my script exits. That RunAs thing can be an extended resolution. My primary concern is the notification. Right now the .exe produces an error(screenshot above) and exits which feels like the script has unresolved bugs. And that is a bad statement.

Link to comment
Share on other sites

you are performing the error check at the wrong time - too late to catch it before crash. you should check for error immediately after the ObjCreate (or equivalent). that is also generally true - check for error immediately after function call.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...