Jump to content
Sign in to follow this  
jimollerhead

Problems using GuiRegisterMsg

Recommended Posts

Hello Folks,

I'm not an AutoIt noob but I am new to the GuiRegisterMsg command.

What I am trying to do is to pop up a "long string edit" window when user double-clicks. Ideally I wanted it to be a duouble-click in the Input box itself but I couldn't get this to work so I was going to settle for a double-click *near* the input box.

Here's a severely curtailed version of my almost 1300-line script. From the msgbox "tell-tale" it appears that the GuiRegisterMsg definition interferes with the GuiGetMsg function and it 'remembers' the last GuiGetMsg return value -- is there some way to 'flush' the holding area? Note that there are bits in there from experiments -- if I comment out the While-Wend and replace it with the sleep line you can better see what I am trying to acheive. The list box is just to give a different kind of control than an input field to have the focus, it's contents are not relevant to the snippet, only to the full app.

All help gratefully acknowledged! Here's the code snippet:

#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <ListBoxConstants.au3>
Dim $InputFileId
Dim $OutputFileId
Dim $winMain
Dim $GUIMsg
GUIRegisterMsg($WM_LBUTTONDBLCLK, "EditText")
$winMain = GUICreate ("Test for Editing Long Strings", 800, 560, -1, -1)
GUICtrlCreateLabel("File to Process", 22,30)
GUICtrlCreateLabel("Output File", 40,60)
$InputFileId = GUICtrlCreateInput ( "", 100, 25, 400, 20)
$OutputFileId = GUICtrlCreateInput ( "", 100, 55, 400, 20)
$btnInputFile = GUICtrlCreateButton ( "Browse for File", 520, 22, 110, 25)
$btnOPFolder = GUICtrlCreateButton ( "Browse for Location", 520, 53, 110, 25)
; Create the list of actions
$ActionList = GUICtrlCreateList( "", 25, 260, 70, 200)
GUICtrlSetData($ActionList, "Delete|Exclude|Include|Insert|Kill Blanks|Move|Remove|Replace|Switch", "Delete")
GUISetState(@SW_SHOW, $winMain)
While 1
$GUIMsg = GUIGetMsg()
Switch $GUIMsg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $btnInputFile
MsgBox(0, "Info", "Input Button pressed")
Case $btnOPFolder
MsgBox(0, "Info", "Output Button pressed")
EndSwitch
WEnd
Func EditText($Window, $Caller, $p1, $p2)
Dim $winEdit
Dim $CtrlName
Dim $edtString
Dim $btnAccept
Dim $btnReject
Dim $Response
Dim $RetString
Dim $CtrlId
Dim $ActCode
Dim $HasFocus
$CtrlName = ControlGetFocus("Test for Editing Long Strings")
msgbox(0,"DOUBLE-CLICK!","Control: " & $CtrlId & @CRLF & "Action: " & $ActCode & @CRLF & "CtrlName: " & $CtrlName)
If StringInStr($CtrlName,"Edit") > 0 Then
$winEdit = GUICreate("Long String Editor", 790, 100, -1, -1, $WS_BORDER)
$edtString = GUICtrlCreateEdit("This is a potentially long string", 5, 5, 780, 20, $ES_AUTOHSCROLL)
$btnAccept = GUICtrlCreateButton( "Accept String", 240, 33, 100, 30)
$btnReject = GUICtrlCreateButton( "Reject String", 440, 33, 100, 30)
GUISetState(@SW_SHOW, $winEdit)
GUICtrlSetState($edtString, $GUI_FOCUS)
; sleep(5000)
;#cs
While 1
$Response = GUIGetMsg()
if $Response = $btnAccept Then
ExitLoop
EndIf
Select
Case $Response = $btnReject
     ExitLoop
Case $Response = $btnAccept
; GUICtrlSetData($CtrlName, $RetString)
     ExitLoop
Case Else
     $RetString = GUICtrlRead($edtString)
EndSelect
WEnd
;#ce
Else
Return $GUI_RUNDEFMSG
EndIf
GUICtrlSetData($CtrlName, $RetString)
GUIDelete($winEdit)
Return $GUI_RUNDEFMSG
EndFunc
Edited by jimollerhead

Share this post


Link to post
Share on other sites

Well what sticks out is you have the message registered before the GUI is created. Also a couple of other points...

  • Don't use Dim, try to use Local or Global exclusively. Read the help file as to why Dim can cause more issues than solve them
  • Use [autoit][/autoit] tags when posting AutoIt code.

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

Share this post


Link to post
Share on other sites

