Leaderboard
Popular Content
Showing content with the highest reputation on 12/07/2017 in all areas
-
i need convert vbs to au3 please
Earthshine and one other reacted to JLogan3o13 for a topic
@Mandolen11 as people have been kindly trying to point out to you, this forum is for helping people with their scripts. It is not a place where you demand something and someone barfs up the code for you. If you are intelligent enough to understand VBS you should have no problem with AutoIt. So if you want help, show us what you have tried from the help file on your own; treat this like Math class and show your work2 points -
i need convert vbs to au3 please
Mandolen11 reacted to Earthshine for a topic
I am trying to help you learn how to do it for yourself. so, you learn. you have the algorithm from the previous code. start writing autoit script and post your code. we can help with that. 1) check if registry key exists 2) if yes then write value1 point -
i need convert vbs to au3 please
Mandolen11 reacted to Earthshine for a topic
do you understand the vbs code? https://www.autoitscript.com/autoit3/docs/ specifically https://www.autoitscript.com/autoit3/docs/functions/RegRead.htm https://www.autoitscript.com/autoit3/docs/functions/RegWrite.htm1 point -
1 point
-
Of course +1 must be added to $iFrom and $iTo. Because your item_id's starts at item_id = 1 and my item_id's starts at item_id = 0. Sorting columns by clicking the column header. I would do it in the same way as the deletions: ; Create sorting table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.Sort1 AS SELECT item_id FROM lvdata ORDER BY f1;") ; Create sorting table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.Sort2 AS SELECT item_id FROM lvdata ORDER BY f2;") ; Create sorting table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.Sort3 AS SELECT item_id FROM lvdata ORDER BY f3;") Detect column header clicks in the listview: Case $LVN_COLUMNCLICK Local $iCol = DllStructGetData( DllStructCreate( $tagNMLISTVIEW, $lParam ), "SubItem" ) Switch $iCol Case 1,2,3 $iSort = $iCol Case Else $iSort = 0 EndSwitch GUICtrlSendMsg( $ListView1, $LVM_SETITEMCOUNT, 500000-5, 0 ) SQL SELECT statements: Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ), $sSQL, $iColumns $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) Switch $iSort Case 1 $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN Sort1 ON Sort1.item_id = lvdata.item_id " & _ "WHERE Sort1.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" Case 2 $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN Sort2 ON Sort2.item_id = lvdata.item_id " & _ "WHERE Sort2.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" Case 3 $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN Sort3 ON Sort3.item_id = lvdata.item_id " & _ "WHERE Sort3.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" Case Else Local $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN RowRelation ON RowRelation.item_id = lvdata.item_id " & _ "WHERE RowRelation.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" EndSwitch _SQLite_GetTable2d( -1, $sSQL, $aResult, $iRows, $iColumns ) ConsoleWrite($sSQL&@CRLF) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <SQLite.au3> ; SQLite #include <Timers.au3> ; Create structure $tagNMLVCACHEHINT Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" ; #include <GuiListView.au3> Global $hListView _SQLite_Startup() $sFileDB = @ScriptDir & '\Data.db' $TableName='lvdata' ; Create DB if not exist If Not FileExists($sFileDB) Then ; Recreate data base $hStarttime=_Timer_Init() _SQLite_Open( $sFileDB ) _SQLite_Exec( -1, "PRAGMA synchronous = OFF;" ) $sExec = 'Create Table lvdata (' & _ '[item_id] INTEGER PRIMARY KEY AUTOINCREMENT,' & _ '[f1] TEXT,' & _ '[f2] TEXT,' & _ '[f3] TEXT,' & _ '[f4] TEXT,' & _ '[f5] TEXT,' & _ '[f6] TEXT,' & _ '[f7] TEXT,' & _ '[f8] TEXT,' & _ '[f9] TEXT );' _SQLite_Exec( -1, $sExec ) _SQLite_Exec( -1, "BEGIN TRANSACTION;" ) $Row=500000 $Line='tuysdufysdfsduyfiusydfisdyfiusfdsdf' For $i=0 To $Row-1 $ind=Random(5,25,1) $sData=StringMid($Line,$ind) $sValues = "(" & $i + 1 & ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "')" For $j = 1 To 99 $sValues &= ",(" & $i + $j + 1 & ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "')" Next _SQLite_Exec( -1, "INSERT INTO lvdata VALUES " & $sValues & ";" ) $i += 99 Next _SQLite_Exec( -1, "COMMIT TRANSACTION;" ) _SQLite_Close( -1 ) ConsoleWrite(@CRLF&'Create DB, create strings, fill table: '&_Timer_Diff($hStarttime)/1000&@CRLF) ; 7.9948113493733 EndIf ; Specially delete 5 records $hDB = _SQLite_Open($sFileDB) _SQLite_Exec($hDB, 'Delete From '&$TableName&' Where item_id > 5 And item_id <= 10 ;') ; Check databases Local $iRows2 = CheckDB( @ScriptDir&"\Data.db" ) ; Count of records Local $iRows ; GUI $Form1 = GUICreate("Virtual ListViews", 908, 524, 192, 114) ; Virtual ListViews - $LVS_OWNERDATA, Reduces flicker - $LVS_EX_DOUBLEBUFFER $ListView1 = GUICtrlCreateListView("", 8, 16, 890, 462, $LVS_OWNERDATA, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) ) $hListView = GUICtrlGetHandle($ListView1) ; Handle ; Add Columns For $i = 0 To 9 _GUICtrlListView_AddColumn( $hListView, "Col" & $i, 75 ) Next $Input1 = GUICtrlCreateInput("Input1", 8, 488, 185, 21) $Button1 = GUICtrlCreateButton("Button1", 200, 488, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 680, 488, 75, 25) $Button3 = GUICtrlCreateButton("Button3", 752, 488, 75, 25) $Button4 = GUICtrlCreateButton("Button4", 824, 488, 75, 25) GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState(@SW_SHOW) $iRows = $iRows2 If $iRows Then _SQLite_Open( $sFileDB ) ; Create memory database _SQLite_Exec(-1, "ATTACH DATABASE ':memory:' AS DisplayMemDb;") ; Create table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.RowRelation AS SELECT item_id FROM lvdata;") ; Create sorting table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.Sort1 AS SELECT item_id FROM lvdata ORDER BY f1;") ; Create sorting table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.Sort2 AS SELECT item_id FROM lvdata ORDER BY f2;") ; Create sorting table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.Sort3 AS SELECT item_id FROM lvdata ORDER BY f3;") ; Send message to $ListView1, $iRows - Count of records GUICtrlSendMsg( $ListView1, $LVM_SETITEMCOUNT, $iRows, 0 ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local Static $tText = DllStructCreate( "wchar[50]" ) Local Static $pText = DllStructGetPtr( $tText ) Local Static $aResult, $iRows, $iFrom, $iSort = 0 Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hListView Switch $iCode ; View Records Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $iIndex = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom + 1 ; number row Local $nCol = DllStructGetData($tNMLVDISPINFO, "subitem") ; number column If $iIndex > 0 And $iIndex < $iRows + 1 Then Local $sItem = $aResult[$iIndex][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) EndIf EndIf Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ), $sSQL, $iColumns $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) Switch $iSort Case 1 $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN Sort1 ON Sort1.item_id = lvdata.item_id " & _ "WHERE Sort1.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" Case 2 $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN Sort2 ON Sort2.item_id = lvdata.item_id " & _ "WHERE Sort2.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" Case 3 $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN Sort3 ON Sort3.item_id = lvdata.item_id " & _ "WHERE Sort3.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" Case Else Local $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN RowRelation ON RowRelation.item_id = lvdata.item_id " & _ "WHERE RowRelation.rowid BETWEEN " & $iFrom + 1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) + 1 & ";" EndSwitch ;Local $sSQL = "SELECT * FROM lvdata WHERE item_id >= " & $iFrom & _ ; " AND item_id <= " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) & ";" ;~ Local $sSQL = "SELECT * FROM lvdata WHERE rowid >= " & $iFrom & _ ;~ " AND rowid <= " & DllStructGetData( $tNMLVCACHEHINT, "iTo" )+1 & ";" _SQLite_GetTable2d( -1, $sSQL, $aResult, $iRows, $iColumns ) ConsoleWrite($sSQL&@CRLF) Case $LVN_COLUMNCLICK Local $iCol = DllStructGetData( DllStructCreate( $tagNMLISTVIEW, $lParam ), "SubItem" ) Switch $iCol Case 1,2,3 $iSort = $iCol Case Else $iSort = 0 EndSwitch GUICtrlSendMsg( $ListView1, $LVM_SETITEMCOUNT, 500000-5, 0 ) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func CheckDB( $sDBname ) Local $aRow, $iRows = 0 If FileExists( $sDBname ) Then _SQLite_Open( $sDBname ) _SQLite_QuerySingleRow( -1, "SELECT COUNT(*) FROM lvdata LIMIT 1;", $aRow ) _SQLite_Close( -1 ) EndIf If IsArray( $aRow ) Then _ $iRows = $aRow[0] + 1 Return $iRows EndFunc I've updated the code to create "lvdata" table so that column 1-3 gets sorted differently. And I've updated the code to use bulk inserts: $Row=500000 $Line='tuysdufysdfsduyfiusydfisdyfiusfdsdf' For $i=0 To $Row-1 $ind=Random(5,25,1) $sData=StringMid($Line,$ind) $sValues = "(" & $i + 1 & ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "')" For $j = 1 To 99 $sValues &= ",(" & $i + $j + 1 & ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & StringMid($Line,Random(5,25,1)) & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "'" & _ ",'" & $sData & "')" Next _SQLite_Exec( -1, "INSERT INTO lvdata VALUES " & $sValues & ";" ) $i += 99 Next This means that the SQL INSERT statement looks like this: INSERT INTO lvdata VALUES (...),(...), ..., (...); This reduces the total time to create database and table, generate strings and insert strings in the table from 25 seconds to 8 seconds on my PC. I've also placed Case statements below Switch $iCode in proper order. The rule is that Case statements with most events should be in top of the list. You must delete and recreate the database to see the effects of the sorting in Col1 - Col3.1 point
-
1 point
-
tempman, This creates a 2d array whereby the first element is the sort argument and the second element is the complete ip address. The sort element is expanded to 4 digits for the sort to work properly... #include <array.au3> Local $aArray[6] = ["175.164.4.196:80", _ "143.59.44.41:443", _ "62.68.190.92:8000", _ "77.119.25.12:80", _ "101.167.48.241:8080", _ "80.243.169.25:8443"] Local $array_that_can_be_sorted[UBound($aArray)][2] For $i = 0 To UBound($aArray) - 1 ;ConsoleWrite($i & @CRLF) $array_that_can_be_sorted[$i][0] = StringFormat('%04i', StringRegExpReplace($aArray[$i], '[^:]+:(.*)', '$1')) $array_that_can_be_sorted[$i][1] = $aArray[$i] Next _ArrayDisplay($array_that_can_be_sorted) _ArraySort($array_that_can_be_sorted) _ArrayDisplay($array_that_can_be_sorted) kylomas1 point
-
Larsj, Thank you very much for the above example. For the correct display, added +1 Local $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN RowRelation ON RowRelation.item_id = lvdata.item_id " & _ "WHERE RowRelation.rowid BETWEEN " & $iFrom+1 & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" )+1 & ";" Larsj, in order to do sorting by clicking on the title, I must: 1. Make a CREATE VIEW 2. Make Order By Or it is possible to make somehow easier?1 point
-
Cannot Automate Win 10 Driver Confirmation Dialog Box
Earthshine reacted to junkew for a topic
As far as I am aware you can allways move your mouse and click with either https://www.autoitscript.com/autoit3/docs/functions/MouseMove.htm https://www.autoitscript.com/autoit3/docs/functions/MouseClick.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_Keybd_Event.htm most likely you have to click position image based as controls in itself not recognizable Below you could also base on the size of your dialog mousemove_perc("50%","50%") func mousemove_perc($x,$y) if stringinstr($x,"%") Then $realX=stringreplace($x,"%","") * (@DesktopWidth / 100) $realy=stringreplace($y,"%","") * (@DesktopHeight / 100) mousemove($realX ,$realy) EndIf EndFunc1 point -
GUI Resizing - Snapping - Centering
argumentum reacted to Deye for a topic
Since I have updated this a few times in the snippets thread (for corrections) That will be the last update Since the code has grown and if anything should change onwards ..will keep it here To resize: hold the gui while dragging it (up or down) (left or right) with the mouse Tip: test it about between different screen borders #include <WindowsConstants.au3> #include <GuiconstantsEx.au3> #include <WinAPISys.au3> #include <WinAPIGdi.au3> #include <Misc.au3> Opt("GUIResizeMode", 904) $hDLL = DllOpen("user32.dll") OnAutoItExitRegister("On_Exit") Global $iWidth = 380, $iHeight = 180 Global $hGUI = GUICreate("X", $iWidth, $iHeight, -1, -1) GUISetBkColor(0X5c6e8c, $hGUI) $iWidth = _WinAPI_GetClientWidth($hGUI) $iHeight = _WinAPI_GetClientHeight($hGUI) $ButtonWidth = 40 $ButtonHeight = 20 $idnew = GUICtrlCreateButton("Change Dimension", ($iWidth / 2) - (3 * $ButtonWidth / 2), ($iHeight / 2) - (4 * $ButtonHeight / 2), 3 * $ButtonWidth, $ButtonHeight) $idCenter = GUICtrlCreateButton("x", ($iWidth / 2) - ($ButtonWidth / 2), ($iHeight / 2) - ($ButtonHeight / 2), $ButtonWidth, $ButtonHeight) Global $moving = False, $PMon = _WinAPI_MonitorFromWindow($hGUI), $aMax = GetMonitorRect($PMon) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", 500, "long", 0x00040010) GUIRegisterMsg($WM_ENTERSIZEMOVE, "WM_ENTERSIZEMOVE") GUIRegisterMsg($WM_EXITSIZEMOVE, "WM_EXITSIZEMOVE") GUISetState() $aGPos = WinGetPos($hGUI) $iWidth = $aGPos[2] $iHeight = $aGPos[3] While 1 Switch GUIGetMsg() Case $GUI_EVENT_close Exit Case $idnew $iWidth = Random(150, 550, 1) $iHeight = Random(150, 550, 1) _NewDimension($iWidth, $iHeight) Case $idCenter _CenterToScreen() Case $GUI_EVENT_PRIMARYDOWN If $moving Then ContinueLoop OnDrag() EndSwitch Sleep(10) WEnd Func OnDrag() Local $aPos, $iRoll, $X, $Y, $PH, $PW = 0, $aCurInfo = GUIGetCursorInfo($hGUI) If $aCurInfo[4] <> 0 Then Return ; Mouse is over a control Local $aGPos = WinGetPos($hGUI) Local $aMPos = MouseGetPos() Local $width = $aGPos[2] Local $height = $aGPos[3] While _IsPressed("01", $hDLL) $aPos = MouseGetPos() $iRoll = (($aMPos[1] - $aPos[1]) - ($aMPos[0] - $aPos[0])) * 100 / 50 $height = Round(($aGPos[3] / $aGPos[2]) * ($aGPos[2] + $iRoll)) If $height < $iHeight Then ExitLoop If $height >= $aMax[3] - $aMax[1] Then $height = $aMax[3] - $aMax[1] $width = Round(($aGPos[2] / $aGPos[3]) * $height) If $width > ($aMax[2] - $aMax[0]) Then $width = ($aMax[2] - $aMax[0]) $height = Round(($aGPos[3] / $aGPos[2]) * $width) EndIf ;Store as Previous Width & Height $PW = $width $PH = $height $X = Round(($aGPos[2] / 2) + $aGPos[0] - ($width / 2)) $Y = Round(($aGPos[3] / 2) + $aGPos[1] - ($height / 2)) If $X < $aMax[0] Then $X = $aMax[0] ElseIf ($X + $width) > $aMax[2] Then $X = Round($aMax[2] - $width) EndIf If $Y < $aMax[1] Then $Y = $aMax[1] ElseIf ($Y + $height) > $aMax[3] Then $Y = Round($aMax[3] - $height) EndIf WinMove($hGUI, "", $X, $Y, $width, $height) Sleep(20) WEnd If $height < $iHeight And $PW <> 0 Then $tRect = _WinAPI_GetWindowRect($hGUI) WinMove($hGUI, "", (($PW / 2) + DllStructGetData($tRect, "Left")) - ($iWidth / 2), Ceiling(($PH / 2) + DllStructGetData($tRect, "Top")) - ($iHeight / 2), $iWidth, $iHeight) EndIf EndFunc Func _NewDimension($width, $height) Local $aPos = WinGetPos($hGUI) WinMove($hGUI, "", ($aPos[2] / 2) + $aPos[0] - ($width / 2), ($aPos[3] / 2) + $aPos[1] - ($height / 2), $width, $height) EndFunc ;==>_NewDimension Func _SnapToScreen(ByRef $aPos, ByRef $aMax) ; Snap the gui back to its full view when moved off screen Local $t0 = $aPos[0], $t1 = $aPos[1] If $aPos[0] < $aMax[0] Then $aPos[0] = $aMax[0] ElseIf ($aPos[0] + $aPos[2]) > $aMax[2] Then $aPos[0] = ($aMax[2] - $aPos[2]) EndIf If $aPos[1] < $aMax[1] Then $aPos[1] = $aMax[1] ElseIf ($aPos[1] + $aPos[3]) > $aMax[3] Then $aPos[1] = ($aMax[3] - $aPos[3]) EndIf If $t0 <> $aPos[0] Or $t1 <> $aPos[1] Then Return 1 EndFunc Func _CenterToScreen($Snap = False) ; Center & Resize the gui dimension if off screen Local $a = WinGetPos($hGUI) Local $Mon = _WinAPI_MonitorFromWindow($hGUI) If $Mon <> $PMon Then $PMon = $Mon $aMax = GetMonitorRect($PMon) EndIf If $a[3] > ($aMax[3] - $aMax[1]) Then $a[2] = Round(($a[2] / $a[3]) * ($aMax[3] - $aMax[1])) ;New Width $a[3] = $aMax[3] - $aMax[1] ;New Height EndIf If $a[2] > ($aMax[2] - $aMax[0]) Then $a[3] = Round(($a[3] / $a[2]) * ($aMax[2] - $aMax[0])) ;New Height $a[2] = $aMax[2] - $aMax[0] ;New Width EndIf If $Snap Then If _SnapToScreen($a, $aMax) Then Return WinMove($hGUI, "", $a[0], $a[1], $a[2], $a[3]) Return EndIf WinMove($hGUI, "", (($aMax[2] + $aMax[0]) / 2) - ($a[2] / 2), (($aMax[1] + $aMax[3]) / 2) - ($a[3] / 2), $a[2], $a[3]) EndFunc Func GetMonitorRect($hMonitor) Local $aData = _WinAPI_GetMonitorInfo($hMonitor) Local $s = DllStructGetData($aData[1], 1) & ',' & DllStructGetData($aData[1], 2) & ',' & DllStructGetData($aData[1], 3) & ',' & DllStructGetData($aData[1], 4) Local $a = StringSplit($s, ',', 2) Return $a EndFunc Func WM_ENTERSIZEMOVE($hWnd, $Msg, $wParam, $lParam) If $hWnd = $hGUI Then $moving = True Return "GUI_RUNDEFMSG" EndFunc Func WM_EXITSIZEMOVE($hWnd, $Msg, $wParam, $lParam) If $hWnd = $hGUI Then $moving = False _CenterToScreen(1) EndIf Return "GUI_RUNDEFMSG" EndFunc Func On_Exit() DllClose($hDLL) EndFunc1 point -
You must establish a unique relationship between the rows in the listview and the rows in the table. If the table is not too big, it can be done in a memory database this way: ; Create memory database _SQLite_Exec(-1, "ATTACH DATABASE ':memory:' AS DisplayMemDb;") ; Create table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.RowRelation AS SELECT item_id FROM lvdata;") And then you need to update your SQL SELECT statement: Local $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN RowRelation ON RowRelation.item_id = lvdata.item_id " & _ "WHERE RowRelation.rowid BETWEEN " & $iFrom & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) & ";" #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <SQLite.au3> ; SQLite #include <Timers.au3> ; Create structure $tagNMLVCACHEHINT Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" ; #include <GuiListView.au3> Global $hListView _SQLite_Startup() $sFileDB = @ScriptDir & '\Data.db' $TableName='lvdata' ; Create DB if not exist If Not FileExists($sFileDB) Then ; Recreate data base $Row=500000 $hStarttime=_Timer_Init() $Line='tuysdufysdfsduyfiusydfisdyfiusfdsdf' $sExec = 'BEGIN; Create Table '&$TableName&' (' & _ '[item_id] INTEGER PRIMARY KEY AUTOINCREMENT,' & _ '[f1] TEXT,' & _ '[f2] TEXT,' & _ '[f3] TEXT,' & _ '[f4] TEXT,' & _ '[f5] TEXT,' & _ '[f6] TEXT,' & _ '[f7] TEXT,' & _ '[f8] TEXT,' & _ '[f9] TEXT );' ; Create string For $i=0 To $Row-1 $ind=Random(5,25,1) $sData=StringMid($Line,$ind) $sExec &= 'INSERT INTO '&$TableName&' (f1,f2,f3,f4,f5,f6,f7,f8,f9) VALUES (' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&',' & _ _SQLite_FastEscape($sData)&');' Next $sExec &= 'COMMIT;' ; Create Table $hStarttime=_Timer_Init() $hDB = _SQLite_Open($sFileDB) _SQLite_Exec( -1, "PRAGMA synchronous = OFF;" ) _SQLite_Exec($hDB, $sExec) _SQLite_Close($hDB) ConsoleWrite(@CRLF&'Add records in DB: '&_Timer_Diff($hStarttime)/1000&@CRLF) EndIf ; Specially delete 5 records $hDB = _SQLite_Open($sFileDB) _SQLite_Exec($hDB, 'Delete From '&$TableName&' Where item_id > 5 And item_id <= 10 ;') ; Check databases Local $iRows2 = CheckDB( @ScriptDir&"\Data.db" ) ; Count of records Local $iRows ; GUI $Form1 = GUICreate("Virtual ListViews", 908, 524, 192, 114) ; Virtual ListViews - $LVS_OWNERDATA, Reduces flicker - $LVS_EX_DOUBLEBUFFER $ListView1 = GUICtrlCreateListView("", 8, 16, 890, 462, $LVS_OWNERDATA, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) ) $hListView = GUICtrlGetHandle($ListView1) ; Handle ; Add Columns For $i = 0 To 9 _GUICtrlListView_AddColumn( $hListView, "Col" & $i, 75 ) Next $Input1 = GUICtrlCreateInput("Input1", 8, 488, 185, 21) $Button1 = GUICtrlCreateButton("Button1", 200, 488, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 680, 488, 75, 25) $Button3 = GUICtrlCreateButton("Button3", 752, 488, 75, 25) $Button4 = GUICtrlCreateButton("Button4", 824, 488, 75, 25) GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState(@SW_SHOW) $iRows = $iRows2 If $iRows Then _SQLite_Open( $sFileDB ) ; Create memory database _SQLite_Exec(-1, "ATTACH DATABASE ':memory:' AS DisplayMemDb;") ; Create table in memory database _SQLite_Exec(-1, "CREATE TABLE DisplayMemDb.RowRelation AS SELECT item_id FROM lvdata;") ; Send message to $ListView1, $iRows - Count of records GUICtrlSendMsg( $ListView1, $LVM_SETITEMCOUNT, $iRows, 0 ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local Static $tText = DllStructCreate( "wchar[50]" ) Local Static $pText = DllStructGetPtr( $tText ) Local Static $aResult, $iRows, $iFrom Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hListView Switch $iCode Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ), $iColumns $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) Local $sSQL = "SELECT lvdata.* FROM lvdata " & _ "INNER JOIN RowRelation ON RowRelation.item_id = lvdata.item_id " & _ "WHERE RowRelation.rowid BETWEEN " & $iFrom & " And " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) & ";" ;Local $sSQL = "SELECT * FROM lvdata WHERE item_id >= " & $iFrom & _ ; " AND item_id <= " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) & ";" ;~ Local $sSQL = "SELECT * FROM lvdata WHERE rowid >= " & $iFrom & _ ;~ " AND rowid <= " & DllStructGetData( $tNMLVCACHEHINT, "iTo" )+1 & ";" _SQLite_GetTable2d( -1, $sSQL, $aResult, $iRows, $iColumns ) ConsoleWrite($sSQL&@CRLF) ; View Records Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $iIndex = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom + 1 ; number row Local $nCol = DllStructGetData($tNMLVDISPINFO, "subitem") ; number column If $iIndex > 0 And $iIndex < $iRows + 1 Then Local $sItem = $aResult[$iIndex][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) EndIf EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func CheckDB( $sDBname ) Local $aRow, $iRows = 0 If FileExists( $sDBname ) Then _SQLite_Open( $sDBname ) _SQLite_QuerySingleRow( -1, "SELECT COUNT(*) FROM lvdata LIMIT 1;", $aRow ) _SQLite_Close( -1 ) EndIf If IsArray( $aRow ) Then _ $iRows = $aRow[0] + 1 Return $iRows EndFunc There is an issue with an almost blank line in the listview. Make sure the height of the listview exactly matches an entire number of rows.1 point
-
Idle Timer from Local System Account?
Skysnake reacted to chaoticyeshua for a topic
I ended up resolving this by applying the following registry keys in Group Policy: HKEY_CURRENT_USER\Control Panel\Desktop Value Type: REG_SZ Value Name: AutoEndTasks Value Data: 1 Value Type: REG_SZ Value Name: HungAppTimeout Value Data: (time in ms to wait before killing tasks)1 point -
You want to return valid anagrams for everything you type? Like a dyslexic help tool? Maybe one that could determine the anagrams with lowest Levenshtein Distance, or sorts an array of returns by number of transpositions? What is the end use case? In my estimation this would be easier with the internal dictionary rather than a third party, any reason you have a want for Clarify?1 point
-
Only to inform you: the links of version 1.0.5.6 are no longer working. I never found something better than scite hopper, so moving to a newer machine I managed to save the scitehopper.exe to reinstall it. But it would be nice to have SciteHopper downloadable, also with google I found only outdated versions. Cheers,1 point
-
COM error handling in a UDF - best practice?
pixelsearch reacted to water for a topic
Example: You define a global COM error handler to grab all COM errors occurring in the main script. A local COM error handler grabs all COM errors occurring inside a function. When the function ends the local COM error handler is dropped and the global COM error handler is active again. Global $oGlobalCOMErrorHandler = ObjEvent("AutoIt.Error", "_ErrFuncGlobal") ; Global COM error handler Global $oIE = ObjCreate("InternetExplorer.Application") $oIE.xyz FunctionLocal() $oIE.xyz Exit Func FunctionLocal() Local $oLocalCOMErrorHandler = ObjEvent("AutoIt.Error", "_ErrFuncLocal") ; Local COM error handler $oIE.xyz EndFunc ; Global COM error handler Func _ErrFuncGlobal($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> Global COM error handler - COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc ; Local COM error handler Func _ErrFuncLocal($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> Local COM error handler - COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc1 point -
How can I click on the ribbon menu item
Earthshine reacted to junkew for a topic
;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=.*WordPad;controltype:=UIA_WindowControlTypeId;class:=WordPadClass") ;Document - WordPad _UIA_setVar("oUIElement","Title:=Afbeelding;controltype:=UIA_SplitButtonControlTypeId;class:=") ;ControlType:=UIA_SplitButtonControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles _UIA_Action("oP1","highlight") _UIA_action("oUIElement","highlight") ;~_UIA_action("oUIElement","click")1 point