Jump to content
Sign in to follow this  
atnextc

Issues with WinExists and ControlClick on CRM Silent Install

Recommended Posts

atnextc

I have been trying to write a script to silently install CRM Outlook client for about the past 6 days. No matter what I have tried this doesn't seem to be doing anything.

Code is below. Any help is appreciated.

Opt("TrayIconDebug",1)
ShellExecute("R:\IT\SoftLib\CRM2011\CRM2011-Client-ENU-i386\SetupClient.exe")
winwait("Microsoft Dynamics CRM 2011 for Outlook Setup")
WinActivate("Microsoft Dynamics CRM 2011 for Outlook Setup")
WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","I &accept the license agreement")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","I &accept the license agreement",1007)
WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","&Next")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","&Next",1008)

WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","Install Now")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","&Install Now",1019)
WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","The installation completed successfully.")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","&Close",1038)

Share this post


Link to post
Share on other sites
kaotkbliss

when you hover your mouse over your autoit icon after running this, what line is it showing?

I also see a couple errors using winexists. That function as you use it will either return true or false, then move on to the next line.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites
atnextc

It just sits at the first screen without ever selecting any boxes.

I have also tried this as well..

winwait("Microsoft Dynamics CRM 2011 for Outlook Setup")
WinActivate("Microsoft Dynamics CRM 2011 for Outlook Setup")
;sleep (10000)
If WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","I &accept the license agreement")Then
;controlgettext("Microsoft Dynamics CRM 2011 for Outlook Setup","",1007)
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","",1007)
;sleep (3000)
EndIf
If WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","&Next")Then
;controlgettext("Microsoft Dynamics CRM 2011 for Outlook Setup","Next",1008)
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","", 1008)
;sleep (3000)
EndIf
If WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","Install Now")Then
;controlgettext("Microsoft Dynamics CRM 2011 for Outlook Setup","Install Now",1019)
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","",1019)
EndIf
;Dim $done
;While Not $done
;Select
;Case WinExists("Microsoft Dynamics CRM 2011 for Outlook Setup","The installation completed successfully.")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","",1038)
;EndIf
;$done = 1
;Case Else
;   Sleep(300)
;EndSelect
;WEnd
  
;controlgettext("Microsoft Dynamics CRM 2011 for Outlook Setup","",1038)

Share this post


Link to post
Share on other sites
kaotkbliss

in case you were not aware, anything on a line after a ; gets ignored by autoit.

you are a little closer, however you have 'If WinExists' so when autoit hits that line, if that window does not exist yet, then it will skip to the line after 'EndIf'


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites
atnextc

Here is the finised code for CRM for Outlook Client Update 6.

This is working great. However, the update to Rollup10 apparently uses a weird form....IE "the next button is Windows.app.Button..etc which in searching the forum those can't really be controlled in Auto it so I just used send keys and it works however it will affect the user if they are using the machine.

;This will execute the CRM Outlook Client with Update 6 Installed.
MsgBox(0,"CRM Update Install", "Please Close Outlook so CRM can be updated.")
ShellExecute("R:ITSoftLibCRM2011CRM2011-Client-ENU-i386.exe")
;This will extract the contents of the program to the users desktop in a folder called CRM.
Winwait("Browse For Folder")
WinActivate("Browse For Folder")
Send("{UP}")
SLeep(100)
Send("{UP}")
SLeep(100)
Send("{TAB}")
SLeep(100)
Send("{ENTER}")
Sleep(100)
Send("CRM")
SLeep(100)
Send("{ENTER}")
SLeep(100)
Send("{TAB}")
SLeep(100)
Send("{ENTER}")

;This will step through the steps in the install.
winwait("Microsoft Dynamics CRM 2011 for Outlook Setup")
WinActivate("Microsoft Dynamics CRM 2011 for Outlook Setup")
WinWait("Microsoft Dynamics CRM 2011 for Outlook Setup","I &accept the license agreement")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","I &accept the license agreement",1007)
WinWait("Microsoft Dynamics CRM 2011 for Outlook Setup","&Next")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","&Next",1008)

WinWait("Microsoft Dynamics CRM 2011 for Outlook Setup","Install Now")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","&Install Now",1019)
WinWait("Microsoft Dynamics CRM 2011 for Outlook Setup","The installation completed successfully.")
ControlClick("Microsoft Dynamics CRM 2011 for Outlook Setup","&Close",1038)
MsgBox(0,"CRM Update Install", "The CRM Update is complete. You can now reopen Outlook.")

Share this post


Link to post
Share on other sites
kaotkbliss

