Jump to content
Sign in to follow this  
snowman533

First Script (error parsing function call)

Recommended Posts

snowman533

hey guys, this is my first script, i have looked at FAQs, looked at the helpfile and found nothing for my problem, except for the standalone Autoit V3 Window Info

this is the entire code

Run("CCleaner.exe")

$ProcessName = "CCleaner.exe"

If ProcessExists($ProcessName) Then
    WinActivate("Piriform CCleaner")
    ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 [, left [, 1 [, 56 , 10 ]]]] ) Else
        Run("Defraggler.exe")
EndIf

this code it to automate one of my most frequently used programs, i have another program in mind to add, but i wish to get this first program working corect before i move on, the program is CCleaner by Piriform

the line that is giving me trouble is this one:

ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 [, left [, 1 [, [ 56 , 10 ]]]]] ) Else

the error returned when attempting to run the script is

ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 ^ ERROR
Error parsing function call

i dont understand, i have written this line as instructed in the help file using the info from the Window Info app

what am i missing? thankyou for your help in advance, please keep in mind that i am relatively new and find most terms and commands quite confusing :D

Note: i have the programs needed in the scripts root folder, and the run command works like a charm, and i have added the if command to ensure that the application is running before the button click simulation takes hold

also: is there a way to tell the computer to wait a certain amount of time before moving on to the next command?

and: is there a way to tell the computer to kill a certain application when it has completed its tasks? i wish to make things automated so i can go out and do whatever, and when i come home all i have to do is fix any viruses or stuff that were found then i can do whatever

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
MrMitchell

I'm not 100% sure but it could help to remove those square brackets. I think the brackets just mean that the paramter is optional, not that it should be a part of the actual function call.

Edit: And it looks like you also have one too many on the right/closing, but again, not sure if AutoIt minds that those are there. I'm sure someone else will jump in to confirm in a few seconds here...

Edited by MrMitchell

Share this post


Link to post
Share on other sites
snowman533

Thankyou MrMitchell it worked, also gave Else its own line now it works like a charm, thanks, now to code in the rest of the commands, is there a way to tell the computer to wait some time before executing the next command?

i will post again after my question has been answered with a thankyou and if i have any more problems with my script :D

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
snowman533

sorry for the double post it wouldnt let me edit my last post

the next command doesnt seem to work first time as the application isnt ready yet, that is why i ask if there is a way to tell the computer to wait a set amount of time between certain commands

*edit* just found the WinWait command, which works great, now is there a way to control click using coords only?

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
MrMitchell

Yea I guess the forum was down for a few minutes. You can use Sleep(), but there are also other things you can do instead of sleep depending on what you need.

Share this post


Link to post
Share on other sites
snowman533

bump, cannot find anything in help file about using coords only for a control, the control i need to click has no id or text, (check box)

and thanks again :D

btw i am moving on to my next program, Defraggler by Piriform

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
bo8ster

check out MouseCoordMode. From there you can decide which is the best for you. Then use MouseClick.

If you have no id or text, you can use the ClassNN.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
snowman533

how exactly do i type in ClassNN?

is it:

ControlClick("<window name>", [CLASS.....])

or am i off the track here? i dont understand how to add in the classNN to the ControlClick command while ID and text is unknown

according to the info window, classNN is Button1

can you please give an example, again i cannot find how to use this in the help file


Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
BlackDragonBE

To wait, you should use Sleep(int).

Winwait just waits untl the specified windows exists. :D

Share this post


Link to post
Share on other sites
bo8ster

Look at control command and other control functions.

Simply the contents of control commands are ControlSomething("WindowName, "", "ClassNN"). You could do ("Piriform CCleaner", "", "button1"). Make sure you check @error.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
snowman533

didnt work, tried all the CommandThings that match that syntax, no errors, just nothing happened where it was assigned for

also, sleep seems to end the script no matter how big the int is

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
snowman533

anyone got any ideas?

i had to trash most of the code for one app, for some reason &No was somehow triggering the &Yes button

this is the code:

Run("CCleaner.exe")

$ProcessName = "CCleaner.exe"

If ProcessExists($ProcessName) Then
    WinActivate("Piriform CCleaner") 
    WinWait("Piriform CCleaner", "", 2)
    ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 )
    WinWait("Piriform CCleaner", "CLEANING COMPLETE")
    ControlClick("Piriform CCleaner", "Re&gistry", 1001)
    ControlClick("Piriform CCleaner", "&Scan for Issues", 1026)
EndIf

Run("Defraggler.exe")

$ProcessName = "Defraggler.exe"

If ProcessExists($ProcessName) Then
    WinActivate("Piriform Defraggler") 
    WinWait("Piriform Defraggler", "Local Disk (C:)", 10 )
    ControlClick("Piriform Defraggler", "Analyze", 1002 )
    WinWait("Piriform Defraggler", "Analysis Complete", 40)
    ControlClick("Piriform Defraggler", "View files...", 1014 )
    Sleep( 600 )
    ControlEnable("Piriform Defraggler", "", "Button1")
EndIf

the code for CCleaner leaves me with the results for registry problems and i need to fix them myself

i did have a section of code to fix them automatic but for some reason as said Above, i wanted to click a No button, which was clearly marked in the Info Window as "&No" and for some reason the yes button was being clicked instead on that particular window

and the code for Defraggler leaves me with the same, i need to wait a max of 2-10 mins to finish as i need to fix the problems found manually due to being unable to code in the selectall check box, which was supposed to be triggered by the last line just before the last EndIf

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
xXUlTiMaTeSiNXx

