Jump to content

Doc Poster

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by Doc Poster

  1. My apologies, the links didn't work. They are: http://forums.microsoft.com/msdn/showpost....82&siteid=1 https://forums.microsoft.com/msdn/showpost....09&siteid=1 http://forums.microsoft.com/msdn/showpost....75&siteid=1 https://forums.microsoft.com/msdn/showpost....26&siteid=1
  2. Looks like I cant post to Example Scripts since I have less than 10 posts, so Ill put the code here. Its a definitely a kluge, but hopefully is better than nothing. Basically, if it attaches to an existing browser session and the browser is IE v7 or above, it calls WinWaitActive with a two second timeout (could probably be less). If it times out, it assumes the desired tab is inactive. It gives the user the opportunity to switch to IE, click the desired tab, then switch back to the dialog box to click Retry. I told you it was clunky! I suppose another workaround would be to just open a new browser if it times out, but I dont want to keep opening new browsers. Hopefully someone will find this useful. #include <IE.au3> AutoItSetOption("WinTitleMatchMode", 2) $strBrowserTitle = "Google" $strURL = "http://www.google.com/" $strIEversion = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version Vector", "IE") ;Open new browser and navigate to web page, or find existing browser with that URL $oIE = _IECreate($strURL, 1, 1, 0, 0) If @extended Then ;Browser already existed, so switch to it If StringLeft($strIEversion, 1) < "7" Then WinActivate($strBrowserTitle) WinWaitActive($strBrowserTitle) Else ;Using IE v7 or higher. Account for tab not being active. Do WinActivate($strBrowserTitle) ;Timeout after two seconds. If the tab is not active, WinWaitActive will wait forever without a ;timeout. This is a clunky workaround until someone finds a way to access inactive tabs in IE 7. ;MS currently does not expose a full-fledged tabbed browsing API set. $strResult = WinWaitActive($strBrowserTitle, "", 2) If $strResult = 0 Then If MsgBox(5 + 48, "Tab Not Active", _ "The " & $strBrowserTitle & "website tab is not active. Please switch" & Chr(13) & _ "to Internet Explorer, click the " & $strBrowserTitle & " tab, then" & Chr(13) & _ "switch back to this dialog and click Retry.") = 2 Then ;User clicked Cancel Exit ;Terminate script EndIf EndIf Until $strResult = 1 EndIf ;Code to manipulate browser once active EndIf
  3. As of 2/12/07, there still seems to be no solution to this, at least in all the searching I did (unless Dale has found a solution?). The key quote I found was on an MS Forum post from 11/14/06: "...unfortunately there's no programmatic way for an extension to select a tab in IE7. IE does not yet expose a full-fledged tabbed browsing API set." Another post says: "To limit opportunities for malicious behavior, scripts running in tabbed windows cannot affect other tabs." That's good news for security reasons, but bad news for us who want to automate things. Perhaps someone smarter than I could get AutoIt to figure out the coordinates of each tab in IE, programmatically move the mouse to the desired tab, and click it to activate it. I found another post with a possible solution that's horribly complicated and might not even work in Vista. Yet one more post talks about how to detect when the user changes tabs. I will follow up with a link to some code with a workaround, albeit a clunky one.
  4. Now I feel like a dork, because I did check VBA help when I was trying to figure this out and saw exactly what you're talking about. My mistake was that I thought the procedure name and parameters had to all be inside one parameter in AutoIt, as follows: $sMacro = "Interact.AutoItDone, Success" $oWord.Application.Run($sMacro)Of course we're all idiots at times. Live and learn. Thanks again.
  5. Locodarwin, you rock! Unfortunately, it appears I can't have my cake and eat it too. That code is great if I simply need to wait for a process to finish. But if I need the process to return a value to my code as well, I get a stalemate. Here's what I did in VBA for Word (along with including the code from the link you gave). CODEPrivate strAutoItReturnVal As String'-------------------------------------- Public Sub Main() strAutoItReturnVal = "" ShellWait "C:\Documents and Settings\User\My Documents\Programming\AutoItTest.exe" MsgBox strAutoItReturnVal End Sub '-------------------------------------- Public Sub AutoItDone(strVal As String) strAutoItReturnVal = strVal End Sub Then in AutoIt, I used your beautiful solution from your answer to my other post. $oWord = ObjGet("","Word.Application") If @error = 1 or $oWord = 0 Then MsgBox(0,"","Failed to access Word") Else $sMacro = "Interact.AutoItDone" $oWord.Application.Run($sMacro, "Success") EndIfWhat happens is that when AutoIt tries connecting with Word, it gets stuck forever because Word is waiting for AutoIt to finish! That's OK, because I can use my prior code since I can pass values to Word from AutoIt. Thanks so much for your help (although if you can figure out a solution to this, you will totally rock!).
  6. I can't believe it was that simple. Argh! I couldn't find any documentation (at least in reference to AutoIt) to show that syntax. Thank you so much Locodarwin!
  7. All my searches in forum posts has not revealed how to pass parameters to macros in Word 2000 VBA. Here is a sample module in Word. CODEPublic Sub ShowMe(Optional strText As String = "") MsgBox "AutoIt says: " & strText End Sub And the companion AutoIt code: $oWord = ObjGet("","Word.Application") If @error = 1 or $oWord = 0 Then MsgBox(0,"","Failed to access Word") Else $sMacro = "AutoItTest.ShowMe" $oWord.Application.Run($sMacro) EndIf oÝ÷ Ù8Z· +ƬÀn¶Ü¢êìxÛh¥«,v¬¶¸§Èr§ëazX§zÚ-çèZ0x"µö¢Æ®¶­s`b33c·4Ö7&òÒgV÷C´WFôEFW7Bå6÷tÖRgV÷C²fײ6"3BfײgV÷C´VÆÆògV÷C²fײ6"3B I've tried many variations, all with no result. Help!
  8. Searched a ton of posts about Word automation, but can't find one on this: I can't seem to access public variables declared in VBA modules. I am calling an AutoIt script from VBA code inside of Word 2000. Once the script completes, I have it notify Word by calling a VBA macro. I have to do this because Word doesn't wait for an executable to complete before moving on. Here is my simplified code in VBA: CODEPublic strAutoItResult As String'---------------------------------------------- Private Sub CallAutoIt() Dim x As Long Dim blnWait As Boolean Dim lngResult As Long 'Call AutoIt script lngResult = Shell("c:\AutoItScript.exe") blnWait = True strAutoItResult = "" 'Keep checking strAutoItResult until it changes or we timeout. 'AutoIt will call a macro that changes strAutoItResult. Do While blnWait If strAutoItResult <> "" Then blnWait = False Else x = x + 1 Pause If x = 60 Then 'Timeout after 60 seconds blnWait = False MsgBox "AutoIt script never finished." End If End If Loop End Sub '---------------------------------------------- Public Sub OjinSuccess() strAutoItResult = "Succeeded" End Sub '---------------------------------------------- Public Sub OjinFailure() strAutoItResult = "Failed" End Sub '---------------------------------------------- Private Sub Pause(Optional ByVal intDelay As Integer = 1) 'Do nothing for a default of one second or for how many seconds passed in. Dim t As Long t = Timer Do While Timer < intDelay + t DoEvents Loop End Sub Here is the companion AutoIt code: $oWord = ObjGet("","Word.Application") If @error = 1 or $oWord = 0 Then MsgBox(0,"","Failed to access Word") Else ;After performing desired code, I set $blnSuccess to indicate success or failure. ;Then I call the appropriate macro in Word. If $blnSuccess Then $sMacro = "OjinSuccess" Else $sMacro = "OjinFailure" EndIf $oWord.Application.Run($sMacro) EndIfIs it simply impossible to do this? If so, I'll have to resort to clunky workarounds, such as having AutoIt save desired data in a file and have Word read it. Big_daddy might be the most likely one to know a solution.
  9. Already had the import psl command in global.properties. Tried uncommenting and setting the lexer line to vb and a few others, all to no avail. Also ran SciteConfig and had it save the default color settings to the SciTEUser.properties file and it made no difference. Seems no matter what I try, it still displays all black. Unless someone has any other ideas (isn't my properties file above correct?), I'll just have to set it to some other language and go with that. Very frustrating... Oh, and Flyingboz, I checked out Kermit. The scripting language looks even worse than PowerTerm's! But even if it wasn't, I'm doing this at work and have to stick with their programs.
  10. I've searched the forums and help to no avail. I'm wanting to use SciTE to color code a language not included with it--PSL, which is PowerTerm power scripting language. I modified the global properties file to recognize the file pattern (*.psl), add it to the language and options menu, and import the psl.properties file. I looked at the other properties files and created one for psl, but it won't change the colors on any psl code when I select PSL as the language; all the text is black. What am I missing? Below is the psl.properties code. # Define SciTE settings for PowerTerm Power Script Language (psl) files. # PSL: Power Script Language file.patterns.psl=*.psl filter.psl=PSL (psl)|$(file.patterns.psl) #lexer.*.psl=psl lexer.$(file.patterns.psl)=psl keywordclass.psl=append array break cd close concat continue copy-from-clipboard copy-to-clipboard cursor \ dde execute initiate poke display eof eval exec expr \ file flush for foreach format gets glob global if incr info input-line \ join key lappend lindex linsert list llength lrange lreplace lsearch lsort \ menu message open open-setup-file proc puts pwd \ read regexp regsub rename return run \ scan screen screen-rect seek send session set baud-rate comm-type parity protocol-type \ split string switch tell time unset uplevel upvar wait while window keywords.$(file.patterns.psl)=$(keywordclass.psl) comment.block.psl=#~ # PSL styles # Default style.psl.32=$(font.base) # White space style.psl.0=fore:#000000,$(font.vbs) # Block comment style.psl.1=$(colour.code.comment.box),$(font.code.comment.box) # Line comment style.psl.2=$(colour.code.comment.line),$(font.code.comment.line) # Number style.psl.4=$(colour.number) # Keyword style.psl.5=$(colour.keyword),bold # String style.psl.6=$(colour.string) # Character style.psl.7=$(colour.char) # Operators style.psl.10=$(colour.operator),bold # Identifiers #style.psl.11= # Braces are only matched in operator style braces.psl.style=10 command.help.$(file.patterns.psl)=$(CurrentWord)!c:\ptw\ptw32.hlp command.help.subsystem.$(file.patterns.psl)=4
×
×
  • Create New...