Jump to content

Problem running script in Windows 7


 Share

Recommended Posts

Hello,

I am new to AutoIt and have been given a script someone else has written. In Windows 7 the script will not change the printing preferences. Does not matter if it is 64bit or 32bit, however, it works in Windows XP for sure. It runs the dll and then opens the print preferences and then suddenly stops.

$NEWACT = FileReadLine("z:\fspac.sys")

Run(@ComSpec & ' /c rundll32 printui.dll PrintUIEntry /n "\\abc-0\' & $CMDLINE[$X] & '" /e', "z:\")

WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences")

WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences", "Color/ Black and White")

ControlSend($CMDLINE[$X] & " on abc-0 Printing Preferences", "Color/ Black and White", "ComboBox1", "B")

Send("^{PGDN 3}")

WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences", "User Code")

ControlSend($CMDLINE[$X] & " on abc-0 Printing Preferences", "User Code", "Edit1", $NEWACT)

Send("{ENTER}")

Please help me understand where this went wrong.

Thank you...

Link to comment
Share on other sites

Hello,

I am new to AutoIt and have been given a script someone else has written. In Windows 7 the script will not change the printing preferences. Does not matter if it is 64bit or 32bit, however, it works in Windows XP for sure. It runs the dll and then opens the print preferences and then suddenly stops.

$NEWACT = FileReadLine("z:\fspac.sys")

Run(@ComSpec & ' /c rundll32 printui.dll PrintUIEntry /n "\\abc-0\' & $CMDLINE[$X] & '" /e', "z:\")

WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences")

WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences", "Color/ Black and White")

ControlSend($CMDLINE[$X] & " on abc-0 Printing Preferences", "Color/ Black and White", "ComboBox1", "B")

Send("^{PGDN 3}")

WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences", "User Code")

ControlSend($CMDLINE[$X] & " on abc-0 Printing Preferences", "User Code", "Edit1", $NEWACT)

Send("{ENTER}")

Please help me understand where this went wrong.

Thank you...

Welcome BlargINC ;).

Not enough information for me. If it "suddenly stops" have you checked that the window which appears really has the title

$CMDLINE[$X] & " on abc-0 Printing Preferences" exactly and that the text really is "Color/ Black and White"?

You really need to add somedebugging. I suggest that instead of

WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences")

you should have

if WinWaitActive($CMDLINE[$X] & " on abc-0 Printing Preferences","",10) = 0 then
 msgbox(262144,"ERROR","Window with title" & @CRLF & $CMDLINE[$X] & " on abc-0 Printing Preferences" & @CRLF "did not appear within 10 s.")
EndIf

and similar for later lines.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You may also want to try adding the line

Opt("WinTitleMatchMode", 2)

To the top of the script and then change all of your WinWaitActive() titles to "Printing Preferences"

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thank you for your help.

Just saw the Opt("WinTitleMatchMode", 2) part, will try it now.

The debugging script you provided gives me a syntax error when I compile it and I am trying to figure our what it could be.

Right now I do not know enough to know if the title and the $CMDLINE match, however, it works without issue in Windows XP. The printer driver/location/name hasn't changed. We just tried running the script on a new computer with Windows 7. Are there any known compatibility issues with AutoIT and Windows 7 that could be relevant?

Thanks, I know just starting the learning curve so everything is new to me right now.

Edited by BlargINC
Link to comment
Share on other sites

  • 4 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...