Jump to content

tmakruck

Members
  • Posts

    15
  • Joined

  • Last visited

tmakruck's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I've developed some AutoIt scripts against C# applications, and in general, Yes the control names stay the same. Unless the app is still under development (in an Agile environment). In this case, NEW controls could mess up your script. But from launch to launch of the SAME BUILD i've been quite successful in my efforts! Good Luck! - Todd
  2. Grrr @ Corporate Download Blocking of ZIP files, executables, etc..! I'll have to look at it at home.
  3. i'd love to see your sorce, but i'm getting a 404 not found when i click the link in your other post...
  4. I have a DLL I created in Microsoft's Visual Studio .NET 2003, called DBInsert.dll I am trying to use AutoIt's DLLCall () to run one of the func's in the .dll Here's my simple autoIt Code $dll = DLLOpen ( "D:\Automation\DBInsert\DBInsert\bin\Release\DBInsert.dll" ) If $dll = -1 then MsgBox ( 16 , "AutoIt" , "DLL Open Failed" ) exit endIf $XMLFile = "C:\Documents and Settings\tmakruck\Desktop\04-28-2006 1-26PM.xml" $Return = DLLCall ( $dll , "str" , "UpdateDatabase" , "str" , $XMLFile ) If @Error then MsgBox ( 16 , "AutoIt" , "DLL Call Failed with Error level " & @Error ) exit EndIf msgbox(0, "", $result[0]) ; Record Number (Returned from UpdateDatabase) msgbox(0, "", $result[1]) ; Should return the filename in XMLFile the AutoIt Code runs down to the MsgBox ( 16 , "AutoIt" , "DLL Call Failed with Error level " & @Error ) then exits, as it should since I apparently am not calling the func in the dll correctly. The reason I'm using the dll, rather than trying to ObjCreate ("ADODB.Connection" ) and continuing on with autoIt commands from there, is that I currently have a .NET GUI that makes a call to that dll and it works fine, and has been for over a year. Currently, AutoIt drives that GUI app. Now that I finally got approval from the powers that be (management) to use the beta, I figured it should be an easy plug and play solution to just DLLCall the same function in AutoIt. Here's basically what the func in the dll looks like, in C# code. I've taken some of our code out for your readability, but there should still be enough for you to get the gist // DBInsert.cs -> Compiled to DBInsert.dll using System; using System.Data; using System.Data.SqlClient; using System.Xml; namespace LaptopConfig { // Trust Me This Code Works. I've been using it for a year. public class DatabaseControls { // Below is the func I'm Calling. UpdateDatabase, with one String Parameter. This is a complete path and filename. public static string UpdateDatabase (string xdocName) { XmlDocument xdoc = new XmlDocument(); xdoc.Load(xdocName); string connectionString = "Data Source=SCCLAB14;Initial Catalog=Automation;User ID=LaptopConfig;Password=autotest"; SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlTransaction tran = conn.BeginTransaction(); try { string projectName = xdoc.SelectSingleNode("/FullReport/MachineSummary/projectname").InnerText; string appName = xdoc.SelectSingleNode("/FullReport/MachineSummary/testname").InnerText; string machineName = xdoc.SelectSingleNode("/FullReport/MachineSummary/machinename").InnerText; string testDuration = xdoc.SelectSingleNode("/FullReport/MachineSummary/duration").InnerText; string testResult = xdoc.SelectSingleNode("/FullReport/MachineSummary/finalresult").InnerText; string testSteps = xdoc.SelectSingleNode("/FullReport/MachineSummary/automatedsteps").InnerText; string testDateTime = xdoc.SelectSingleNode("/FullReport/MachineSummary/testdatetime").InnerText; string testStepsFailed = xdoc.SelectSingleNode("/FullReport/MachineSummary/numstepsfailed").InnerText; string testerID = xdoc.SelectSingleNode("/FullReport/MachineSummary/testerid").InnerText; string ClaimNumber = xdoc.SelectSingleNode("/FullReport/MachineSummary/claimnumber").InnerText; string PullDuration = xdoc.SelectSingleNode("/FullReport/MachineSummary/pullduration").InnerText;//.InnerText; if (PullDuration==null) PullDuration = ""; string sql = "INSERT INTO dtLaptopTestSummary " +"(ProjectName, ApplicationName, MachineName, TestDateTime, " +"TestResult, TestDuration, TestSteps, TestStepsFailed, " +"TesterID, ClaimNumber, PullDuration) " +"values " +"(@ProjectName, @AppName, @MachineName, @TestDateTime, " +"@TestResult, @TestDuration, @TestSteps, @TestStepsFailed, " +"@TesterID, @ClaimNumber, @PullDuration)" +"; SELECT @@IDENTITY"; SqlCommand cmd = new SqlCommand(sql, conn, tran); // Use cmd2.Parameters.Add(....) to finish building the SQL. TRUST ME IT WORKS with my .NET GUI // continue making parameters for all @'s //cmd.ExecuteNonQuery(); int testId = decimal.ToInt32((decimal)cmd.ExecuteScalar()); foreach (XmlNode detailNode in xdoc.SelectNodes("/FullReport/teststeps/Record")) { string conditionNumber = detailNode.SelectSingleNode("tcnumber").InnerText; string conditionAction = detailNode.SelectSingleNode("action").InnerText; string conditionResult = detailNode.SelectSingleNode("result").InnerText; string conditionResultDetail = detailNode.SelectSingleNode("description").InnerText; // get the other sub nodes string sql2 = "insert into dtLaptopTestDetail (TestID, ConditionNumber, ConditionAction, ConditionResult, ConditionResultDetail) values (@TestID, @ConditionNumber, @ConditionAction, @ConditionResult, @ConditionResultDetail)"; SqlCommand cmd2 = new SqlCommand(sql2, conn, tran); // Use cmd2.Parameters.Add(....) to finish building the SQL. TRUST ME IT WORKS with my .NET GUI // continue making parameters for all @'s cmd2.ExecuteNonQuery(); } tran.Commit(); conn.Close(); return testId.ToString(); } catch (Exception e) { tran.Rollback(); conn.Close(); return (e.Message + Environment.NewLine + e.StackTrace); } } } } Thanks! Todd
  5. thanks JdeB. That's exactly what I was lookin for... don't know why i didnt just try something like that on my own... so really, to handle all the random popups they'd all have to be accounted for in one adlib function, but we'd probably want to reset the delay to something a little higher so that it's not boggin down the machine lookin for stuff...
  6. You know, I read your initial response before you made the edit, and wasn't real happy with your response, but your added suggestion in the edit kind of helps me. But unfortunately it's not the exact answer I'm lookin for, simply because even though it's quite minimal, there is a performance loss. and it's ugly with it's global variables, and starting a function (by default) every 250ms just to return after one operation (the comparison of $PingAdlibRunning). Hey, i'm picky, but in my defense, that is an extra operation 4 times a second, and say the script is so big it takes an hour to run, that's on the order of about 15000 useless operations. That's like a bad case of OCD.
  7. I don't want to know about the performance of the adlib functions that have been created. I'd like to know how AdLibEnable () works. If I Have in my code AdLibEnable ( "myAdlib1" ) AdLibEnable ( "myAdlib1" ) AdLibEnable ( "myAdlib1" ) Func myAdlib1 () ;Do some stuff EndFunc Is myAdlib1 going to be running 3 times, simultaneously. Or will it just run once, even though I've called it 3 times.
  8. I'm going to go into a hypothetical question here. I can't post my code, because it doesn't exist. This is basically a "What happens when...?" question. I'm not looking to get into a discussion of here's a better way to do it blah blah blah... I just want to know "how" the adlib function handles a certain situation... So, here goes the "hypothetical situation": Say we have a script with many execution paths, depending on what all is installed on the machine and what needs to be updated. Certain Sections of the script may encounter some random message boxes, like security warnings, and print confirmations etc. but these messageboxes will not ALWAYS appear. If they do appear, it won't always be at the same time, like the print confirmation will take longer or shorter depending on how much the printer is backed up. So AdLibbing Seems like the logical choice. Say there are about 20 different popup messages that "might" happen, but I know that some will only happen at certain times, like "Communication error happened in Program X" is only going to happen while program x is runnning. But it's only the active window for about 1/2 the time the script is running, but not in one consecutive section. More like three five minute sections here and there. In some cases, the first out of three sections won't need to execute (like i said multiple execution paths) so now we're running 2 sections of 5 minutes each. So program x is in the background basically pinging a server for the whole script, but we're only driving program x for 10 or 15 minutes. If this ping action fails, it pops up a modal msgbox that we need to get rid of before we can do anything else on the computer. So in all three functions I AdLibEnable ( "ClearPingError" ) Because the program x doesn't start until the first time we need to use it, and we don't want to sacrifice "any" performance with the Adlib function prior to Program X being launched. Also remember we've got say 20 different adlibs to handle different messageboxes for different applications. so we don't want to just adlib one function that handles all the possible messageboxes, because that's a cut on performance. We only want to adlib the ones we need, which is determined at runtime (when the program starts we start handling that application's popups.) QUESTION HERE: In this type of situation, does AdLibEnable cause there to be three instances of ClearPingError to be running in adlib mode, or is autoit smart enough to realize that ClearPingError is already running, so we don't have to start another copy? Please remember, I can't post any code. This is JUST a What Happens When.... question because I'm curious. Thanks, Todd
  9. I've got a script that will be running on different machine types, which may have different versions of software, like MSOffice 2003 vs Office 2000. I want to be able to check that the shortcut icon is built correctly, then use the target path to launch the executable. On what I call "normal" applications, like notepad, this is easy because the target path is just "C:\winnt\notepad.exe" or whatever. Unfortunately, some apps have what microsoft calls "Advertised Shortcuts". These don't have an active Target field when you right click - Properties on one of these. and If you run an autoit FileGetShortcut on an Advertised Shortcut, like those for MS Office applications, it returns something like "C:\winnt\installer\{90010409-0600-11D3-8CFE-0150048383C9}\pptico.exe" (for powerpoint). Now I know that the executable for Powerpoint is in the Program Files\[office installation folder]\powerpnt.exe. Since the version of powerpoint may be different, it might reside in, say, Program files\Office10 , or maybe Program Files\Office11. How can I resolve that ugly C:\winnt\installer\{90010409-0600-11D3-8CFE-0150048383C9}\pptico.exe thing into the path to powerpnt.exe? Or, how does windows do it, so I can try to recreate it on my own, in autoit language? I've looked on msdn, and cant seem to search for the right thing to get my answer thanks in advance, Todd
  10. No I Cant. Basically what I'm trying to do is "Count" how many icons are in the Windows Task Tray. I want to look at each one, and make sure certain ones are displayed. Unfortunately,my task tray is located in the bottom right of my screen, yet it's position is X: 1369 Y: 1.(Variable based on what apps are running, minimized, etc) Since my screen res is 1680x1050, I would expect the position to be close to X: 1369 Y: 1000, since the task tray is only one line tall. So, I'm processing the icons from right to left ( Start at the clock, and move towards the Start Button) but once i'm outside the bounds of the task tray, quit looking. So what I want to do is say Func FindTrayIcon ( $WinTitle ) $xpos = @DesktopWidth - 103 $yPos = @DesktopHeight - 15 ControlGetPos ( "", "", "ToolbarWindow321" ) msgBox ( 0 , "" , "X = " & $xpos & @CR & "Y = " & $ypos ) $Found = 0 While NOT $Found MouseClick ( "secondary" , $xpos, $ypos ) Wait ( 1 ) If WinActive ( $WinTitle , "" ) Then $Found = 1 $strCoordinates = $xpos & "," & $ypos MsgBox ( 0 , "Information" , "Found """ & $WinTitle & """ Icon at " & $strCoordinates ) EndIf $xpos = $xpos - 18 Send ( "{ESC}" ) ; If we've reached the end of the tasktray, exit the loop Wend Send ( "{ESC}" ) Return $strCoordinates EndFunc
  11. I actually want to do this from inside the script itself... I know that the window spy exists, but I dont want that running while my script is running...
  12. Is there a way to get the controlID or ClassNameNN of the control that is currently under the mouse pointer? I couldnt figure out how to do it.... This would have to be done without knowing the name of the active window. Maybe do something like this: Func _GetControlUnderMouse () $arrMousePos = MouseGetPos () ; use the $arrMousePos to get the Control Under Mouse ; kinda like how au3Info.exe does it Return $strControlName EndFunc;_GetControlUnderMouse () I couldn't figure out how to do this... Thanks, Todd
  13. Problem Resolved This has been resolved. I Used the following for checking the version number $strIEVersion = RegRead ( "HKLM\SOFTWARE\Microsoft\Internet Explorer" , "Version" ) if $strIEVersion = "" Then Select Case @Error = 1 MsgBox ( 16 , "AutoIt Error" , "unable to open requested key" ) Case @Error = -1 MsgBox ( 16 , "AutoIt Error" , "Unable to open requested value" ) Case @Error = -2 MsgBox ( 16 , "AutoIt Error" , "Value type not supported" ) Case Else MsgBox ( 64 , "AutoIt Information" , "Version number is blank!" ) EndSelect EndIf $strIECustomizedVersion = RegRead ( "HKLM\SOFTWARE\Microsoft\Internet Explorer" , "CustomizedVersion" ) if $strIECustomizedVersion = "" Then Select Case @Error = 1 MsgBox ( 16 , "AutoIt Error" , "unable to open requested key" ) Case @Error = -1 MsgBox ( 16 , "AutoIt Error" , "Unable to open requested value" ) Case @Error = -2 MsgBox ( 16 , "AutoIt Error" , "Value type not supported" ) Case Else MsgBox ( 64 , "AutoIt Information" , "Customized Version is blank!" ) EndSelect EndIf MsgBox ( 0 , "IE Complete Version" , $strIEVersion & $strIECustomizedVersion ) and the following for checking for the service pack $strIE60SP1 = RegRead ( "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "MinorVersion" ) if $strIE60SP1 = "" Then Select Case @Error = 1 MsgBox ( 16 , "AutoIt Error" , "unable to open requested key - True Error" ) Case @Error = -1 MsgBox ( 64 , "AutoIt Information" , "Unable to open requested value" ) Case @Error = -2 MsgBox ( 16 , "AutoIt Error" , "Value type not supported" ) Case Else MsgBox ( 64 , "AutoIt Information" , "Minor Version is blank!" ) EndSelect EndIf If StringInStr ( $strIE60SP1 , ";SP1;" ) Then MsgBox ( 0 , "Service Pack" , "Passed" ) Else MsgBox ( 16 , "Service Pack" , "Failed" ) EndIf
  14. The version info, including the customized version details are available in this hive. Thanks Joon. I never thought to look in the reg. That may be a way for me to check on the SP number as well! - Todd
  15. So i've been tasked with dertermining if the correct version of IE and applicable service packs have been installed on a huge group of machines. This is a custom version of IE, so I don't think that just using FileGetVersion ("iexplore.exe") will work. Our version of IE has an additional "CO" at the end of the version number, when you look at the Help-About window. (See the attached file) Also, I need to get the "update versions" line, and make sure SP1 is in the text. Unfortunately, the window is a "Internet Explorer_TridentDlgFrame" , and all the text is in an "Internet Explorer_Server" control. I tried using the IE UDF to do some checking on it, but the data on the window is not being recognized as an HTML Document, so the IE UDFs arent working. for example If WinExists ( "About Internet Explorer" ) THen MsgBox ( 0 , "" , "It Exists" ) Else MsgBox ( 0 , "" , "It DONT Exists" ) EndIf $o_HelpWindow = _IEAttach ( "About Internet Explorer" ) MsgBox ( 0 , "@error" , @error ) Running this code when the about window is up Yields a MsgBox saying "It exists" then the msgbox @error = 1. Any help would be greatly appreciated! - Todd
×
×
  • Create New...