kor Posted June 1, 2012 Posted June 1, 2012 my code expandcollapse popup#NoTrayIcon #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <Constants.au3> #include <String.au3> #include <CompInfo.au3> #include <File.au3> #include <Array.au3> $aIP = StringSplit(@IPAddress1, ".") ; read each octect of IP address Select Case $aIP[3] <= 15 $sSite = "dom" Case $aIP[3] >= 16 And $aIP[3] <= 31 $sSite = "bal" Case $aIP[3] >= 32 And $aIP[3] <= 47 $sSite = "crk" Case $aIP[3] >= 48 And $aIP[3] <= 63 $sSite = "grf" Case $aIP[3] >= 64 And $aIP[3] <= 79 $sSite = "orn" Case $aIP[3] >= 80 And $aIP[3] <= 95 $sSite = "brn" Case Else $sSite = "dom" ; set site to dom if can't determine so Eos will ask EndSelect ; If site is district then prompt user for site selection If $sSite = "dom" Then $bValid = False Do $hGUI = GUICreate("Location", 165, 115, -1, -1, $WS_CAPTION) ; , $WS_CAPTION GUICtrlCreateLabel("Select Site", 51, 10, 165, 25) ; left, top, width, height GUICtrlSetFont(-1, 9, 700) Local $sInput = GUICtrlCreateCombo("", 10, 40, 145, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "0|1|2|3|4|5") Local $sOk = GUICtrlCreateButton("&OK", 43, 75, 80, 25) GUICtrlSetState($sOk, $GUI_DEFBUTTON) ; allows enter inside input boxes GUICtrlCreateLabel("IP = " & @IPAddress1, 1, 105, 100, 10) GUICtrlSetFont(-1, 6, 200) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() $sCode = GUICtrlRead($sInput) ; read machine type Select Case $msg = $sOk If $sCode <> "" Then ; if not blank $bValid = True ; input must be valid $sCode = StringLeft($sCode, 1) ; re-calculate site Switch $sCode Case "0" $sSite = "dom" Case "1" $sSite = "bal" Case "2" $sSite = "crk" Case "3" $sSite = "grf" Case "4" $sSite = "orn" Case "5" $sSite = "brn" EndSwitch ExitLoop Else MsgBox(16, "Error", "Site cannot be blank") GUICtrlSetState($sInput, $GUI_FOCUS) ; set focus back to input EndIf EndSelect WEnd GUIDelete($hGUI) Until $bValid = True EndIf What I'd like to do is build a sort of backdoor into this popup window such that if I press a certain key combination (lets say ALT+&) it will pop up a command window) Is there a way to listen for keystrokes inside the while loop for a popup?
kor Posted June 1, 2012 Author Posted June 1, 2012 (edited) got it If I put this anywhere inside my while loop it works. thanks If _IsPressed("2E", $dll) Then RunWait(@ComSpec) Edited June 1, 2012 by kor
Moderators JLogan3o13 Posted June 1, 2012 Moderators Posted June 1, 2012 You could also incorporate a HotKeySet function. "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!
kor Posted June 1, 2012 Author Posted June 1, 2012 I looked at that, but since I only need to launch a command if a single keystroke is pressed the _IsPressed seemed cleaner. Plus I can accomplish what I need with only 1 line of code.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now