Jump to content

Recommended Posts

Posted

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
Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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!

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
×
×
  • Create New...