Jump to content

GUIGetMsg()


feeks
 Share

Recommended Posts

I have an issue that I have been trying to resolve for a while and would appreciate any assistance.

I am running the latest version of AutoIT and get the same with the Beta on XPSP3

The issue is with the firing of a subsequent action from the result of the GUIGetMsg() function call. What I am finding is that the GUIGetMsg() response is not fired if I click and edit either of the input controls as a first action. I have tested this with and without GUIGetMsg() default and advanced modes. If i tab to the input control following the default order of control definition and change the content the expected action is performed.

The following is the GUI

;   #Include <dbug.au3>
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <adfunctions.au3>
#include <array.au3>
#include <string.au3>
#include <File.au3>
#include <StatusBarConstants.au3>
#include <ComboConstants.au3>

Global $courseProfile, $accountsTextFile, $accountsExpiryDate, $accountsSite, $administrativeAccount, $administrativePassword, _
        $preserveHDrive, $processRunDate, $processRunTime, $processRunServer, $textandJobFile, $copyMRMT, $defaultAccount = "TRN\Administrator", _
        $dialogHeader = "BARPS - Batch Account Reset Processing System", $msg, $accountsFileStatus

#Region     ;   BARPS GUI
$BARPSGUI = GUICreate($dialogHeader, 581, 173, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "BARPSClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "BARPSMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "BARPSMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "BARPSRestore")
$MenuItem1 = GUICtrlCreateMenu("&BARPS")
$MenuItem2 = GUICtrlCreateMenuItem("Edit Accounts Master File", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Process Accounts Request", $MenuItem1)
$MenuItem8 = GUICtrlCreateMenuItem("View BARPS Log File", $MenuItem1)
$MenuItem9 = GUICtrlCreateMenuItem("View Task schedules for currently selected Server", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Quit", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenu("&Help")
$MenuItem6 = GUICtrlCreateMenuItem("Help BARPS", $MenuItem5)
$MenuItem7 = GUICtrlCreateMenuItem("About BARPS", $MenuItem5)
$Combo1 = GUICtrlCreateCombo("", 16, 12, 59, 25)
GUICtrlSetData($Combo1, ".|g2cse|g3cse|jlcse|pcccse|rsmcse|sgtcse|wocse", "jlcse")
GUICtrlSetTip($Combo1, "Select profile directory [. = root of userdata\usersettings]")
$Date1 = GUICtrlCreateDate("", 87, 12, 90, 21, $WS_TABSTOP)
GUICtrlSetTip($Date1, "Select course march-out date + 1 day")
$Combo2 = GUICtrlCreateCombo("", 189, 12, 57, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL, $CBS_SORT))
GUICtrlSetData($Combo2, "TCE|TCH|TCK|TCM|TCT|TCW", "TCK")
GUICtrlSetTip($Combo2, "Select processing site")
$I1 = GUICtrlCreateInput("", 258, 12, 155, 21, -1)
GUICtrlSetTip($I1, "Enter you administrative account name [including domain TRN\]")
GUICtrlSetData($I1,$defaultAccount)
$I2 = GUICtrlCreateInput("", 426, 12, 87, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
GUICtrlSetTip($I2, "Enter your administrative accounts' password")
GUICtrlSetData($I2,"Password")
$Checkbox1 = GUICtrlCreateCheckbox("Copy MRM data to Home Drive", 16, 48, 185, 17)
GUICtrlSetTip($Checkbox1, "Copy MRM [Checked = Yes/Unchecked = No]")
$Checkbox2 = GUICtrlCreateCheckbox("Preserve current Home Drive data", 200, 48, 200, 17)
GUICtrlSetTip($Checkbox2, "Preserve H: drive data [Checked = Yes/Unchecked = No]")
$Button1 = GUICtrlCreateButton("Edit Accounts File", 400, 48, 113, 25)
GUICtrlSetBkColor($Button1, 0x00FFFF)
GUICtrlSetTip($Button1, "Edit accounts file")
$Date2 = GUICtrlCreateDate("", 16, 88, 90, 21, $WS_TABSTOP)
GUICtrlSetTip($Date2, "Select processing request date")
$Date3 = GUICtrlCreateDate("", 120, 88, 90, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT, $WS_TABSTOP))
GUICtrlSetTip($Date3, "Select processing request time")
$Combo3 = GUICtrlCreateCombo("", 224, 88, 86, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $CBS_SORT, $CBS_UPPERCASE))
GUICtrlSetData($Combo3, "TCERSN01|TCERSN02|TCHRSN01|TCKRSN01|TCMRSN01|TCTRSN01|TCTRSN01|TCWRSN01", "TCKRSN01")
GUICtrlSetTip($Combo3, "Select processing server")
$Button2 = GUICtrlCreateButton("Process Accounts Request", 325, 88, 174, 25)
GUICtrlSetBkColor($Button2, 0x00FF00)
GUICtrlSetTip($Button2, "Submit accounts processing request")
GUICtrlSetState($Button2,$GUI_DISABLE)
$Button3 = GUICtrlCreateButton("Quit", 512, 88, 57, 25, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
GUICtrlSetBkColor($Button3, 0xFF0000)
GUICtrlSetTip($Button3, "Quit BARPS")
$Icon1 = GUICtrlCreateIcon("C:\WINDOWS\winhelp.exe", -1, 520, 8, 48, 64, BitOR($SS_NOTIFY, $WS_GROUP))
GUICtrlSetTip($Icon1, "BARPS Help?")
$StatusBar1 = _GUICtrlStatusBar_Create($BARPSGUI, -1, "", BitOR($SBARS_TOOLTIPS, $WS_BORDER), $WS_EX_CLIENTEDGE)
Dim $StatusBar1_PartsWidth[9] = [40, 260, 325, 355, 370, 385, 450, 520, -1]
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar1, "", 0)
_GUICtrlStatusBar_SetText($StatusBar1, "", 1)
_GUICtrlStatusBar_SetText($StatusBar1, "", 2)
_GUICtrlStatusBar_SetText($StatusBar1, "", 3)
_GUICtrlStatusBar_SetText($StatusBar1, "", 4)
_GUICtrlStatusBar_SetText($StatusBar1, "", 5)
_GUICtrlStatusBar_SetText($StatusBar1, "", 6)
_GUICtrlStatusBar_SetText($StatusBar1, "", 7)
_GUICtrlStatusBar_SetText($StatusBar1, "", 8)
_GUICtrlStatusBar_SetBkColor($StatusBar1, 0xC8D0D4)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 22)
GUISetState(@SW_SHOW)
#EndRegion      ;   BARPS GUI
;   InitialiseStatusBar()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = 0
            ;   don't do a thing!
        Case $msg = $MenuItem1
