Leaderboard
Popular Content
Showing content with the highest reputation on 05/25/2019 in all areas
-
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
-
OnAutoItExitRegister questions
argumentum reacted to BrewManNH for a topic
I don't understand at all what you're trying to say here, or in the comments in your script. BTW, script writers are programmers, don't sell yourself short.1 point -
therefore, the use of Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & ... does not generate a detached process, but in this case, it generates a process that is "child" and still connected to the main script (I thought it was not so). it seems however that using ShellExecute () instead of run (), generates a detached and independent process from the main script. Good to know... here a working version of the WatchDog that works as expected (at least as expected by me) so that if you force the close of the main scipt, the WatchDog still runs and acts as it was programmed to do #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #pragma compile(AutoItExecuteAllowed, true) Local $hPid = ShellExecute('notepad.exe') _WatchDog_OnAutoItExitRegister() MsgBox(0, "Demo", "press ok to exit (and let notepd be closed by the watchdog)") Func _WatchDog_OnAutoItExitRegister() ; prepare the "On exit" script (it must stay all in one line) Local $sCommand = "Local $WatchDog = ProcessWaitClose($CmdLine[1]), $Dummy = ProcessClose($CmdLine[2]) + MsgBox(0,'WatchDog','All done! ... woof woof!' )" ; adjust quotes if needed ;https://www.autoitscript.com/forum/topic/181491-question-about-autoit3executeline/?do=findComment&comment=1303199 $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' ; unleash the "WatchDog" ; the @AutoItPID passed here is the Pid of the "main" script (not the pid of the detached script) ; Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand & ' ' & @AutoItPID & ' ' & $hPid) ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand & ' ' & @AutoItPID & ' ' & $hPid, '', '', @SW_HIDE) EndFunc ;==>_WatchDog_OnAutoItExitRegister1 point
-
So make one exe with all functionality and based on parameter it can start itself and call the function you indicate by parameter. You are having focus to much on your solution instead of detailing requirements. This way its hard to give you a good direction on a solution. Same exe starting many times from itself calling another function shouldnt be that difficult.1 point
-
Script only runs script for first 100 Elements in ARRAY
Earthshine reacted to Jos for a topic
@Earthshine, So what do you really think about this topic? You could choose to do like I do, just ignore the topic when people aren't prepared to being helped. Jos1 point -
OnAutoItExitRegister questions
MattHiggs reacted to argumentum for a topic
; *** Start added by AutoIt3Wrapper *** #include <AutoItConstants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.15.0 (Beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ReRun() ; ugly fix Func ReRun() If Not @Compiled Then ConsoleWrite(@CRLF & @CRLF & @CRLF & "!!! compile to run the example !!!" & @CRLF & @CRLF & @CRLF & @CRLF) Exit 0 EndIf If Not StringInStr($CmdLineRaw, "/ErrorStdOut") Then WinSetState(@ScriptFullPath, "", @SW_HIDE) Local $errorlevel = ShellExecuteWait(@ScriptFullPath, "/ErrorStdOut " & $CmdLineRaw) Do ProcessClose ( "notepad.exe" ) Until Not ProcessExists ( "notepad.exe" ) Exit $errorlevel EndIf EndFunc ;~ OnAutoItExitRegister ( "endproc" ) ; replaced by ugly fix ShellExecute ( "notepad.exe" ) $text = 0 WinActivate(@ScriptFullPath) Do $text = $text + 1 ConsoleWrite('loop # ' & $text & ' of 10'& @CRLF) ; Do stuff Sleep(2000) Until $text = 10 ; Do more stuff here Func endproc () Do ProcessClose ( "notepad.exe" ) Until Not ProcessExists ( "notepad.exe" ) EndFunc Same here. If I close the compiled script it does not behave has expected. But you could write a watchdog that'll do the work of OnAutoItExitRegister() when you exit =/1 point -
Using Python scripting in AutoIT
Earthshine reacted to JLogan3o13 for a topic
Why would you want to? If you're writing Python, write Python. If you're writing AutoIt, write AutoIt. If you have a situation where you simply cannot get away from mixing and matching languages (doubtful) a little more explanation would be wonderful.1 point -
Script only runs script for first 100 Elements in ARRAY
Earthshine reacted to BrewManNH for a topic
Good luck with that, might need WikiLeaks to get anything useful to work with.1 point -
Thank you that was perfect. In case anyone else runs into a similar issue here is the working code. #include "CUIAutomation2.au3" Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window --- ConsoleWrite( "--- Find window ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "XenDesktop 7.6.300", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Children, $pCondition0, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find control --- ConsoleWrite( "--- Find Control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Next", $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pButton1, $oButton1 $oWindow1.FindFirst( $TreeScope_Children, $pCondition1, $pButton1 ) $oButton1 = ObjCreateInterface( $pButton1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oButton1 ) Then Return ConsoleWrite( "$oButton1 ERR" & @CRLF ) ConsoleWrite( "$oButton1 OK" & @CRLF ) Local $pInvoke, $oInvoke $oButton1.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() EndFunc1 point
-
1 point
-
TYPELIB Viewer
argumentum reacted to trancexx for a topic
So, what's this? It's a tool-script you would use when you want to know details about specific type libraries. There are some tools available on the net for the job. None written in AutoIt (take this conditionally and search for posts made by doudou). That made me wonder how hard it would be to write one from the scratch. Turned to be very demanding. TypeLib format is not officially or publicly available, at least not to my knowledge. Doing the research I found what's called The Unofficial TypeLib Data Format Specification. Sort of a must read when it comes to understanding the organization of typelib format. Script I'm posting here is written solely upon that document. I must also say that I had to do few modifications of some fields because of found inconsistencies in order to get correct readings. Also I'm doing few deliberate shortcuts mostly because of incomplete description within theircorp's document. What's covered is MSFT type of TypeLib. This obviously means there are more types. Actually one more, called SLTG TypeLib, but this one is very rare (probably less than 1/100 of all TypeLibs). GUI will certainly look familiar if you have run some of the scripts I posted recently. This time it's a wrapper for edit control. Main function is called _TLB_TypelibMSFT(). Everything else inside script serves it. What to learn from it? DllStruct manipulation maybe. But who wants that? Script: TLBViewer.au3 Try AutoItX3.dll or wscript.exe or winhttp.dll or shell32.dll or thousand more to see what this really is. Object(s) some more.1 point