Thanks for the quick reply Guinnes, but I don't think that's what my main problem was... I was doing too much in the EditText function (despite having read sevreal times in the Forum that you should "get in and out fast" when interrupting the messaging!

Here is an "almost there" version....my main problem now is detecting the field that had the focus when the double-click occurred. Using the ControlGetFocus function returns the CLASNN name which is useless for later when I want to copy the string back into the calling field because I need the internal ID then. I suspect I can get it by diddling around with the third parameter but the usual bitshifting that you use with WM_COMMAND doesn't work with WM_LBUTTONDBLCLK.... Here's the revised "almost there" version: (BTW I did try to use the 'AutoIT code' thing to paste last time but it just sat there and would not accept my mouse click) -- I'll research the "Don't use dim" thing if you can tell me what section of the helpfile it's in -- most examples use Dim and nothing says don't use it....

#include
#include
#include
#include
#include

Dim $InputFileId
Dim $OutputFileId
Dim $winMain
Dim $GUIMsg
Dim $EditCtrlId
Dim $EditCtrlName
Dim $EditCtrlHandle
Dim $DoubleClick = False

GUIRegisterMsg($WM_LBUTTONDBLCLK, "DblClick")

$winMain = GUICreate ("Test for Editing Long Strings", 800, 560, -1, -1)
GUICtrlCreateLabel("File to Process", 22,30)
GUICtrlCreateLabel("Output File", 40,60)
$InputFileId = GUICtrlCreateInput ( "", 100, 25, 400, 20)
$OutputFileId = GUICtrlCreateInput ( "", 100, 55, 400, 20)
$btnInputFile = GUICtrlCreateButton ( "Browse for File", 520, 22, 110, 25)
$btnOPFolder = GUICtrlCreateButton ( "Browse for Location", 520, 53, 110, 25)
; Create the list of actions
$ActionList = GUICtrlCreateList( "", 25, 260, 70, 200)
GUICtrlSetData($ActionList, "Delete|Exclude|Include|Insert|Kill Blanks|Move|Remove|Replace|Switch", "Delete")
GUISetState(@SW_SHOW, $winMain)

While 1
$GUIMsg = GUIGetMsg()
Switch $GUIMsg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $btnInputFile
MsgBox(0, "Info", "Input Button pressed")

Case $btnOPFolder
MsgBox(0, "Info", "Output Button pressed")
EndSwitch
If $DoubleClick Then
EditText()
EndIf
WEnd

Func DblClick($Window, $Caller, $p1, $p2)

$EditCtrlId = $p2 ; BitAND($p1, 0x0000FFFF)
$EditCtrlName = ControlGetFocus("Test for Editing Long Strings")
$EditCtrlHandle = ControlGetHandle("Test for Editing Long Strings", "", $EditCtrlName)
msgbox(0,"DOUBLE-CLICK!","Control: " & $EditCtrlId & @CRLF & "ControlName: " & $EditCtrlName & @CRLF & "Handle: " & $EditCtrlHandle)
$DoubleClick = True
Return $GUI_RUNDEFMSG
EndFunc

Func EditText()
Dim $winEdit
Dim $edtString
Dim $btnAccept
Dim $btnReject
Dim $Response
Dim $RetString

If StringInStr($EditCtrlName,"Edit") > 0 Then
$winEdit = GUICreate("Long String Editor", 790, 100, -1, -1, $WS_BORDER)
$edtString = GUICtrlCreateEdit("This is a potentially long string", 5, 5, 780, 20, $ES_AUTOHSCROLL)
$btnAccept = GUICtrlCreateButton( "Accept String", 240, 33, 100, 30)
$btnReject = GUICtrlCreateButton( "Reject String", 440, 33, 100, 30)
GUISetState(@SW_SHOW, $winEdit)
GUICtrlSetState($edtString, $GUI_FOCUS)

While 1
$Response = GUIGetMsg()
Select
Case $Response = $btnReject
ExitLoop
Case $Response = $btnAccept
GUICtrlSetData(5, $RetString)
; GUICtrlSetData($EditCtrlHandle, $RetString)
ExitLoop
Case Else
$RetString = GUICtrlRead($edtString)
EndSelect
WEnd
GUIDelete($winEdit)
EndIf
$DoubleClick = False
EndFunc
Edited by jimollerhead

Share this post


Link to post
Share on other sites

http://www.autoitscript.com/autoit3/docs/keywords/Dim.htm

You should use Local or Global, instead of Dim, to explicitly state which scope is desired for a variable/constant/array.

Also 99% of the examples don't use Dim, if they did then they've been zapped in the latest beta version of the help file.


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

Share this post


Link to post
Share on other sites

OK thanks for the link...I was expecting some kind of performance-related reason rather than being too gormless to differentiate locals and globals without explicitly saying so. As I've been programming professionally with 3GLs since the early 80's (Basic then Pascal, the king of 3GLs, then C) I think I am OK to manage to make the differentiation unaided. I will, however take the advice for future AutoIt code if only to make it more readable for posting in the forum. My far more pressing issue is trying to identify the ID for the control that has the focus in my code!

Regards,

Jim.

Share this post


Link to post
Share on other sites

Sorted! Found this little beauty in a Forum example: _WinAPI_GetDlgCtrlID - Thank you, thank you, thank you, Authenticity!!

It effectively is just a converter that takes a handle in and spits an ID (i.e. what you get from the Create...statement) out!

Here's the finally working beast:

#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <ListBoxConstants.au3>
#include <WinAPI.au3>
Global $InputFileId
Global $OutputFileId
Global $winMain
Global $GUIMsg
Global $EditCtrlId
Global $EditCtrlName
Global $EditCtrlHandle
Global $DoubleClick = False
$winMain = GUICreate ("Test for Editing Long Strings", 800, 560, -1, -1)
GUICtrlCreateLabel("File to Process", 22,30)
GUICtrlCreateLabel("Output File", 40,60)
$InputFileId = GUICtrlCreateInput ( "", 100, 25, 400, 20)
$OutputFileId = GUICtrlCreateInput ( "", 100, 55, 400, 20)
$btnInputFile = GUICtrlCreateButton ( "Browse for File", 520, 22, 110, 25)
$btnOPFolder = GUICtrlCreateButton ( "Browse for Location", 520, 53, 110, 25)
; Create the list of actions
$ActionList = GUICtrlCreateList( "", 25, 260, 70, 200)
GUICtrlSetData($ActionList, "Delete|Exclude|Include|Insert|Kill Blanks|Move|Remove|Replace|Switch", "Delete")
GUISetState(@SW_SHOW, $winMain)
GUIRegisterMsg($WM_LBUTTONDBLCLK, "DblClick")
While 1
$GUIMsg = GUIGetMsg()
Switch $GUIMsg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $btnInputFile
MsgBox(0, "Info", "Input Button pressed")
Case $btnOPFolder
MsgBox(0, "Info", "Output Button pressed")
EndSwitch
If $DoubleClick Then
EditText()
EndIf
WEnd
Func DblClick($Window, $Caller, $p1, $p2)
; $EditCtrlId = $p2 ; BitAND($p1, 0x0000FFFF)
$EditCtrlName = ControlGetFocus("Test for Editing Long Strings")
$EditCtrlHandle = ControlGetHandle("Test for Editing Long Strings", "", $EditCtrlName)
$EditCtrlId = _WinAPI_GetDlgCtrlID($EditCtrlHandle)
msgbox(0,"DOUBLE-CLICK!","Control: " & $EditCtrlId & @CRLF & "ControlName: " & $EditCtrlName & @CRLF & "Handle: " & $EditCtrlHandle)
$DoubleClick = True
Return $GUI_RUNDEFMSG
EndFunc
Func EditText()
Local $winEdit
Local $edtString
Local $btnAccept
Local $btnReject
Local $Response
Local $RetString
If StringInStr($EditCtrlName,"Edit") > 0 Then
$winEdit = GUICreate("Long String Editor", 790, 100, -1, -1, $WS_BORDER)
$edtString = GUICtrlCreateEdit("This is a potentially long string", 5, 5, 780, 20, $ES_AUTOHSCROLL)
$btnAccept = GUICtrlCreateButton( "Accept String", 240, 33, 100, 30)
$btnReject = GUICtrlCreateButton( "Reject String", 440, 33, 100, 30)
GUISetState(@SW_SHOW, $winEdit)
GUICtrlSetState($edtString, $GUI_FOCUS)
While 1
$Response = GUIGetMsg()
Select
    Case $Response = $btnReject
     ExitLoop
    Case $Response = $btnAccept
;    GUICtrlSetData(5, $RetString)
     GUICtrlSetData($EditCtrlId, $RetString)
     ExitLoop
    Case Else
     $RetString = GUICtrlRead($edtString)
EndSelect
WEnd
GUIDelete($winEdit)
EndIf
$DoubleClick = False
EndFunc
Edited by jimollerhead

Share this post


Link to post
Share on other sites

This is how the message should be structured as per the instructions of the help file...

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate('Left Button Click', 300, 300)

    GUIRegisterMsg($WM_LBUTTONDBLCLK, 'WM_LBUTTONDBLCLK')
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example

; http://msdn.microsoft.com/en-us/library/windows/desktop/ms645606(v=vs.85).aspx
Func WM_LBUTTONDBLCLK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $iCode = _WinAPI_LoWord($wParam)
    Local $iX = _WinAPI_LoWord($lParam)
    Local $iY = _WinAPI_HiWord($lParam)
    ConsoleWrite($iCode & ' - Double-Click on GUI:  hWnd = ' & $hWnd & '; X = ' & $iX & '; Y = ' & $iY & @CRLF)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDBLCLK

I still feel inclined to help and provide a more robust solution, but you seem to have things in hand.

Edited by guinness

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

Share this post


Link to post
Share on other sites

jimollerhead,

F.Y.I. - a method of detecting input control double clicks using control subclassing

; *** Start added by AutoIt3Wrapper ***
#include <WindowsConstants.au3>
; *** End added by AutoIt3Wrapper ***

; based on code developed by D4ARKON3 and modified by PhoenixXL

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('SubClass Two Input Controls', 400, 300)
Local $inp010 = GUICtrlCreateInput('', 10, 20, 380, 20)
Local $inp020 = GUICtrlCreateInput('', 10, 120, 380, 20)
GUISetState()

$hInputSubClassProc = DllCallbackGetPtr(DllCallbackRegister('_InputSubClassProc', 'LRESULT', 'HWND;UINT;WPARAM;LPARAM;UINT_PTR;DWORD_PTR'))
If ($hInputSubClassProc == 0) Then
    MsgBox(16, 'Subclass Test', 'Call to DllCallbackRegister failed.')
    Exit
EndIf

SetWindowSubclass(GUICtrlGetHandle($inp010), $hInputSubClassProc, 0, 0)
If (@error) Then
    MsgBox(16, 'Subclass Test', 'Call to WinProc for inp010 failed.')
    Exit
EndIf

SetWindowSubclass(GUICtrlGetHandle($inp020), $hInputSubClassProc, 1, 0)
If (@error) Then
    MsgBox(16, 'Subclass Test', 'Call to WinProc for inp020 failed.')
    Exit
EndIf

While (True)
    Switch (GUIGetMsg())
        Case -3 ;GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

RemoveWindowSubclass(GUICtrlGetHandle($inp010), $hInputSubClassProc, 0, 0)
RemoveWindowSubclass(GUICtrlGetHandle($inp020), $hInputSubClassProc, 1, 0)

Exit

Func _InputSubClassProc($hWnd, $uMsg, $wParam, $lParam, $uIdSubclass, $dwRefData)
    Switch $uMsg
        Case $wm_lbuttondblclk
            Switch $uIdSubclass
                Case 0
                    GUICtrlSetData($inp010, 'I was double clicked')
                Case 1
                    GUICtrlSetData($inp020, 'I was double clicked')
            EndSwitch
    EndSwitch
    Return DefSubclassProc($hWnd, $uMsg, $wParam, $lParam)
EndFunc   ;==>_InputSubClassProc

Func SetWindowSubclass($hWnd, $pfnSubclass, $uIdSubclass, $dwRefData)
    Local $bResult = DllCall('Comctl32.dll', 'BOOL', 'SetWindowSubclass', _
            'HWND', $hWnd, _
            'ptr', $pfnSubclass, _
            'UINT_PTR', $uIdSubclass, _
            'DWORD_PTR', $dwRefData)
    If (@error) Or ($bResult[0] == 0) Then Return SetError(1, 0, 0)
    Return SetError(0, 0, 1)
EndFunc   ;==>SetWindowSubclass

Func GetWindowSubclass($hWnd, $pfnSubclass, $uIdSubclass, ByRef $dwRefData)
    Local $bResult = DllCall('Comctl32.dll', 'BOOL', 'GetWindowSubclass', _
            'HWND', $hWnd, _
            'ptr', $pfnSubclass, _
            'UINT_PTR', $uIdSubclass, _
            'DWORD_PTR*', 0)
    If (@error) Or ($bResult[0] == 0) Then Return SetError(1, 0, 0)
    $dwRefData = $bResult[4]
    Return SetError(0, 0, 1)
EndFunc   ;==>GetWindowSubclass

Func RemoveWindowSubclass($hWnd, $pfnSubclass, $uIdSubclass, $dwRefData)
    Local $bResult = DllCall('Comctl32.dll', 'BOOL', 'RemoveWindowSubclass', _
            'HWND', $hWnd, _
            'ptr', $pfnSubclass, _
            'UINT_PTR', $uIdSubclass)
    If (@error) Or ($bResult[0] == 0) Then Return SetError(1, 0, 0)
    Return SetError(0, 0, 1)
EndFunc   ;==>RemoveWindowSubclass

Func DefSubclassProc($hWnd, $uMsg, $wParam, $lParam)
    Local $aRet = DllCall('Comctl32.dll', 'LRESULT', 'DefSubclassProc', _
            'HWND', $hWnd, _
            'UINT', $uMsg, _
            'WPARAM', $wParam, _
            'LPARAM', $lParam)
    Return $aRet[0]
EndFunc   ;==>DefSubclassProc

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

That's not for your 'average AutoIt user' and actually you've given me my next topic to grasp. Thanks kylomas.


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

Share this post


Link to post
Share on other sites

D4RKON3 developed the UDF (in examples section), PhoenixXL corrected some errors and provided example.

MSDN has a small intro here.


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Thanks. I could see from the comments you were only the messenger 0_-.


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

Share this post


Link to post
Share on other sites

kylomas,

Thank you for posting that - I have been trying (and failing) to detect double-clicks in inputs since this thread started. ;)

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

 