;           MenuItem1Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem1 " & $msg & " " & GUICtrlRead($MenuItem1) & @CRLF,2)
        Case $msg = $MenuItem2
;           MenuItem2Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem2 " & $msg & " " & GUICtrlRead($MenuItem2) &  @CRLF,2)
        Case $msg = $MenuItem3
;           MenuItem3Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem3 " & $msg & " " & GUICtrlRead($MenuItem3) &  @CRLF,2)
        Case $msg = $MenuItem4
;           MenuItem4Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem4 " & $msg & " " & GUICtrlRead($MenuItem4) &  @CRLF,2)
        Case $msg = $MenuItem5
;           MenuItem5Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem5 " & $msg & " " & GUICtrlRead($MenuItem5) &  @CRLF,2)
        Case $msg = $MenuItem6
;           MenuItem6Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem6 " & $msg & " " & GUICtrlRead($MenuItem6) &  @CRLF,2)
        Case $msg = $MenuItem7
;           MenuItem7Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem7 " & $msg & " " & GUICtrlRead($MenuItem7) &  @CRLF,2)
        Case $msg = $MenuItem8
;           MenuItem8Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem8 " & $msg & " " & GUICtrlRead($MenuItem8) &  @CRLF,2)
        Case $msg = $MenuItem9
;           MenuItem9Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "MenuItem9 " & $msg & " " & GUICtrlRead($MenuItem9) &  @CRLF,2)
        Case $msg = $Combo1
;           Combo1Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Combo1 " & $msg & " " & GUICtrlRead($Combo1) &  @CRLF,2)
        Case $msg = $Date1
;           Date1Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Date2 " & $msg & " " & GUICtrlRead($Date1) &  @CRLF,2)
        Case $msg = $Combo2
;           Combo2Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Combo2 " & $msg & " " & GUICtrlRead($Combo2) &  @CRLF,2)
        Case $msg = $I1
;           Input1Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Input1 " & $msg & " " & GUICtrlRead($I1) &  @CRLF,2)
        Case $msg = $I2
;           Input2Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Input2 " & $msg & " " & GUICtrlRead($I2) &  @CRLF,2)
        Case $msg = $Checkbox1
;           Checkbox1Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Checkbox1 " & $msg & " " & GUICtrlRead($Checkbox1) & @CRLF,2)
        Case $msg = $Checkbox2
;           Checkbox2Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Checkbox2 " & $msg & " " & GUICtrlRead($Checkbox2) &  @CRLF,2)
        Case $msg = $Button1
;           Button1Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Button1 " & $msg & " " & GUICtrlRead($Button1) & @CRLF,2)
        Case $msg = $Date2
;           Date2Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Date2 " & $msg & " " & GUICtrlRead($Date2) & @CRLF,2)
        Case $msg = $Date3
;           Date3Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Date3 " & $msg & " " & GUICtrlRead($Date3) & @CRLF,2)
        Case $msg = $Combo3
;           Combo3Change()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Combo2 " & $msg & " " & GUICtrlRead($Combo3) & @CRLF,2)
        Case $msg = $Button2
