masusaca Posted May 3, 2019 Share Posted May 3, 2019 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 More sharing options...
Exit Posted May 3, 2019 Share Posted May 3, 2019 (edited) Just omit the "call " Please show us your script Edited May 3, 2019 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
masusaca Posted May 3, 2019 Author Share Posted May 3, 2019 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 More sharing options...
Exit Posted May 3, 2019 Share Posted May 3, 2019 This is an Autoit forum, not a VB Script forum masusaca 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 3, 2019 Moderators Share Posted May 3, 2019 @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... masusaca 1 "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 More sharing options...
masusaca Posted May 3, 2019 Author Share Posted May 3, 2019 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 More sharing options...
junkew Posted May 3, 2019 Share Posted May 3, 2019 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 masusaca 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
masusaca Posted May 3, 2019 Author Share Posted May 3, 2019 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 More sharing options...
Moderators JLogan3o13 Posted May 4, 2019 Moderators Share Posted May 4, 2019 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. masusaca 1 "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 More sharing options...
masusaca Posted May 4, 2019 Author Share Posted May 4, 2019 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 More sharing options...
Moderators JLogan3o13 Posted May 4, 2019 Moderators Share Posted May 4, 2019 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 More sharing options...
masusaca Posted May 4, 2019 Author Share Posted May 4, 2019 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 More sharing options...
Moderators JLogan3o13 Posted May 4, 2019 Moderators Share Posted May 4, 2019 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. masusaca 1 "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 More sharing options...
masusaca Posted May 4, 2019 Author Share Posted May 4, 2019 I got it! I forgot the parentheses on the ControlClick function. Link to comment Share on other sites More sharing options...
masusaca Posted May 4, 2019 Author Share Posted May 4, 2019 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 More sharing options...
Moderators JLogan3o13 Posted May 4, 2019 Moderators Share Posted May 4, 2019 No worries, we were all on Day 1 once masusaca 1 "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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now