Sign in to follow this  
Followers 0
Ghost21

Reading whole string...

6 posts in this topic

If $nMsg = $Button7 Then

$ret = _GUICtrlListGetSelItemsText($List1)

If (Not IsArray($ret)) Then

MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")

Else

For $i = 1 To $ret[0]

$printer = StringMid($ret[$i], 12, StringLen($ret[$i]))

Run("RunDll32.EXE printui.dll,PrintUIEntry /c\\" & GUICtrlRead($Input5) & " /in\\purcell /n\\" & $server & "\" & $printer)

Next

EndIf

Else

EndIf

The string that i'm reading looks like ShareName: HP OFFICEJET

Now I remove the first 12 characters to get the printername but it stops at the ( Space ) so it only shows me HP

How can I get it to read the whole thing... if I grab a different printer that's all attached like HPOFFICEJET3456 it reads it no problem ???

Help please...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$printer=StringTrimRight("MY PRINTER HP OFFICEJET",13)
MsgBox(0,"",$printer)

?

Edited by Nahuel

Share this post


Link to post
Share on other sites

What does the string look like BEFORE you start stripping things off?

You can probably do better than blindly stripping a set number of characters.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

What does the string look like BEFORE you start stripping things off?

You can probably do better than blindly stripping a set number of characters.

:)

The string that i'm reading looks like ShareName: HP OFFICEJET

it always has ShareName: Printer

but if the printer label has a space in the name it stops at the space....

ACTUALLY

msgbox(4000,"test",$printer) <--- it shows me the full name...

Run("RunDll32.EXE printui.dll,PrintUIEntry /c\\" & GUICtrlRead($Input5) & " /in\\purcell /n\\" & $server & "\" & $printer)

Is it losing the other data because of the rundll command ?

Share this post


Link to post
Share on other sites

$printer=StringTrimRight("MY PRINTER HP OFFICEJET",13)
MsgBox(0,"",$printer)

Isn't this the opposite of what is needed? This will return "MY PRINTER"

Just do:

$printer = StringMid($ret[$i], 12)

- or -

$printer = StringTrimLeft ( $ret[$i], 11 )

Share this post


Link to post
Share on other sites

$printer=StringTrimRight("MY PRINTER HP OFFICEJET",13)
MsgBox(0,"",$printer)

Isn't this the opposite of what is needed? This will return "MY PRINTER"

Just do:

$printer = StringMid($ret[$i], 12)

- or -

$printer = StringTrimLeft ( $ret[$i], 11 )

Hey weapon I'm not sure what he was talking about but I have found that if I do a RUN command it drops everything after the ( space ) if I do a shellexecute command it shows me the correct information but says it can't find the rundll command even though I changed it to @windowsdir\system32\rundll.exe etc.

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