
Yoriz
Active Members-
Posts
346 -
Joined
-
Last visited
Everything posted by Yoriz
-
EzMySql UDF - Use MySql Databases with autoit
Yoriz replied to Yoriz's topic in AutoIt Example Scripts
Sorry not used autoit or been on forum in a while, the download still works ok for me. -
You could give my GDIPlusDispose UDF a try and not have to worry about the disposing, it will be done automatically see the link in signature.
-
Hi, What about putting the text in an edit control so it takes care of the scrollbars for you. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Tabbed Notebook Dialog", 623, 442, 192, 124) $Tab1 = GUICtrlCreateTab(8, 8, 609, 425) $TabSheet1 = GUICtrlCreateTabItem("TabSheet1") $TabSheet2 = GUICtrlCreateTabItem("TabSheet2") GUICtrlSetState(-1,$GUI_SHOW) $Edit1 = GUICtrlCreateEdit("", 16, 40, 593, 385) GUICtrlSetData(-1, StringFormat("\r\n\r\n\r\n\r\n hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n\r\n\r\n\r\n\r\n\r\nhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n\r\n\r\n\r\n\r\n hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n\r\n\r\n\r\nhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n\r\n\r\n\r\nhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n\r\n hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\r\n")) $TabSheet3 = GUICtrlCreateTabItem("TabSheet3") GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
-
Close Gui after a certain time of inactivity
Yoriz replied to Naveed's topic in AutoIt GUI Help and Support
Hi, Here is a way of doing it, have a TimerInit() before the start of the windows msg loop, check for it reaching a idle maximum duration as one of the cases, after any other case reset the timmer. i made a little example that has two button that will reset the timmer and a status to show the idle time in seconds. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> _Form1() Func _Form1() #Region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 196, 94, -1, -1) Local $hButton1 = GUICtrlCreateButton("Button1", 20, 24, 75, 25) Local $hButton2 = GUICtrlCreateButton("Button2", 100, 24, 75, 25) Local $hStatusBar1 = _GUICtrlStatusBar_Create($Form1) _GUICtrlStatusBar_SetSimple($hStatusBar1) _GUICtrlStatusBar_SetText($hStatusBar1, "Idle Time: ") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $iTimmer = TimerInit() Local $iTimmerDuraction = 20000 Local $sStatusText While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $hButton1 MsgBox(0, "Button1", "Idle timmer reset") $iTimmer = TimerInit() Case $nMsg = $hButton2 MsgBox(0, "Button2", "Idle timmer reset") $iTimmer = TimerInit() Case TimerDiff($iTimmer) >= $iTimmerDuraction MsgBox(0, "Times up", "Idle time limit reached") ExitLoop Case Else Local $sNewTimeText = "Idle Time: " & Round(TimerDiff($iTimmer) / 1000) If $sStatusText <> $sNewTimeText Then $sStatusText = $sNewTimeText _GUICtrlStatusBar_SetText($hStatusBar1, $sStatusText) EndIf EndSelect WEnd EndFunc ;==>_Form1 -
Hi , welcome to the forum, there are examples in this thread.
-
How to kill an AutoIT exe after itscompletion
Yoriz replied to getafix's topic in AutoIt General Help and Support
Hey, Your code looks like it might be getting stuck on one of the WinWait or WinWaitActive. you could use the optional timeout parameter to give your code a way out if something it is waiting for doesn't happen. If WinWaitActive($title, "", 10) Then MsgBox(0, "Good", "It didn't time out so i can continue with the normal code") Else MsgBox(0, "Doh", "It timed out , what should i do instead?, maybe just exit") Exit EndIf -
Generating random Numbers for tooltip x and y coordinates
Yoriz replied to focksie's topic in AutoIt General Help and Support
Hey, You should use the 3rd parameter of random to ensure you get a whole number. ToolTip( "Riveting story", Random(0, 1680, 1), Random(0, 1050, 1), "Cool Story Bro") -
SQLite with command line parameters for import
Yoriz replied to Jfish's topic in AutoIt General Help and Support
Your welcome , One thing to note when importing, watch out for any of the data having coma's it will throw the delimeter all out of wack. -
SQLite with command line parameters for import
Yoriz replied to Jfish's topic in AutoIt General Help and Support
SQLite> testimport.db SQLite> .separator , SQLite> .import importdata.csv testdata = _SQLite_SQLiteExe($sDatabaseFilePath, ".separator ," & @CRLF & ".import '" & FileGetShortName($hImportFilePath) & "' TableName" & @CRLF, $sOutputFile) #include <File.au3> #include <SQLite.au3> _CreateDatabaseFile() _ImportTxtToSql() _ReadArrayToSql() Func _CreateDatabaseFile() Local $hFile = @ScriptDir & "\Test.Txt" If FileExists($hFile) Then Return Local $iArraysize = 1000, $aArray[$iArraysize] For $i = 0 To $iArraysize - 1 Step 1 $aArray[$i] = $i & "-One," & $i & "-Two," & $i & "-Three," & $i & "-Four" Next _FileWriteFromArray($hFile, $aArray) EndFunc ;==>_CreateDatabaseFile Func _ImportTxtToSql() Local $sDatabaseFile = @ScriptDir & "\Test.Db", $sOutputFile Local $hFile = @ScriptDir & "\Test.Txt" If FileExists($sDatabaseFile) Then FileDelete($sDatabaseFile) _SQLite_SQLiteExe($sDatabaseFile, "CREATE TABLE test (ColOne,ColTwo,ColThree,ColFour);", $sOutputFile) Local $iTimmer = TimerInit() _SQLite_SQLiteExe($sDatabaseFile, ".mode csv" & @CRLF & ".import '" & FileGetShortName($hFile) & "' test" & @CRLF, $sOutputFile) ConsoleWrite(TimerDiff($iTimmer) & " :Time to import file" & @CR) EndFunc ;==>_ImportTxtToSql Func _ReadArrayToSql() Local $sDatabaseFile = @ScriptDir & "\Test.Db", $sOutputFile Local $hFile = @ScriptDir & "\Test.Txt" If FileExists($sDatabaseFile) Then FileDelete($sDatabaseFile) Local $aArray _FileReadToArray($hFile, $aArray) _SQLite_Startup() _SQLite_Open($sDatabaseFile) _SQLite_Exec(-1, "CREATE TABLE test (ColOne,ColTwo,ColThree,ColFour);") Local $iTimmer = TimerInit() _SQLite_Exec(-1, "Begin") For $i = 1 To $aArray[0] Step 1 _SQLite_Exec(-1, "INSERT INTO test values ('" & StringReplace($aArray[$i], ",", "','") & "');") Next _SQLite_Exec(-1, "END ;") ConsoleWrite(TimerDiff($iTimmer) & " :Time to read & insert array" & @CR) _SQLite_Close() _SQLite_Shutdown() EndFunc ;==>_ReadArrayToSql -
24th December, 2008 - v3.3.0.0 AutoIt: Added: New flag for StringSplit() to not return the count in element 0. UDFs: Removed: _StringSplit, no longer needed Looks like StringSplit was possibly made to work like _StringSplit so check the parameters your giving and you might just have remove the _ from your function calls.
-
Set the max number of characters that can be in an editbox with func GUICtrlSetLimit
-
Link: is there a function for reading images into 2d arrays?
-
Is this any good ? #include <GuiImageList.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> $hGUI = GUICreate("") $hGUIListView = _GUICtrlListView_Create($hGUI, "", 0, 0, 212, 300, BitOR($LVS_LIST, $LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS)) $hImageList = _GUIImageList_Create(24, 24, 5) _GUIImageList_AddIcon($hImageList, "icon.ico", 0, True) _GUICtrlListView_SetImageList($hGUIListView, $hImageList, 1) _GUICtrlListView_AddItem($hGUIListView, "1", 0) _GUICtrlListView_AddItem($hGUIListView, "2", 0) _GUICtrlListView_AddItem($hGUIListView, "3", 0) GUISetState() MsgBox(0, "", "moving index 2 to index 0 position") _guiCtrlListViewMoveIndex($hGUIListView, 2, 0) MsgBox(0, "", "moving index 1 to index 2 position") _guiCtrlListViewMoveIndex($hGUIListView, 1, 2) While 1 If GUIGetMsg() = -3 Then Exit WEnd Func _guiCtrlListViewMoveIndex($hWnd, $iCurrentIndex, $iNewIndex) $sText = _GUICtrlListView_GetItemText($hWnd, $iCurrentIndex) _GUICtrlListView_DeleteItem($hWnd, $iCurrentIndex) _GUICtrlListView_InsertItem($hWnd, $sText, $iNewIndex) EndFunc ;==>_guiCtrlListViewMoveIndex
-
Link: is there a function for reading images into 2d arrays?
-
I dont know what _Crypt_HashData returns but the code checks the password is correct with this line so alter it to suit. Case $sPassword = "Correct" To have ESC key and when user hits OK just leaving the input box blank count as an attempt to login just comment out the following. Case $sPassword = "" If @error = 1 Then Return 0 Locking the mouse/keyboard sounds a bit harsh, why not just set that user to disabled , then once that user account has been investigated it can be reanabled or lock it out for a certain time or something.
-
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _ParentGui() Func _ParentGui() Local $hParent = GUICreate("Parent", 300, 300 , -1, -1) Local $hButton = GUICtrlCreateButton("OpenChild", 10, 10) GUISetState() while 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hButton GUISetState(@SW_DISABLE, $hParent) _ChildGui($hParent) EndSwitch WEnd EndFunc Func _ChildGui($hParent) Local $hChild = GUICreate("Parent", 200, 200 , -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU,$WS_CHILD), -1, $hParent) Local $hButton = GUICtrlCreateButton("Close", 10, 10) GUISetState() while 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $hButton MsgBox(0, "Child button clicked", "Closing window", 0, $hChild) ExitLoop EndSwitch WEnd GUISetState(@SW_ENABLE, $hParent) WinActivate($hParent) GUIDelete($hChild) EndFunc
-
Something like this ? Switch _PasswordCheck() Case 1 MsgBox(0, "Result", "Login Correct") Case 0 MsgBox(0, "Result", "Login Cancelled ") case -1 MsgBox(0, "Result", "Failed 3 times lock out user") EndSwitch Func _PasswordCheck() Local $iXTimes = 3, $iCount = 1 While 1 Local $sPassword = InputBox("Login", "Enter Password", "", "", 320, 100) Select Case $sPassword = "Correct" Return 1 Case $iCount = $iXTimes MsgBox(16, "Access Denied", "Too many failed attempted logins have occurred !") Return -1 Case $sPassword = "" If @error = 1 Then Return 0 Case Else MsgBox(16, "Access Denied", "Password Incorrect!" & @CR & "You have " & $iXTimes - $iCount & " trys left") $iCount += 1 EndSelect WEnd EndFunc ;==>_PasswordCheck
-
Using listbox data in the same GUI form
Yoriz replied to DoubleMcLovin's topic in AutoIt GUI Help and Support
#include <GUIConstantsEx.au3> Opt("MustDeclareVars", 1) _GUI() Func _GUI() Local $hForm1 = GUICreate("Form1", 252, 117, -1, -1) Local $hList1 = GUICtrlCreateList("", 8, 8, 121, 97) GUICtrlSetData(-1, "1. Choice One|2. Choice Two|3. Choice Three|4. Choice Four") Local $hLabel1 = GUICtrlCreateLabel("", 144, 48, 102, 17) GUISetState(@SW_SHOW) Local $sCurrentSelected, $sText While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hList1 $sText = GUICtrlRead($hList1) If $sCurrentSelected <> "You have " & StringLeft($sText, 1) & " selected" Then GUICtrlSetData($hLabel1, "You have " & StringLeft($sText, 1) & " selected") EndIf EndSwitch WEnd EndFunc ;==>_Gui -
Pixelsearch & annoying coordinates
Yoriz replied to Tyranlol's topic in AutoIt General Help and Support
The whole point im getting at is, if you find yourself repeating code entry you create your own function, _PixelSearchWindow is a function i created combining the internal functions WinGetPos & PixelSearch. The example is using self created functions, if you copy the whole lot it including the new functions it will work. -
Send a key every certian interval...?
Yoriz replied to Aloosh's topic in AutoIt General Help and Support
Hi, You should read the sticky Announcement: Game Bots and decide if you want to take this any further. -
Pixelsearch & annoying coordinates
Yoriz replied to Tyranlol's topic in AutoIt General Help and Support
Does this example make sense ? $sTitle = "Untitled - Notepad" Run("NotePad") WinWait($sTitle) $aPos = _PixelSearchWindow($sTitle, "", 0xFFFFFF) If IsArray($aPos) Then MouseMove($aPos[0], $aPos[1]) _ArrayDisplay($aPos, "White Found") WinClose($sTitle) WinWaitClose($sTitle) Run("NotePad") WinWait($sTitle) $aWinPos = WinGetPos($sTitle, "") $aPos = _PixelSearchByArray($aWinPos, 0xFFFFFF) If IsArray($aPos) Then MouseMove($aPos[0], $aPos[1]) _ArrayDisplay($aPos, "White Found") WinActivate($sTitle) $aPos = _PixelSearchByArray($aWinPos, 0x000000) If IsArray($aPos) Then MouseMove($aPos[0], $aPos[1]) _ArrayDisplay($aPos, "Black Found") WinClose($sTitle) Func _PixelSearchWindow($sTitle, $sText, $Colour, $iShade = "", $iStep = "") Local $aPos = WinGetPos($sTitle, $sText) If Not IsArray($aPos) Then Return SetError(2, 0, -1) Return PixelSearch($aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3], $Colour, $iShade, $iStep) EndFunc ;==>_PixelSearchWindow Func _PixelSearchByArray($aPos, $Colour, $iShade = "", $iStep = "") If Not IsArray($aPos) Then Return SetError(2, 0, -1) Return PixelSearch($aPos[0], $aPos[1], $aPos[0] + $aPos[2], $aPos[1] + $aPos[3], $Colour, $iShade, $iStep) EndFunc ;==>_PixelSearchByArray -
You Could use ControlCommand with the "SetCurrentSelection, occurrence" command option ( use "FindString", 'string' with ControlCommand to get the occurance) or with "SelectString", 'string' command, or there is the functions from the GuiComboBox udf _GUICtrlComboBox_SetCurSel( use _GUICtrlComboBox_FindString or _GUICtrlComboBox_FindStringExact to get index).
-
Are we Scripters, or Programmers?
-
Pixelsearch & annoying coordinates
Yoriz replied to Tyranlol's topic in AutoIt General Help and Support
Make your own function. If you want to get co-ordinates of the window each time, use something like this. Func _PixelSearchWindow($sTitle, $sText, $Colour, $iShade = "", $iStep = "") local $aPos = WinGetPos($sTitle, $sText) If Not IsArray($aPos) Then Return SetError(2, 0, -1) Return PixelSearch($aPos[0], $aPos[1], $aPos[0]+$aPos[2], $aPos[1]+$aPos[3], $Colour, $iShade, $iStep) EndFunc If you want to use the same array of co-ordinates returned by a WinGetPos, use something like this. Func _PixelSearchByArray($aPos, $Colour, $iShade = "", $iStep = "") If Not IsArray($aPos) Then Return SetError(2, 0, -1) Return PixelSearch($aPos[0], $aPos[1], $aPos[0]+$aPos[2], $aPos[1]+$aPos[3], $Colour, $iShade, $iStep) EndFunc Edit: note not tested the code on anything