Have you tried using the Window Info Tool that came with autoit on it to get the button's Class and Instance? You can use those to controlClick on it.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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  

  • Similar Content

    • MaximusCZ
      By MaximusCZ
      Hello, and apologies if this have been discussed before, but I googled and couldnt find anything relevant.
      I have a problem where I try to send a control clink into to a window. 
      Part of window I try to send clicks to looks like this . The black border is showing when I mouse over it Au3Info, I get following information:

      I am testing its interaction with code

      The result I get is that it makes control clicks trough first line, opens and closes menus, as expected.
      When It gets to second line, it does not click a single icon. I can tell that coords are correct as the dropdown menus (No view active) gets focused(altough not rolled out). Same behaviour happens if roughly 40<y<60, so I know I am hitting good height. You can look at how it behaves here: output.webm 
      Dropdown 1 focuses at around 8 sec mark, and 13 sec mark it changes to second dropdown, defocusing first one, seemingly not registering any clinks inbetween.
       
      Have you ever encountered similar behaviour? I need to click the Key button, first on second line, with controlclick (or any other way not hijacking the mouse). I cant trigger that button by keyboard and There is no other control having control over it.
      Help
       
    • Skysnake
      By Skysnake
      I need to automate a specific GUI from a legacy system written in C.
      The spy tool gives me this

      I use this code
      Local $swintit = WinGetTitle("[active]") ConsoleWrite("active Window " & $swintit & @CRLF) If $swintit = "FILES NOTES" Then ; If $swintit = "FILES NOTES" Then ; got Window, now atomate ConsoleWrite("got Window " & @CRLF) ; now focus, then click :) ;EditPaste ;ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(404, $GUI_Focus) ControlCommand("FILES NOTES", "", 404, $acno) ; paste acno GUICtrlSetState(401, $GUI_Focus) ControlClick("FILES NOTES", "", 401, $acno) ; click okay EndIf ; If $swintit = "FILES NOTES" Then The idea is to paste the acno value into the edit box, then click an Okay button.
      I get a console write that the active Window is as expected, but my loop completes without ever writing anything into the GUI.
      I also tried the control ID as text "404" - same result
      What am I missing?
      Skysnake
       
    • JNutt
      By JNutt
       

       
       
      I'm trying to use mouseclick in a panel above.  I want to click on a list item, such as 'Estimated'.  (I've given up on trying to use control click for this).  I'm using window info coordinates from 'Control' tab.

      ; click 'Columns' WinActivate("Innovaya Studio with Sage (Archtectural 2017_V1.invx") MouseClick("primary", 292, 88, 1, 1) WinActivate("Select Browsing Properties") Sleep(1000) MouseClick("primary", 27, 70, 0,0) Sleep(2000) Send("{TAB}{TAB}{TAB}{TAB}{TAB}") Sleep(1000) Send("{ENTER}") ControlClick( But when I used the code Autoit doesn't click where the coordinates are.  In the scipts it is the second MouseClick that won't work.  Any ideas?
    • jantograaf
      By jantograaf
      Hi all,
      I'm having some trouble restoring a program which uses a normal AutoIT-GUI and is used as a ToolKit for our customers to open different (external) tools, check their network connections or ping different destinations. Almost all customers are running this script on Win7 x64. 
      What do I want to do?
      When the program is already running and the user tries to start it for a second time, it should exit the second instance after activating/restoring the first instance.
      What did I do to integrate this?
      I used a little piece of script found on the forums to prevent opening a second instance and modified it as follows:
      $g_szVersion = "VSOL ToolKit" If WinExists($g_szVersion) Then Local $gState = WinGetState($g_szVersion) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinSetState($g_szVersion,"",@SW_SHOW) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinSetState($g_szVersion,"",@SW_RESTORE) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinActivate($g_szVersion) Exit EndIf AutoItWinSetTitle($g_szVersion) I have tried it with only the @SW_SHOW, only the @SW_RESTORE, both of them in a different order, same difference, it doesn't work.
      What does happen then?
      It detects the current state (when it's minimized) as '5', which means enabled and hidden. After setting the state to show, the state changes to 7. Restoring doesn't change the state. But what is really odd, is that the window doesn't appear but AutoIt seems to create a néw window with the same title as the existing one. 

      It doesn't matter if the window was originally minimized by clicking the minimize button in the GUI or by a line of code in my script. For example, when users open a software package from within my script, a similar function to this one will be called:
      Func VSOL_FFTOOLS_SHOW_DOWNLOADS() GUISetState(@SW_MINIMIZE,$VSOL_BACKEND) ShellExecute(@UserProfileDir & "\Downloads") EndFunc The only thing that does work, is when the window is running in a non-minimized state (somewhere behind the current window), it gets activated and receives the focus when trying to start the second instance.
      If anyone could help me out with this one, I'd be forever thankful :-)
      Thanks in advance!
      Kind regards,
      Jan Geurts
    • Miliardsto
      By Miliardsto
      Hello I got this script works below and I want to do not move cursor on screen when action is performed.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y,0) MouseClick("right", $x, $y)) MouseMove($xMiddle, $yMiddle,0) MouseClick("left", $xMiddle, $yMiddle) EndIf I changed this above to this below and what happen is. It clicks right button and then left button but not move mouse to $x $y and then to $xMiddle $yMiddle.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then ControlClick("","",0,"secondary",1,$x,$y) ControlClick("","",0,"primary",1,$xMiddle,$yMiddle) EndIf If needed I got handle in var $hwnd
      Please tell me how parameters in ControlClick would like be
×