Jump to content

Radio Button Switching


Ballistix
 Share

Recommended Posts

I am having problems with a script I wrote to Choose a radio button and depending on which radio button is chosen, populate a dropdown menu.

It works fine when you know what you want and choose the correct radio button the first time. If you click one and then the other the Dropdown contents don't change accordingly.

Can anyone help with this? I would much appreciate it.

Thanks

CODE
; Script Function:

; Asks user for device information and enters it into the registery key HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS

; and into the Computer Properties page under My Computer Properties.

#include <File.au3>

#include <GUIComboBox.au3>

#include <GUIConstants.au3>

AutoItSetOption ( "ExpandEnvStrings", 1);; Enables use of enviromental variables

$SerNum = Int(0)

$DevType = Chr("Device Type")

$ClassType = Chr("Class")

; Setup GUI

GuiCreate("Philips IPC Device Info Entry", 350, 250,-1,-1)

GUISetState (@SW_SHOW)

; Philips Logo

GuiCtrlCreatePic("%windir%\system32\oemlogo.bmp",50,10,240,71)

; Xper/S4 Radio Button Selection

$XperRadioIn = GUICtrlCreateRadio ("Xper IM", 100, 90, 75, 20)

$S4RadioIn = GUICtrlCreateRadio ("S4/I4", 180, 90, 75, 20)

; Serial Number Input box

GUICtrlCreateLabel ("Serial Number",5, 164,95,20)

$SerNumIn=GuiCtrlCreateInput("", 97, 160, 125, 20)

; Submit Button

$SubmitButton=GuiCtrlCreateButton("Submit", 60, 200, 100, 30)

; Remove Button

$RemoveButton=GuiCtrlCreateButton("Remove Device Info", 170, 200, 130, 30)

;End GUI Setup

$aLoop = 1

While $aLoop = 1

$msg1 = GUIGetMsg()

Select

Case $msg1 = $GUI_EVENT_CLOSE

Exit

Case $msg1 = $XperRadioIn And BitAND(GUICtrlRead($XperRadioIn), $GUI_CHECKED) = $GUI_CHECKED

; Device Dropdown

GUICtrlCreateLabel ("Device Type:",5, 124,85,20)

$DevTypeIn=GuiCtrlCreatecombo("", 97, 120, 250, 100)

GUICtrlSetData(-1,"Patient Care Console|Patient Care Console Elite|Patient Care Console Professional|Host|Nurse Station|Personal Assistant|Central Station|Central Station Plus|Data Center|Interface Broker|Xcelera Server|SPOT")

$bLoop = 0

;Loop to process info from Ctrl's

$bLoop = 1

While $bloop = 1

$msg2 = GUIGetMsg()

Select

Case $msg2 = $GUI_EVENT_CLOSE

Exit

Case $msg2 = $SubmitButton

$SerNum = GUICtrlRead($SerNumIn)

$DevType = (_GUICtrlComboBox_GetEditText ($DevTypeIn))

$ClassType = ("Xper IM")

; They clicked Submit, but did they type the right format?

If $SerNum < 199800000 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

ElseIf $SerNum > 299999999 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

Else

; Creates oeminfo.ini file in the System32 folder to put the device serial number in the System Properties box.

$file = FileOpen("%windir%\system32\oeminfo.ini", 2)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, "[General]" & @CRLF)

FileWrite($file, "Manufacturer=Philips " & $ClassType & " S/N: " & $SerNum & @CRLF)

FileWrite($file, "Model=" & $DevType)

FileClose($file)

; Creates value with serial number in HKEY_LOCAL_MACHINE\SOFTWARE\Witt registery key.

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber", "REG_SZ", $SerNum)

; Print the success message

MsgBox(4096,"IPC Device Serial Number Entry", "The serial number has been changed to "& $SerNum)

MsgBox(4096,"IPC Device Serial Number Entry", "The Device Type has been changed to "& $ClassType &" " & $DevType)

$bLoop =0

$aLoop =0

EndIf

Case $msg2 = $RemoveButton

FileDelete("%windir%\system32\oeminfo.ini")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber")

MsgBox (0,'Remove Device Info', 'Device info Removed')

$bLoop = 0

$aLoop =0

Exit

EndSelect

WEnd

Case $msg1 = $S4RadioIn And BitAND(GUICtrlRead($S4RadioIn), $GUI_CHECKED) = $GUI_CHECKED

; Device Dropdown

GUICtrlCreateLabel ("Device Type:",5, 124,85,20)

$DevTypeIn=GuiCtrlCreatecombo("", 97, 120, 250, 100)

GUICtrlSetData(-1,"Nurse Station|Review Station|Central Station|Patient Care Monitor Basic|Patient Care Monitor Advanced|Host|HL Recorder|HL Review|XA Recorder|Jukebox Controller|WAS Controller|File Server|Web Server|MFI|Web-DV Interface|FLI|FTI|SPOT")

$bLoop = 0