Share this post


Link to post
Share on other sites

Thanks. I could see from the comments you were only the messenger 0_-.

 

Clarification - D4ARKON developed the UDF.  PhoenixXL corrected a problem with not handing back control correctly.  I wrote this code using an example from the origional topic but expanded it it to show subclassing multiple controls to the same procedure (function).  You can probably tell that from the coding style.

Not to get all anal about it but if there is something wrong with this code then I don't want it to blow back on PhoenixXL or D4RKON3...

edit: spelling

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

You can probably tell that from the coding style.

Your style is unique, that's true. 0_-


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

Share this post


Link to post
Share on other sites

Thanks for carrying on with this folks even though I managed a solution (of sorts)

@Guinness, I did indeed spot that example in the helpfile, however knowing the X/Y coordinates at the time of the double-click would give me no end of grief in performing other programming cartwheels in order to figure out which of the many (and dynamically created and destroyed within the app) input fields named 'EditN' the mouse cursor was over.... my main problem in the end was switching from the CLASSNN descriptor to the ID which I had to do by going via the handle.... it would be nice for the double-click to be actually ON the edit field rather than close to it but I am happy with "good enough" rather than "perfect" using the 80/20 rule of programming!! In case you are curious what I am up to, the executable is called Textreme and downloadable from jollybean.co.uk -- I had an enhancement request from a user asking if it would be possible to have a pop-up editor for the functon parameters as some of his search strings were quite long and he'd like to see them in full without having to sideways-scroll the input box. BTW, the current release doesn't yet incorporate the Long String Editor, because the same user asked for a batch run function which is even more work!

