Shibuya Posted August 26, 2005 Share Posted August 26, 2005 Hi all, I'm a newbie wif AutoIT and have started for a couple of days. I started designing a script, which I've taken portability into consideration. After finishing the scripton my laptop, tested and reviewed the design plenty times. Then I compiled and started using the executable on other desktops. It's only then I found problems popping up, e.g. some commands were not executed programs did not respond to the executed command. You ppl ever encounter things like that? Any resolution? The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!" Link to comment Share on other sites More sharing options...
trids Posted August 26, 2005 Share Posted August 26, 2005 See it as part of your testing: if you intend to run your script on machines other than the one you develop it on, then you should be extra careful to test @ERROR .. and check for files you need rather than assume they're there .. or check for desktop dimensions .. even OS versions .. etc .. HTH Link to comment Share on other sites More sharing options...
Shibuya Posted August 29, 2005 Author Share Posted August 29, 2005 See it as part of your testing: if you intend to run your script on machines other than the one you develop it on, then you should be extra careful to test @ERROR .. and check for files you need rather than assume they're there .. or check for desktop dimensions .. even OS versions .. etc ..HTH <{POST_SNAPBACK}>I've already taken these into consideration while designing the script.What I'm currently facing now is that simple commands like sending Windows hotkey commands, e.g. "^p" in MS Word to launch the print dialog(this has given me the biggest headache )Attached is part of the above mentioned code that is giving me headaches.It's one of my #include files. The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!" Link to comment Share on other sites More sharing options...
brandonm Posted August 29, 2005 Share Posted August 29, 2005 Here is your code with coments, don't be offended please, I'm just making sure you have checked everything. ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: Kayne heong <kayne.heong@t-est.com> ; ; Script Function: ; Open t1.doc AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start $file = FileOpen("D:\AutoIt_Scripts\Test_Files\t1.doc", 0) ;;you are sure that the file is on the d: drive on all machines? ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit Else ; Opens t1.doc from location Run( "cmd /c D:\AutoIt_Scripts\Test_Files\t1.doc", "", @SW_HIDE) ;;if the machine runs on windows earlier than xp, i believe that command rather than cmd should be used. likeso: Run( "command /c D:\AutoIt_Scripts\Test_Files\t1.doc", "", @SW_HIDE) EndIf If WinWaitActive("t1.doc - Microsoft Word", "", 10) = 0 Then MsgBox( 0, "Failure", "Test file failed to load") Exit Else $file_name = "t1.doc - Mircosoft Word" ;;probably should be: $file_name = "t1.doc - Microsoft Word" EndIf Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 29, 2005 Moderators Share Posted August 29, 2005 $file_name = "t1.doc - Mircosoft Word";;probably should be: $file_name = "t1.doc - Microsoft Word"<{POST_SNAPBACK}>What's the difference between those 2 brandonm... am I missing something?@Shibuya -- What are the 2 OS's? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 29, 2005 Moderators Share Posted August 29, 2005 Try this Shibuya: expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: Kayne heong <kayne.heong@t-est.com> ; ; Script Function: ; Open t1.doc AutoIt script. ; ; ---------------------------------------------------------------------------- Opt("WinTitleMatchMode", 4) ; Script Start $file = FileOpen(@HomeDrive & "\AutoIt_Scripts\Test_Files\t1.doc", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit Else ; Opens t1.doc from location Run( @HomeDrive & "\AutoIt_Scripts\Test_Files\t1.doc", "", @SW_HIDE) EndIf $Timer = TimerInit() Do Sleep(100) Until TimerDiff($Timer) / 1000 >= 9 Or WinExists("t1.doc - Microsoft Word") MsgBox(0, "", "Done!") If Not WinExists("t1.doc - Microsoft Word") Then MsgBox( 0, "Failure", "Test file failed to load") Exit Else $file_name = "t1.doc - Mircosoft Word" EndIf Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Shibuya Posted August 29, 2005 Author Share Posted August 29, 2005 Here is your code with coments, don't be offended please, I'm just making sure you have checked everything.Not at all, thanks for the help @Shibuya -- What are the 2 OS's?<{POST_SNAPBACK}>my laptop's on WinXP.Other systems are Win98, WinME, WinNT and Win2KI've tried another round on my laptop again, now it's giving me problems I faced on other systems. It worked fine last week.Yet to try your script, but I now trying to add delay in-between some of the executions.So far it's slightly more stable, but some occasional hiccups/freezing.Thanks for the help and reply so far. The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!" Link to comment Share on other sites More sharing options...
LxP Posted August 29, 2005 Share Posted August 29, 2005 How about this (I'm assuming that this script sits in D:\AutoIt_Scripts): $file = @scriptDir & "\Test_Files\t1.doc" $handle = fileOpen($file, 0) ; Check if file opened for reading OK if ($handle = -1) then msgBox(0x10, "Error", "Unable to open file.") exit endIf ; I closed the if..endIf block above -- it will make the following code cleaner ; be sure to *close* any files that you open! fileClose($handle) ; Opens t1.doc from location ; @comSpec can be used as a more portable solution run(@comSpec & ' /c start "' & $file & '"', "", @SW_HIDE) $wordStarted = processWait("winword.exe", 10) if not($wordStarted) then msgBox(0x10, "Failure", "Test file failed to load.") exit endIf ; Microsoft typo fixed $file_name = "t1.doc - Microsoft Word" Link to comment Share on other sites More sharing options...
Shibuya Posted September 15, 2005 Author Share Posted September 15, 2005 Thanks for all the above reply and sorry for the late feedback. Somehow my systems are having problems with the use of @ComSpec. They all seem to don't recognise the macro/command, that's why I'm using "cmd /c". The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!" 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