
Ace08
Active Members-
Posts
157 -
Joined
-
Last visited
Everything posted by Ace08
-
Hi guys I know its just an easy problem but i realy cant figure it out, the idea would be having 2 sets of files one of these file will be a reference while the other will be the input, what im supposed to do here is to count the lines from file1 thats not existing in file 2 and those existing. What i did was open both files, read a line from file1 and checks the lines from file2 if its not existing then it will be counted in the sample below the count for those non existing should only be equal to 2 since "train" and "sub" is not defined from file2 Thanks for the help File1: toy boat plane van train sub File2: toy boat van plane $var = FileOpenDialog ("Choose The File.", @ScriptDir & "\Input", "File(*.txt)" , 2) Local $file = FileOpen($var, 0), $count, $_count ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 Local $line = FileReadLine($file) If @error = -1 Then ExitLoop Local $RefFile = FileOpen(@ScriptDir & "\Input\b.txt",0) If $RefFile = -1 Then MsgBox(0, "Error", "Unable to open reference file.") Exit EndIf While 2 $refFileLine = FileReadLine($RefFile) If @error = -1 Then ExitLoop If $line = $refFileLine Then $count = $count + 1 Else $_count = $_count + 1 EndIf WEnd FileClose($RefFile) WEnd FileClose($file) MsgBox(0,"Notice", "Total match : " & $count & @CRLF & "Count no match : " & $_count)
-
Although im still in the designing part i'll try a different approach to make it running, hopefuly it'll be finished before January ends
-
Thanks somdcomputerguy for the quick response have also do some research and found the needed function #include <GuiDateTimePicker.au3> _GUICtrlDTP_Create($hWnd, $iX, $iY [, $iWidth = 120 [, $iHeight = 21 [, $iStyle = 0x00000000 [, $iExStyle = 0x00000000]]]]) @kylomas wow thanks for the sample script this will come in handy (almost look like the one im making >_<)
-
Hi Guys, Lately we've been extracting a bunch from our database so i thought why not make only one that can save queries instead of creating 1:1 apps and adding them on scheduled task, The problem is how do i make a time picker control(attached is a pic)? or rather, can this be done with autoit? If it is possible kindly guide me with the functions to use. Thank you in advance.
-
Have searched the forum and found out that same question was already asked. Below code was provided by ptrex. Const $adSchemaTables = 20 Const $adOpenStatic = 3 Const $adLockOptimistic = 3 Const $adCmdText = 0x0001 ; =&H0001 Global $s_Filename=FileGetShortName("D:sampletest.xls") ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $objConnection = ObjCreate("ADODB.Connection") $objRecordSet = ObjCreate("ADODB.Recordset") $objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source="&$s_Filename&";" & _ "Extended Properties=""Excel 8.0;HDR=Yes;"";") ConsoleWrite(_adoListTables() & @LF) ConsoleWrite( @LF) Func _adoListTables() Local $oList = '' If IsObj($objConnection) = 0 Then Return SetError(1) $oRec = $objConnection.OpenSchema($adSchemaTables) While NOT $oRec.EOF If StringLen( $oRec("TABLE_TYPE").value) > 5 Then;; Skip the hidden internal tables $oRec.movenext ContinueLoop EndIf $oList = $oList & $oRec("TABLE_NAME").value & ' | ' $oRec.movenext Wend If $oList <> '' Then Return '|' & StringTrimRight($oList,1) Else SetError(3, 0, 0) Return $oList EndIf EndFunc ;<===> _adoListTables() $objConnection.Close $objConnection = "" $objRecordSet = "" Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc Thanks ptrex
-
Whew thats what im afraid of. might as well look for other options thanks water for the help
-
just xls
-
Hi I'm just wondering is there a way to get the sheet name of an excel file without having to use excel objects? I dont have MS Excel installed on my PC. I've found ptrex's script to read an excel file as dbf but the table name (Sheet Name) also needs to be defined currently i need to read 10 files with different sheet names. Const $adOpenStatic = 3 Const $adLockOptimistic = 3 Const $adCmdText = 0x0001 Global $s_Filename=FileGetShortName("D:\Sample\638FE12D2614.xls") Global $s_Tablename = "[Sheet1$]" ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Source XLS data $objConnection = ObjCreate("ADODB.Connection") $objRecordSet = ObjCreate("ADODB.Recordset") $objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source="&$s_Filename&";" & _ "Extended Properties=""Excel 8.0;HDR=Yes;"";") $objRecordSet.Open ("Select Count(*) FROM"& $s_Tablename & "Order by 1 Asc" , $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText) Do ConsoleWrite ($objRecordSet.Fields(0).value+1 [email="&@CR"]&@CR[/email]) ; + 1 because it is 0 based $objRecordSet.MoveNext() Until $objRecordSet.EOF() $objConnection.Close $objConnection = "" $objRecordSet = "" Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc
-
Thanks jchd for the quick response Unforunately yes im bound with dBase IV as the users require the results in this format. Looks like i'll be needing a different approach with this one. Oh man my head hurts.
-
Thanks Spiff59 and jchd for the help. @jchd: I've tried using getrows() however this won't work with me, my query results ranges from 700k+ records and autoit(via MyErrFunc()) gives me an error "Not enough storage is available to complete this operation."
-
Thanks jchd for the response, I already did that in fact it was my original script. Local $DBFConn Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $DBFConn = OpenDBFConn("c:") Func OpenDBFConn($DBFPath) $DBFConn = ObjCreate("ADODB.Connection") $DBFConn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & $DBFPath & ";" & _ "Extended Properties=""DBASE IV;"";") $DBFOpenDBFConn = $DBFConn $DBFrs = ObjCreate( "ADODB.RecordSet" ) ;~ Create a new DBF file named DBFFILETABLE $DBFrs.open("Create Table DBFFILETABLE (FNAME char(50), LNAME char(50), MINIT char(50))",$DBFConn) OpenCon() EndFunc Func OpenCon() ;~ ====================================================================== ;~ DATABASE Connection and Query ;~ ====================================================================== $DBconn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=Servername;DATABASE=sqldb;UID=userid;PWD=pwd;" $DBrs = ObjCreate( "ADODB.RecordSet" ) $DBrs.open("select top 10FNAME,LNAME,MINIT from names with (nolock) where date between '02-01-2012 00:00:00.000' and '02-01-2012 23:59:59.998'",$DBConn) Do If $DBrs.EOF() Then ExitLoop $DBFrs.open("Insert into DBFFILETABLE Values('" & $DBrs.Fields(0).value & "', '" & $DBrs.Fields(1).value & "', '" & $DBrs.Fields(2).value & "')" ,$DBFConn) Until $DBrs.EOF() $DBrs.close MsgBox(0,"Report Maker","File has been created") ;~ ====================================================================== EndFunc Func MyErrFunc() Local $HexNumber, $oMyRet[2] $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) MsgBox(0,"Debug","### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF); Error Description SetError(1); something to check for when this function returns Exit EndFunc ;==>MyErrFunc Im looking for a way on how to speed up the insert statement. in the above code I'm inserting it per record but this takes time to finish specialy with huge records.
-
Hi what I'm trying to do here is get the names in our database and return the results to a dbf file. The file creation is working fine even the select statement, however I'm getting an error "Syntax error in INSERT INTO statement." when i add the insert into query with the select query. any help would be appreciated thank you. Local $DBFConn Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $DBFConn = OpenDBFConn("c:") Func OpenDBFConn($DBFPath) $DBFConn = ObjCreate("ADODB.Connection") $DBFConn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & $DBFPath & ";" & _ "Extended Properties=""DBASE IV;"";") $DBFOpenDBFConn = $DBFConn $DBFrs = ObjCreate( "ADODB.RecordSet" ) ;~ Create a new DBF file named DBFFILETABLE $DBFrs.open("Create Table DBFFILETABLE (FNAME char(50), LNAME char(50), MINIT char(50))",$DBFConn) OpenCon() EndFunc Func OpenCon() ;~ ====================================================================== ;~ DATABASE Connection and Query ;~ ====================================================================== $DBconn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=Servername;DATABASE=sqldb;UID=userid;PWD=pwd;" $DBrs = ObjCreate( "ADODB.RecordSet" ) $DBFrs.open("Insert into DBFFILETABLE (FNAME,LNAME,MINIT;" & $DBrs.Open("select top 10FNAME,LNAME,MINIT from" & _ " names with (nolock) where date between '02-01-2012 00:00:00.000' and '02-01-2012 23:59:59.998'",$DBConn) ,$DBFConn) $DBrs.close MsgBox(0,"Report Maker","File has been created") ;~ ====================================================================== EndFunc Func MyErrFunc() Local $HexNumber, $oMyRet[2] $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) MsgBox(0,"Debug","### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF); Error Description SetError(1); something to check for when this function returns Exit EndFunc ;==>MyErrFunc
-
Whew I was able to remove the error by removing "adVarWChar" from $tbl.Columns.Append ("Column1", "adVarWChar") However the header looks like "COLUMN1,C,254" anyone know why?
-
Hi Guys, I've found a simple code in vb which creates a simple dbf file after translating it to autoit making the file seems ok however I'm encountering an error "The requested action with this object has failed." when I try to Add/Append columns Dim $tbl = ObjCreate("ADOX.Table") Dim $cat = ObjCreate("ADOX.Catalog") $cat.ActiveConnection = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & @ScriptDir & ";" & _ "Extended Properties=dBase III;" $tbl.NAME = "SAMPLEDB" $tbl.Columns.Append ("Column1", "adVarWChar") ;~ $tbl.Columns.Append ("Column2", "adInteger") ;~ $tbl.Columns.Append ("Column3", "adVarWChar") $cat.Tables.Append ($tbl) I was also able to check ptrex's sample however there are gibberish characters when i try to open it thru excel or scalc(Open Office)
-
Passing Arguments on a DLL Function
Ace08 replied to Ace08's topic in AutoIt General Help and Support
Thanks Shaggi for the help i did look in the help file and that is why i was able to formulate the code posted above which unfortunately is'nt working T_T its a 64bit dll running on a 64 bit PC for the arguments i have attached the documentation below Returns a Boolean value indicating whether the encryption is successful. Syntax encryptFile(strPath, strSourceFile, strPassword, strMessage, strTargetFile) The encryptFile function syntax has these arguments: Part Description strPath Required (String expression). The path or location of file to be encrypted strSourceFile Required (String expression). The filename of file to be encrypted strPassword Required (String expression). The password that will be used during encryption. (Note: The password must be encrypt by the encrypt decrypt program) strMessage Required (String expression). Returning error message during encryption. If strMessage is empty (“”) the encryption is successful otherwise, the error description during encryption will be the value for strMessage. strTargetFile Optional (String expression). The filename that will be used after the encryption. If omitted. The encrypted file will be the source filename with the extension name of “ENC”. -
Passing Arguments on a DLL Function
Ace08 replied to Ace08's topic in AutoIt General Help and Support
Ohhhhh sorry about that my bad and thanks D4RKON3 for the help however i tried both your code and mine(added the missing $) but still nothing happens. i'm getting a bit frustrated here its much easier to debug a code with errors rather than those without. can you guys confirm that i used the dllcall func correctly? if so i think i should ask the company about their dll. -
Hi guys this will be my 1st time with dllcalls so please bear with me. a certain company was able to provide us with an encryption dll, the problem is that when i try to execute the func nothing happens. The syntax for the dll func is this: encryptFile(strPath, strSourceFile, strPassword, strMessage, strTargetFile) what i did was this: Global dll = "C:\ENC DEC DLL\EncDec.dll" $Call = DllCall(dll, " BOOLEAN", "encryptFile(c:\ENC DEC DLL, samplefile.TXT, password, unable to encrypt)") msgbox(0,"test dll", $Call)I think i'm wrong to use encryptFile(c:\ENC DEC DLL, samplefile.TXT, password, unable to encrypt) inside the DllCall but i don't know where i'm supposed to put the arguments for this function.
-
Timeout expired on large queries SQL
Ace08 replied to Ace08's topic in AutoIt General Help and Support
Thanks ChrisL will try this one and get back on you with this -
Hi there i have this piece of code that works fine for small queries however i'm getting timeout expired on complex queries. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=server;DATABASE=db;UID=User;PWD=Password2;" $conn.Open($DSN) $rs = ObjCreate( "ADODB.RecordSet" ) $rs.Open("select count(*) from table",$conn) $Inc = $rs.Fields(0).value $rs.close $rs.Open("select lname, fname, mname, school, address1, address2, city, state from table",$conn) Do If $rs.EOF() Then ExitLoop $cont = $cont & Chr(34) & $rs.Fields(0).value & Chr(34) & "," & Chr(34) & $rs.Fields(1).value & Chr(34) & "," & Chr(34) & $rs.Fields(2).value & Chr(34) & "," & Chr(34) & $rs.Fields(3).value & Chr(34) & "," & Chr(34) & $rs.Fields(4).value & Chr(34) & "," & Chr(34) & $rs.Fields(5).value & Chr(34) & "," & Chr(34) & $rs.Fields(6).value & Chr(34) & "," & Chr(34) & $rs.Fields(7).value & Chr(34) & @CRLF $rs.MoveNext() Until $rs.EOF() $rs.close MsgBox(0,"debug",$cont) Func MyErrFunc() Local $HexNumber $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Exit Endfunc I've tried doing someting like $DSN = "DRIVER={SQL Server};SERVER=server;DATABASE=db;UID=User;PWD=Password2;Connection Timeout=0;" with no luck even tried doing $conn.ConnectionTimeout = 0 with same results
-
Hi there i have this piece of code that works fine for small queries however i'm getting timeout expired on complex queries. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=server;DATABASE=db;UID=User;PWD=Password2;" $conn.Open($DSN) $rs = ObjCreate( "ADODB.RecordSet" ) $rs.Open("select count(*) from table",$conn) $Inc = $rs.Fields(0).value $rs.close $rs.Open("select lname, fname, mname, school, address1, address2, city, state from table",$conn) Do If $rs.EOF() Then ExitLoop $cont = $cont & Chr(34) & $rs.Fields(0).value & Chr(34) & "," & Chr(34) & $rs.Fields(1).value & Chr(34) & "," & Chr(34) & $rs.Fields(2).value & Chr(34) & "," & Chr(34) & $rs.Fields(3).value & Chr(34) & "," & Chr(34) & $rs.Fields(4).value & Chr(34) & "," & Chr(34) & $rs.Fields(5).value & Chr(34) & "," & Chr(34) & $rs.Fields(6).value & Chr(34) & "," & Chr(34) & $rs.Fields(7).value & Chr(34) & @CRLF $rs.MoveNext() Until $rs.EOF() $rs.close MsgBox(0,"debug",$cont) Func MyErrFunc() Local $HexNumber $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Exit Endfunc I've tried doing someting like $DSN = "DRIVER={SQL Server};SERVER=server;DATABASE=db;UID=User;PWD=Password2;Connection Timeout=0;" Sorry for posting twice have accidently clicked post and stop ie tought it was'nt posted yet
-
Thanks jchd i know its not an error, but an empty set should return an empty string thats what i think. Thanks a lot its now working
-
Hi there i have here a script that connects to a certain database and returns names and addresses based on the ID, its working if the value queried exists however if not i'am getting an error "Either BOF or EOF is True, or the correct record has been deleted.requested operation requires a current record.". ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=ServerName;DATABASE=Database;UID=UserID;PWD=Password;" $conn.Open($DSN) $rs = ObjCreate( "ADODB.RecordSet" ) $rs.Open( "select LastName,FirstName,MiddleInitial,Address1,Address2,City from Table where ID = '015000040277'",$conn ) MsgBox(0,"",$rs.Fields(0).value) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Exit Endfunc Does anyone know how to deal with the error i've tried to do something like If Not $rs.Fields(0).value = "" Then MsgBox(0,"",$rs.Fields(0).value) EndIf but it seems like when i try to extract a non existing value from $rs.Fields(0).value triggers this error. would appreciate your help.
-
Thanks guys for the help @guinness Thanks but im not actualy going to resize the gui and take the controls with it but to resize the listview control itself only @KaFu Thanks KaFu just what i needed i tried _WinAPI_MoveWindow() and it did the trick
-
Hi there is it possible to resize a created listview? say i created a listview with $hListView = _GUICtrlListView_Create($hGUI, "", 2, 20,990, 268) because i want to resize the height to 500 if it meets a certain value. Thanks in advance
-
Hi sorry for bringing this post back up, i'm having trouble with my scroll bars(down). when scrolling down the listview, it scrolls until the end of the record however when scrolling up it does'nt behave that way. here is what i did #include <GuiMenu.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <StaticConstants.au3> #include <GDIPlus.au3> Opt("TrayIconDebug", 1) Global $sText,$sText2,$iCurrLvTop1,$iCurrLvTop2,$check,$Start,$End $hGUI = GUICreate('Read ListView Item', 1000, 620) $Label1 = "ListView 1" $lenLabel1 = getTextLengthInPixel($Label1, "Tahoma", 10, 2) ; bold GUICtrlCreateLabel($Label1, 430, 2, $lenLabel1+30, 20, $ss_leftnowordwrap) GUICtrlSetFont(-1, 10, 600) $check = GuiCtrlCreateCheckbox("All", 8, 290, 80, 20) $Label2 = "ListView 2" $lenLabel2 = getTextLengthInPixel($Label2, "Tahoma", 10, 2) ; bold GUICtrlCreateLabel($Label2, 430, 290, $lenLabel2+30, 200, $ss_leftnowordwrap) GUICtrlSetFont(-1, 10, 600) $hListView = _GUICtrlListView_Create($hGUI, "", 2, 20,990, 268) $hListView2 = _GUICtrlListView_Create($hGUI, "", 2, 310,990,268) $Prev = GUICtrlCreateButton("<<Prev",470,590) $Next = GUICtrlCreateButton("Next>>",512,590) $Update = GUICtrlCreateButton("Update",950,590) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOr($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES)) _GUICtrlListView_SetExtendedListViewStyle($hListView2, BitOr($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT,$LVS_EX_CHECKBOXES)) GUISetState() Global $iLvCount = _GUICtrlListView_GetCounterPage($hListView) - 1 GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;~ 1st ListView ;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "Col1", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Col2", 150) _GUICtrlListView_InsertColumn($hListView, 2, "Col3", 150) _GUICtrlListView_InsertColumn($hListView, 3, "Col4", 80) _GUICtrlListView_InsertColumn($hListView, 4, "Col5", 400) _GUICtrlListView_InsertColumn($hListView, 5, "Col6", 80) _GUICtrlListView_InsertColumn($hListView, 6, "Col7", 80) For $i = 0 to 30 _GUICtrlListView_AddItem($hListView, "Col1 Row" & $i+1, 0) _GUICtrlListView_AddSubItem($hListView, $i, "Col2 Row" & $i+1, 1) _GUICtrlListView_AddSubItem($hListView, $i, "Col3 Row" & $i+1, 2) _GUICtrlListView_AddSubItem($hListView, $i, "Col4 Row" & $i+1, 3) _GUICtrlListView_AddSubItem($hListView, $i, "Col5 Row" & $i+1, 4) _GUICtrlListView_AddSubItem($hListView, $i, "Col6 Row" & $i+1, 5) _GUICtrlListView_AddSubItem($hListView, $i, "Col7 Row" & $i+1, 6) Next ;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;~ 2nd ListView ;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Add columns _GUICtrlListView_InsertColumn($hListView2, 0, "Col1", 100) _GUICtrlListView_InsertColumn($hListView2, 1, "Col2", 150) _GUICtrlListView_InsertColumn($hListView2, 2, "Col3", 150) _GUICtrlListView_InsertColumn($hListView2, 3, "Col4", 80) _GUICtrlListView_InsertColumn($hListView2, 4, "Col5", 400) _GUICtrlListView_InsertColumn($hListView2, 5, "Col6", 80) _GUICtrlListView_InsertColumn($hListView2, 6, "Col7", 80) for $y = 0 to 30 ; Add items _GUICtrlListView_AddItem($hListView2, "Col1 Row" & $i+1, 0) _GUICtrlListView_AddSubItem($hListView2, $y, "Col1 Row" & $i+1, 1) _GUICtrlListView_AddSubItem($hListView2, $y, "Col1 Row" & $i+1, 2) _GUICtrlListView_AddSubItem($hListView2, $y, "Col1 Row" & $i+1, 3) _GUICtrlListView_AddSubItem($hListView2, $y, "Col1 Row" & $i+1, 4) _GUICtrlListView_AddSubItem($hListView2, $y, "Col1 Row" & $i+1, 5) _GUICtrlListView_AddSubItem($hListView2, $y, "Col1 Row" & $i+1, 6) Next GUISetState() ; Loop until user exits while 1 If $sText <> _GUICtrlListView_GetItemTextString($hListView) Then $sText = _GUICtrlListView_GetItemTextString($hListView) $RowNum = _GUICtrlListView_GetSelectedIndices($hListView) _GUICtrlListView_SetItemState($hListView2, $RowNum, $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_SetItemState($hListView, $RowNum, $LVIS_SELECTED, $LVIS_SELECTED) EndIf If $sText2 <> _GUICtrlListView_GetItemTextString($hListView2) Then $sText2 = _GUICtrlListView_GetItemTextString($hListView2) $RowNum = _GUICtrlListView_GetSelectedIndices($hListView2) _GUICtrlListView_SetItemState($hListView, $RowNum, $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_SetItemState($hListView2, $RowNum, $LVIS_SELECTED, $LVIS_SELECTED) EndIf $iLvTop1 = _GUICtrlListView_GetTopIndex($hListView) $iLvTop2 = _GUICtrlListView_GetTopIndex($hListView2) If $iLvTop1 <> $iCurrLvTop1 Then If $iLvTop1 < $iLvTop2 Then _GUICtrlListView_EnsureVisible($hListView2, $iLvTop1) ElseIf $iLvTop1 > $iLvTop2 Then _GUICtrlListView_EnsureVisible($hListView2, $iLvTop1 + $iLvCount) EndIf $iCurrLvTop1 = $iLvTop1 $iCurrLvTop2 = $iLvTop1 ElseIf $iLvTop2 <> $iCurrLvTop2 Then If $iLvTop2 < $iLvTop1 Then _GUICtrlListView_EnsureVisible($hListView, $iLvTop2) ElseIf $iLvTop2 > $iLvTop1 Then _GUICtrlListView_EnsureVisible($hListView, $iLvTop2 + $iLvCount) EndIf $iCurrLvTop1 = $iLvTop2 $iCurrLvTop2 = $iLvTop2 EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;~ CheckBox (All) ;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Case $check If GUICtrlRead($check) = $GUI_CHECKED Then For $checkbox = 0 to $y _GUICtrlListView_SetItemChecked($hListView2, $checkbox) Next Else For $checkbox2 = 0 to $y _GUICtrlListView_SetItemChecked($hListView2, $checkbox2,False) Next EndIf EndSwitch WEnd Func ListView_Click() EndFunc ;==>ListView_Click Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo,$OldText $hWndListView = $hListView $hWndListView2 = $hListView2 If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"));$iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) ; Get id of clicked item If $aHit[0] <> -1 Then ; Check it was an item ;~ $sText = _GUICtrlListView_GetItemTextString($hListView, $aHit[0]); Read the item text once clicked ;~ ConsoleWrite($sText & @CRLF) ; Display it _GUICtrlListView_SetItemState($hListView, $aHit[0], $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_SetItemState($hListView2, $aHit[0], $LVIS_SELECTED, $LVIS_SELECTED) EndIf Return 0 EndSwitch Case $hWndListView2 Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button Local $aHit = _GUICtrlListView_SubItemHitTest($hListView2) ; Get id of clicked item If $aHit[0] <> -1 Then ; Check it was an item ;~ $sText2 = _GUICtrlListView_GetItemTextString($hListView2, $aHit[0]); Read the item text once clicked ;~ ConsoleWrite($sText2 & @CRLF) ; Display it _GUICtrlListView_SetItemState($hListView2, $aHit[0], $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_SetItemState($hListView, $aHit[0], $LVIS_SELECTED, $LVIS_SELECTED) EndIf Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func getTextLengthInPixel($text, $font, $size = 9, $style = 0) ;Calculate actual width of the given text _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hFamily = _GDIPlus_FontFamilyCreate($font) $hGDIFont = _GDIPlus_FontCreate($hFamily, $size, $style) $hFormat = _GDIPlus_StringFormatCreate() $tLayout = _GDIPlus_RectFCreate(0, 0, @DesktopWidth, @DesktopHeight) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $text, $hGDIFont, $tLayout, $hFormat) $width = Int(DllStructGetData($aInfo[0], 3)) + 1 _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontDispose($hGDIFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Return $width EndFunc Also i have noticed that if the fields are wide enough to create a left/right scroll bar this happens however if all the fields fit inside, it does not show this kind of behavior. would appreciate if you could tell me whats wrong Thanks in advance