Jump to content

TunaSalad

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by TunaSalad

  1. Thanks for your help SoulA! Got it working after compiling my script with the AutoIT3Wrapper. http://www.autoitscript.com/autoit3/scite/downloads.shtml http://www.autoitscript.com/autoit3/scite/...oIt3Wrapper.htm
  2. Bump!
  3. In my experience with the WinXXXXX functions like WinClose, WinActivate. WinExists, etc... the TEXT parameter you can optionally pass in never worked well for me so I never use that argument, on top of the fact that most of time I need to write language independent scripts and therefore can't hardcode English (or any other language) strings. So I'd suggest you to replace the following line: WinWaitActive("Notepad", "Do you want to save") for this one WinWaitActive("Notepad") EDIT: Added code Tags
  4. Not an expert myself on .Net but could you check under which credentials the notepad.exe is running? If the autoIT program is started by a service it might happen that is not able to interact with your desktop & therefore won't display the UI In the task manager, what session ID is given to notepad.exe? (you may need to add the Session ID column from the View menu) Is it the same session ID as other programs running by the currently logged in user? just my 5 cts.
  5. Hi all, Here's my problem with versions & updates I have a central location (UNC share) where I store a the latest version of a script. Let's call it "Latest.exe". This file is then distributed to the users so they use the script on their machines. I make modifications in "Latest.exe" every few weeks and I'd like for my users to be notified (i.e MsgBox) that the version they are running in their machines is no loger the latest after comparing their version against the one in the central location. Whenever I compile my scripts into "exe" the version of the file is automatically set to the AutoIT's version. For instace 3.2.10.0, so when I use FileGetVersion both, the "NoLongerTheLatest.exe" and "Latest.exe" return the same version. How do I do to set the file version properties when compiling scripts? Is there any directive of function I'm missing here? How can I solve this "check if running latest version" problem. Thanks!!
  6. Why to do this the hard way when McAfee has a tool that does it for you -MCPR.EXE- ? http://service.mcafee.com/FAQdocument.aspx...083&lc=1033 I know you are learning scripting and AutoIT, but dealing with 200+ reg keys manually does not seem to be the most efficient way to learn.
  7. I had a similar challenge few months ago. A main script that sequentially runs smaller scripts and monitors whether the small scripts are successfull or not. Opted for invoking each small script using RunWait and monitoring the return value. Each small script created its own log file and several screenshots. Then in the main script I was also generating an HTML execution report including the overall result (PASS or FAILED), a link to the log file and the screenshots for each of the small scripts run. Worked flawlessly.
  8. Thanks for the FileRead hint, didn't know that was posible as the example listed in the Help File for FileRead does use FileOpen before actually reading the file Cheers!
  9. I answer to my self: #include <SQLite.au3> #include <SQLite.dll.au3> _SQLite_Startup () $hDB = _SQLite_Open ("exam.db") $sql = _ReadTextFromFile("MyScript") Local $sOut _SQLite_Exec($hDB, $sql, $sOut) _SQLite_Close () _SQLite_Shutdown () Func _ReadTextFromFile($fileName) $file = FileOpen($fileName, 0) $text = FileRead($file) Return $text EndFunc
  10. The following code should do it, however I'm afraid it will also count anything that contains "form" as a substring, not only as word... StringReplace($txt, "form", "form") MsgBox(0, "Number of occurences", @extended)
  11. What you mean by "There are no useable controls"?
  12. I would suggest you to install IE developer toolbar from Miscrosoft to have a full view of the DOM. It will show other element properties that quite likely will uniquely identify the element you are looking for, for instace the "source index" property (make sure you check the "show read-only properties" in the IE Web Developer Toolbar) Then you could do something like this (not tested!): $objINPUTtags = _IETagNameGetCollection($objIE, "INPUT") For $objINPUTtag In $objINPUTtags If $objINPUTtag.sourceIndex = _your_source_index_here_ Then _IEAction ( $objINPUTtag, "click") EndIf Next
  13. Hi all, I'm new to the SQLite UDF and I was wondering what would be the best way to input a whole SQL script into SQLite in just one go using the functions provided in the UDF. For instance, a SQL script like this one: CREATE TABLE exam (ekey INTEGER PRIMARY KEY, fn VARCHAR(15), ln VARCHAR(30), exam INTEGER, score DOUBLE, timeEnter DATE); CREATE TRIGGER insert_exam_timeEnter AFTER INSERT ON exam BEGIN UPDATE exam SET timeEnter = DATETIME('NOW') WHERE rowid = new.rowid; END; I know it could easily be done in SQLite's command line interpeter by just typing $ sqlite3 MyDatabase < MyScript but I want to accomplish this task using AutoIt code. Could I read the contents of the SQL script into a string (using FileOpen and FileRead) and then invoking _SQLite_Exec(-1, $sScriptContents) ??? Any advice is appreciated!
  14. Hi lads, I'm creating a script that after a fresh OS install, will automatically install my favourite apps (firefox, VideoLan, Winamp, AutoIT ;-) etc...) So far I've been quite successful, as I can perform silent installations for most of them... However, I'm having trouble when it comes to install the Antivirus software. I'm using McAfee Total Protection, that came on a CD with my brand new DELL PC. When I execute the autorun (CDSetup.exe) I get a fancy installation menu, showing options like "Install McAfee Total Protection", "Install Acrobat Reader", "Browse the CD", "View Readme" and so for (See link at the bottom) I was expecting that those menu elements were easily recognized by AutoIT's Window Info Tool, however the whole thing shows up as an "Internet Explorer_Server" control, and I cannot access the menu items individually. At this point I still had hope, as other times that I came across the "Internet Explorer_Server" control I was able to access the "HTML" behind, and manipulate the DOM elements using the fantastic IE.au3 library. But in this particular case, I can get the reference to the $oIE using the auxiliar function _ObjGetFromHWND but not much more... A snippet of my code is as follows: #include <IE.au3> _IEErrorHandlerRegister() $h_Win = WinGetHandle("McAfee CDSetup") WinActivate($h_Win) $h_Ctrl = ControlGetHandle($h_Win, "", "[Class:Internet Explorer_Server]") ; As shown by Window Info... $o_IE = _ObjGetFromHWND($h_Ctrl) If IsObj($o_IE) Then ConsoleWrite("Got the IE Object" & @CRLF) ConsoleWrite(ObjName($o_IE) & @CRLF); This shows "DispHTMLWindow2" so should be a Window, Frame or iFrame? ; The following 2 statements raise errors: $o_Doc = _IEDocGetObj($o_IE) ; COM error description is "Access Denied", regular error is "ie.au3 (2443) The requested action with this object has failed: Return $o_IE.document^ ERROR $s_HTML = _IEDocReadHTML($o_IE) ; COM error description is "Access Denied", regular error is "ie.au3 (2208) The requested action with this object has failed: Return $o_IE.document^ ERROR _IENavigate($o_IE, "www.autoitscript.com"); This worked Else ConsoleWrite("Not an object" & @CRLF) Endif Func _ObjGetFromHWND(ByRef $hWin) DLLCall("ole32.dll","int","CoInitialize","ptr",0) If @error Then Return SetError(@error,@extended,0) Local Const $WM_HTML_GETOBJECT = _RegisterWindowMessage("WM_HTML_GETOBJECT") If @error Then Return SetError(@error,@extended,0) Local Const $SMTO_ABORTIFHUNG = 0x0002 Local $lResult, $typUUID, $aRet, $oIE _SendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $lResult) If @error Then Return SetError(@error,@extended,0) $typUUID = DLLStructCreate("int;short;short;byte[8]") DLLStructSetData($typUUID,1,0x626FC520) DLLStructSetData($typUUID,2,0xA41E) DLLStructSetData($typUUID,3,0x11CF) DLLStructSetData($typUUID,4,0xA7,1) DLLStructSetData($typUUID,4,0x31,2) DLLStructSetData($typUUID,4,0x0,3) DLLStructSetData($typUUID,4,0xA0,4) DLLStructSetData($typUUID,4,0xC9,5) DLLStructSetData($typUUID,4,0x8,6) DLLStructSetData($typUUID,4,0x26,7) DLLStructSetData($typUUID,4,0x37,8) $aRet = DllCall("oleacc.dll", "int", "ObjectFromLresult", "int", $lResult, _ "ptr", DLLStructGetPtr($typUUID), "int", 0, "idispatch_ptr", "") If @error Then Return SetError(@error,@extended,0) If Not IsObj($aRet[4]) Then Return SetError(1,@extended,0) $oIE = $aRet[4].Script() ; $oIE is now a valid IDispatch object ;Return $oIE.document.parentwindow Return $oIE EndFunc Func _RegisterWindowMessage($sMsg) Local $aRet = DllCall("user32.dll", "int", "RegisterWindowMessage", "str", $sMsg) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc; _RegisterWindowMessage() Func _SendMessageTimeout($hWnd, $msg, $wParam, $lParam, $nFlags, $nTimeout, ByRef $vOut, $r = 0, $t1 = "int", $t2 = "int") Local $aRet = DllCall("user32.dll", "long", "SendMessageTimeout", "hwnd", $hWnd, "int", $msg, $t1, $wParam, $t2, $lParam, "int", $nFlags, "int", $nTimeout, "int_ptr", "") If @error Then $vOut = 0 Return SetError(@error, @extended, 0) EndIf $vOut = $aRet[7] If $r >= 0 And $r <= 4 Then Return $aRet[$r] Return $aRet EndFunc; _SendMessageTimeout() Whenever I try a method that accesses the DOM, I get the "Return $o_IE.document^ ERROR" as if the $o_IE had no document! I'm running the latest Autoit3 (3.2.4.9) Any ideas on how to automate this dialog? I would prefer to stay away from mouse clicks and coordinates, as in my experience, automating DOM elements using IE.au3 is much more reliable. I have extracted from the CD and attached the CDsetup.exe along with the files needed to display the dialog, as this should be enough to do some testing. It can be downloaded from here Any help, concern, comment, recommendation is much appreciated as I'm farily new to AutoIT and there's probably something that I'm missing here! Regards, TunaSalad
  15. You can always use relative coords to the active window, thus making your script screen-resolution agnostic in most of the cases. Have a look at "MouseCoordMode (Option)" in the help file. BTW, which kind of control is the Window Information tool showing? I was having trouble with "Internet Explorer_Server" controls. Basically, they are embedded IE objects, so buttons, links, images, tables, etc... are invisible to Windows Information Tool. Thanks god, I found the way to "unembed" Internet Explorer_Server controls.
  16. Hi lads, I'm experiencing issues with IE.au3 on Vista too. My version of AutoIt is 3.2.4.9 The flavour of Vista I'm using is Home Premium, and the language is ZH-CN (chinese simplified). User Access Control (UAC) is enabled -default setting on Vista- For instance: #include <IE.au3> $url = http://www.google.com _IECreate($url,0,0) will show the IE instance, despite the "visible" argument is set to 0! If visible is set to 1, then 2 IE windows show up, one empty (as DaleHohm mentioned ), one showing www.google.com I also noticed that despite the page gets fully loaded, the script keeps running, so _IELoadWait doesn't work as expected either... However I just discovered that all these issues are gone when you disable Vista's UAC, or you run the script with Administrator credentials (for instace, compiling the script to an exe, right clicking on it and then selecting "Run as Administrator") Even when you are logged with a user that has administrator right, you still need to do the "Run as administrator" trick. Definitely weird... Summarizing, it's all about user permissions. IE.au3 does work. Hope it helps.
  17. I was facing a similar problem with a combo and that pipe trick did the job! Thanks GeoSoft!
×
×
  • Create New...