@kylomas - Whilst I am sure that your example is a neat and elegant solution, I use AutoIT to *avoid* DLL-hell, not to jump straight in welly-deep! Thank you for contributing though and, even though I am not taking on your solution, you have apparently helped out Melba23 in the process!

Share this post


Link to post
Share on other sites

I'm aware of Textreme, didn't realise you were the developer though.

Believe it or not I used to be anti-UDF, anti-DLL, anti-GUIRegisterMsg, anti-non-Native AutoIt functions but that's the old me.


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

Share this post


Link to post
Share on other sites

Well that's one of the most surprising things I have read in the forum -- that someone was "aware" of Textreme!

It's very much just a hobby project that was originally much simpler and for my own use only, that I have expanded the versatility of over time. As I use my own name in here you can now, I guess, make the link from the warp of my initial and surname to the website name!  :o)   I don't make any efforts to hide the WhoIs info so it would hardly take Clouseau to track down the registered owner! 

Personally, I am not really "anti" anything *provided there is supporting information*. The 3rd and 4th parameters of the GUIRegisterMsg-responding function obviously contain different things depending upon which of the Windows messages you are intercepting. How you all know what these are is a mystery to me as is how you find out about the DLL functions, what they do,  and the parameters they expect/return. There is nowt to be found in the help file (nor would I expect there to be, TBH) so you must have some esoteric info gained from somewhere that I have no knowledge of!

