Jump to content

Think this is autoit bug: gui thinks i am focusing control which i am not


Recommended Posts

Once you click input control, put something in it and afterwards that inputcontrol loses focus and if you later click on checkbox control in another tab it will turn ON the keyboard focus of the last input control that was focused.

Try it yourself and you will see

Edited by Aktonius
Link to comment
Share on other sites

edited: bump

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Marko\Desktop\2+2scripts\ongame\test.kxf
$Form2 = GUICreate("Form2", 405, 294, 302, 218)
$Tab1 = GUICtrlCreateTab(8, 8, 369, 273)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Input1 = GUICtrlCreateInput("Input1", 48, 72, 121, 21)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlSetState(-1,$GUI_SHOW)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 48, 64, 97, 17)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by Aktonius
Link to comment
Share on other sites

Firstly don't bump your thread less than 24 hours :huh2: Secondly, it would be best to have some code where you're getting the problem, because 95% of the someone will try to replicate a supposed problem and funnily enough there isn't one!

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Once you click input control, put something in it and afterwards that inputcontrol loses focus and if you later click on checkbox control in another tab it will turn ON the keyboard focus of the last input control that was focused.

Try it yourself and you will see

Say what now?

Link to comment
Share on other sites

  • Moderators

Aktonius,

What you suggest is an AutoIt bug is normal Windows behaviour. When you reselect "TabSheet1" focus is given to the only control on the page - actioning the checkbox on the other tabsheet has nothing to do with it. :huh2:

If you want to prevent the text in the input being selected, then you have to tell Windows that this is what you want to do:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>

$Form2 = GUICreate("Form2", 405, 294, 302, 218)

$Tab1 = GUICtrlCreateTab(8, 8, 369, 273)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Input1 = GUICtrlCreateInput("Input1", 48, 72, 121, 21)

$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlSetState(-1,$GUI_SHOW)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 48, 64, 97, 17)

GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Tab1 ; Tab clicked <<<<<<<<<<<<<
            Switch GUICtrlRead($Tab1)
                Case 0 ; Tabsheet1 was clicked <<<<<<<<<<<<<
                    _GUICtrlEdit_SetSel($Input1, -1, -1) ; Send the cursor to the end of the text <<<<<<<<<<<<<
        EndSwitch
    EndSwitch
WEnd

All clear? ;)

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

Another trick to avoid setting focus to a control on a window is to create a 1x1 empty label someplace and set focus to that. I've also been know to create other controls with the position outside the GUI window and set focus to that.

EDIT:

I've noticed a few times now that you have quickly come to the conclusion that something you don't understand makes you jump to the conclusion that it's a bug. There may still be a couple of bugs floating around from the last release version but you can bet that most actual bugs have been reported by now.

You can always look through Trac to see what has been reported and what has been fixed.

Edited by GEOSoft

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!"

Link to comment
Share on other sites

Aktonius,

What you suggest is an AutoIt bug is normal Windows behaviour. When you reselect "TabSheet1" focus is given to the only control on the page - actioning the checkbox on the other tabsheet has nothing to do with it. :)

If you want to prevent the text in the input being selected, then you have to tell Windows that this is what you want to do:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>

$Form2 = GUICreate("Form2", 405, 294, 302, 218)

$Tab1 = GUICtrlCreateTab(8, 8, 369, 273)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Input1 = GUICtrlCreateInput("Input1", 48, 72, 121, 21)

$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlSetState(-1,$GUI_SHOW)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 48, 64, 97, 17)

GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Tab1 ; Tab clicked <<<<<<<<<<<<<
            Switch GUICtrlRead($Tab1)
                Case 0 ; Tabsheet1 was clicked <<<<<<<<<<<<<
                    _GUICtrlEdit_SetSel($Input1, -1, -1) ; Send the cursor to the end of the text <<<<<<<<<<<<<
        EndSwitch
    EndSwitch
WEnd

All clear? ;)

M23

Its clear what you mean, thanks for explaining.

But then again even this is not a bug i still think its stupid and pointless Windows behavior.

Why would windows focus any control in the entire Tab. So even if you say have only checkboxes in tab2 it will keyboard input-focus control from tab1 when you click checkbox in tab2. Really weird and arrogant by Windows.

On the end i had to make invisible dummy control which i focus to avoid this.

Another trick to avoid setting focus to a control on a window is to create a 1x1 empty label someplace and set focus to that. I've also been know to create other controls with the position outside the GUI window and set focus to that.

EDIT:

I've noticed a few times now that you have quickly come to the conclusion that something you don't understand makes you jump to the conclusion that it's a bug. There may still be a couple of bugs floating around from the last release version but you can bet that most actual bugs have been reported by now.

You can always look through Trac to see what has been reported and what has been fixed.

Say what?

This is the first time i ever said i think something in Autoit is a bug and even its not i think this is at least pointless by Windows.

Link to comment
Share on other sites

  • Moderators

Aktonius,

stupid and pointless Windows behavior [...] Really weird and arrogant by Windows

Join the club! :)

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

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...