;Loop to process info from Ctrl's

$bLoop = 1

While $bloop = 1

$msg2 = GUIGetMsg()

Select

Case $msg2 = $GUI_EVENT_CLOSE

Exit

Case $msg2 = $SubmitButton

$SerNum = GUICtrlRead($SerNumIn)

$DevType = (_GUICtrlComboBox_GetEditText ($DevTypeIn))

$ClassType = ("Series IV")

; They clicked Submit, but did they type the right format?

If $SerNum < 199800000 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

ElseIf $SerNum > 299999999 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

Else

; Creates oeminfo.ini file in the System32 folder to put the device serial number in the System Properties box.

$file = FileOpen("%windir%\system32\oeminfo.ini", 2)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, "[General]" & @CRLF)

FileWrite($file, "Manufacturer=Philips " & $ClassType & " S/N: " & $SerNum & @CRLF)

FileWrite($file, "Model=" & $DevType)

FileClose($file)

; Creates value with serial number in HKEY_LOCAL_MACHINE\SOFTWARE\Witt registery key.

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber", "REG_SZ", $SerNum)

; Print the success message

MsgBox(4096,"IPC Device Serial Number Entry", "The serial number has been changed to "& $SerNum)

MsgBox(4096,"IPC Device Serial Number Entry", "The Device Type has been changed to "& $ClassType & " " & $DevType)

$bLoop =0

$aLoop =0

EndIf

Case $msg2 = $RemoveButton

FileDelete("%windir%\system32\oeminfo.ini")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber")

MsgBox (0,'Remove Device Info', 'Device info Removed')

$bLoop = 0

$aLoop =0

Exit

EndSelect

WEnd

Case $msg1 = $RemoveButton

FileDelete("%windir%\system32\oeminfo.ini")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber")

MsgBox (0,'Remove Device Info', 'Device info Removed')

$bLoop = 0

$aLoop =0

Exit

Do

$msg1 = GUIGetMsg()

until $msg1 = $GUI_EVENT_CLOSE or $aLoop =0

EndSelect

WEnd

; Finished!

Link to comment
Share on other sites

I am having problems with a script I wrote to Choose a radio button and depending on which radio button is chosen, populate a dropdown menu.

It works fine when you know what you want and choose the correct radio button the first time. If you click one and then the other the Dropdown contents don't change accordingly.

Can anyone help with this? I would much appreciate it.

Thanks

CODE
; Script Function:

; Asks user for device information and enters it into the registery key HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS

; and into the Computer Properties page under My Computer Properties.

#include <File.au3>

#include <GUIComboBox.au3>

#include <GUIConstants.au3>

AutoItSetOption ( "ExpandEnvStrings", 1);; Enables use of enviromental variables

$SerNum = Int(0)

$DevType = Chr("Device Type")

$ClassType = Chr("Class")

; Setup GUI

GuiCreate("Philips IPC Device Info Entry", 350, 250,-1,-1)

GUISetState (@SW_SHOW)

; Philips Logo

GuiCtrlCreatePic("%windir%\system32\oemlogo.bmp",50,10,240,71)

; Xper/S4 Radio Button Selection

$XperRadioIn = GUICtrlCreateRadio ("Xper IM", 100, 90, 75, 20)

$S4RadioIn = GUICtrlCreateRadio ("S4/I4", 180, 90, 75, 20)

; Serial Number Input box

GUICtrlCreateLabel ("Serial Number",5, 164,95,20)

$SerNumIn=GuiCtrlCreateInput("", 97, 160, 125, 20)

; Submit Button

$SubmitButton=GuiCtrlCreateButton("Submit", 60, 200, 100, 30)

; Remove Button

$RemoveButton=GuiCtrlCreateButton("Remove Device Info", 170, 200, 130, 30)

;End GUI Setup

$aLoop = 1

While $aLoop = 1

$msg1 = GUIGetMsg()

Select

Case $msg1 = $GUI_EVENT_CLOSE

Exit

Case $msg1 = $XperRadioIn And BitAND(GUICtrlRead($XperRadioIn), $GUI_CHECKED) = $GUI_CHECKED

; Device Dropdown

GUICtrlCreateLabel ("Device Type:",5, 124,85,20)

$DevTypeIn=GuiCtrlCreatecombo("", 97, 120, 250, 100)

GUICtrlSetData(-1,"Patient Care Console|Patient Care Console Elite|Patient Care Console Professional|Host|Nurse Station|Personal Assistant|Central Station|Central Station Plus|Data Center|Interface Broker|Xcelera Server|SPOT")

$bLoop = 0

;Loop to process info from Ctrl's

$bLoop = 1

While $bloop = 1

$msg2 = GUIGetMsg()

Select

Case $msg2 = $GUI_EVENT_CLOSE

Exit

Case $msg2 = $SubmitButton

$SerNum = GUICtrlRead($SerNumIn)