Share this post


Link to post
Share on other sites

How you all know what these are is a mystery to me as is how you find out about the DLL functions, what they do,  and the parameters they expect/return. There is nowt to be found in the help file (nor would I expect there to be, TBH) so you must have some esoteric info gained from somewhere that I have no knowledge of!

 

By reading MSDN and looking at working examples. The help file explains the function, but the backend stuff is nothing to do with AutoIt. Also considering Microsoft are changing this and that, would mean the help would soon become out dated.


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

Share this post


Link to post
Share on other sites

Apologies for not responding to the convo this afternoon Guinness but I was just checking the thread in my lunch-hour so could not engage in a 'live' interaction....I do find your nick a tad ironic given that I am an Englishman marooned in the ROI and I cannot stand the stuff!  [grin].....and not only that I live next door to the original site of the first Guinness brewery!  (which has just been sold BTW)

Edited by jimollerhead

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By argumentum
      #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include "GuiChildTabUDF.au3" Global $__iFlashWindowEx = 0 ; ..see _WM_SETCURSOR() tabGUI_OPTs("RandomColor", 1) ; ..to add coloring to the GUIs, for debug. ( Default is 0 ) tabGUI_OPTs("SetCtrlDbgCreateWidth", 1) ; tells the UDF to leave some space for the debug buttons ( see tabGUI_CtrlDbgCreate() ). ( Default is 0 ) tabGUI_Example() Func tabGUI_Example() ; tabGUI_Create() has the same parameters as GUICreate() ; ..just skip the styles, as those are handled by the function. tabGUI_Create("Parent/Children Example") ; the first GUI will have to be the parent tabGUI_CtrlDbgCreate("Show GUI array") ; All these are tabGUI_CtrlDbgCreate("Show OPT array") ; for debug and tabGUI_CtrlDbgCreate("Swap GUIs/LABELs") ; are not needed tabGUI_CtrlDbgCreate("Can Drag child") ; to use the UDF tabGUI_CtrlDbgCreate("Self CPU usage") ; These are called after a GUI is present. ; search for "SetResizing:" to understand the TITLE modification ( used for tabGUI_DockStr2Int() ) tabGUI_Create("SetResizing:LBWH;1", 400, 400, 20, 20) ; all other GUI will be child addSomeControls() tabGUI_Create("2", 400, 400, 60, 60) addSomeControls() ; multiple child in child example ; ..skip the width and heigth, to have the function calculate the values. tabGUI_Create("3", Default, Default, 200, 230) tabGUI_Create("4", Default, Default, 20, 20, Default, Default, $__a_tabGUI[@extended][$eGui_HWindowSelf]) tabGUI_Create("5", Default, Default, 20, 20, Default, Default, $__a_tabGUI[@extended][$eGui_HWindowSelf]) Local $hGUI = tabGUI_Create("6", Default, Default, 20, 20, Default, Default, $__a_tabGUI[@extended][$eGui_HWindowSelf]) ; ..the function returns the windows handle, just like GUICreate() would. ConsoleWrite('$hGUI = ' & $hGUI & ' - @extended: ' & @extended & ' ( @extended returns the GUI index in the array )' & @CRLF) addSomeControls() GUISetState(@SW_SHOW, $__a_tabGUI[1][$eGui_HWindowSelf]) ; Time to show the parent GUI GUISwitch($__a_tabGUI[1][$eGui_HWindowSelf]) ; and get focus. GUIRegisterMsg($WM_SETCURSOR, "_WM_SETCURSOR") ; for _WinAPI_FlashWindowEx() While 1 Sleep(1000000) ; ..no need to sleep() a minimum in this loop, as is just there to not close the script in this example. WEnd EndFunc ;==>tabGUI_Example Func addSomeControls() ; ..some controls to add to the example GUICtrlCreateButton("bttn 1", 10, 10, 55, 25) GUICtrlSetOnEvent(-1, "addSomeEvents") GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlCreateButton("bttn 2", 10, 35, 55, 25) GUICtrlSetOnEvent(-1, "addSomeEvents") GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlCreateTab(10, 70, 380, 320) GUICtrlSetOnEvent(-1, "addSomeEvents") GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKBOTTOM) GUICtrlCreateTabItem("TabSheet1") GUICtrlCreateTabItem("TabSheet2") GUICtrlCreateTabItem("") EndFunc ;==>addSomeControls Func addSomeEvents() ;~ $__iFlashWindowEx = TimerInit() MsgBox(0, "your ""OnEvent""", "@GUI_CtrlId = " & @GUI_CtrlId, 1, $__a_tabGUI[1][$eGui_HWindowSelf]) ;~ $__iFlashWindowEx = 0 EndFunc ;==>addSomeEvents Func _WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; FYI: this is meant to flash the Parent GUI of a MsgBox(), ; so the MsgBox() needs a Parent GUI declaration. ; If the 0xFFFE guess don't work, or just wanna save CPU cycles, then you'll need a trigger. ; Maybe something like this below. ;~ If $__iFlashWindowEx = 0 Then Return $GUI_RUNDEFMSG ;~ If TimerDiff($__iFlashWindowEx) < 100 Then Return $GUI_RUNDEFMSG Local Static $hTimerTooSoon = TimerInit(), $hTimerWaitAMoment = TimerInit() If _WinAPI_LoWord($lParam) <> 0xFFFE Then $hTimerWaitAMoment = TimerInit() Return $GUI_RUNDEFMSG EndIf If TimerDiff($hTimerWaitAMoment) < 200 Then Return $GUI_RUNDEFMSG If TimerDiff($hTimerTooSoon) < 500 Then Return $GUI_RUNDEFMSG Local $mouse = _WinAPI_HiWord($lParam) ; https://docs.microsoft.com/en-us/windows/win32/menurc/wm-setcursor ; https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-mousemove Local Const $MK_LBUTTON = 0x0001 Local Const $MK_RBUTTON = 0x0002 Local Const $MK_MBUTTON = 0x0010 Local Const $MK_XBUTTON1 = 0x0020 Local Const $MK_XBUTTON2 = 0x0040 ;~ If BitAND($mouse, $MK_LBUTTON) Then ConsoleWrite('- clicked MK_LBUTTON' & @CRLF) ;~ If BitAND($mouse, $MK_RBUTTON) Then ConsoleWrite('- clicked MK_RBUTTON' & @CRLF) ;~ If BitAND($mouse, $MK_MBUTTON) Then ConsoleWrite('- clicked MK_MBUTTON' & @CRLF) ;~ If BitAND($mouse, $MK_XBUTTON1) Then ConsoleWrite('- clicked MK_XBUTTON1' & @CRLF) ;~ If BitAND($mouse, $MK_XBUTTON2) Then ConsoleWrite('- clicked MK_XBUTTON2' & @CRLF) If BitAND($mouse, $MK_LBUTTON) Or BitAND($mouse, $MK_RBUTTON) Or _ BitAND($mouse, $MK_MBUTTON) Or BitAND($mouse, $MK_XBUTTON1) Or _ BitAND($mouse, $MK_XBUTTON2) Then $hTimerTooSoon = TimerInit() _WinAPI_MessageBeep(4) ; mimic what windows does by default when _WinAPI_FlashWindowEx($hWnd, 3, 6, 50) ; clicking the title. _WinAPI_FlashWindowEx(WinGetHandle("[CLASS:#32770;]"), 3, 6, 50) ; ..this works on the MsgBox() because is the "on top" in the Z order ; as the code just created it ( and it *is* on top ). EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_SETCURSOR This is a post of example(s).
      The code started due to the observation that controls don't look the same when in a tab control.
      Digging thru the forum I found chunks of code so I smash them together to solve my issues.
      The "UDF" is more of an useful include than an UDF, but it shows how to use Child GUIs instead of a TAB control.
      In each child GUI you can have a GUICtrlCreateTab(). ( something that I did not realize until I browse the Wiki )
      Working on the code I found myself having to GUIRegisterMsg(). Then why not register more and do more.
      Took me about a month to discover how to put it together. Then I'm like "this would make a good example".
      So try it out, use what you need ( or as is ). Hopefully it'll save you the learning curve. The code is in the downloads section.
      ( I'm a copy and paste kind of coder, so racking my brain is not my forte. But at times, is what it takes to get working code )
      PS: if you find a better way to do something or a gross misinterpretation in the code, do share. ( so I can copy and paste )
    • By mistersquirrle
      TL;DR: Anyway to bypass built in sleep on TrayGetMsg() and GUIGetMsg() ?
       
      I'm currently working on a project that does some heavy array/ GDI+ processing, which depending what I have it do can take between 4s - 1min. During this time, I'd like to have the Tray icon (mainly, possibly also the GUI) for the program be responsive, so that if someone wanted to change actions or exit the script during this, they can without closing the process.
       
      Currently I have my TrayGetMsg and GUIGetMsg captures in my main program loop, working great, and once I go into the array/ GDI+ functions I tried switching it to an AdlibRegister call, unregistering it once completed. The problem with this is that it's adding ~10-20% more time into those functions, which I'd like to avoid. As I understand it, and from the helpfile: "This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU." From what I've read/ seen/ tested, this adds a 10ms sleep into the calls. I would rather avoid that sleep all together.
       
      The array/ GDI+ function that I'm doing peg the CPU at 100% (for its core) anyways, so that's not a concern of mine. My only concern for this is speed (and having things be responsive to other actions).
       
      Here's an example:
      Local $iBlockSize = 20, $iWidth = 1920, $iHeight = 1080, $aBigArray[$iWidth * $iHeight], $iPercentDone, $sLastMsg Local $aSmallerArray[Int(Ceiling($iWidth / $iBlockSize)) * Int(Ceiling($iHeight / $iBlockSize))] Local $sAdlib[] = ["Registered: ", "UnRegistered: ", "Registered to _FakeTray: "], $timer, $iIndexLength = UBound($aBigArray) Local $ixBlocks = Int(Ceiling($iWidth / $iBlockSize)), $iBlockIndex, $iBlockX, $iBlockY For $j = 0 To 2 If $j = 0 Then AdlibRegister("_CheckTray", 100) ElseIf $j = 1 Then AdlibUnRegister("_CheckTray") ElseIf $j = 2 Then AdlibRegister("_FakeTray", 100) EndIf $timer = TimerInit() For $i = 0 To $iIndexLength - 1 ; Loop through $aBigArray $aBigArray[$i] = Random(1, 10, 1) $iPercentDone = Floor(($i / $iIndexLength * 100)) ; Hopefully quick maths to get progress If $sLastMsg <> "We are " & $iPercentDone & "% done" Then ; Check if we're on a new percent $sLastMsg = "We are " & $iPercentDone & "% done" ; If so, update the msg ToolTip($sLastMsg, 0, 0) ; And display the current progress EndIf $y = Floor($i / $iWidth) ; Convert index to Y coordinate $x = Floor($i - ($y * $iWidth)) ; Convert index to X coordinate $iBlockX = Floor($x / $iBlockSize) ; Convert X coord to xBlock coord $iBlockY = Floor($y / $iBlockSize) ; Convert Y coord to yBlock coord $iBlockIndex = Int($iBlockX + ($iBlockY * $ixBlocks)) ; Convert into a blockIndex ;~ If Mod($i, 10000) = 0 Then ;~ ConsoleWrite($iBlockIndex & " - " & $i & @CRLF) ;~ EndIf $aSmallerArray[$iBlockIndex] += Int($aBigArray[$i]) ; Add into $aSmallerArray Next ConsoleWrite("Time to run with Adlib" & $sAdlib[$j] & TimerDiff($timer) & @CRLF) Next Func _CheckTray() Switch TrayGetMsg() Case "Meow" Return Case "Woof" Return EndSwitch EndFunc ;==>_CheckTray Func _FakeTray() Local $sMeow = "Oink" Switch $sMeow Case "Meow" Return Case "Woof" Return EndSwitch EndFunc ;==>_FakeTray Exit On my system, this takes ~1 minute to run, output:
       
      Time to run with AdlibRegistered: 19649.335 Time to run with AdlibUnRegistered: 16264.4124 Time to run with AdlibRegistered to _FakeTray: 16860.1283 >Exit code: 0 Time: 53.92 As you can see, it's ~20.8% faster without the Adlib check, and ~16.5% faster using a (hopefully) reproduction of TrayGetMsg() without the built in sleep. These timings vary, but it's consistently much faster without the TrayGetMsg() sleep (unless it's just that slow). I've used the OnEventModes, and those also slow down performance, more so than just using the GetMsgs, so those are out (but effective, and pretty easy to use).
    • By Skysnake
      I have read the Tutorial. Used the Help File and used an example script by @Melba23.  I am still struggling.
      To use GUIRegisterMsg one needs the following
      a control in the GUI a GUIRegisterMsg instruction in the GUI to link the control to the WM_COMMAND function a Case statement in the Switch loop to run it a WM_COMMAND function and a processor function... Mine looks like this
      ;~ ; QuickSearch combo box $g_cbQwkSrch = GUICtrlCreateCombo("", 8, 26, 180, 17) ; start blank GUICtrlSetTip($g_cbQwkSrch, "Type to search", "QuickSearch") GUIRegisterMsg($WM_COMMAND, "__WM_COMMAND_QWKSEARCH_CMB") ;------------------------------------ ; use in Switch Loop ;~ ; QuickSearch Case $g_cbQwkSrch ConsoleWrite("221 Case $g_cbQwkSrch" & @CRLF) ;-------------------------------------- Func _QwkSrch_Edit_Changed() ConsoleWrite("41 _QwkSrch_Edit_Changed" & @CRLF) ; Autocomplete the edit _GUICtrlComboBox_AutoComplete($g_cbQwkSrch) ; Change the label to match the autocompleted edit entry EndFunc ;==>_QwkSrch_Edit_Changed Func __WM_COMMAND_QWKSEARCH_CMB($hWnd, $iMsg, $wParam, $lParam) ; GUIRegisterMsg($WM_COMMAND, "__WM_COMMAND_QWKSEARCH_CMB") ConsoleWrite("50 _WM_COMMAND_QWKSEARCH_CMB fired " & @CRLF) Local $Found = '' #forceref $hWnd, $iMsg If $lParam = GUICtrlGetHandle($g_cbQwkSrch) And BitShift($wParam, 16) = $CBN_EDITCHANGE Then ; Our combo edit content has changed ; get data from source ---------------------------- Local $datafromsource = fFindFilesForQuickSearch($stringtofind) ; datafromsource convert to Combo friendly format ; Add data to combo _GUICtrlComboBox_BeginUpdate($g_cbQwkSrch) GUICtrlSetData($g_cbQwkSrch, $Found) _GUICtrlComboBox_EndUpdate($g_cbQwkSrch) EndIf _QwkSrch_Edit_Changed() ; Action this function EndIf EndFunc ;==>_WM_COMMAND_QWKSEARCH_CMB Func fFindFilesForQuickSearch($stringtofind) ; helper function for QuickSearch ; get data here Return $aResult EndFunc ;==>fFindFilesForQuickSearch Now the following:
      Can I declare the variable $g_cbQwkSrch in Global, then use in multiple functions - reassigning different combo's to it as I go along? Should GUIRegisterMsg be expressly de-registered, or does that happen automatically at GuiDelete()? Where is the best/correct place to call GUIRegisterMsg? With the creation of its control, before the GUISetState, or before the start of the loop? The Help File contains this entry, what is the intent?  Must this always be called with four args, or a max of four...   !!! To make the user function workable you have to define it with maximum 4 function parameters otherwise the function won't be called !!!
    • By Skysnake
      Hi
      Best example I could find is here
      ::/html/libfunctions/_GUICtrlTreeView_ClickItem.htm
      The way I understand this, the standard Windows messages, such as Left/Right Click etc are covered by AutoIt macros, but the real power is locked up inside this WM_NOTIFY .  I have tried, but I am not even sure I understand what I am looking at.
      I need help understanding this.  What I am looking for is Help file or Tutorial explaining how this works?  
      Perhaps if there is a script showing both the working of an AutoIt macro and the WM_NOTIFY  in action, it would help.
      Right now I am so lost, I do not even know what are the right questions to ask.  One issue I have is on ListViews, how to combine the "Click" of a line with a standard Switch loop?  Like users clicks a line, then get the loop to detect the click and ;do something ...
      Any ideas?
      Skysnake
    • By kcvinu
      Hi all,
      I am using GuiGetMsg(). Assume that i have a combo box in my gui. And when i use this code - 
      While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $CMB_NamesList ; Handle of my Combo box             CellSelect()          EndSwitch WEnd This code will call my "CellSelect()" function only when the selection change event occurred. But assume that i need to call this function right after the user clicks on the combo box. So do i need to use GuiRegisterMsg function for that ? Or can i simply do the task with GUIGetMsg() ? If the second option is possible, then i wonder how to do it. 
×
×
  • Create New...