Sign in to follow this  
Followers 0
jcorr1339

Code works seperate, but not together

9 posts in this topic

:) Hello, This is my first post.......Sorry its a long one...... I am at the end of the road here.... help PLEASE...Ok, Here is the issue. I have two peices of code that work on seperate .au3 files, but not when in the same script. I have been at this for hours, are bugs common?

Purpose - of the code: Copy updated location infomation from an excel sheet to 2,600qty laser printers via their web interface. In my test code I have it set to repeat 10 times.

Problem - my variable $IP does not seem to work correctly when the code is combined into one script. Specifically it does not add the string "/port_0/config/general" when I open the web interface. Very strange since it works correctly by itself.

Example - When ran by its self it will open http://10.10.10.61"/port_0/config/general Which is what I want.

When ran combined with the excel lookup it only returns http://10.10.10.61 sending me to the root not the configuration page as I wish.

Script#1

#include <Process.au3>

$1=1

$IP=InputBox ("input ip", "Here","")

Do

_RunDos("start http://"& $IP & "/port_0/config/general") ;To be called as from the START menu

;Wait for print server window to be activly loaded, then send the following;

WinWaitActive("Print Server Settings - Microsoft Internet Explorer","")

Sleep(1000)

Send("{Tab}")

Send("{Tab}")

Send("123")

Send("{Tab}")

Send("{CTRLDOWN}a{CTRLUP}{BACKSPACE}")

Send("location")

Sleep(500)

Send("{Enter}")

WinWaitActive("Configuration Change Submitted - Microsoft Internet Explorer","")

SoundPlay(@WindowsDir & "\media\tada.wav",1)

Until $1 = 777

Script#2

; Excel Cell reference lookup example

; This code is ran while an excel sheet is already open.

$A = "A"

$1 = 1

Do

$combo = $A & $1

$x=getcell($combo)

Send("{right}")

ControlSend("Microsoft Excel","","XLDESK1","^c"); copies contents

$y=clipget(); move clipboard to $y

ControlSend("Microsoft Excel","","XLDESK1","{esc}"); return excel to normal state

Send("{right}")

ControlSend("Microsoft Excel","","XLDESK1","^c"); copies contents

$z=clipget(); move clipboard to $z

ControlSend("Microsoft Excel","","XLDESK1","{esc}"); return excel to normal state

MsgBox(0,"output", $x & $y & $z)

$1 = $1 + 1

Until $1 = 11

SoundPlay(@WindowsDir & "\media\tada.wav",1)

Func getcell($combo) ;Function gets cell reference "$combo" off the clipboard into variable $x

winactivate("Microsoft Excel")

ControlSend("Microsoft Excel","","XLDESK1","{f5}")

While NOT ControlCommand ("Go To","","EDTBX1","IsVisible", "") ; wait for window

sleep(100)

Wend

ControlSend("Go To","","EDTBX1",$combo&"{enter}")

ControlSend("Microsoft Excel","","XLDESK1","^c"); copies contents

$x=clipget(); move clipboard to $x

ControlSend("Microsoft Excel","","XLDESK1","{esc}"); return excel to normal state

Return $x

EndFunc

Script-Combined as attachment

Printer_ReName.au3

Share this post


Link to post
Share on other sites



not sure but this could be an error for combining

First

Script 1

$1=1

Until $1 = 777

Script 2

$1=1

Until $1 = 11

*** maybe change one of them to $2=

YOU, should look for other combination errors

Second

You should be able to have script 1?

call("script_2")

Func Script_2

; Excel Cell reference lookup example

; This code is ran while an excel sheet is already open.

$A = "A"

bla... bla... bla

hope it helps

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I will try calling the second script as a function, never thought of that... still a Noob.

As for the difference in numers, its just an example of what I was doing. I have spent sooo much time doing diff combos, @compsec and _RunDos. They do match on the combined script. If you have time could you review the combined? Its an attachmet above,

Thanks - I am under the gun with the holiday weekend.

I will include it here as well.

Code:

;Combined script

; ----------------------------------------------------------------------------

; 6/30/05

; Lexmark Printer WH Name and Address update

; ----------------------------------------------------------------------------

#include <Process.au3>

Dim $IP ; lookup from col "A" on SS

Dim $ContactName ; lookup from col "B" on SS

Dim $LocationName ; lookup from col "C" on SS

Dim $OpenWeb ; Launches the web-interface

$A = "A" ; Starting Cell Reference

$1 = 1 ; Starting Cell Reference

Do ;All the code needed for one full loop;

$combo = $A & $1

$IP=getcell($combo)

Send("{right}")

ControlSend("Microsoft Excel","","XLDESK1","^c"); copies contents

