pranaynanda

General Query

27 posts in this topic

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.

Share this post


Link to post
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:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for 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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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) * 

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 *

"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: 2017-06-04

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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
1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for 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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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) * 

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 *

"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: 2017-06-04

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

How you run this exe ?
 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for 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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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) * 

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 *

"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: 2017-06-04

Share this post


Link to post
Share on other sites
1 hour ago, mLipok said:

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

 

 

I trial and it is still worked fine (:

 


Regards,
 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

That video gave me a clear answer! Thanks @Trong! @mLipok now I know what it actually intends to do.

Edited by pranaynanda

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@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 ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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,
 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

Please post your full script!


Regards,
 

Share this post


Link to post
Share on other sites

There you go. That's nearly all I have.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

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