hey guys, this is my first script, i have looked at FAQs, looked at the helpfile and found nothing for my problem, except for the standalone Autoit V3 Window Info

this is the entire code

Run("CCleaner.exe")

$ProcessName = "CCleaner.exe"

If ProcessExists($ProcessName) Then
    WinActivate("Piriform CCleaner")
    ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 [, left [, 1 [, 56 , 10 ]]]] ) Else
        Run("Defraggler.exe")
EndIf

this code it to automate one of my most frequently used programs, i have another program in mind to add, but i wish to get this first program working corect before i move on, the program is CCleaner by Piriform

the line that is giving me trouble is this one:

ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 [, left [, 1 [, [ 56 , 10 ]]]]] ) Else

the error returned when attempting to run the script is

ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 ^ ERROR
Error parsing function call

i dont understand, i have written this line as instructed in the help file using the info from the Window Info app

what am i missing? thankyou for your help in advance, please keep in mind that i am relatively new and find most terms and commands quite confusing :D

Note: i have the programs needed in the scripts root folder, and the run command works like a charm, and i have added the if command to ensure that the application is running before the button click simulation takes hold

also: is there a way to tell the computer to wait a certain amount of time before moving on to the next command?

and: is there a way to tell the computer to kill a certain application when it has completed its tasks? i wish to make things automated so i can go out and do whatever, and when i come home all i have to do is fix any viruses or stuff that were found then i can do whatever

I recently wrote a scrupt to run the egzact same program, i recall it going somewhat like this;

Run("CCleaner.exe")
winwaitactive("Piriform CCleaner")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{TAB}")
send("{ENTER}")
sleep(5000)
MsgBox(0, "CCLeaner", "CCLeaner ran succsesfuly!")
exit
Edited by xXUlTiMaTeSiNXx

I'm new to AutoIT, please help me where you can.[size=10]Profanity is the one language that all programmers understand[/size]

Share this post


Link to post
Share on other sites
snowman533

thankyou for the idea xXUlTiMaTeSiNXx, its fully working now including the defragger

new finished code:

Run("CCleaner.exe")

$ProcessName = "CCleaner.exe"

If ProcessExists($ProcessName) Then
    WinActivate("Piriform CCleaner") 
    WinWait("Piriform CCleaner", "", 2)
    ControlClick("Piriform CCleaner", "&Run Cleaner", 1021 )
    WinWait("Piriform CCleaner", "CLEANING COMPLETE")
    ControlClick("Piriform CCleaner", "Re&gistry", 1001)
    ControlClick("Piriform CCleaner", "&Scan for Issues", 1026)
    Sleep(30000)
    Send("{TAB}")
    ProcessClose("CCleaner.exe")
EndIf

sleep(10000)
Run("Defraggler.exe")

$ProcessName = "Defraggler.exe"

If ProcessExists($ProcessName) Then
    WinActivate("Piriform Defraggler") 
    WinWait("Piriform Defraggler", "Local Disk (C:)", 10 )
    ControlClick("Piriform Defraggler", "Analyze", 1002 )
    WinWait("Piriform Defraggler", "Analysis Complete", 40)
    Sleep(10000)
    Send("{TAB}")
    Send("{ENTER}")
EndIf

this has been designed to ensure that only one program is doing something at once, and also ensures that the programs that close after their operations, close fully, so the next activity will run flawlessly, with every program that i add to this script i will be extending this rule

Note about CCleaner (code section unfinished): i had no registry issues when i was coding this, i will code it in when i do, then test it when i have more after that

question: is there a way to launch a shortcut?

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
xXUlTiMaTeSiNXx

thankyou for the idea xXUlTiMaTeSiNXx, its fully working now including the defragger

YAY, the first user i have helped on AutoITscript forums! :D


I'm new to AutoIT, please help me where you can.[size=10]Profanity is the one language that all programmers understand[/size]

Share this post


Link to post
Share on other sites
bo8ster

Well done xXUlTiMaTeSiNXx!


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
snowman533

*sigh* do i have to keep repeating my questions twice before they get answered?

is there a way to launch a shortcut?

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
Jos

*sigh* do i have to keep repeating my questions twice before they get answered?

*sigh* do we have to keep repeating ourselfves to tell you this has been asked many times and there is a search function to figure it out yourself? :D

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
snowman533

i tried using search and have found nothing that helps, tried the phrases "launch shortcut" "shortcut" "how to launch a shortcut"

and found nothing, all results were non related, so, how do i launch a shortcut?

tried using shellexecute with all parameters, the file i am after is not running

ShellExecute(@desktopdir & "\Thule.lnk","","C:\Program Files\Thule\","open",@SW_MAXIMIZE)

i am trying to launch a shortcut that is on my desktop

Edited by snowman533

Intermediate AutoIt/Autohotkey User

Share this post


Link to post
Share on other sites
MrMitchell

Why can't you just Run or ShellExecute the program that the shortcut points to? Anyway the shortcut might be a common shortcut so look for it in C:\Documents and Settings\All Users\Desktop\something.lnk (at least on my machine) instead of in your profile desktop directory. The following worked for me...I had to add the "\..\..\All Users\Desktop\" and I use standard WinXP. There may be other macros that point to this folder as well.

ShellExecute(@DesktopDir & "\..\..\All Users\Desktop\WinZip.lnk", "")

Add: Just found it, it's @DesktopCommonDir so try using "ShellExecute(@DesktopCommonDir & "\WinZip.lnk", "")"

Edited by MrMitchell

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  

×