Jump to content



Photo

how to listen for keystrokes in a popup window?


  • Please log in to reply
3 replies to this topic

#1 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 01 June 2012 - 01:32 PM

my code
AutoIt         
#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?





#2 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 01 June 2012 - 02:13 PM

got it
If I put this anywhere inside my while loop it works.
thanks


Edited by kor, 01 June 2012 - 02:13 PM.


#3 JLogan3o13

JLogan3o13

    Down to 98

  • MVPs
  • 2,081 posts

Posted 01 June 2012 - 02:25 PM

You could also incorporate a HotKeySet function.
J.I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, SCCM 2007 Front End, Windows Firewall UDF

#4 kor

kor

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 01 June 2012 - 02:40 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users