Jump to content

Send/Receive data from external listview


Recommended Posts

Hi guys!! I'm going crazy... please help me -.- :)

First, open the attached screenshot. Second: I'd like to grab info from external window. The program is "Metatrader4", a tool for trading and charts analysis.

The function _GUICtrlListView_GetItemText() return an empty string! I tried to change the index $index (the second parameter) into Number($index), as recommended by other similar posts in this forum, but this did not solve my problem :sweating:

Well, why I'm going mad? Because in my mind an UDF approach works great or it does not work at all; instead, in my code something works and something else does not. I really don't understand why... and you?

THXX!!!! :) 

$handle=ControlGetHandle("Expert - "&$expertname,"",1383);List: Variable|Value
For $i=0 To _GUICtrlListView_GetItemCount($handle)-1;WORKS!!!
    $temp=_GUICtrlListView_GetItemText($handle,0+$i);RETURN EMPTY STRING :-(
    MsgBox(0, "", $temp)
    $temp = _GUICtrlListView_GetItemSelected($handle,$i);WORKS!!!
    MsgBox(0, "", $temp)
Next

 

Immagine.png

Link to post
Share on other sites
On ‎17‎/‎12‎/‎2017 at 3:01 AM, jdelaney said:

What about if you include the third parameter 'sub item'...maybe getting each value independently will work.

Hi jdelaney,

not work for me :-( the 3d param is 0 if omitted; i try with 1,2,3... the getText string is empty :sweating:

Not a lucky question :D but i really don't understand this behavior. The child item is recognized but fewUDF functions does not work properly. Another idea? :blink::)

Thanks, M.

Link to post
Share on other sites

well...if *_getitemselected works, you can loop through selecting each and calling that...either that or just trying each _guictrllistview* function until you get your result is all I can tell you.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to post
Share on other sites
  • 1 month later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mbee
      I've been researching this topic for about three weeks, but I'm still very confused. What I'm trying to do is to add a menu item to an arbitrary, third- party applications title bar system menu and process user events relating to it. The main problem I'm having is that there appears to be  a wealth of UDFs and other techniques to accomplish this, and I can't figure out which to concentrate on as a good solution.  For example, I've looked closely at @BrewManNHB 's  GUIRegisterMsg replacement for GUICtrlSetOnEvent and GUIGetMsg, and @LarsJJ 's stunning product GUIRegisterMsg20 UDF, as well as standard build- in AutoIt functions and WinAPI functions, But before I ask for recommendations, I'll elaborate my needs in more detail...

      I'm nearing completion of my muilt-monitor UDF and AutoWinSwitch stand-alone application, but one tricky issue remains. The purpose of the application is to automatically move newly arisen windows and context menus and the like from a monitor which is being used for some other purpose (like playing a game or watching videos) to the other monitor so that the user can see them and act upon them.
      The feature I need all this for is to allow the user to prevent a user-designated window from being moved, even though it exists on the "blocked" or used monitor so that it would normally require moving. In my testing, I've run into this situation often enough that a solution is necessary.
      So what I've done so far is to call _GUICtrlMenu_GetSystemMenu() for the window in question, then called  _GUICtrlMenu_AddMenuItem() to add a new menu item named "Pinned". This is working perfectly, but of course that's far from sufficient. Because obviously I need to establish some kind of event handler so that when the user selects that item, I can then toggle or alter the state and style of that item to show whether it's pinned or not.
      I've tried simply adding an on-event handler when I created the menu item, but even with the proper "Opt" value for On Event mode, the handler is never invoked.
      I also tried BrewmanNH's UDF and then LarsJ's, but even though I get no errors, again the handlers are never invoked.
      Finally, before I post the code of my last try using -- probably erroneously -- LarsJ's GUIRegisterMsg20 UDF, may I please ask for each of your recommendations and advice as to what approach you would favor? It's clear I don't know the most apt solution. Thanks!
      When you examine my code snippets, please overlook the mistakes and false starts that still remain there until I'm in the final stages of cleanup. Note also that the code depends vitally on Maps, so it will only run properly on the latest Beta version of AutoIt. But I guess that's actually irrelevant, since the posted code won't pass syntax checking...
       
      #AutoIt3Wrapper_Res_Fileversion=1.3 #AutoIt3Wrapper_icon=iPulse.ico #AutoIt3Wrapper_UseX64=Y #AutoIt3Wrapper_Run_After=copy "%out%" AutoWinSwitch.exe #include <WinAPIGdi.au3> #include <APIGdiConstants.au3> #include <GUIConstants.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <Process.au3> #include <String.au3> #include <StringConstants.au3> #include <Timers.au3> #include <WinAPIProc.au3> #include <GUIConstantsEx.au3> #include <GuiMenu.au3> ;~ #include <TrayConstants.au3> #include "LocalIncludes\GetMonitorTables_v1.1.au3" #include "LocalIncludes\_GetHwndFromPID.au3" #include "LocalIncludes\GUIRegisterMsg20.au3" AutoItSetOption("MustDeclareVars", 1) ; Variables must be declared before use AutoItSetOption("GUIOnEventMode", 1) ; We will temporarily disable this later for StateChange GUI AutoItSetOption("WinTitleMatchMode", 1) ; 1 = Matches partial titles from the start AutoItSetOption("MouseCoordMode", 0) ; 0 = Coords are relative to window (not screen) AutoItSetOption("GUICloseOnESC", 1 ) ; Close if user presses ESC AutoItSetOption("TrayOnEventMode", 0) ; We will enable this later ; ; Const $C_ThisAppName = "AutoWinSwitch" Const $C_VersionStr = "v1.3 Beta" Global Const $C_Title = $C_ThisAppName & " " & $C_VersionStr ; ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Const $C_AutoSwitchRegRootKey = "HKCU\Environment" Const $C_AutoSwitchRegValName = "AUTOWINSWITCHSTATE" Const $C_PathToTestApp = "B:\AutoIt Scripts\!ISN My Folder\My Projects\NFS Mounter\NFS_Mounter.exe" Const $C_StateDisabled=1, $C_StateBlockPrimary=2, $C_StateBlockSecondary=3, $C_StateUnset=4, $C_NumStateStrs=8 Const $C_ValidStateStrAra[$C_NumStateStrs] = [ "DIS", "TOP", "TOS", "DISABL", "BLOCKN", "BLOCKS", "BLOCKP", "NOTSET" ] Const $C_MoveTblNumCols=8 Global Enum $C_MoveTblHdlIx, $C_MoveTblMonIxIx, $C_MoveTblTitleIx, $C_MoveTblClassIx, $C_MoveTblProcIx, _ $C_MoveTblTypeIx, $C_MoveTblWinLocIx, $C_MoveTblDimsIx Const $C_NumDimCols=6 Global Enum $C_DimsWidthIx, $C_DimsHeightIx, $C_DimsLeftIx, $C_DimsTopIx, $C_DimsRightIx, $C_DimsBottomIx Const $C_CalcAbsLeft=1, $C_CalcAbsRight=2, $C_CalcAbsTop=3, $C_CalcAbsBot=4 Const $C_WinTypeMain=1, $C_WinTypePopup=2 Const $C_OnOpenMon = 1, $C_OnBlockedMon = 2, $C_SpansMon = 3 Const $C_TitlesToIgnoreAraCount = 7 Const $C_TitlesToIgnoreAra[$C_TitlesToIgnoreAraCount] = [ "Microsoft Text Input", _ "Program Manager", _ "*AutoIt", _ "Settings", _ "WorkerW", _ "*Debugger", _ "*DBUG" ] ;- - - - - - Global $G_GenMonTbl[$Gc_GMTblNumCols], $G_MMonitorTbl[1][$Gc_MMTblNumCols] Global $G_CurWinMap[], $G_PrevWinMap[], $G_PinnedMap[], $L_EmptyMap[] Global $G_MoveTimerAra[1][2], $G_MoveTimerAraIdx=-1, $G_AWS_HidWinHdl = -1 Global $G_MutexHdl, $G_WeOwnMutex, $G_Gid_PriRadioBtn, $G_Gid_SecRadioBtn, $G_Gid_DisabledRadioBtn Global $G_MonIxToShowGUI = 0 Global $G_SwitchStateStr, $G_SwitchStateCode, $G_SwitchStateChanged = False Global $G_NumValidMons=0, $G_TestAppPID, $G_TestAppWinHdl, $G_TestAppTitle="NFS_Mounter", $G_TestAppPosAra[2] ;~ $WM_CLOSE = 0x0010 ;~ $WM_MENUCOMMAND = 0x0126 ;~ $WM_MENUSELECT = 0x011F ;~ $WM_MOVE = 0x0003 ;~ $WM_MOVING = 0x0216 Global Enum $C_UseExtWinHdl, $C_UseExtCtrlHdl Global $G_SysWinMsgCodesRegAraCount = 5 Global $G_SysWinMsgCodesRegAra[$G_SysWinMsgCodesRegAraCount][3] = [ _ [ $C_UseExtWinHdl, $WM_CLOSE, __ExtCloseCmdHandler ], _ [ $C_UseExtWinHdl, $WM_MOVE, __ExtMoveWinHandler ], _ [ $C_UseExtWinHdl, $WM_MOVING, __ExtMovIngWinHandler ], _ [ $C_UseExtCtrlHdl, $WM_MENUCOMMAND, __ExtMenuCmdHandler ], _ [ $C_UseExtCtrlHdl, $WM_MENUSELECT, __ExtMenuSelectHandler ] ] ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Local $L_WorkDir = "B:\ISN AutoIt Studio\Projects\AutoWinSwitch\AutoWinSwitch Release 1.3 Beta" $L_RptPath = _UniqueOutFilePath( "WinReport", "txt", $L_WorkDir, 99 ) If @error <> 0 Then MsgBox($MB_OK, $C_Title, "Error: Unable to generate unique output filepath -- Exiting...") Exit 0 EndIf Global $G_RptFileHdl = FileOpen( $L_RptPath, $FO_OVERWRITE + $FO_UTF8_NOBOM ) If $G_RptFileHdl = -1 Then MsgBox($MB_OK, $C_Title, "ERROR - Unable to open report file -- Exiting...") Exit EndIf OnAutoItExitRegister("_ExitCapture") FileWriteLine( $G_RptFileHdl, "-- Begin run --" & @CRLF ) ; ;=================================================================================================================== ; ; ; The following code ensures that no other instance of AutoWinSwitch is running. ; ;~ $G_RptFileHdl = FileOpen( $L_RptPath, "About to check Mutex") ;~ $G_MutexHdl = _Singleton( "Global\AutoWinSwitchMUTEX", 3 ) ;~ If $G_MutexHdl = 0 Then ;~ FileWriteLine( $G_RptFileHdl, "We do NOT own the Mutex -- Exiting" ) ;~ MsgBox($MB_OK + $MB_TOPMOST, $C_Title, "Another copy of this tool is already running -- This copy will now exit") ;~ Exit 47 ;~ EndIf $G_WeOwnMutex = True ; ; Setup all the information about whatever monitors are present in this system ; ;~ <snip> <snip> <snip> ; ;=================================================================================================================== ; $G_SwitchStateStr = RegRead( $C_AutoSwitchRegRootKey, $C_AutoSwitchRegValName ) If @error <> 0 Then FileWriteLine( $G_RptFileHdl, "Error reading Switch State -- Setting Reg to DIS for now" ) $L_Stat = RegWrite( $C_AutoSwitchRegRootKey, $C_AutoSwitchRegValName, "REG_SZ", "DIS" ) ; Set registry to disabled $G_SwitchStateStr = "NOTSET" $G_SwitchStateCode = $C_StateUnset Else FileWriteLine( $G_RptFileHdl, "Switch State read from Registry is: " & $G_SwitchStateStr ) EndIf $G_SwitchStateCode = _StateStrToCode( $G_SwitchStateStr ) If @error <> 0 Then FileWriteLine( $G_RptFileHdl, "_StateStrToCode() Returned @error = " & @error & " -- Exiting") MsgBox($MB_OK + $MB_TOPMOST, $C_Title, "AutoWinSwitch - ERROR: Unrecognizable State in Registry - Exiting") Exit 6 EndIf $L_VerboseStateStr = _StateCodeToStr( $G_SwitchStateCode, "Verbose" ) If @error <> 0 Then FileWriteLine( $G_RptFileHdl, "_StateCodeToStr() Returned @error = " & @error & " -- Exiting") MsgBox($MB_OK + $MB_TOPMOST, $C_Title, "_StateCodeToStr() Returned @error = " & @error & " -- Exiting") Exit 7 EndIf $L_SpashMonIdx = $L_PrimaryMonTblIdx If $G_SwitchStateCode = $C_StateBlockPrimary Then $L_SpashMonIdx = $L_SecondaryMonTblIdx EndIf $L_SplashStr = "Initial State: " & $L_VerboseStateStr $L_SplashStrLen = StringLen( $L_SplashStr ) $L_SplashX = $G_MMonitorTbl[$L_SpashMonIdx][$Gc_MMTblCenterXIx] - Floor($L_SplashStrLen / 2) $L_SplashY = $G_MMonitorTbl[$L_SpashMonIdx][$Gc_MMTblTopIx] + 4 ;~ For $i = 1 To 2 $L_SplashHdl = SplashTextOn( "AutoWinSwitch Current State", $L_SplashStr, 400, 40, $L_SplashX, $L_SplashY, _ $DLG_CENTERONTOP + $DLG_MOVEABLE, "Lucida Sans Unicode", 11, $FW_SEMIBOLD ) Sleep( 1000 ) SplashOff() ;~ Sleep( 500 ) ;~ Next $L_OrigStateCode = $G_SwitchStateCode If ($L_OrigStateCode = $C_StateDisabled) Or ($L_OrigStateCode = $C_StateUnset) Then $G_SwitchStateCode = _ShowSwitchStateChangeGUI() If $G_SwitchStateChanged Then If $G_SwitchStateCode = $C_StateDisabled Then FileWriteLine( $G_RptFileHdl, "The GUI told us to disable and exit. Code = " & $G_SwitchStateCode ) MsgBox($MB_OK + $MB_TOPMOST, $C_Title, "The GUI told us to disable and exit!") Exit 5 EndIf EndIf $G_SwitchStateChanged = False EndIf Switch $G_SwitchStateCode Case $C_StateBlockPrimary $L_BlockedMonIdx = $L_PrimaryMonTblIdx $L_OpenMonIdx = $L_SecondaryMonTblIdx $L_CurMonTblIdx = $L_SecondaryMonTblIdx $G_MonIxToShowGUI = $L_OpenMonIdx Case $C_StateBlockSecondary $L_BlockedMonIdx = $L_SecondaryMonTblIdx $L_OpenMonIdx = $L_PrimaryMonTblIdx $L_CurMonTblIdx = $L_PrimaryMonTblIdx $G_MonIxToShowGUI = $L_OpenMonIdx EndSwitch $L_MoveTblCount = -1 ; We'll increment this when we want to add new windows to be moved $L_NumPrevWins = 0 $L_NumPrevPopups = 0 ; ; Begin Primary Operations... ; $G_TestAppWinHdl = WinGetHandle( $G_TestAppTitle ) If $G_TestAppWinHdl = 0 Then $G_TestAppPID = ShellExecute( $C_PathToTestApp ) ; This launches the test app asynchronously If $G_TestAppPID = 0 Then ; If the launch failed... MsgBox($MB_OK, $C_Title, "Fatal Error: Unable to launch test app -- Exiting") Exit 12121 EndIf $G_TestAppWinHdl = _GetHwndFromPID( $G_TestAppPID ) $G_TestAppTitle = WinGetTitle( $G_TestAppWinHdl ) Else $G_TestAppPID = WinGetProcess( $G_TestAppWinHdl ) EndIf $L_Stat = _AddPinMenuItem( $G_TestAppWinHdl ) ;~ <snip> <snip> <snip> $L_Stat = HotKeySet( "+!a", "_ShowSwitchStateGUIWrapper" ) ; Shift-Alt-A brings up the State Change GUI While True Local $L_CurTopWinAra = _WinAPI_EnumWindowsTop() $L_NumCurWins = $L_CurTopWinAra[0][0] If $L_NumPrevWins = 0 Then ; If this is the first time through this watch loop... For $i = 1 To $L_NumCurWins ; Build the Map of all top-level wins, to provide a basis for later comparison $L_CurWinHdl = $L_CurTopWinAra[$i][0] If WinExists( $L_CurWinHdl ) <> 1 Then ; This window may have been closed by this time ContinueLoop EndIf If ($L_CurWinHdl <> 0) And (IsHWnd($L_CurWinHdl) = 1) Then $L_ThisClass = $L_CurTopWinAra[$i][1] EndIf Next $L_NumPrevWins = $L_NumCurWins Else ; If we've been through this loop more than once, we'll have something to compare against $G_PrevWinMap = $G_CurWinMap ; Move the contents of the "current" Map (from from the previous pass) here. $G_CurWinMap = $L_EmptyMap ; We must empty that old Map so that we can load it up with ONLY the current windows $L_NumPrevWins = $L_NumCurWins ; That count now represents the number of top-level windows from previous pass For $i = 1 To $L_NumCurWins ; Re-build the current window Map $L_CurWinHdl = $L_CurTopWinAra[$i][0] If WinExists( $L_CurWinHdl ) <> 1 Then ; This window may have been closed by this time ContinueLoop EndIf If ($L_CurWinHdl <> 0) And (IsHWnd($L_CurWinHdl) = 1) Then $L_ThisClass = $L_CurTopWinAra[$i][1] ;~ If MapExists( $G_PinnedMap, $L_CurWinHdl ) Then ; If we're supposed to leave this win where it is ;~ ContinueLoop ;~ EndIf ;~ _Add2Map( $L_CurSpclMap, $L_CurWinHdl, $L_ThisClass ) ;~ If @error <> 0 Then ;~ FileWriteLine( $G_RptFileHdl, "ERROR - _Add2Map( #2 = " & Hex($L_CurWinHdl) * " ) Failed -- Aborting") ;~ MsgBox($MB_OK, $C_Title, "ERROR - _Add2Map( #2 = " & Hex($L_CurWinHdl) * " ) Failed -- Aborting") ;~ Exit 6 ;~ EndIf EndIf Next ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - For $i = 1 To $L_NumCurWins ; Now that we have the NEW Cur Map built, we can compare it to Previous Map $L_CurWinHdl = $L_CurTopWinAra[$i][0] If ($L_CurWinHdl <> 0) And (IsHWnd($L_CurWinHdl) = 1) Then If WinExists( $L_CurWinHdl ) <> 1 Then ; This window may have been closed by this time ContinueLoop EndIf If MapExists( $G_PinnedMap, $L_CurWinHdl ) Then ; If we're supposed to leave this win where it is ContinueLoop EndIf $L_ThisClass = $L_CurTopWinAra[$i][1] If Not MapExists( $G_PrevWinMap, $L_CurWinHdl ) Then ; If this window wasn't in the prev list, i'ts new $L_Stat = _AnalyzeNewWin( $G_PrevWinMap, $L_CurWinHdl, $L_ThisClass ) If $L_Stat <> 0 Then ; If this window is new & has been added to the table of wins to be moved $L_ThisClass = $G_PrevWinMap[$L_CurWinHdl] MapRemove( $G_CurWinMap, $L_CurWinHdl ) ; Ensure that this win doesn't look like a fresh one MapRemove( $G_PrevWinMap, $L_CurWinHdl ) ; ... either past or present EndIf EndIf EndIf Next EndIf ; ; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; If $L_MoveTblCount >= 0 Then ; IF we need to move at least 1 win (valid indices/count start at 0) $L_Stat = _RelocateWins( ) $L_MoveTblCount = -1 EndIf ;;~ <snip> <snip> <snip> Sleep( 1000 ) WEnd Exit 12 ; ;=================================================================================================================== ; ; This function was kindly contributed by jchd ; See: https://www.autoitscript.com/forum/topic/204187-please-review-my-usage-of-scripting-dictionaries/?do=findComment&comment=1467804 ; Func _Add2Map(ByRef $map, $key, $value) If MapExists($map, $key) Then ; same as If $m[$key] = Null Then If IsMap($map[$key]) Then MapAppend($map[$key], $value) Else Local $m2[] ; an empty map $m2[1] = $map[$key] $m2[2] = $value $map[$key] = $m2 EndIf Else $map[$key] = $value EndIf EndFunc ;==>_Add2Map ; ;=================================================================================================================== ; ; _AnalyzeNewWin -- Analyze a newly discovered window to see if it should be moved to the other monitor. ; ; Return code: 0 = Ignore this window. ; 1 = This is an intruding window entirely on a blocked monitor, so it must be moved ; 2 = This is an intruding window partially on a blocked monitor, so it might need to be moved ; -1 = An error occurred during processing ; Func _AnalyzeNewWin( ByRef $arg_Map, $arg_WinHdl, $arg_Class ) ;~ <snip> <snip> <snip> Return 2 EndFunc ;==>_AnalyzeNewWin ; ;=================================================================================================================== ; ; We now know that there's at least one window (normal or popup) that needs to be relocated to a ; different monitor. ; ; Currently, there's no need to distinguish between the two window types (normal or popup), but ; there might need to be in the future, so I've decided to prepare for this eventuality. ; Func _RelocateWins() Const $Lfc_MoveFull = 1, $Lfc_MovePartial = 2 ;~ <snip> <snip> <snip> Return 1 EndFunc ;==>_RelocateWins ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; Func _AddIfUnseenWin( ByRef $arg_Map, ByRef $arg_MoveTblWinInfoRow ) ; ; This function determines if we've seen this window before, and if NOT, then it ; gets added to the appropriate Map. ; ;~ <snip> <snip> <snip> Return 1 EndFunc ;==>_AddIfUnseenWin ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; Func _AddPinMenuItem( $arg_ExtWinHdl ) Local $Lf_Stat, $Lf_ExtPID, $Lf_ExtSysMenuHdl, $Lf_ExtPinMenuHdl, $Lf_PinMenuItemIndex, $Lf_PinMenuItemID Local $Lf_InPinnedMap, $Lf_PinMenuItemExists, $Lf_SysMsgCodeMin, $Lf_SysMsgCodeMax If MapExists( $G_PinnedMap, $arg_ExtWinHdl ) Then $Lf_InPinnedMap = True Else $Lf_InPinnedMap = False EndIf $Lf_ExtPID = WinGetProcess( $arg_ExtWinHdl ) $Lf_ExtSysMenuHdl = _GUICtrlMenu_GetSystemMenu( $arg_ExtWinHdl, False ) $Lf_PinMenuItemIndex = _GUICtrlMenu_FindItem( $Lf_ExtSysMenuHdl, "Pinned", True ) If $Lf_PinMenuItemIndex = -1 Then $Lf_PinMenuItemExists = False Else $Lf_PinMenuItemExists = True $Lf_PinMenuItemID = _GUICtrlMenu_GetItemID( $Lf_ExtSysMenuHdl, $Lf_PinMenuItemIndex, True ) EndIf If Not $Lf_PinMenuItemExists Then If $Lf_InPinnedMap Then MapRemove( $G_PinnedMap, $arg_ExtWinHdl ) Return SetError( 0, 0, 2 ) EndIf $Lf_PinMenuItemIndex = _GUICtrlMenu_AddMenuItem( $Lf_ExtSysMenuHdl, "Pinned", 47 ) If $Lf_PinMenuItemIndex = -1 Then Return SetError( 17226, 0, 0 ) EndIf $Lf_PinMenuItemID = _GUICtrlMenu_GetItemID( $Lf_ExtSysMenuHdl, $Lf_PinMenuItemIndex, True ) _Add2Map( $G_PinnedMap, $arg_ExtWinHdl, $Lf_PinMenuItemID) $Lf_ExtPinMenuHdl = GUICtrlGetHandle( $Lf_PinMenuItemID ) $Lf_Stat = _SetupExtWinMsgRegs( $arg_ExtWinHdl, $Lf_ExtPinMenuHdl ) Return SetError( @error, 0, $Lf_Stat ) EndIf Return SetError( 0, 0, 1 ) EndFunc Func __PinMenuCmdHandler() Local $Lf_ControlID, $Lf_SendingWinHdl, $Lf_ControlHdl, $Lf_ExtSysMenuHdl Local $Lf_Enabled, $Lf_Highlighted $Lf_ControlID = @GUI_CtrlId $Lf_SendingWinHdl = @GUI_WinHandle $Lf_ControlHdl = @GUI_CtrlHandle $Lf_ExtSysMenuHdl = _GUICtrlMenu_GetSystemMenu( $Lf_SendingWinHdl, False ) $Lf_Enabled = _GUICtrlMenu_GetItemDisabled( $Lf_ExtSysMenuHdl, $Lf_ControlID, False ) $Lf_Highlighted = _GUICtrlMenu_GetItemHighlighted( $Lf_ExtSysMenuHdl, $Lf_ControlID, False ) If $Lf_Enabled Or $Lf_Highlighted Then _GUICtrlMenu_SetItemEnabled( $Lf_ExtSysMenuHdl, $Lf_ControlID, False, False ) _GUICtrlMenu_SetItemHighlighted( $Lf_ExtSysMenuHdl, $Lf_ControlID, False, False ) _GUICtrlMenu_EnableMenuItem( $Lf_ExtSysMenuHdl, $Lf_ControlID, 2, False ) If MapExists( $G_PinnedMap, $Lf_ExtSysMenuHdl) Then MapRemove( $G_PinnedMap, $Lf_ExtSysMenuHdl ) EndIf Else _GUICtrlMenu_SetItemEnabled( $Lf_ExtSysMenuHdl, $Lf_ControlID, True, False ) _GUICtrlMenu_SetItemHighlighted( $Lf_ExtSysMenuHdl, $Lf_ControlID, True, False ) _GUICtrlMenu_EnableMenuItem( $Lf_ExtSysMenuHdl, $Lf_ControlID, 0, False ) _GUICtrlMenu_DrawMenuBar( $Lf_ExtSysMenuHdl ) _Add2Map( $G_PinnedMap, $Lf_ExtSysMenuHdl, $Lf_ControlID ) EndIf _GUICtrlMenu_DrawMenuBar( $Lf_ExtSysMenuHdl ) Return EndFunc ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; Func _IsMonitorBlocked( ByRef $arg_MoveTblWinInfoRow ) ; ; This func determines if the passed window is currently presented on a "blocked" monitor ; ; Returns: $C_OnOpenMon (=1) If the window in the passed Move Table Window Info Row is on an Open monitor ; $C_OnBlockedMon (=2) If ... on Blocked mon ; $C_SpansMon (=3) If the window spans across both open and blocked mon ; ;~ <snip> <snip> <snip> EndFunc ;==>_IsMonitorBlocked ; ; = = = = = = = = = = = = = = = = = = = ; Func _SetupExtWinMsgRegs( $arg_ExtWinHdl, $arg_ExtControlHdl ) Local $Lf_Stat For $i = 0 To $G_SysWinMsgCodesRegAraCount -1 If $G_SysWinMsgCodesRegAra[$i][0] = $C_UseExtWinHdl Then $Lf_Stat = GUIRegisterMsg20( $arg_ExtWinHdl, $G_SysWinMsgCodesRegAra[$i][1], $G_SysWinMsgCodesRegAra[$i][2] ) Else $Lf_Stat = GUIRegisterMsg20( $arg_ExtControlHdl, $G_SysWinMsgCodesRegAra[$i][1], $G_SysWinMsgCodesRegAra[$i][2] ) EndIf If $Lf_Stat <> 1 Then Return SetError( @error, 0, 1 ) EndIf Next Return SetError( 0, 0, 0 ) EndFunc ; ; = = = = = = = = = = = = = = = = = = = ; Func __ExtCloseCmdHandler( $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam ) #forceref $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam Return $GUI_RUNDEFMSG EndFunc ; ; - - - - - - - - - - - - - - - - - - - ; Func __ExtMoveWinHandler( $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam ) #forceref $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam FileWriteLine( $G_RptFileHdl, "In __ExtMoveWinHandler()" ) Return $GUI_RUNDEFMSG EndFunc ; ; - - - - - - - - - - - - - - - - - - - ; Func __ExtMovIngWinHandler( $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam ) #forceref $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam FileWriteLine( $G_RptFileHdl, "In __ExtMovIngWinHandler()" ) Return $GUI_RUNDEFMSG EndFunc ; ; - - - - - - - - - - - - - - - - - - - ; Func __ExtMenuCmdHandler( $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam ) #forceref $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam FileWriteLine( $G_RptFileHdl, "In __ExtMenuCmdHandler()" ) Return $GUI_RUNDEFMSG EndFunc ; ; - - - - - - - - - - - - - - - - - - - ; Func __ExtMenuSelectHandler( $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam ) #forceref $arg_hWnd, $arg_Msg, $arg_wParam, $arg_lParam FileWriteLine( $G_RptFileHdl, "In __ExtMenuSelectHandler()" ) Return $GUI_RUNDEFMSG EndFunc  
    • By UEZ
      This project has been discontinued!
       
      Here a small tool I wrote to update my Sysinternal tools collection without the need to download always the whole package or visiting the site to check for updates. I know that there are several tools available (also some tools written in AutoIt) but here another one for the collection. It was good exercise for me to code it.
       
       
        
       
       
      Some files from the live web site cannot be downloaded although they are visible!
       
      Here the download link of the source code only: AutoIt Sysinternal Tools Synchronizer v0.99.6 build 2020-09-23 beta.7z  (1557 downloads previously)
      -=> Requires AutoIt version 3.3.13.20 or higher / tested on Win8.1 real machine and some VMs: Win7 / Vista / Win10
       
      Compiled exe only: @MediaFire
       
      Just select the Sysinternal Tools folder or create one and press the synchronize button to download the selected items. Click on AutoIt label (near to left upper corner) to open menu.
       
      Special thanks to LarsJ, Melba23 and mesale0077 for their help. 
       
      I've still some ideas to implement which are more gimmick related, so it is not finished yet...
      If you want to add your language please check out #Region Language. Thanks. 
       
      Please report any bug or if you have any suggestions.
       
      The language of the tool tip from each of the executable in the left list view were automatically created using Google translator and weren't checked for correctness.
       
      Br,
      UEZ
    • By Cengokill
      Hi everyone,
      I have created a ListView that is in a tab, and I want to display an image in that tab, with the ListView on top.
      However, the image still appears on top of my ListView.
      If I remove the tabs everything works. 
      I looked at the autoit documentation and the <GuiListView.au3> documentation , I can't figure out how to display a background image, and put on top a ListView, inside a tab. 😥
      Here is the code:
      Opt("GUIOnEventMode", 1) $Form1 = GUICreate($Titre, 700, 627, $Form1Width, $Form1Height); main window $tabulation = GUICtrlCreateTab(148,0,700,580); creating tabs $tab1=GUICtrlCreateTabItem("Tab 1"); first tab GUICtrlSetState(-1, $GUI_SHOW); this tab is selected by default $Pic1 = GUICtrlCreatePic("image.jpg", 0, 30, 700, 627) GUICtrlSetState(-1, $GUI_DISABLE). $idListview = GUICtrlCreateListView("list 1|list 2|list 3", 200, 50, 390, 200) GUISetState(@SW_SHOW) While 1     Sleep(100) WEnd Thank you in advance.

    • By DrJohn
      Hello all.  It's me again.
      I've got a ListView with an associated ImageList to display icons.  What I seem to be hung up on is how to keep the ImageList updated to match the ListView as the latter changes.  I thought it was the case that the indices of the items in the ListView and those in the ImageList just needed to match.  So, for example, if I:
      Delete an item from the ListView [_GUICtrlListView_DeleteItem()], and also delete the image at the matching index in the ImageList [_GUIImageList_Remove()]. Then add a new item to the end of the ListView [_GUICtrlListView_AddItem()], and correspondingly add an image at the end of the ImageList [_GUIImageList_AddIcon()] Shouldn't everything stay in sync?
      Here's the code I thought would work:
      #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <FontConstants.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> Test() func Test() $gui = GUICreate("Test", 400, 300) ; Create ListView $lv = _GUICtrlListView_Create($gui, "", 10, 10, 380, 240, $LVS_DEFAULT) _GUICtrlListView_AddColumn($lv, "Col1", 50) _GUICtrlListView_AddColumn($lv, "Col2", 50) for $i = 0 to 2 $s = StringFormat("%d,1", $i+1) _GUICtrlListView_AddItem($lv, $s, $i) $s = StringFormat("%d,2", $i+1) _GUICtrlListView_AddSubItem($lv, $i, $s, 1) next ; Add ImageList $img_list = _GUIImageList_Create(16, 16, 5, 3) for $i = 0 to 2 $ico = StringFormat("%d.ico", $i+1) _GUIImageList_AddIcon($img_list, $ico) next _GUICtrlListView_SetImageList($lv, $img_list, 1) ; $btn = GUICtrlCreateButton("Test", 10, 260, 60, 30) GUISetState(@SW_SHOW) HotKeySet("^q", Quit) ; Loop until the user exits. while True switch GUIGetMsg() case $GUI_EVENT_CLOSE Exit case $btn ; Remove 2nd list item and image _GUICtrlListView_DeleteItem($lv, 1) _GUIImageList_Remove($img_list, 1) ; Add new item to end of ListView $idx = _GUICtrlListView_AddItem($lv, "foo") _GUICtrlListView_AddSubItem($lv, $idx, "bar", 1) ; Add new image to end of ImageList _GUIImageList_AddIcon($img_list, "5.ico") endswitch wend GUIDelete() endfunc func Quit() Exit endfunc What seems to happen is that when the new item is added to the ListView, its icon is 1.ico (the first item in the ImageList), rather than 5.ico (the newly added item that should be at the end of the ImageList).
      Or do I need to re-create the whole ImageList any time the ListView changes?
      A zip file is attached that contains the script and also the .ico files, for easier testing.
      Thanks!
      /John
      test.zip
    • By Dan_555
      Hi.
      I'm using the FreeCommander XE file manager here, and i'v written a script, which will create an empty, new file, after choosing an extension out from the Listbox.
       
      The listview code  is not mine, iv found the scripts somewhere on this forum. I have no credits in it, because it was intended to be only for my personal use.
      But now, i have a lot of free time, so i remembered that i haven't posted anything on this forum, yet, so here is my first script:
      It should be compiled with the Autoit v3.3.14.3 .
      The compiled exe needs a folder passed as a parameter, so that it know where to create the new file.
      A Listbox is opened, with a selection of available extensions.
      After selecting and doubleclicking (or using the ok button), the script creates a filename (if specified in the config file) with increased numbers (up to 9999).
      If the filename exist, the counter is checking the next number, until the maximum is reached.
      This script uses an ini file for configuration, called "NewFile.ini" which should be in the same folder, as the compiled exe.
      NewFile.au3
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <String.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <ScrollBarsConstants.au3> Global $test[0][2], $hFile, $cmd = "", $cmdtmp, $tmptxt, $tmpinidir, $filesetting, $MouseX, $MouseY, $UseMouseX, $UseMouseY, $Edit1 Global $aArray[1] = [] $cmdtmp = StringReplace($cmdlineraw, Chr(34), "") If StringLen($cmdtmp) = 2 Then     If StringRight($cmdtmp, 1) = ":" Then         $cmd = $cmdtmp & "\"     EndIf Else     If StringRight($cmdtmp, 1) <> "\" Or StringRight($cmdtmp, 1) <> "/" Then         $cmd = $cmdtmp & "\"     EndIf EndIf If Not FileExists($cmd) Then                    ;Check if the folder exists, display an error message if not !     DisplayReadMe(1)     Exit EndIf If StringLen(@ScriptDir) > 3 And StringRight(@ScriptDir, 1) <> "\" Then     $tmpinidir = @ScriptDir & "\" Else     $tmpinidir = @ScriptDir EndIf Local Const $sFilePath = $tmpinidir & "NewFile.ini" $filesetting = IniRead($sFilePath, "setting", "filename", "MyNewFile") $filesetting = StringReplace($filesetting, ">", " ") ;msgbox (0,"",$filesetting)  ;Debugging If FileExists($sFilePath) Then     $aArray = IniReadSectionNames($sFilePath) ; Read the INI section names. This will return a 1 dimensional array. EndIf $UseMouseX = IniRead($sFilePath, "setting", "UseMouseX", "1") $UseMouseY = IniRead($sFilePath, "setting", "UseMouseY", "0") ; Check if an error occurred. If Not @error Then     ; Enumerate through the array displaying the section names.     Local $count = 0     If FileExists($sFilePath) Then         For $i = 1 To $aArray[0]             $tmp1 = IniRead($sFilePath, $aArray[$i], "1", "none")             If $tmp1 <> "none" And StringLeft($tmp1, 1) = "." Then            ;Extension need to have a dot, or it will be ignored !                 $tmptxt = $tmptxt & $tmp1 & "|" & $aArray[$i] & @CRLF                 $count = $count + 1                                            ;Count how many extensions are added !             EndIf         Next     EndIf     If $count = 0 Then $tmptxt = ".au3|AutoIt 3" & @CRLF & ".txt|Text File" & @CRLF     ;MsgBox($MB_SYSTEMMODAL,"",$tmptxt)     _ArrayAdd($test, $tmptxt, 0, "|", @CRLF) Else                                                            ;Reading the ini failed, create a default array for the extensions     $tmptxt = ".au3|AutoIt 3" & @CRLF & ".txt|Text" & @CRLF     _ArrayAdd($test, $tmptxt, 0, "|", @CRLF) EndIf ;Local $test[5][2] = [['.au3', 'AutoIt'], ['.ahk', 'Auto Hotkey'], ['.txt', 'text'], ['.sdlbas', 'Sdl Basic'], ['.html', 'Webpage']] If $UseMouseX = 1 Then     $MouseX = MouseGetPos(0) Else     $MouseX = -1 EndIf If $UseMouseY = 1 Then     $MouseY = MouseGetPos(1) Else     $MouseY = -1 EndIf $Form1 = GUICreate("Create New File", 210, 247, $MouseX, $MouseY, $WS_CAPTION, $WS_EX_TOOLWINDOW) $List = GUICtrlCreateListView("", 5, 5, 200, 200) _GUICtrlListView_InsertColumn($List, 0, "Extension", 65) _GUICtrlListView_InsertColumn($List, 1, "Description", 115) _GUICtrlListView_AddArray($List, $test) GUICtrlCreateLabel("Example:" & $filesetting & "0000.ext", 5, 205) $Button1 = GUICtrlCreateButton("Ok", 16, 224, 45, 22) $Button3 = GUICtrlCreateButton("ReadMe", 80, 224, 55, 22) $Button2 = GUICtrlCreateButton("Cancel", 150, 224, 45, 22) $cDummy = GUICtrlCreateDummy() GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE, $Button2             Exit         Case $Button3             DisplayReadMe(0)         Case $Button1, $cDummy             Local $tmptxt = StringSplit(_GUICtrlListView_GetItemTextString($List), "|")[1]             If StringLen($tmptxt) > 0 Then                 Local $fnr = 0, $tmpfile = ""                 While $fnr < 10000                     $tmpfile = $cmd & $filesetting & _StringRepeat("0", 4 - StringLen($fnr)) & $fnr & $tmptxt                     ;MsgBox(0,"",$tmpfile) ; for debugging                     If Not (FileExists($tmpfile)) Then                         $hFile = _WinAPI_CreateFile($tmpfile, 0)                         _WinAPI_CloseHandle($hFile)                         Exit                     EndIf                     $fnr = $fnr + 1                 WEnd             EndIf     EndSwitch WEnd ;================================================================================ Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)     Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView     $hWndListView = $List     If Not IsHWnd($List) Then $hWndListView = GUICtrlGetHandle($List)     $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))     $iCode = DllStructGetData($tNMHDR, "Code")     Switch $hWndFrom         Case $hWndListView             Switch $iCode                 Case $NM_DBLCLK                     ; Fire the dummy if the ListView is double clicked                     GUICtrlSendToDummy($cDummy)             EndSwitch     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_NOTIFY Func DisplayReadMe($err)     Local $Form1 = GUICreate("Read Me", 550, 400, 10, 10, BitOR($WS_CAPTION, $WS_THICKFRAME ,$WS_MAXIMIZEBOX))     $Edit1 = GUICtrlCreateEdit("", 0, 0, 549, 399)     GUICtrlSetData(-1, "")     GUISetState(@SW_SHOW)     If $err=1 then         local $txttmp01="Error: Path does not exist"         local $txttmp02="Commandline call was: "         AddText ($txttmp01)         Addtext ($txttmp02 & $cmd & @CRLF & @CRLF)     EndIf     AddText("Instructions:" & @CRLF)     AddText("Displays a selection of available extensions and then creates a new file at the Path's location." & @CRLF & @CRLF & "Usage: NewFile Path")     AddText("Example: NewFile c:\myfolder\" & @CRLF)     AddText("Result: A file with a name 'MyFile0000.ext' will be created at the Path's location.")     AddText("If the filename exists, the number counter will increase, until it finds a free number, up to 9999." & @CRLF)     AddText("Uses a configuration file in the .exe folder named NewFile.ini !" & @CRLF)     AddText("Example of a config file:" & @CRLF)     AddText("[setting]" & @CRLF & "filename=MyFile>")     AddText("UseMouseX=0                ;0 or 1 - position the dialog at the mouse x coordinate - usefull for multi monitor settings !")     AddText("UseMouseY=0                ;0 or 1 - Set this and UseMouseX to spawn the dialog at the mouse coordinates !" & @CRLF)     AddText(";Use > in filename as a space char ! (only needed if you want the space char at the beginning or at the end : in between filename and the number)" & @CRLF)     AddText(";Format for this ini file is:" & @CRLF & ";Name              e.g [Auto It]")     AddText(";extension       e.g 1=.au3" & @CRLF & "; p.s. only 1 extension per section ! the number must be 1" & @CRLF)     AddText("[AutoIt3]" & @CRLF & "1=.au3" & @CRLF & @CRLF & "[Text]" & @CRLF & "1=.txt")     _GUICtrlEdit_SetSel($Edit1, 0, 0)     _GUICtrlEdit_Scroll($Edit1, $SB_SCROLLCARET)     If $err=1 Then         _GUICtrlEdit_SetSel($Edit1, 0, StringLen($txttmp01 & $txttmp02 & $cmd)+5)     EndIf     While 1         $nMsg = GUIGetMsg()         Switch $nMsg             Case $GUI_EVENT_CLOSE                 GUIDelete($Form1)                 ExitLoop         EndSwitch     WEnd EndFunc   ;==>DisplayReadMe Func AddText($edittxt)     _GUICtrlEdit_AppendText($Edit1, $edittxt & @CRLF) EndFunc   ;==>AddText  
       NewFile.ini
      [setting] filename=MyNewFile_ UseMouseX=0                ;0 or 1 - position the dialog at the mouse x coordinate - usefull for multi monitor settings ! UseMouseY=0                ;0 or 1 - Set this and UseMouseX to spawn the dialog at the mouse coordinates ! ;Use > in filename as a space char ! (only needed if you want the space char at the beginning or at the end : in between filename and the number) ;Format for this ini file is: ;Name              e.g [Auto It] ;extension       e.g 1=.au3 ; p.s. only 1 extension per section ! the number must be 1 [AutoIt3] 1=.au3 [Auto Hotkey] 1=.ahk [Text] 1=.txt [Sdl Basic] 1=.sdlbas [Webpage] 1=.html [Basic] 1=.bas [Pascal] 1=.pas [Rich Text (RTF)] 1=.rtf [Word Document] 1=.doc [Hex File] 1=.hex
×
×
  • Create New...