Leaderboard
Popular Content
Showing content with the highest reputation on 04/24/2019 in all areas
-
Connecting with a VBA/COM or .NET API
water and 3 others reacted to jantograaf for a topic
You're all heroes, truly! Thanks a lot! I got this to work, so I'll build from that example to implement what I need in my code. Thanks, @Danyfirex! And of course, a lot of gratitude as well for @Earthshine and @water and @TheXman for getting this discussion going! 😍4 points -
Hello. my two cents... #include <MsgBoxConstants.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ;Register AutoIt Error handler Global $oObject = ObjCreate("JustRemotePhone.RemotePhoneService.ApplicationFactory") ;Create Main object ConsoleWrite("-oObject: " & IsObj($oObject) & @CRLF) Global $oApplication = $oObject.CreateApplication("AutoIt Client") ;Create Application If Not IsObj($oApplication) Then Exit MsgBox($MB_ICONERROR, "Error", "Unable to Create 'Remote Phone Call' Instance") EndIf Global $sNumber = InputBox("Add a number to be Called", "Phone Number", "") If Not $sNumber Then Exit MsgBox($MB_ICONINFORMATION, "Error", "Phone Number is Emtpy Script will Exit.") $oApplication.BeginConnect(True) ;Begin Connection ;You probably will need to grant accest to the application at this point. Global $oPhone = $oApplication.Phone ;Create Phone Object ConsoleWrite("-oPhone: " & IsObj($oPhone) & @CRLF) ;Call $oPhone.Call($sNumber) $oApplication.BeginDisconnect() ;End Connection ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> 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 PD: Can't load syntaxhighlighter Cuz My Connection is too slow. So I'll update it later. Saludos3 points
-
OutlookTools: Import/Export from/to iCal/vCard/CSV
argumentum and one other reacted to water for a topic
Next step: Export events and contacts to iCal and vCard files. The function will export a single event/contact when you pass a single event/contact object or EntryID. The function will export a list of events/contacts when you pass an array with event/contact objects or EntryIDs. The export will create a single file or a new file for every event/contact in a specified directory. Anything else you would like to see in this functions?2 points -
Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team2 points
-
Connecting with a VBA/COM or .NET API
Earthshine and one other reacted to TheXman for a topic
According to the OleView image above, the object name should be "JustRemotePhone.RemotePhoneService.ApplicationFactory". What I usually look for when trying to figure out what the object name should be, is the ProgID or the VersionIndependentProgID if it has one. The following example appears to successfully create the application object for me. If you change "ApplicationFactory" back to just "Application" and run the example, you will see that it fails with an invalid class string error (as I think was stated earlier). #include <Constants.au3> example() Func example() Local $oComErr, $oApp $oComErr = ObjEvent("AutoIt.Error", "com_error_handler") $oApp = ObjCreate("JustRemotePhone.RemotePhoneService.ApplicationFactory") If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", $oComErr.WinDescription) MsgBox($MB_ICONINFORMATION, "INFO", "Application object successfully created!") EndFunc Func com_error_handler($oError) Return EndFunc2 points -
I've made this HTTP lib to simplify HTTP requests, mainly when dealing about POST data or file uploads. Three functions are available: string _HTTP_Get ( string $sURL ) string _HTTP_Post ( string $sURL , string $sPostData ) string _HTTP_Upload ( string $sURL , string $sFilePath , string $sFileField , string $sPostData = '' , string $sFilename = Default) Additionaly, two helper functions are also available: URLEncode($sStr) URLDecode($sStr) Full documentation: https://github.com/jesobreira/HTTP.au3/blob/master/README.md Fork me on Github: https://github.com/jesobreira/HTTP.au3 Download lib + docs: https://github.com/jesobreira/HTTP.au3/archive/master.zip1 point
-
MySQL UDFs using libmysql.dll functions: most functions from MySQL API all are prefixed with an underscore: _MySql... e.g.: _MySQL_Real_Query( sometimes parameters are chaged - read function descriptions in include file MySQL.au3 If you do not need the power of these UDFs and you simple want to use basic SQL commands, then have a look at not included: MySQL_Connect - This function is deprecated. Use _MySQL_Real_Connect instead. MySQL_Create_DB - This function is deprecated. Use mysql_query() to issue an SQL CREATE DATABASE statement instead. MySQL_Drop_DB - This function is deprecated. Use mysql_query() to issue an SQL DROP DATABASE statement instead. MySQL_Escape_String - You should use _mysql_real_escape_string() instead! MySQL_Kill - This function is deprecated. Use mysql_real_query() to issue an SQL KILL statement instead mysql_library_end - Called by _MySQL_EndLibrary. mysql_library_init - Called by _MySQL_InitLibrary. I included a fallback-libmysql.dll: yoou can include libMySQLDLL.au3 and set $Use_EmbeddedDLL=True when calling _MySQL_InitLibrary an example for XAMPP / cdcol is also included in ZIP. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 (beta) Author: Prog@ndy Script Function: MySQL-Plugin Demo Script #ce ---------------------------------------------------------------------------- #include <array.au3> #include "mysql.au3" ; MYSQL starten, DLL im PATH (enthält auch @ScriptDir), sont Pfad zur DLL angeben. DLL muss libmysql.dll heißen. _MySQL_InitLibrary() If @error Then Exit MsgBox(0, '', "could nit init MySQL") MsgBox(0, "DLL Version:",_MySQL_Get_Client_Version()&@CRLF& _MySQL_Get_Client_Info()) $MysqlConn = _MySQL_Init() ;Fehler Demo: MsgBox(0,"Error-demo","Error-Demo") $connected = _MySQL_Real_Connect($MysqlConn,"localhostdfdf","droot","","cdcol") If $connected = 0 Then $errno = _MySQL_errno($MysqlConn) MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn)) If $errno = $CR_UNKNOWN_HOST Then MsgBox(0,"Error:","$CR_UNKNOWN_HOST" & @LF & $CR_UNKNOWN_HOST) Endif ; XAMPP cdcol MsgBox(0, "XAMPP-Cdcol-demo", "XAMPP-Cdcol-demo") $connected = _MySQL_Real_Connect($MysqlConn, "localhost", "root", "", "cdcol") If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn)) $query = "SELECT * FROM cds" $mysql_bool = _MySQL_Real_Query($MysqlConn, $query) If $mysql_bool = $MYSQL_SUCCESS Then MsgBox(0, '', "Query OK") Else $errno = _MySQL_errno($MysqlConn) MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn)) EndIf $res = _MySQL_Store_Result($MysqlConn) $fields = _MySQL_Num_Fields($res) $rows = _MySQL_Num_Rows($res) MsgBox(0, "", $rows & "-" & $fields) ; Access2 1 MsgBox(0, '', "Access method 1- manual") Dim $array[$rows][$fields] For $k = 1 To $rows $mysqlrow = _MySQL_Fetch_Row($res,$fields) $lenthsStruct = _MySQL_Fetch_Lengths($res) For $i = 1 To $fields $length = DllStructGetData($lenthsStruct, 1, $i) $fieldPtr = DllStructGetData($mysqlrow, 1, $i) $data = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1) $array[$k - 1][$i - 1] = $data Next Next _ArrayDisplay($array) ; Access 2 MsgBox(0, '', "Access method 2 - row for row") _MySQL_Data_Seek($res, 0) ; just reset the pointer to the beginning of the result set Do $row1 = _MySQL_Fetch_Row_StringArray($res) If @error Then ExitLoop _ArrayDisplay($row1) Until @error ; Access 3 MsgBox(0, '', "Access method 3 - read whole result in 2D-Array") $array = _MySQL_Fetch_Result_StringArray($res) _ArrayDisplay($array) ; fieldinfomation MsgBox(0, '', "Access fieldinformation") Dim $arFields[$fields][3] For $i = 0 To $fields - 1 $field = _MySQL_Fetch_Field_Direct($res, $i) $arFields[$i][0] = _MySQL_Field_ReadValue($field, "name") $arFields[$i][1] = _MySQL_Field_ReadValue($field, "table") $arFields[$i][2] = _MySQL_Field_ReadValue($field, "db") Next _ArrayDisplay($arFields) ; free result _MySQL_Free_Result($res) ; Close connection _MySQL_Close($MysqlConn) ; exit MYSQL _MySQL_EndLibrary() MySQL UDf Downloads: (including x86 and x64)</array.au3>1 point
-
WinHttp.au3: #include-once Global Const $HTTP_STATUS_OK = 200 Func HttpPost($sURL, $sData = "") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("POST", $sURL, False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($sData) If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc Func HttpGet($sURL, $sData = "") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", $sURL & "?" & $sData, False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.Send() If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc Example 1: #include "WinHttp.au3" Global $MD5 = HttpPost("http://www.afk-manager.ir/test/post.php", "password=WeWantThisAsMd5") MsgBox(64, "MD5", $MD5) Example 2: #include "WinHttp.au3" Global $sGet = HttpGet("http://www.google.com/") FileWrite("Google.txt", $sGet) Speed compare: [WinHttp.WinHttpRequest.5.1 GET] 1 = 422.961162765649 2 = 455.738280639636 3 = 441.821516504421 4 = 390.538648365335 Total = 1711.059608275041 Average = 427.7649020687603 [WinHttp.WinHttpRequest.5.1 POST] 1 = 826.436200956633 2 = 872.366642546045 3 = 871.266802895081 4 = 875.792832686324 Total = 3445.862479084083 Average = 861.4656197710208 [HTTP UDF GET] 1 = 984.282912132673 2 = 813.896511915435 3 = 781.158836566862 4 = 791.901235916364 Total = 3371.239496531334 Average = 842.8098741328335 [HTTP UDF POST] 1 = 788.734835486743 2 = 975.688234142967 3 = 785.810779035388 4 = 847.537193542955 Total = 3397.771042208053 Average = 849.4427605520133 [InetRead GET] 1 = 672.120733570292 2 = 595.221462195098 3 = 561.122261209642 4 = 738.180516302658 Total = 2566.64497327769 Average = 641.6612433194225 Tests result: Server 2003 32bit OK Server 2003 64bit Not Tested Server 2008 32bit Not Tested Server 2008 64bit OK XP 32bit OK XP 64bit Not Tested Vista 32bit Not Tested Vista 64bit Not Tested 7 32bit OK 7 64bit OK 8 32bit OK 8 64bit OK Are you interested? Check this out: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384106(v=vs.85).aspx1 point
-
You should use OnEvent Mode, allowing you to have the main script running outside the message loop. Else, any processing inside a Case of the msg loop is trapping code flow there until the code reaches end of Case (or function Start() returns in your example). Spurious Exit lines in code snippet. Also you don't need to explicitely declare array bounds: Local $MyArray = [1, 2, 3]1 point
-
I've assumed that all Windows 10 PCs are at least updated to feature update 1803. So I've assumed that a feature update has been postponed for a maximum of one year. I think it's a reasonable assumption. On your Windows 10 1607, you're getting errors on objects that require a higher windows 10 update. You can use the version here, which is the latest version before the Windows 8, 8.1 and 10 update: The zip-file has been moved to bottom of first post.1 point
-
OutlookTools: Import/Export from/to iCal/vCard/CSV
water reacted to argumentum for a topic
I like what you are doing even if I haven't need it. But surely is a god-sent when is needed. So thank you for working on it1 point -
Connecting with a VBA/COM or .NET API
Danyfirex reacted to Earthshine for a topic
yeah, that should do it! i was thinking along those lines after looking at the VBA example1 point -
Connecting with a VBA/COM or .NET API
Earthshine reacted to jantograaf for a topic
Yeah, I can connect the ApplicationFactory-object as well, without any issues, but this ApplicationFactory-object is mentioned nowhere in RemotePhone's API. So, I contacted them to see what possibilities there are to get this to work. If I find out more, I'll post it here... Greetings!1 point -
WM_Mousemove not moving
badcoder123 reacted to Zedna for a topic
Look at function ControlGetHandle()1 point -
Yes, it will set @error if the child process is still running, the way how it works is that the child process has a handle to write to stdout, if the child closes it, then StdOutRead will set @error because the stream has been closed. The more technically accurate explanation is that, to read the stdout of a child process, you will have to use the ReadFile/ReadFileEx function. The child can use the CloseHandle function on its write handle without exiting, this will make the ReadFile function in the parent return an ERROR_BROKEN_PIPE error, which means that the other end of the "pipe" (write handle) has been closed. More details from the documentation: That is how StdOutRead would detect EOT/EOL and set @error and how the child could still well be running Though I should mentioned that it is rare for programs to close their stdout write handle without following up with an exit, but still a thing to note That is perfectly fine to do as well, I was just trying to provide a more generic loop, it is meant to be adjusted to your needs... like how in this case it might be a good idea to detect the elapsed time and exit the loop when it reaches 01 point
-
Unless you know something that I don't know, there is no way StdOutRead will set @error if the child process is still running. As you can see with BetaLeaf, he found a way to identify EOT by checking the string "Elapsed time". Then the script can exit the reading loop to continue its work. That is exactly what I was referring to.1 point
-
If StringRight ($sOutput, ??) = "Something" Then ExitLoop ; this is the tricky part, you need to find a way to know <End of Transmission> @Nine This is nice to have, but not needed to detect EOT or EOL at all, since StdOutRead should set @error if the child has ended the transmission by closing the stream1 point
-
Sample code creation through Sample code main menu The Sample code main menu is used for Sample code creation. Much more code can be created through the menu than through the Detail info listview page. In addition, the menu can be used to set Sample code options and for Sample code maintenance. Menu items with a 3-point ending opens an intermediate listview page. These pages works in the same way as the Detail info listview page. Select one or more rows and right-click to create Sample code. Unlike the Detail info page, rows can be selected in several sections at once. The upper part of the menu through Sleep(1000) creates common Sample code. Code snippets... adds functions and code sections to solve tasks of a more specific nature. If the Check error setting is off, the Check error menu can be used to add error checking as needed. Corrections adds a list of necessary and optional corrections to the code. In the Options menu, settings can be turned on/off. The lower part of the menu is about Sample code maintenance. The Help system includes a review of the menu items.1 point
-
Slider control - jump to next tick
abberration reacted to UEZ for a topic
Here a another way using windows messaging. #include <GUIConstantsEx.au3> #include <GuiSlider.au3> #include <WindowsConstants.au3> #include <GuiSlider.au3> #include <GuiEdit.au3> Global $TicArray[7] = [0, 5, 30, 50, 70, 90, 100] Local $oldpos = MouseGetPos(0) ; Create GUI $hGUI = GUICreate("Slider Set Tic", 400, 296) $iSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_BOTH, $TBS_ENABLESELRANGE)) $hSlider = GUICtrlGetHandle($iSlider) $edit = GUICtrlCreateEdit("--", 50, 50) GUISetState() _GUICtrlSlider_ClearTics($iSlider) ; Set Tics ArrayTicks($TicArray, $iSlider) Global $iSliderPos = 0, $iPos = 0, $iPosOld = -1, $bUpdate = False GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;~ Case $iSlider ;~ While $iSlider ;~ Local $mPos = MouseGetPos(0) ;~ If $oldpos < $mPos Then ;~ _GUICtrlEdit_SetText($edit, "moving right") ;~ ;$oldpos = $mPos ;~ ;ExitLoop ;~ ElseIf $oldpos > $mPos Then ;~ _GUICtrlEdit_SetText($edit, "moving left") ;~ ;$oldpos = $mPos ;~ ;ExitLoop ;~ EndIf ;~ Sleep(250) ;~ $oldpos = $mPos ;~ ExitLoop ;~ WEnd EndSwitch WEnd Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $i, $c, $d = 0xFFFFFF, $p Switch $lParam Case $hSlider $iPos = _GUICtrlSlider_GetPos($hSlider) For $i = 0 To UBound($TicArray) - 1 $c = Abs(1 - (($TicArray[$i] + 1) / ($iPos + 1))) If $c < $d Then $d = $c $p = $i EndIf Next _GUICtrlSlider_SetPos($hSlider, $TicArray[$p]) EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL ; Create array tics Func ArrayTicks($array, $CurrentSlider) Local $iMax = UBound($array), $i For $i = 0 To $iMax - 1 _GUICtrlSlider_SetTic($CurrentSlider, $array[$i]) Next EndFunc ;==>ArrayTicks I know that the arrow keys are not working this way. Maybe I will find a solution for this... Br, UEZ1 point -
How to return two values from a function
AndrewSchultz reacted to jefhal for a topic
I'm embarrassed to show this code, but I need help in getting the function to return two values (the mac id and the value of $j): #include-once #include <array.au3> #include <Constants.au3> ;_GetMacIDs("sysl025"); unremark this line for testing from Scite Func _GetMacIDs($strComputer) dim $onemac, $pid dim $x = 0, $y = 6, $i = 0, $j = 0 dim $lineIPC[16], $onlyMacs[1], $MacID[3], $splitIPC[100] Global $cmdOUT Global $rawIPC, $Exprss dim $rawExprss Global $description, $NewDesc dim $i, $j, $lineIPC, $cancel Global $MacDesc = "" dim $rawPing, $rawST, $ServTag Global $MacID dim $MacIDsReturn[4] ClipPut("") ToolTip("Getting MacID's of target computer") ;;; Check to see if machine is online $var = Ping($strComputer,250) If $var Then; if $var was not equal to zero --- also possible: If @error = 0 Then ... $PID = run(@comspec & ' /c ' & "\\student2\apps$\_bin\utils\psexec.exe \\" & $strComputer & " ipconfig /all","","",$STDOUT_CHILD) MsgBox(1,"$PID for ping=",$PID) $cmdOUT = StdoutRead($PID) $rawIPC = $cmdOUT MsgBox(1,"$cmdOUT=",$rawIPC) $splitIPC = StringSplit($cmdOUT,@CRLF) MsgBox(1,"$splitIPC[0]=",$splitIPC[0]) While $x < $splitIPC[0] if StringInStr($splitIPC[$x],"Phys") <> "0" Then $onemac = StringStripCR(StringStripWS(StringLeft(StringTrimLeft($splitIPC[$x],StringInStr($splitIPC[$x],":")),18),8)) MsgBox(1,"onemac=",$onemac) if StringInStr($splitIPC[$x-2],"wireless",0) or StringInStr($splitIPC[$x-2],"wlan",0) then $onemac = $onemac & " WLAN" ReDim $onlyMacs[$i + 1] _ArrayAdd($onlyMacs,$onemac) _ArrayDisplay($onlyMacs,"Now onlymacs is:") $i = $i + 1 EndIf $x = $x + 1 WEnd ;;; Tidy up the results and send them to the clipboard with formatting ;ToolTip("Cleaning up the variables and concatenating them") _ArraySort($onlyMacs,1) _ArrayPop($onlyMacs) if $i > 1 and StringInStr($onlyMacs[1],"WLAN") then _ArraySwap($onlyMacs[0],$onlyMacs[1]) ;_ArrayDisplay($onlyMacs,"Here are all of the MacIDs:") While $j < $i $MacID[$j] = $onlyMacs[$j] tooltip($onlyMacs[$j]) sleep(3000) $j = $j + 1 ;MsgBox(1,"$MacDesc and $j = ",$MacDesc & " " & $j) WEnd MsgBox(1,"$MacID=",$MacID[$j-1] & " " & $j-1) Return $MacID[$j-1] $MacID[$j] = $j Return $MacID[$j] Else Msgbox(0,"Status","An error occured with number: " & @error) Exit EndIf Exit EndFunc Here's the script that I'm using (not successfully) to get the two values out of the function above: #include <GetMacIDs.au3> dim $var[5] $strcomputer = "sys0298" $var[5] = _GetMacIDs($strcomputer) MsgBox(1,"Returned value =",$var) Sleep(5000) Ugly, but works (up to a point). By the way, if your computer has two mac id's (or more) this function should return all of those values...1 point -
How to return two values from a function
AndrewSchultz reacted to Uten for a topic
You could also use one or two ByRef variables. Func _GetMacID($computer, ByRef $retMacID, ByRef $retI) $retMacID = "00-00-01-00" $retI = 3 EndFunc MsgBox(1, "Test _GetMacID","$retMacID:=" & $retMacID & ", $retI:=" & $retI) Regards Uten1 point -
How to return two values from a function
AndrewSchultz reacted to is8591 for a topic
It is a little above me too but Return can only have 1 parameter, soeither do Return($strcomputer & "*" & $j) where * could be any character that does not exist normally in the data ( I often use "μ" from character map) and in your main code split string on this character. or pass array by ref and let function modify the array1 point