Jump to content

function with multiple case


pcjunki
 Share

Recommended Posts

I'm adding a new button to my gui, and I can't figure out how to get this to work

I think because I'm trying to use a function on 2 cases, but I can't rename the function

I'm adding the "case $printerweb" to my existing script

and would like to have a new function where I can web into it, like shellexecute

$Label1 = GUICtrlCreateLabel("Computer", 216, 69, 233, 25)
$input1 = GUICtrlCreateCombo("", 216, 107, 233, 25, BitOR($CBS_DROPDOWN, $WS_VSCROLL))





$label14 = GUICtrlCreateLabel("Printer Install", 556, 555, 233, 25)

$printercombo = GUICtrlCreateCombo("", 556, 580, 297, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "1STFLOOR_PRINTER|2NDFLOR_PRINER")

$printerbutton = GUICtrlCreateButton("install printer", 730, 615, 123, 73)

$printerweb = GUICtrlCreateButton("web printer", 556, 615, 123, 73)





Case $printerbutton
            $printer = GUICtrlRead($printercombo)
            $pc = GUICtrlRead($input1)
            Call($printer, $pc)


Case $printerweb
            $webprinter = GUICtrlRead($printercombo)
            Call($webprinter)




Func 1STFLOOR_PRINTER($printerbutton)
    RunWait(@ComSpec & ' /k' & 'c:\windows\system32\spool\tools\printbrm.exe -r -s ' & $pc & ' -f \\SERVER356\deploy\printers\192.168.1.10.printerExport', "", @SW_SHOW)
EndFunc   ;==>1STFLOOR_PRINTER

Func 2NDFLOR_PRINER($printerbutton)
    RunWait(@ComSpec & ' /k' & 'c:\windows\system32\spool\tools\printbrm.exe -r -s ' & $pc & ' -f \\SERVER356\deploy\printers\192.168.2.10.printerExport', "", @SW_SHOW)
EndFunc   ;==>2NDFLOR_PRINER




`this is the new function to web into the printer
Func 1STFLOOR_PRINTER($printerweb)
 ShellExecute("C:\Program Files\Internet Explorer\iexplore.exe", "http://192.168.1.10/ews/index.htm")
EndFunc   ;==>1STFLOOR_PRINTER
Link to comment
Share on other sites

You're trying to go to a function selected from the combobox, but you're calling the function incorrectly. Your functions are looking for a parameter to be sent to them, and you're not sending that parameter. Second, the parameter used in the function head isn't being used inside the function at all, so it doesn't appear like you even need it there.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This should do the trickk NOT TESTED

 Call($webprinter, "Web")
 
 
Func 1STFLOOR_PRINTER($pc)
If $pc == "Web" then
 ShellExecute("C:\Program Files\Internet Explorer\iexplore.exe", "http://192.168.1.10/ews/index.htm")
Else
    RunWait(@ComSpec & ' /k' & 'C:\Windows\System32\spooltoolsprintbrm.exe -r -s ' & $pc & ' -f SERVER356deployprinters192.168.1.10.printerExport', "", @SW_SHOW)
EndIf
EndFunc   ;==>1STFLOOR_PRINTER

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

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