Jump to content

MsgBox Func use


 Share

Recommended Posts

I have a simple msgbox function that I need to use in multiple places, but have different outcomes.  For example, in one location if the left button was pressed I need it to write a one of the reg values.  How do I accomplish this?

 

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Local $reg0 = RegWrite("HKLM\SOFTWARE\Wow6432Node\Newton\Default\Servers", "WRKSTN_ID", "REG_DWORD", "0")
Local $reg1 = RegWrite("HKLM\SOFTWARE\Wow6432Node\Newton\Default\Servers", "WRKSTN_ID", "REG_DWORD", "1")
Local $reg2 = RegWrite("HKLM\SOFTWARE\Wow6432Node\Newton\Default\Servers", "WRKSTN_ID", "REG_DWORD", "2")
Local $reg3 = RegWrite("HKLM\SOFTWARE\Wow6432Node\Newton\Default\Servers", "WRKSTN_ID", "REG_DWORD", "3")
Local $reg4 = RegWrite("HKLM\SOFTWARE\Wow6432Node\Newton\Default\Servers", "WRKSTN_ID", "REG_DWORD", "4")

MainGUI()

Func MainGUI()
  Local $Left, $Right, $msg
  GUICreate("Light")

  Opt("GUICoordMode", 2)
  $Left = GUICtrlCreateButton("Left", 10, 30, 50)
  $Right = GUICtrlCreateButton("Right", 0, -1)

  GUISetState()


  While 1
    $msg = GUIGetMsg()
    Select
     Case $msg = $GUI_EVENT_CLOSE
       ExitLoop
     Case $msg = $Left
       ; write reg value
     Case $msg = $Right
       ; write reg value
    EndSelect
  WEnd
EndFunc

 

Link to comment
Share on other sites

  • Moderators

Something like this, perhaps:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Local $sKey = "HKLM\SOFTWARE\Wow6432Node\Newton\Default\Servers"
Local $sVal = "WRKSTN_ID"
Local $sType = "REG_DWORD"

MainGUI()

Func MainGUI()
  Local $Left, $Right, $msg
  GUICreate("Light")

  Opt("GUICoordMode", 2)
  $Left = GUICtrlCreateButton("Left", 10, 30, 50)
  $Right = GUICtrlCreateButton("Right", 0, -1)

  GUISetState()

  While 1
    $msg = GUIGetMsg()
    Select
     Case $msg = $GUI_EVENT_CLOSE
       ExitLoop
    Case $msg = $Left
        RegWrite($sKey, $sVal, $sType, 0)
     Case $msg = $Right
       RegWrite($sKey, $sVal, $sType, 1)
    EndSelect
  WEnd
EndFunc

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

×
×
  • Create New...