Sign in to follow this  
Followers 0
althurm

MsgBox not takin enter key

4 posts in this topic

Hello all.

I am having a problem with my MsgBox. First I have a custom GUI that I create and then after getting the users input in the GUI, I use the HotkeySet in the function for the GUI to get the Enter key. This will then end the GUI's function and call the MsgBox to get a confirmation. My problem is when the MsgBox comes up everything works fine except highlighting Yes or No and then pressing Enter doesn't do anything. I have to either click with the mouse or press Y for yes and N for No (normally enter works). Any ideas why enter doesn't work on my message box in this case?

In the main part of the script:

DeviceNumGUI()

$RUSure = MsgBox( 4, "Confirm Device Number", "Install Device Number " & $DeviceNumber & "?")

Func DeviceNumGUI()

$Complete = 0
$DeviceNumGUI = GUICreate("Installation", $ScreenRes[0] , $ScreenRes[1] , -1, -1, 0x00800000, -1 )

;Create Label
$L1Width = $ScreenRes[0] / 2
$L1Height = $ScreenRes[1] / 8
$L1Left = $ScreenRes[0] / 4
$L1Top = $ScreenRes[1] / 8
$Label1 = GUICtrlCreateLabel("Enter Device Number and Press Enter", $L1Left, $L1Top, $L1Width, $L1Height, 0x01)
GUICtrlSetFont($Label1, 12, 700)

;Create Input Box for the Device Number
$IWidth = $ScreenRes[0] / 4
$IHeight = $ScreenRes[1] / 30
$ILeft = $ScreenRes[0] * 3 / 8
$ITop = $L1Top + $L1Height + 60
$DeviceNumInput = GUICtrlCreateInput("", $ILeft, $ITop, $IWidth, $IHeight)

HotKeySet("{ENTER}", "EnterPressed" )

GUISetState(@SW_SHOW, $DeviceNumGUI)

While $Complete = 0
$nMsg = GUIGetMsg()
WEnd

EndFunc


Func EnterPressed()


$DeviceNumber = ControlGetText("Installation","", $DeviceNumInput)
$MachineName = "AND1P" & StringFormat("%04d", $DeviceNumber)
$Certificate = "AND1P" & StringFormat("%04d", $DeviceNumber) & ".pfx"
If StringLen($DeviceNumber) = 0 OR StringIsDigit($DeviceNumber) = 0 Then

ControlSetText("Installation","", $Label1,"Device Number Format Invalid:" & @CRLF & "Enter Device Number Again and Press Enter")
ControlSetText("Installation","", $DeviceNumInput,"")
ControlFocus("Installation","",$DeviceNumInput)

Else

$Complete = 1
;GUIDelete($DeviceNumGUI)
;RunInstallWinPE($DeviceNumber, $MachineName)

EndIf

EndFunc

Share this post


Link to post
Share on other sites



HotKeySet still consumes the Enter key and calls function EnterPressed. You have to unset the HotKey when it's no longer needed.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

HotKeySet still consumes the Enter key and calls function EnterPressed. You have to unset the HotKey when it's no longer needed.

Got it ... i figured it had something to do with hotkeyset but the help file doesn't say anything about unsetting it. Thanks!

Share this post


Link to post
Share on other sites

The help file states this:

function - [optional] The name of the function to call when the key is pressed. Not specifying this parameter will unset a previous hotkey.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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