Sign in to follow this  
Followers 0
martin

set printer for application automatically

17 posts in this topic

#1 ·  Posted (edited)

I think an application should instinctively know which printer I want so I don't have to think about choosing it.

It should also know what to do if I'm not connected to the network.

This script saves me from forgetting to set the correct printer and annoying myself.

Each time a new application has focus it will be added to the list and remembered. The printer for each new application will initially be set to a default which depends on whether there is a network connection. The actual printer can be set to any in the list of printers instead of the default.

If an app's printer is on the network, then when the network is not connected it will be set to use the default for no network.

This is mainly intended for laptops.

Const $version = "v3"
#include <Constants.au3>
#include <GUIConstants.au3>
#include <GuicomboBox.au3>
#include <guilistview.au3>
#include <tabconstants.au3>
#include <windowsconstants.au3>
#include <editconstants.au3>

Opt("MustDeclareVars",1)
Opt("TrayAutoPause",0); Script will not be paused when clicking the tray icon.

Const $NormalDefaultText = 'Normal Default'

Global $printerNames[10]
Global $inifile = "PrintersByApp.ini"
Global $NormalPrinter
Global $presentfocus = '', $lastfocused = ''
Global $Processes = 0
Global $sortdescend = False, $sortCol = 0
Global $objWMIService
Global $nMsg
Global $lastfocused = ''; the last window we detected with focus ignoring this app.
Global $Form1_1,$Tab1,$ListView1,$TabSheet1,$TabSheet2,$Group1,$Group2,$button1,$Button2,$Button3,$button4
Global $Label1,$Label2,$Label3,$Label4,$Label5,$IPCurrentDefault
Global $Combo1,$ComboNetPrinters,$ComboNoNetPrinters
Global $colum, $tempsort
Global $objWMIService = 0
Global $Group3, $radio1, $Radio2,$input1,$input2,$input3,$input4,$label6,$label7,$label8,$label9
Global $BtnApply
Global $netway
Global $MainTitle,$lastAppLabel,$mainState
Global $nn
#Region ### START Koda GUI section ### Form=d:program filesautoit3betakodaformsmgspecialssetprinterssetprintersform1.kxf
$Form1_1 = GUICreate("PSYCHO - Printer Selection, You Can Have Options   " & $version, 667, 562, 285, 144)
$Tab1 = GUICtrlCreateTab(8, 8, 650, 545, $TCS_FIXEDWIDTH)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Printers by Application")
$ListView1 = GUICtrlCreateListView("            Application Name      |      Preferred Printer", 16, 39, 630, 400, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_VSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
GUICtrlSendMsg(-1, 0x101E, 0, 270)
GUICtrlSendMsg(-1, 0x101E, 1, 330)
$lastAppLabel = GUICtrlCreateLabel("Last focused window title",16, 448,300,20)
$Group2 = GUICtrlCreateGroup("Select Printer for application", 16, 471, 630, 78)
$Combo1 = GUICtrlCreateCombo("ComboApps", 34, 491, 555, 25)
$Button3 = GUICtrlCreateButton("Apply to Selected Application", 34, 519, 203, 21, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button4 = GUICtrlCreateButton("Remove Selected Application", 480, 448, 155, 22, 0)
$TabSheet2 = GUICtrlCreateTabItem("Defaults")
GUICtrlSetState(-1,$GUI_SHOW)
$Group1 = GUICtrlCreateGroup("Normal Default Printer", 14, 127, 633, 329)
$ComboNoNetPrinters = GUICtrlCreateCombo("ComboNoNetPrinters", 38, 296, 555, 25)
$ComboNetPrinters = GUICtrlCreateCombo("ComboNetPrinters", 38, 177, 555, 25)
$Label2 = GUICtrlCreateLabel("When connected to Network", 38, 159, 142, 17)
$Label3 = GUICtrlCreateLabel("When Not connected to Network", 38, 278, 162, 17)
$Button1 = GUICtrlCreateButton("Apply", 38, 327, 115, 25, 0)
$Button2 = GUICtrlCreateButton("Apply", 38, 205, 115, 25, 0)
$Label4 = GUICtrlCreateLabel("The Normal Default Printer for No Network will be used for any application that uses a Network printer ", 48, 400, 484, 17)
$Label5 = GUICtrlCreateLabel("when there is no Network Connection to that printer.", 51, 420, 250, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("Currently set Default Printer", 40, 59, 132, 17)
$IPCurrentDefault = GUICtrlCreateInput("IPCurrentDefault", 40, 77, 553, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$Group3 = GUICtrlCreateGroup("Test method for network connection", 15, 461, 630, 85)
$Radio1 = GUICtrlCreateRadio("Check for any connection", 48, 480, 161, 17)
$Radio2 = GUICtrlCreateRadio("by testing the IP address below", 333, 480, 193, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Input1 = GUICtrlCreateInput("Input1", 336, 512, 57, 21)
$Input2 = GUICtrlCreateInput("Input2", 407, 512, 57, 21)
$Input3 = GUICtrlCreateInput("Input3", 478, 512, 57, 21)
$Input4 = GUICtrlCreateInput("Input4", 549, 512, 65, 21)
$Label6 = GUICtrlCreateLabel(".", 395, 512, 10, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel(".", 466, 512, 10, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel(".", 537, 512, 10, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label9 = GUICtrlCreateLabel("to another PC", 64, 496, 69, 17)
$BtnApply = GUICtrlCreateButton("Apply", 544, 477, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetState(@SW_HIDE)

Global $Traymenu1   = TrayCreateItem("Show psycho")
TraySetState()

GuictrlSendMsg($Tab1, $TCM_SETITEMSIZE, 0, _MakeLong(323, 20)); I like big tabs
SplashTextOn("Psycho is initializing","Getting default printer",200,50)
Global $currentPrinter = GetDefaultPrinter()
Global $Defaultnet = $currentPrinter
Global $Defaultnonet = $currentPrinter
Global $ip1[4],$ip1All
GUICtrlSetData($IPCurrentDefault,$currentPrinter)
SplashTextOn("Pyscho is inializing","Reading ini file..",200,50)
If FileExists($inifile) Then
    $Defaultnonet = IniRead($inifile,"Defaults","NoNetwork","not selected")
    $Defaultnet = IniRead($inifile,"Defaults","Network","not selected")
    $ip1All = IniRead($inifile,"IPADDRESSES","IP1","0")
    $ip1 = StringSplit($ip1All,".")
    if Ubound($ip1)< 5 Then
        redim $ip1[5]
        for $nn = 1 to 4
            $ip1[$nn] = 0
        Next
    EndIf

    GUICtrlSetData($input1,$ip1[1])
    GUICtrlSetData($input2,$ip1[2])
    GUICtrlSetData($input3,$ip1[3])
    GUICtrlSetData($input4,$ip1[4])
    Local $plist,$nAp
    $plist = IniReadSection($inifile,"Applications")
    If IsArray($plist) Then

        For $nAp = 1 To $plist[0][0]
           _GUICtrlListView_SetItemText($ListView1, _GUICtrlListView_InsertItem($ListView1,$plist[$nAp][0]),$plist[$nAp][1],1)
        Next
        _GUICtrlListView_SimpleSort($ListView1,$sortdescend,$sortCol)
        $sortdescend = Not $sortdescend
    EndIf
    $netway = IniRead($inifile,"Defaults","CheckIP",0)
    If $netway = 1 Then

        GUICtrlSetState($Radio2,$GUI_UNCHECKED)
        GUICtrlSetState($radio1,$GUI_CHECKED)
    EndIf


Else
    IniWrite($inifile,"Defaults","NoNetwork",$currentPrinter)
    IniWrite($inifile,"Defaults","Network",$currentPrinter)
EndIf
SplashTextOn("Pyscho is inializing","Setting printer list...",200,50)
SetupComboPrinters();fill the combos with the list of printers
SplashOff()
AdlibRegister("CheckCurrentApp",3000);keep aware of current app and set the default printer if needed
Global $lastTopItem = 999,$newtopitem
Local $sel,$seltext
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE,WinGetHandle("PSYCHO"))


        Case $ListView1;clicked heading to sort
            $colum = GUICtrlGetState($ListView1)
            If $sortCol = $colum Then
                $sortdescend = Not $sortdescend
            Else
                $sortcol = $colum
            EndIf
            $tempsort = $sortdescend
            _GUICtrlListView_SimpleSort($ListView1,$tempsort,$sortcol)

        Case $button1 ;nonetwork apply
            $Defaultnonet = GUICtrlRead($ComboNoNetPrinters)
            IniWrite($inifile,"Defaults","NoNetwork",$Defaultnonet)


        Case $Button2 ;network apply
            $Defaultnet = GUICtrlRead($ComboNetPrinters)
            IniWrite($inifile,"Defaults","Network",$Defaultnet)

        Case $Button3;apply printer to selected application
            $sel = _GUICtrlListView_GetNextItem($ListView1)
            If $sel <> $LV_ERR Then
                _GUICtrlListView_SetItemText($ListView1,$sel,GUICtrlRead($Combo1),1)
                IniWrite($inifile,"Applications",_GUICtrlListView_GetItemText($ListView1,$sel,0),GUICtrlRead($Combo1))
            EndIf

        Case $button4;remove from list
            $sel = _GUICtrlListView_GetNextItem($ListView1)
            If $sel <> $LV_ERR Then
                $seltext = _GUICtrlListView_GetItemText($ListView1,$sel,0)
                If MsgBox(4,'Confirm','Do you want To remove ' &$seltext & ' from the list?' & @CRLF & "(item " & $sel + 1 & ')') = 6 Then
                    ConsoleWrite("removing" & @CRLF)
                    _GUICtrlListView_DeleteItem(GuiCtrlGetHandle($ListView1),$sel)
                    if MsgBox(4,'Confirm','Is ' &$seltext & ' removed from the list?' & @CRLF & "(item " & $sel + 1 & ')') <> 6 Then exit
                     _GUICtrlListView_SimpleSort($ListView1,$tempsort,$sortcol)
                    IniDelete($inifile,"Applications",$seltext)
                EndIf
            EndIf

        Case $BtnApply
            $ip1All = ''
            For $n = 1 To 4
                If $n > 1 Then $ip1All = $ip1All & '.'
                $ip1All = $ip1All & GUICtrlRead(Eval("input" & $n))
            Next
            IniWrite($inifile,"IPADDRESSES","IP1",$ip1All)
            $netway = BitAND(GUICtrlRead($radio1),$GUI_CHECKED)
            IniWrite($inifile,"Defaults","CheckIP",$netway)
        Case $radio1

    EndSwitch

    ;If @Compiled Then
        $nMsg = TrayGetMsg()
        If $nMsg = $Traymenu1 Then
            GUISetState(@SW_SHOW,WinGetHandle("PSYCHO"))
            GUISetState(@SW_RESTORE,WinGetHandle("PSYCHO"))
        EndIf
    ;EndIf
$mainState = WinGetState($MainTitle,'')
If BitAND($mainState,16) And BitAND($mainState,2) Then
     WinSetState($MainTitle,'',@SW_HIDE)
EndIf


$newtopitem = _GUICtrlListView_GetTopIndex($ListView1)
If $newtopitem <> $lastTopItem Then
    $lastTopItem = $newtopitem
    DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($ListView1), "int", 0, "int", 1)
EndIf

WEnd



Func SetupComboPrinters()
    Local $strComputer,$colEvents,$objWMIService,$np

    $strComputer = "."
    If $objWMIService = 0 Then $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootcimv2")

    $colEvents = $objWMIService.ExecQuery _
            ("Select * From Win32_Printer"); Where Default = TRUE");TRUE
    $np = 0
    GUICtrlSetData($ComboNoNetPrinters,"|")
    GUICtrlSetData($ComboNetPrinters,"|")
    GUICtrlSetData($Combo1,"|")

    For $objPrinter in $colEvents
        If $np + 1 > UBound($printerNames) Then ReDim $printerNames[$np + 2]
        $printerNames[$np] = $objPrinter.DeviceID

        _GUICtrlComboBox_AddString($ComboNoNetPrinters,$objPrinter.DeviceID)
        _GUICtrlComboBox_AddString($ComboNetPrinters,$objPrinter.DeviceID)
        _GUICtrlComboBox_AddString($Combo1,$objPrinter.DeviceID)

        $np += 1
    Next
    _GUICtrlComboBox_AddString($Combo1,$NormalDefaultText)
    GUICtrlSetData($ComboNoNetPrinters,$Defaultnonet)
    GUICtrlSetData($ComboNetPrinters,$Defaultnet)
    GUICtrlSetData($Combo1,$currentPrinter)


EndFunc

Func GetDefaultPrinter()

    Local $result,$strComputer,$np,$colEvents
    $result = ''

    $strComputer = "."
    $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootcimv2")

    $colEvents = $objWMIService.ExecQuery _
            ("Select * From Win32_Printer Where Default = TRUE");TRUE
    $np = 0

    For $objPrinter in $colEvents
        $result = $objPrinter.DeviceID
    Next

    Return $result
EndFunc



Func PrinterSetAsDefault($PrinterName)
    Local $result, $strComputer, $colEvents, $np

    If $currentPrinter = $PrinterName Then Return
    $result = 0
    $strComputer = "."
    If $objWMIService = 0 Then $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootcimv2")
    $colEvents = $objWMIService.ExecQuery _
            (StringFormat('Select * From Win32_Printer')); Where DeviceID = "%s"', $PrinterName));TRUE
    $np = 0
    For $objPrinter in $colEvents
        If $objPrinter.DeviceID = $PrinterName Then
            $objPrinter.SetDefaultPrinter()
            $result = 1
        EndIf

    Next
    If $result Then
        $currentPrinter = $PrinterName
        GUICtrlSetData($IPCurrentDefault,$currentPrinter)
    EndIf
    Return $result

EndFunc

Func CheckCurrentApp()
    Local $Processes,$windows,$i,$presentfocus,$wid,$tempsort,$tempsort
    ;sets global $lastfocused to the name of the exe whose window has the current focus
    ;If app changes then sets the default printer for the app.
    ;update the list of processes
    $Processes = ProcessList();process name, PID
    If @error = 1 Then Return
    ;update the list of windows
    $windows = WinList()

    For $i = 1 to $windows[0][0];title,handle
        ; Only want focused window with or without a title
        $presentfocus = ''
        If  IsFocused($windows[$i][1]) Then
            $presentfocus = $windows[$i][0]
            If $presentfocus <> $lastfocused And  StringLeft($presentfocus,6) <> 'PSYCHO' Then ;App has changed

                $lastfocused = $presentfocus
                $wid = WinGetProcess($presentfocus)
                For $p = 1 To $Processes[0][0]
                    If $Processes[$p][1] = $wid Then
                        If $Processes[$p][0] <> 'psycho.exe' Then GUICtrlSetData($lastAppLabel,'Last focused app = ' & $Processes[$p][0])
                        setprinterfor($Processes[$p][0])
                        If updatelist($Processes[$p][0]) Then
                            $tempsort = $sortdescend
                            _GUICtrlListView_SimpleSort($ListView1,$tempsort,$sortCol)
                        EndIf
                        ExitLoop
                    EndIf

                Next

            EndIf

        EndIf
    Next

EndFunc  ;CheckCurrentApp


Func updatelist($proc)
    ;checks if $proc is in the list of applications
    ;If Not Then add To list
    ;Returns False if nothing added To list else returns true

    Local $found,$upl
    #region exclude apps
    ;looks like I need an exclusion list here, another listview maybe
    If $proc = "explorer.exe" Then Return False;no change made

    If StringInStr($proc,'.src') > 0 Then Return False;ignore screen savers

    If StringInStr($proc,"AutoIt3") > 0 Then Return False
    If $proc = "psycho.exe" Then Return False
    #endregion exclude apps

    $found = False
    For $upl = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1
        If _GUICtrlListView_GetItemText($ListView1,$upl,0) = $proc Then
            $found =True
            Return False
        EndIf
    Next
    If Not $found Then
         _GUICtrlListView_SetItemText($ListView1,  _GUICtrlListView_InsertItem($ListView1,$proc),$NormalDefaultText,1)
        IniWrite($inifile,"Applications",$proc,$NormalDefaultText)
        Return True
    EndIf

EndFunc ;updatelist




Func Setprinterfor($AppToSet)
    ;set that printer for Apptoset to default
    Local $found,$appPrinter,$foo,$readlines,$network,$line

    $found = False;haven't found the app in the list yet

    For $n = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1
        If _GUICtrlListView_GetItemText($ListView1,$n,0) = $AppToSet Then
            $appprinter =  _GUICtrlListView_GetItemText($ListView1,$n,1)
            $found = True
            ExitLoop
        EndIf
    Next

    If Not $found Then Return;failed
    $network = 0;
    ; ping takes about 34mS, net view takes about 330 mS so use ping
    If $netway = 0 Then
    $foo = Run(@ComSpec & " /c net view", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    $readlines = ''
    While 1
        $line = StdoutRead($foo)
        If @error Then ExitLoop
        $readlines = $readlines & $line;
    Wend
    ;detect if network connected

    ;Don't like this -needs a better way
    $network =  StringInStr($readlines,"completed successfully") > 0
    ;If $network Then
    Else
    If Ping($ip1All) Then $network = 1;if connected to router
    EndIf
    If $network <>0 Then
        If $appPrinter = $NormalDefaultText Then
            $appPrinter = $Defaultnet
        EndIf
    Else  ;see if printer is over network- don't like this bit, could fail if printers renamed
        If StringInStr($appprinter,'') > 0 Or StringInStr($appprinter,' on ') > 0 Then
            $appPrinter = $Defaultnonet
        Else
            If $appPrinter = $NormalDefaultText Then
                $appPrinter = $Defaultnonet
            endif

        EndIf
    EndIf

    PrinterSetAsDefault($appPrinter)

EndFunc  ; Setprinterfor


Func IsVisible($handle)
    Return BitAnd( WinGetState($handle), 2 )
EndFunc

Func IsFocused($handle)
    Return BitAnd( WinGetState($handle), 8 ); Then
EndFunc


Func _MakeLong($l, $h)
    Return BitOR(BitAnd($l, 0xFFFF), BitShift(BitAnd($h, 0xFFFF), -16))
EndFunc; _MakeLong()

Updated script to version 3 on 18th November 2011

Updated script to version 2 on 22nd July 2007

EDIT: 2nd Dec 2009 - changed the 2 lines with _GUICtrlListView_InsertItem because the newer GUICtrlLIstView udf has changed that function somewhen in the last 2 years.

I didn't notice other errors but that's no guarantee.

+ (Found that _GuiCtrlListView_DeleteItem has also changed and documentation in the help incorrectly says that the control ID can be passed but now only the handle works. Bug reported - ticket #1326)

Edited by martin

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.

Share this post


Link to post
Share on other sites



Might be a useful script for me, but I'm getting an error when running it..

Line 319

$foo = Run(@ComSpec & " /c net view", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

$foo = Run(@ComSpec & " /c net view", @SystemDir, @SW_HIDE,^ERROR

Error: Variable used without being declared.

Any Ideas?

Thanks

:whistle:

Share this post


Link to post
Share on other sites

Forgot to add-

error is generated when I start the script and open any application up, soon as I highlight the application or try to set a printer the error pops up

Share this post


Link to post
Share on other sites

Forgot to add-

error is generated when I start the script and open any application up, soon as I highlight the application or try to set a printer the error pops up

$STDERR_CHILD is defined in constants.au3, so maybe it's only in later versions of AutoIt and perhaps your version is not up-to-date.

here is the section from constants.au3

==============================================

; STDIO Constants

;==============================================

Global Const $STDIN_CHILD = 1

Global Const $STDOUT_CHILD = 2

Global Const $STDERR_CHILD = 4

I'll update the script in my first post with a slightly newer version, but this won't affect the error you get.


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.

Share this post


Link to post
Share on other sites

My mistake..when I copied the text I missed the

1st 2 lines which was the #include <constant>

Now working, but have another error...when script is running everything is fine,when I exit it and then rerun it I get the following error -

Line 102

GUICtrlSetData($input2,$IP 1[2])

GUICtrlSetData($input2,^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded

Is this related to the new part youve added for 'testing method for network conection'?

Apologies but i'm a noob when it comes to faultfinding scripts of this magnitude

:">

$STDERR_CHILD is defined in constants.au3, so maybe it's only in later versions of AutoIt and perhaps your version is not up-to-date.

here is the section from constants.au3

==============================================

; STDIO Constants

;==============================================

Global Const $STDIN_CHILD = 1

Global Const $STDOUT_CHILD = 2

Global Const $STDERR_CHILD = 4

I'll update the script in my first post with a slightly newer version, but this won't affect the error you get.

Share this post


Link to post
Share on other sites

My mistake..when I copied the text I missed the

1st 2 lines which was the #include <constant>

Now working, but have another error...when script is running everything is fine,when I exit it and then rerun it I get the following error -

Line 102

GUICtrlSetData($input2,$IP 1[2])

GUICtrlSetData($input2,^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded

Is this related to the new part youve added for 'testing method for network conection'?

Apologies but i'm a noob when it comes to faultfinding scripts of this magnitude

:">

It looks like there is a space between $IP and 1; it should be $IP1. Try removing the space and run it again. If you look at my first post I think you will see that there is no space there.

If that's not it then please let me know because I need to make sure the script works.


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.

Share this post


Link to post
Share on other sites

No space in script, seems to be when it tries to read the generated ini file on restart that it causes the error mentioned.

It looks like there is a space between $IP and 1; it should be $IP1. Try removing the space and run it again. If you look at my first post I think you will see that there is no space there.

If that's not it then please let me know because I need to make sure the script works.

Share this post


Link to post
Share on other sites

No space in script, seems to be when it tries to read the generated ini file on restart that it causes the error mentioned.

OK, I thought it looked like there was a space.

I've found the problem. I hadn't allowed for there being no IP set. This is now corrected and I've renewed the script in my first post.

Thanks for finding the error, sorry for the mistake.


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.

Share this post


Link to post
Share on other sites

yep, working fine now.

Many thanks for topnotch script. :whistle:

OK, I thought it looked like there was a space.

I've found the problem. I hadn't allowed for there being no IP set. This is now corrected and I've renewed the script in my first post.

Thanks for finding the error, sorry for the mistake.

Share this post


Link to post
Share on other sites

this is FREAKING RAD!!!!!!

Talk about saving time!

Good layout too Martin

;)

Rock it :)


A decision is a powerful thing

Share this post


Link to post
Share on other sites

this is FREAKING RAD!!!!!!

Talk about saving time!

Good layout too Martin

;)

Rock it :)

Thanks.

The main time it saved for me was by not printing to the wrong printer because I have a habit of just clicking the printer icon without thinking about it.


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.

Share this post


Link to post
Share on other sites

same here


A decision is a powerful thing

Share this post


Link to post
Share on other sites

hello, grate post,

I noticed you have two functions to setdefault printer and getdefault printer. can you help me with a function to list papertypes and papersizes?

Share this post


Link to post
Share on other sites

hello, grate post,

I noticed you have two functions to setdefault printer and getdefault printer. can you help me with a function to list papertypes and papersizes?

Would probably have been better to post your question in general help, or even better to have searched for "paper+sizes". :)

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.

Share this post


Link to post
Share on other sites

@Martin

I did, but am not getting a solution yet,

see here

i just need beg for help

Share this post


Link to post
Share on other sites

i dont know what you guys talking about, script is not working.

Too much undefined functions and none included script files reported so i cant even try it. :D

Share this post


Link to post
Share on other sites

I haven't looked at this for some time. It would possibly safe me some time if you could say what errors you get, give an example of an undefined function etc.

I'll spend a bit of time on it this weekend but I just tried running the version I have and I needed to change AdLibEnable to AdLibRegister, otherwise it runs ok, so I'll update the first post.


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.

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