$ContactName=clipget(); move clipboard to $ContactName

ControlSend("Microsoft Excel","","XLDESK1","{esc}"); return excel to normal state

Send("{right}")

ControlSend("Microsoft Excel","","XLDESK1","^c"); copies contents

$LocationName=clipget(); move clipboard to $LocationName

ControlSend("Microsoft Excel","","XLDESK1","{esc}"); return excel to normal state

MsgBox(0,"output", $IP & $ContactName & $LocationName) ; Just validates my output is what I want

$OpenWeb=_RunDos("start http://" & $IP & "/port_0/config/general") ;To be called as from the START menu

;Wait for print server window to be activly loaded, then send the following;

WinWaitActive("Print Server Settings - Microsoft Internet Explorer","")

Sleep(3000)

Send("{Tab}")

Send("{Tab}")

Send($ContactName)

Send("{Tab}")

Send("{CTRLDOWN}a{CTRLUP}{BACKSPACE}")

Send($LocationName)

Sleep(500)

Send("{Enter}")

WinWaitActive("Configuration Change Submitted - Microsoft Internet Explorer","")

$1 = $1 + 1 ;Start over on next IP, move down one cell

Until $1 = 11 ;Number of printers to update xtimes to repeat

SoundPlay(@WindowsDir & "\media\tada.wav",1)

Func getcell($combo) ;Function to get cell reference "$combo" off the clipboard into variable $x

winactivate("Microsoft Excel")

ControlSend("Microsoft Excel","","XLDESK1","{f5}")

While NOT ControlCommand ("Go To","","EDTBX1","IsVisible", "") ; wait for window

sleep(100)

Wend

ControlSend("Go To","","EDTBX1",$combo &"{enter}")

ControlSend("Microsoft Excel","","XLDESK1","^c"); copies contents

$IP=clipget(); move clipboard to $x

ControlSend("Microsoft Excel","","XLDESK1","{esc}"); return excel to normal state

Return $IP

EndFunc

Share this post


Link to post
Share on other sites

did the function call for script 2 work?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

did the function call for script 2 work?

8)

<{POST_SNAPBACK}>

I believe the issue to be a bug with the clipget() function using the & operator from excel. I used the clipget() function with word, and notepad with no issues joining the string together with &.

Am I going crazy>? Can someone else verify this as well?

Code:

#include <Process.au3>

$IP=clipget()

_RunDos("start http://" & $IP & "/port_0/config/general")

Share this post


Link to post
Share on other sites

I have sent the output to an inputbox as a little debug. here is a pic of what I get. Some extra data being picked up from excel.

Any ideas?

Share this post


Link to post
Share on other sites

Ok,

Got it solved. Man I am thick. I should have seen this from a mile away. The problem is a bug(feature) with how clipget() interfaces with Excel.

Excel seems to be the standard fro SS apps, so I am shocked I could not find any posts with the same issue. I used 2 diff versions of Excel and this little script to debug. If someone can show me otherwise or let me know the "real" reason its acting this way please do so. Hope this can be of use to others:

Here we go- The final solution was to use the StringStripWS() cmd to get rid of the unwantted characters. To validate have 10.22.211.69 in an Excel cell. then run the code:

;Debug process for input text

;Start by getting text off the clipboad from execl

$IP=clipget()

;Display the number of charactrers on the clipboard

MsgBox(0,"Pasted from Clipboard", "Clip board contains: " & StringLen ($IP) & " characters." & @CRLF & "Clip board: " & ClipGet())

;Test what it looks like pasted from the clipboard into an input field

InputBox("test","",$IP)

;Remove all white spaces from the Excel field

MsgBox(0,"Removal of returns and spaces", "Now the strip")

$IP=StringStripWS($IP, 8)

InputBox("Extra spaces removed","",$IP)

Well, I can't say its been completly fun, but now I can update my 2,600qty stinkin printers before the 5th (deadline), Which should save me about 100hrs of O&M. Now back to the weekend............. MmmmmmmmBeeeeer. :)

Share this post


Link to post
Share on other sites

Good for you!!!.... You kept trying and got it.... thats mostly how I learned

have a greta weekend

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Good for you!!!.... You kept trying and got it.... thats mostly how I learned

have a greta weekend

8)

<{POST_SNAPBACK}>

I had a similar issue with an extraneous CR on each line I read. The way it evinced itself was to send the line to the dialog box field I was trying to fill in, and then to send an ENTER to the dialog box. I could not figure out why the dialog box was closing itself without me sending such a command (focus was on the Cancel button). I used the StringStripCR function to remove the trailer and everything worked.

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

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  
Followers 0