Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/22/2017 in all areas

  1. JLogan3o13

    I meet loop problem

    @anphat1995 That is what I figured. It appears you strolled right past our forum rules on your way in. I suggest you take a look at them now, especially the section on game automation, and you will see why this thread is now locked. You will not get any assistance on this subject.
    2 points
  2. benners

    Relative GUI centering

    The problem seems to be with the second GUI's styles BitOR($WS_EX_APPWINDOW, $WS_EX_TOPMOST) It is throwing the calculations out. If you remove the styles for the second GUI it works. You just need to find out how to adjust for the styles. If it's an option you could create both GUIs first then show and hide as required
    1 point
  3. benners

    Relative GUI centering

    I have used something like this in the past, well, I still do, they maybe of use centering Func _OIG_CentreGUI($h_Parent, $h_Child) Local $ai_ParentPos = WinGetPos($h_Parent, '') ; get the position of the parent gui Local $a_ViewerGUISize = WinGetClientSize($h_Child, '') ; get the size of the viewer gui Local $i_Xcord = $ai_ParentPos[0] + ($ai_ParentPos[2] / 2) - ($a_ViewerGUISize[0] / 2) Local $i_Ycord = $ai_ParentPos[1] + ($ai_ParentPos[3] / 2) - ($a_ViewerGUISize[1] / 2) WinMove($h_Child, '', $i_Xcord, $i_Ycord) ; move the child gui to the centre of the parent gui EndFunc ;==>_OIG_CentreGUI When switching between GUIs Func _OIG_SwitchGUI($h_NewGUI, $i_EventMode = 0, $i_DisableGUI = 0, $h_OldGUI = '') ; Change current GUI ($hwdGUI = GUI to change to, $i_EventMode = Set GUIOnEventMode option 0/1, $iDisableMain = Disable the main OI GUI 0/1) Opt('GUIOnEventMode', $i_EventMode) ; Set on event mode. GUISwitch($h_NewGUI) ; Switch control to the specified GUI. GUISetState(@SW_ENABLE, $h_NewGUI) If $i_DisableGUI Then GUISetState(@SW_DISABLE, $h_OldGUI) ; Disable the main GUI. EndFunc ;==>_OIG_SwitchGUI
    1 point
  4. ControlGetText is your friend. Saludos
    1 point
  5. Floops

    Wait until text is visible

    Wouldn't you have to put the _IEBodyReadText() into the loop aswell? Like this? Do Sleep(1000) $sText = _IEBodyReadText($oIE) ; or this? --> $sText = _IEPropertyGet("innerText") Until StringInStr($sText, 'Your text')
    1 point
  6. @anphat1995 which game is this for?
    1 point
  7. Check the returned value from FileCopy. Probably a file overwriting along with the $FC_NOOVERWRITE flag will cause the entire FileCopy command to fail (returns 0). If so, you'll have to copy the files one at a time in a loop so each file can fail without all the other files failing at the same time.
    1 point
  8. LerN, #include <Array.au3> Local $readvalue, $aSection = IniReadSectionNames(@ScriptDir & "\test.ini") For $i = 1 To UBound($aSection) - 1 $readvalue = IniReadSection("test.ini", $aSection[$i]) If $readvalue[0][0] = 1 And $readvalue[1][0] = "name" And $readvalue[1][1] = "askjfjgkjfd" Then MsgBox(0, 'Section name is', $aSection[$i]) _ArrayDisplay($readvalue, "read") EndIf Next
    1 point
  9. try this: #include <ADO_CONSTANTS.au3> ConsoleWrite($ADO_ERR_SUCCESS & @CRLF) ConsoleWrite($ADO_ERR_GENERAL & @CRLF) ;.... ConsoleWrite($ADO_ERR_RECORDSETEMPTY & @CRLF) ConsoleWrite($ADO_ERR_NOCURRENTRECORD & @CRLF)
    1 point
  10. I was looking also on $ADO_ERR_NOCURRENTRECORD ElseIf $oRecordset.bof And $oRecordset.eof Then ; no current record Return SetError($ADO_ERR_NOCURRENTRECORD, $ADO_EXT_DEFAULT, $ADO_RET_FAILURE) I make an investigation and: I found that $ADO_ERR_RECORDSETEMPTY and $ADO_ERR_NOCURRENTRECORD is only used inside of this following function: Func __ADO_Recordset_IsNotEmpty(ByRef $oRecordset) ; Error handler, automatic cleanup at end of function Local $oADO_COM_ErrorHandler = ObjEvent("AutoIt.Error", __ADO_ComErrorHandler_InternalFunction) If @error Then Return SetError($ADO_ERR_COMHANDLER, @error, $ADO_RET_FAILURE) #forceref $oADO_COM_ErrorHandler __ADO_Recordset_IsReady($oRecordset) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) ElseIf $oRecordset.bof And $oRecordset.eof Then ; no current record Return SetError($ADO_ERR_NOCURRENTRECORD, $ADO_EXT_DEFAULT, $ADO_RET_FAILURE) ElseIf $oRecordset.RecordCount = 0 Then Return SetError($ADO_ERR_RECORDSETEMPTY, $ADO_EXT_DEFAULT, $ADO_RET_FAILURE) EndIf Return SetError($ADO_ERR_SUCCESS, $ADO_EXT_DEFAULT, $ADO_RET_SUCCESS) EndFunc ;==>__ADO_Recordset_IsNotEmpty and at the end of this following function: Return SetError($ADO_ERR_RECORDSETEMPTY, $ADO_EXT_DEFAULT, $ADO_RET_FAILURE) EndFunc ;==>_ADO_Recordset_ToArray ............................................................... First let's take a look on __ADO_Recordset_IsNotEmpty() This is used in: Func _ADO_Recordset_Display(ByRef $vRocordset, $sTitle = '', $iAlternateColors = Default, $bFieldNamesInFirstRow = False) Local $vResult = $ADO_RET_FAILURE If UBound($vRocordset) Then $vResult = __ADO_RecordsetArray_Display($vRocordset, $sTitle) Return SetError(@error, @extended, $vResult) ElseIf __ADO_Recordset_IsNotEmpty($vRocordset) = $ADO_RET_SUCCESS Then Local $aRecordset_GetRowsResult = _ADO_Recordset_ToArray($vRocordset, $bFieldNamesInFirstRow) $vResult = __ADO_RecordsetArray_Display($aRecordset_GetRowsResult, $sTitle, $iAlternateColors) Return SetError(@error, @extended, $vResult) EndIf Return SetError(@error, @extended, $ADO_RET_FAILURE) ; @error and @extended returned from __ADO_Recordset_IsNotEmpty EndFunc ;==>_ADO_Recordset_Display and: Func _ADO_Recordset_Find(ByRef $oRecordset, $Criteria, $SkipRows = 0, $SearchDirection = $ADO_adSearchForward, $Start = $ADO_adBookmarkCurrent) ; Error handler, automatic cleanup at end of function Local $oADO_COM_ErrorHandler = ObjEvent("AutoIt.Error", __ADO_ComErrorHandler_InternalFunction) If @error Then Return SetError($ADO_ERR_COMHANDLER, @error, $ADO_RET_FAILURE) #forceref $oADO_COM_ErrorHandler __ADO_Recordset_IsNotEmpty($oRecordset) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) $oRecordset.Find($Criteria, $SkipRows, $SearchDirection, $Start) If @error Then Return SetError($ADO_ERR_COMERROR, @error, $ADO_RET_FAILURE) Return SetError($ADO_ERR_SUCCESS, $ADO_EXT_DEFAULT, $ADO_RET_SUCCESS) EndFunc ;==>_ADO_Recordset_Find and: Func _ADO_Recordset_ToArray(ByRef $oRecordset, $bFieldNamesInFirstRow = False) ; Error handler, automatic cleanup at end of function Local $oADO_COM_ErrorHandler = ObjEvent("AutoIt.Error", __ADO_ComErrorHandler_InternalFunction) If @error Then Return SetError($ADO_ERR_COMHANDLER, @error, $ADO_RET_FAILURE) #forceref $oADO_COM_ErrorHandler __ADO_Recordset_IsNotEmpty($oRecordset) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) ...... and: Func _ADO_Recordset_ToString(ByRef $oRecordset, $sDelim = "|", $bReturnColumnNames = True) ; Error handler, automatic cleanup at end of function Local $oADO_COM_ErrorHandler = ObjEvent("AutoIt.Error", __ADO_ComErrorHandler_InternalFunction) If @error Then Return SetError($ADO_ERR_COMHANDLER, @error, $ADO_RET_FAILURE) #forceref $oADO_COM_ErrorHandler __ADO_Recordset_IsNotEmpty($oRecordset) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) ..... of course this following function: Func _ADO_Execute(ByRef $oConnection, $sQuery, $bReturnAsArray = False, $bFieldNamesInFirstRow = False) ...... If $bReturnAsArray Then Local $aRecordsetAsArray = _ADO_Recordset_ToArray($oRecordset, $bFieldNamesInFirstRow) Return SetError(@error, @extended, $aRecordsetAsArray) EndIf ....... also use __ADO_Recordset_IsNotEmpty() but only in case when you want to get Array as a result. This is very important to check for $ADO_ERR_RECORDSETEMPTY and $ADO_ERR_NOCURRENTRECORD before any function will try to return array. If SQL / ADO is not get any data from data store then you can not get as a result any type of array, for this case this two $ADO_ERR_... Is essential. Of course this is not needed when you want to get Recordset as an $oRecordset I mean object , but each time when you want to get result as a variables you should check if recordset is not empty and has any current record. So IMHO each time one of this functions: _ADO_Recordset_ToArray() _ADO_Recordset_ToString() is called then this should be checked . The same calling: _ADO_Recordset_Find() it is important to use: __ADO_Recordset_IsNotEmpty($oRecordset) before using Find methode on Recordset object. ............................................................... as to this case: Return SetError($ADO_ERR_RECORDSETEMPTY, $ADO_EXT_DEFAULT, $ADO_RET_FAILURE) EndFunc ;==>_ADO_Recordset_ToArray this should be rethinked ..... ............................................................... I hope my statement is clear and consistent. If anybody finds mistakes in my reasoning I will gladly listen to the arguments. Regards, mLipok
    1 point
  11. Helpfile is pretty clear: Jos
    1 point
  12. MattyD

    DLL calls

    Well done Andreik! I hope this clarifys things a bit. Ilendros, If you can follow this code WlanGetAvailableNetworkList should be a doddle. Cheers, Matt local $hDLL = DllOpen("wlanapi.dll"), $aResult, $hClientHandle, $pInterfaceList, _ $tInterfaceList, $iInterfaceCount, $tInterface, $pInterface, $tGUID, $pGUID $aResult = DllCall($hDLL, "dword", "WlanOpenHandle", "dword", 2, "ptr", 0, "dword*", 0, "hwnd*", 0) If @error Or $aResult[0] Then ConsoleWrite("WlanOpenHandle Failed" & @CRLF) Exit EndIf $hClientHandle = $aResult[4] $aResult = DllCall($hDLL, "dword", "WlanEnumInterfaces", "hwnd", $hClientHandle, "ptr", 0, "ptr*", 0) If @error Or $aResult[0] Then ConsoleWrite("WlanEnumInterfaces Failed" & @CRLF) Exit EndIf $pInterfaceList = $aResult[3] ;pointer to WLAN_INTERFACE_INFO_LIST. This is where the struct is in memory. ;The WLAN_INTERFACE_INFO_LIST structure contains two dwords followed by an array of WLAN_INTERFACE_INFO structures. ;~ DWORD dwNumberOfItems; ;~ DWORD dwIndex; ;~ WLAN_INTERFACE_INFO InterfaceInfo[]; ;The first dword defines how many interfaces are in the list - this is all we are interested in for the minute. $tInterfaceList = DllStructCreate("dword", $pInterfaceList) $iInterfaceCount = DllStructGetData($tInterfaceList, 1) If Not $iInterfaceCount Then ConsoleWrite("no interfaces were found" & @CRLF) Exit EndIf Local $abGUIDs[$iInterfaceCount] ;The next thing we need to do is find out more about a WLAN_INTERFACE_INFO structure. ;~ GUID InterfaceGuid; ;~ WCHAR strInterfaceDescription[256]; ;~ WLAN_INTERFACE_STATE isState; ;we know what a WCHAR is, but what about GUID and WLAN_INTERFACE_STATE types?. ;from MSDN we can see the GUID data type is actually a structure in itself. ;~ DWORD Data1; ;~ WORD Data2; ;~ WORD Data3; ;~ BYTE Data4[8]; ;We dont really care what each element contains - however we do need the size of a GUID struct. 4 + 2 + 2 + (8 x 1) = 16 bytes ;WLAN_INTERFACE_STATE is an enumeration. In other words it is just an integer. ;So now we know a WLAN_INTERFACE_INFO struct is 532 bytes in size. 16 + (256 * 2) + 4. ;This means we can pinpoint the location of every WLAN_INTERFACE_INFO struct in WLAN_INTERFACE_INFO_LIST ;the first will be offset 8 bytes to $pInterfaceList (dwNumberOfItems + dwIndex) ;the second (if there is one) will be offset 540 bytes to $pInterfaceList (dwNumberOfItems + dwIndex + WLAN_INTERFACE_INFO) and so on. For $i = 0 To $iInterfaceCount - 1 $pInterface = Ptr(Number($pInterfaceList) + ($i * 532 + 8)) ;Find pointer to WLAN_INTERFACE_INFO struct. $tInterface = DllStructCreate("byte GUID[16]; wchar descr[256]; int State", $pInterface) $abGUIDs[$i] = DllStructGetData($tInterface, "GUID") ConsoleWrite("Found: " & DllStructGetData($tInterface, "descr") & @CRLF) Next ;We dont need the WLAN_INTERFACE_INFO_LIST struct anymore. we should free the memory that our program has gobbled up. DllCall($hDLL, "dword", "WlanFreeMemory", "ptr", $pInterfaceList) ;So now we have an array of all the GUIDs the WlanEnumInterfaces has found. ;We need to choose the interface we want to work with and throw it back into memory (because other funtions need a pointer to a GUID - not a GUID). ;I will choose the first interface. $tGUID = DllStructCreate("byte[16]") DllStructSetData($tGUID, 1, $abGUIDs[0]) $pGUID = DllStructGetPtr($tGUID) ;We now have our GUID pointer! ;Finish things off properly. DllCall($hDLL, "dword", "WlanCloseHandle", "ptr", $hClientHandle, "ptr", 0); second param is reserved DllClose($hDLL)
    1 point
  13. DW1

    AUTOIT Logging

    Oh I wasn't aware you were trying to get a return from a command prompt... There is no reason to use Send() for this. You can use run() to send commands to a command prompt (cmd.exe) and StdoutRead() to grab the returned data. You can also just pipe out the return to a text file through cmd, but for the sake of autoit doing all the logging, I made this example: #include <Constants.au3> #include <date.au3> CMDAndLog('winrm', -1, True) CMDAndLog('winrm help remoting', -1, True) CMDAndLog('winrm help switches', -1, True) Func CMDAndLog($Data, $FileName = -1, $TimeStamp = False) If $FileName == -1 Then $FileName = @ScriptDir & '\Log.txt' $hCMD = Run(@ComSpec & " /c " & $Data, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $Return While 1 $Return &= StdoutRead($hCMD) If @error Then ExitLoop WEnd $Return = StringReplace($Return, @CR, @CRLF & @TAB); Place a tab in each line of the output for a nicer log format $hFile = FileOpen($FileName, 1) If $hFile <> -1 Then If $TimeStamp = True Then $Data = @CRLF & _Now() & ' - ' & $Data & @CRLF & 'Output: ' & $Return FileWriteLine($hFile, $Data) FileClose($hFile) EndIf EndFunc ;==>CMDAndLog
    1 point
×
×
  • Create New...