;           Button2Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Button2 " & $msg & " " & GUICtrlRead($Button2) & @CRLF,2)
        Case $msg = $Icon1
;;          Icon1Click()
            MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "Icon1 " & $msg & " " & GUICtrlRead($Icon1) & @CRLF,2)
        Case $msg = $Button3
            BARPSClose()
            ExitLoop
        Case $msg = $GUI_EVENT_CLOSE
            BARPSClose()
            ExitLoop
        Case Else
            ;   MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & $msg & @CRLF & $I1 & @CRLF,2)
    EndSelect
WEnd

Func BARPSClose()
    GUIDelete($BARPSGUI)
    MsgBox(0, $dialogHeader, @CRLF & @TAB & "O-k-a-y! ... BARPS off then! ..." & @CRLF)
EndFunc   ;==>BARPSClose

Func BARPSMinimize()
EndFunc   ;==>BARPSMinimize

Func BARPSMaximize()
EndFunc   ;==>BARPSMaximize

Func BARPSRestore()
EndFunc   ;==>BARPSRestore
Edited by feeks
Link to comment
Share on other sites

  • Moderators

feeks,

Happy New Year! ;) First post of 2010.

Here is one way of getting round your problem:

; Add these lines when creating your GUI - I put them in just before the Status Bar was created
$Dum = GUICtrlCreateDummy()
Dim $Accels[1][2] = [["{ENTER}", $Dum]] ; This will fire when Enter is pressed in your GUI
GUISetAccelerators($Accels)

; Then add these lines to your loop - I put them just above the Case Else
Case $msg = $Dum ; Enter has been pressed in your GUI, so check if we were in one of the edits
    If ControlGetFocus($BARPSGUI) = "Edit2" Then MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "I1 " & $msg & " " & GUICtrlRead($I1) & @CRLF,2)
    If ControlGetFocus($BARPSGUI) = "Edit3" Then MsgBox(0,"Testing GUIGetMsg() fire",@CRLF & "I2 " & $msg & " " & GUICtrlRead($I2) & @CRLF,2)

What we are doing here is to set up "ENTER" as an accelerator key. When the acceleraror key ("ENTER") is pressed in your GUI, it will send the ControlID of associated control ($Dum) to GUIGetMsg(). We then see which control has focus at that moment - you need to use the Au3WindowInfo tool to determine the ClassNameNN of the Input controls in your GUI) - and Robert is your mother's sister! :evil:

I hope that is clear enough and helps you out. Please ask if not.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23

Thank you for both the NY greeting and the assistance with the Accelerator. This works.

I do not however understand why the {TAB} key does not fire the associated action in the first direct access instance to the first input field. I can control-tab back to the input field once the {TAB} key has been depressed then {TAB} out of the field with the associated action firing.

Is this a known issue? Or is there an error either in my control definition or my reading and use of the interface?

From a user (of the interface) perspective it would be better to have a consistent activation method for each control particularly given that all other controls respond to the {TAB} key!

Link to comment
Share on other sites

I do not however understand why the {TAB} key does not fire the associated action in the first direct access instance to the first input field. I can control-tab back to the input field once the {TAB} key has been depressed then {TAB} out of the field with the associated action firing.

Is this a known issue? Or is there an error either in my control definition or my reading and use of the interface?

From a user (of the interface) perspective it would be better to have a consistent activation method for each control particularly given that all other controls respond to the {TAB} key!

What you describe doesn't occur for me. What I get, and what is standard in Windows, is that if you tab out of an edit without changing the text then an event for the edit itself is not generated as far as GuiGetMsg is concerned. If you want to respond to an edit loosing focus you will need to register $WM_COMMAND and test for the edit sending the notification $EN_KILLFOCUS.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

What you describe doesn't occur for me. What I get, and what is standard in Windows, is that if you tab out of an edit without changing the text then an event for the edit itself is not generated as far as GuiGetMsg is concerned. If you want to respond to an edit loosing focus you will need to register $WM_COMMAND and test for the edit sending the notification $EN_KILLFOCUS.

Hi Martin

The problem that I am having is not with exiting the control via the tab key but the consistent firing of the respective input control action as a result of editing the input control data.

When using the mouse to select either of the input controls as the first control selected and editing the input data the defined action does not fire if I tab from and control+tab back into the control perform an input edit and tab out the changed data is seen and the action performed.

If I tab from the default first control sequentially to either of the input controls the field content is selected, editable and editing and tabbing from the control fires the required action and performs both as you have indicated and as I would expect.

Using M23's solution proceeding directly to either input control with the {ENTER} key accelerator defined the required action is performed. Where I was describing consistence of action I was previously referring to having 2 input control that require a difference navigation and management process than the rest of the controls {TAB}

I have tested this in multiple XP environments and the issue seems to be consistent

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...