$DevType = (_GUICtrlComboBox_GetEditText ($DevTypeIn))

$ClassType = ("Xper IM")

; They clicked Submit, but did they type the right format?

If $SerNum < 199800000 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

ElseIf $SerNum > 299999999 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

Else

; Creates oeminfo.ini file in the System32 folder to put the device serial number in the System Properties box.

$file = FileOpen("%windir%\system32\oeminfo.ini", 2)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, "[General]" & @CRLF)

FileWrite($file, "Manufacturer=Philips " & $ClassType & " S/N: " & $SerNum & @CRLF)

FileWrite($file, "Model=" & $DevType)

FileClose($file)

; Creates value with serial number in HKEY_LOCAL_MACHINE\SOFTWARE\Witt registery key.

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber", "REG_SZ", $SerNum)

; Print the success message

MsgBox(4096,"IPC Device Serial Number Entry", "The serial number has been changed to "& $SerNum)

MsgBox(4096,"IPC Device Serial Number Entry", "The Device Type has been changed to "& $ClassType &" " & $DevType)

$bLoop =0

$aLoop =0

EndIf

Case $msg2 = $RemoveButton

FileDelete("%windir%\system32\oeminfo.ini")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber")

MsgBox (0,'Remove Device Info', 'Device info Removed')

$bLoop = 0

$aLoop =0

Exit

EndSelect

WEnd

Case $msg1 = $S4RadioIn And BitAND(GUICtrlRead($S4RadioIn), $GUI_CHECKED) = $GUI_CHECKED

; Device Dropdown

GUICtrlCreateLabel ("Device Type:",5, 124,85,20)

$DevTypeIn=GuiCtrlCreatecombo("", 97, 120, 250, 100)

GUICtrlSetData(-1,"Nurse Station|Review Station|Central Station|Patient Care Monitor Basic|Patient Care Monitor Advanced|Host|HL Recorder|HL Review|XA Recorder|Jukebox Controller|WAS Controller|File Server|Web Server|MFI|Web-DV Interface|FLI|FTI|SPOT")

$bLoop = 0

;Loop to process info from Ctrl's

$bLoop = 1

While $bloop = 1

$msg2 = GUIGetMsg()

Select

Case $msg2 = $GUI_EVENT_CLOSE

Exit

Case $msg2 = $SubmitButton

$SerNum = GUICtrlRead($SerNumIn)

$DevType = (_GUICtrlComboBox_GetEditText ($DevTypeIn))

$ClassType = ("Series IV")

; They clicked Submit, but did they type the right format?

If $SerNum < 199800000 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

ElseIf $SerNum > 299999999 Then

MsgBox(4096, "Error", "Incorrect Format - try again!")

Else

; Creates oeminfo.ini file in the System32 folder to put the device serial number in the System Properties box.

$file = FileOpen("%windir%\system32\oeminfo.ini", 2)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, "[General]" & @CRLF)

FileWrite($file, "Manufacturer=Philips " & $ClassType & " S/N: " & $SerNum & @CRLF)

FileWrite($file, "Model=" & $DevType)

FileClose($file)

; Creates value with serial number in HKEY_LOCAL_MACHINE\SOFTWARE\Witt registery key.

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber", "REG_SZ", $SerNum)

; Print the success message

MsgBox(4096,"IPC Device Serial Number Entry", "The serial number has been changed to "& $SerNum)

MsgBox(4096,"IPC Device Serial Number Entry", "The Device Type has been changed to "& $ClassType & " " & $DevType)

$bLoop =0

$aLoop =0

EndIf

Case $msg2 = $RemoveButton

FileDelete("%windir%\system32\oeminfo.ini")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber")

MsgBox (0,'Remove Device Info', 'Device info Removed')

$bLoop = 0

$aLoop =0

Exit

EndSelect

WEnd

Case $msg1 = $RemoveButton

FileDelete("%windir%\system32\oeminfo.ini")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\PHILIPS", "PhilipsSerialNumber")

MsgBox (0,'Remove Device Info', 'Device info Removed')

$bLoop = 0

$aLoop =0

Exit

Do

$msg1 = GUIGetMsg()

until $msg1 = $GUI_EVENT_CLOSE or $aLoop =0

EndSelect

WEnd

; Finished!

There is so much wrong with that GUI code that it's hard to find where to start. For openers don't create controls in a while loop. For example, everytime you click $XperRadioIn you are creating a new label and a new ComboBox over top of the old ones. Create those controls in the GUI itself and just use GUICtrlSetData() to set them.

To change the data in the ComboBox use a pipe ("|") at the beginning of the data. That will empty it first.

Example

GUICtrlSetData($DevTypeIn,"|Patient Care Console|Patient Care Console Elite|Patient Care Console Professional|Host|Nurse Station|Personal Assistant|Central Station|Central Station Plus|Data Center|Interface Broker|Xcelera Server|SPOT")

It a quick glance the whole GUI needs a lot of work though.

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

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...