MattZ Posted January 5, 2010 Posted January 5, 2010 I have created a GUI form that takes a bunch of user input and has some defaults filled out. I have set a hotkey to Enter so that it does the same thing as clicking the OK button, and validate the data. This part works great, the issue is when all the data is processed I have a message box come up asking the user if they want to to fill out the form again. On the message box I have to click OK or Cancel, I can't press Enter like normal. If I do press enter then click OK the validation script runs. Is there a better way to make hitting Enter do the same thing as clicking a button, that will still let me hit enter on the msgboxes?
Xenobiologist Posted January 5, 2010 Posted January 5, 2010 Normally, the first Buttons hs git the focus, I gues. So why does enter not work on the MsgBox? You can create your own GUI. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
MattZ Posted January 5, 2010 Author Posted January 5, 2010 Normally, the first Buttons hs git the focus, I gues. So why does enter not work on the MsgBox?You can create your own GUI.I did create my own gui, the first thing created is actually an input field. I'm setting enter as a hotkey so when the user hits enter it does the same thing as pressing button 1. If I don't set enter as a hotkey you have to tab down to button 1 for enter to do anything (There are 5 default fields that can be changed but won't usually be changed that you would have to tab through). I'd like to have a way for someone to hit enter anywhere on the form once they are complete, then be able to also hit enter to clear the message boxes.I'll post some code when I get to work, maybe that will explain it better.
Hawkwing Posted January 5, 2010 Posted January 5, 2010 I think you want GUISetAccelerators. The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
GEOSoft Posted January 5, 2010 Posted January 5, 2010 Unset the hotkey before the message box opens and set it again after.HotKeySet("{Enter}","Somefunc")Do something hereHotKeySet("{Enter}")If MsgBox(4, "TEST", "Do you want to try again?") = 7 ThenHotKeySet("Enter", "SomeFunc")Do whatever is neededEndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
MattZ Posted January 5, 2010 Author Posted January 5, 2010 (edited) Unset the hotkey before the message box opens and set it again after. GEO - that was perfect, here is the code that is making it work for me. Thanks! While 1 HotKeySet("{ENTER}", "_ValidateData") $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button_Cancel Exit Case $msg = $Button_OK _ValidateData() EndSelect Func _ValidateData() HotKeySet("{Enter}") ....bunch of processing. End_Func @Hawkwing - I tried to use the GUISETAccelerators and it would throw me into a loop where the gui thought enter was being pressed repeatedly. Edited January 5, 2010 by MattZ
GEOSoft Posted January 6, 2010 Posted January 6, 2010 Good to hear you have it working now. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Splash Posted January 6, 2010 Posted January 6, 2010 Look at these sample: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $connection = false HotKeySet("{Enter}", "Go") Opt("GUIOnEventMode", 1) $Najort = GUICreate("Najort 0.2 Cliente", 627, 436, -1, -1) $commandResult = GUICtrlCreateEdit("", 0, 72, 625, 361) GUICtrlSetTip(-1, "Resultado dos comandos enviados.") $command = GUICtrlCreateInput("", 0, 40, 529, 21) GUICtrlSetTip(-1, "Comando a ser executado.") $connectButton = GUICtrlCreateButton("Conectar", 168, 8, 81, 25, $WS_GROUP) GUICtrlSetTip(-1, "Conectar-se ao servidor.") $serverIP = GUICtrlCreateInput("", 0, 8, 161, 21) GUICtrlSetTip(-1, "Endereço IP do servidor.") $disconnectButton = GUICtrlCreateButton("Desconectar", 256, 8, 81, 25, $WS_GROUP) GUICtrlSetTip(-1, "Desconectar-se do servidor.") $sendButton = GUICtrlCreateButton("Enviar", 536, 40, 89, 25, $WS_GROUP) GUICtrlSetTip(-1, "Enviar comando.") GUISetState(@SW_SHOW) ;Definição de eventos para os controles. GUICtrlSetOnEvent($connectButton, "connectButton") GUICtrlSetOnEvent($disconnectButton, "disconnectButton") GUICtrlSetOnEvent($sendButton, "sendButton") GUISetOnEvent($GUI_EVENT_CLOSE, "exitGui") ;Obtém o ID externo dos controles. GUICtrlSetState($command, $GUI_FOCUS) $commandID = ControlGetFocus($Najort) GUICtrlSetState($serverIP, $GUI_FOCUS) $serverIPID = ControlGetFocus($Najort) Func Go() If (ControlGetFocus($Najort) == $commandID) Then sendButton() ElseIf (ControlGetFocus($Najort) == $serverIPID) Then connectButton() Else HotKeySet("{Enter}") Send("{Enter}") HotKeySet("{Enter}", "Go") EndIf EndFunc Func connectButton () ToolTip("Conectar pressionado.", 0, 0) Sleep(1000) ToolTip("") _ConsoleWrite("Conectando ao IP " & GuiCtrlRead($serverIP) & "...") _ConsoleWrite("Conexão realizada com sucesso.") GUICtrlSetState($serverIP, $GUI_DISABLE) $connection = true ControlFocus($Najort, "", $commandID) EndFunc Func disconnectButton () GUICtrlSetState($serverIP, $GUI_DISABLE) ToolTip("Desconectar pressionado.", 0, 0) Sleep(1000) ToolTip("") _ConsoleWrite("Desconectando do IP " & GuiCtrlRead($serverIP) & "...") _ConsoleWrite("Desconexão realizada com sucesso.") GUICtrlSetState($serverIP, $GUI_ENABLE) $connection = false ControlFocus($Najort, "", $serverIPID) EndFunc Func sendButton () ToolTip("Enviar pressionado.", 0, 0) Sleep(1000) ToolTip("") If ($connection == true) Then _ConsoleWrite("Resultado para: " & GUICtrlRead($command)) Else MsgBox(0, "Erro", "Você não está conectado a nenhum computador.") EndIf GUICtrlSetData($command, "") EndFunc Func exitGui () Exit EndFunc Func _ConsoleWrite ($data) If (GuiCtrlRead($commandResult) == "") Then GUICtrlSetData($commandResult, $data) Else GUICtrlSetData($commandResult, GuiCtrlRead($commandResult) & @CRLF & $data) EndIf EndFunc ;Loop principal. While 1 Sleep(20) WEnd Is the GUI for my RAT. Automatic Update UDF - IP Address UDF - WinPcap AutoIt _FindDevice()[font="Verdana"][size="2"]AutoIt Spanish/Brasil/World community!!![/size][/font]Use you wanna a dot.tk domain please use my link:
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