Jump to content

AutoIT - vbs ControlClick()


Recommended Posts

I'm new to AutoIt and vbs. I'm trying to make a script that opens a program and clicks on a specific location. I already got that part that opens the program. Now, I am having issues with the ControlClick() funciton. Whenever I try to run it, it returns an error.

https://gyazo.com/ee85855846b81632cb67a0bec3f87eff

This is the function for the ControlClick

Call ControlClick ( "Canon IJ Scan Utility","","[CLASS:Button; Text:Auto; INSTANCE:1]" )

Link to comment
Share on other sites

5 minutes ago, Exit said:

Just omit the "call "

Please show us your script

I've tried that. That's not the problem. 

Here is the full script.

 Set objShell = WScript.CreateObject("WScript.Shell")

    rv = objShell.Run(chr(34)&"C:\Program Files (x86)\Canon\IJ Scan Utility\SCANUTILITY.exe"&chr(34), 1 , False)
    If rv <> 0 Then
        MsgBox "Failed : " & rv
    End If
    WScript.Sleep 3000
    objShell.Run  "taskkill /f /im ""Mspaint.exe"" ",0,False

    Set objShell = Nothing
    
Call MouseClick ( "Canon IJ Scan Utility","","[CLASS:Button; Text:Auto; INSTANCE:1]" )

Link to comment
Share on other sites

  • Moderators

@masusaca as mentioned, you're not going to get much in the way of VBScript help on an AutoIt forum. Please look at the AutoIt help file for Run, including the examples - much easier than VBS...

"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

20 minutes ago, JLogan3o13 said:

@masusaca as mentioned, you're not going to get much in the way of VBScript help on an AutoIt forum. Please look at the AutoIt help file for Run, including the examples - much easier than VBS...

I'm sorry, I thought that the problem was probably due to AutoIT.

Link to comment
Share on other sites

Some direction to get you started (fully in AutoIt no VBS needed)

https://www.autoitscript.com/autoit3/docs/functions/Run.htm

Example()

Func Example()
    ; Run Notepad with the window maximized.
    Local $iPID = Run(chr(34)&"C:\Program Files (x86)\Canon\IJ Scan Utility\SCANUTILITY.exe"&chr(34), "", @SW_SHOWMAXIMIZED)

    ; Wait 10 seconds for the window to appear.
    WinWait("Canon IJ Scan Utility", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ControlClick ( "Canon IJ Scan Utility","","[CLASS:Button; Text:Auto; INSTANCE:1]" )
    ; Wait for 20 seconds.
    Sleep(20000)
    
    ; TODO: Whatever your needs are
    ; Close the process using the PID returned by Run.
    ProcessClose($iPID)
EndFunc   ;==>Example

For taskkill

https://www.autoitscript.com/autoit3/docs/functions/ProcessList.htm

https://www.autoitscript.com/autoit3/docs/functions/ProcessClose.htm

Link to comment
Share on other sites

50 minutes ago, junkew said:

Some direction to get you started (fully in AutoIt no VBS needed)

https://www.autoitscript.com/autoit3/docs/functions/Run.htm

Example()

Func Example()
    ; Run Notepad with the window maximized.
    Local $iPID = Run(chr(34)&"C:\Program Files (x86)\Canon\IJ Scan Utility\SCANUTILITY.exe"&chr(34), "", @SW_SHOWMAXIMIZED)

    ; Wait 10 seconds for the window to appear.
    WinWait("Canon IJ Scan Utility", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ControlClick ( "Canon IJ Scan Utility","","[CLASS:Button; Text:Auto; INSTANCE:1]" )
    ; Wait for 20 seconds.
    Sleep(20000)
    
    ; TODO: Whatever your needs are
    ; Close the process using the PID returned by Run.
    ProcessClose($iPID)
EndFunc   ;==>Example

For taskkill

https://www.autoitscript.com/autoit3/docs/functions/ProcessList.htm

https://www.autoitscript.com/autoit3/docs/functions/ProcessClose.htm

It wouldn't work because I need the vb script so another software execute it. Anyways, thank you for the help.

Link to comment
Share on other sites

  • Moderators
1 hour ago, masusaca said:

It wouldn't work because I need the vb script so another software execute it. Anyways, thank you for the help.

Good luck, but realize there is nothing vbscript can do that AutoIt cannot. You are just making things more complicated for yourself mixing languages.

"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

1 minute ago, JLogan3o13 said:

Good luck, but realize there is nothing vbscript can do that AutoIt cannot. You are just making things more complicated for yourself mixing languages.

Yes, that's what I noticed now. I'm trying to understand how can I convert those codes to AutoIT. It gives me error whenever I try to run them..

Link to comment
Share on other sites

  • Moderators

Again, vbscript to AutoIt is not a difficult transition:

Set objShell = WScript.CreateObject("WScript.Shell") ;Not needed

    rv = objShell.Run(chr(34)&"C:\Program Files (x86)\Canon\IJ Scan Utility\SCANUTILITY.exe"&chr(34), 1 , False) ;Read the help file under Run or RunWait
    If rv <> 0 Then
        MsgBox "Failed : " & rv ;Read the help file under Run or Runwait to view the return codes they supply
    End If
    
    WScript.Sleep 3000 ;Read the help file under Sleep
    
    objShell.Run  "taskkill /f /im ""Mspaint.exe"" ",0,False ;Read the help file under ProcessClose

    Set objShell = Nothing ;Not needed

 

"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

Just now, JLogan3o13 said:

Again, vbscript to AutoIt is not a difficult transition:

Set objShell = WScript.CreateObject("WScript.Shell") ;Not needed

    rv = objShell.Run(chr(34)&"C:\Program Files (x86)\Canon\IJ Scan Utility\SCANUTILITY.exe"&chr(34), 1 , False) ;Read the help file under Run or RunWait
    If rv <> 0 Then
        MsgBox "Failed : " & rv ;Read the help file under Run or Runwait to view the return codes they supply
    End If
    
    WScript.Sleep 3000 ;Read the help file under Sleep
    
    objShell.Run  "taskkill /f /im ""Mspaint.exe"" ",0,False ;Read the help file under ProcessClose

    Set objShell = Nothing ;Not needed

 

I got it to work, by opening it. However, I'm having trouble with the ControlClick.

This is the script:

$canonscan = "C:\Program Files (x86)\Canon\IJ Scan Utility\SCANUTILITY.exe"
Run($canonscan)
ControlClick "Canon IJ Scan Utility","","[CLASS:Button; Text:Auto; INSTANCE:1]"

 

Error parsing function call.

Link to comment
Share on other sites

  • Moderators

If that is how you're running ControlClick, there is no question you are going to get an error. Look at the entry for ControlClick in the help file, specifically the examples provide, to see how to correctly use the syntax.

"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

1 minute ago, JLogan3o13 said:

If that is how you're running ControlClick, there is no question you are going to get an error. Look at the entry for ControlClick in the help file, specifically the examples provide, to see how to correctly use the syntax.

Sorry for the mess. This is my first time messing with vbs and autoit. I'm trying to learn them.

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...