Leaderboard
Popular Content
Showing content with the highest reputation on 09/06/2021 in all areas
-
@StartUpCommonDir -- internal logic
argumentum reacted to CarlD for a topic
I'll see if I can get some more details about his OS. And I'm not suggesting that @StartUpCommonDir ever points to a non-existent directory (clearly that would be a problem!) -- although in my tester's system @StartUpDir does not exist, which is why I modified the script to fall back to @StartUpCommonDir in that case. My question really relates to documenting my script. I could say, "If '{systemdrive}:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup' does not exist on your system, the file will be saved to the directory identified by AutoIt's @StartUpCommonDir macro", but that would not provide meaningful information for AutoIt-unaware users. I'd like to document the fallback directory more concretely -- hence my question.1 point -
You can't have the following in AlwaysMatch if you are also going to place it in FirstMatch -- "browserName":"firefox", "acceptInsecureCerts":true With the FirstMatch section calling for "browserName":"test", it can never combine with the AlwaysMatch settings of "browserName":"firefox". I haven't tested this, but I hope you will get the idea -- Func _Example_Danp2() Local $s_My_Profile_Dir = @ScriptDir & '\WD_Testing_Profile' _WD_Capabilities_Startup() _WD_Capabilities_CreateObject('alwaysMatch', '') _WD_Capabilities_Capability('acceptInsecureCerts', True) _WD_Capabilities_CreateObject('firstMatch', 'firefox') _WD_Capabilities_Capability('browserName', 'firefox') _WD_Capabilities_Argument('-profile') _WD_Capabilities_Argument($s_My_Profile_Dir) _WD_Capabilities_CreateObject('firstMatch', 'chrome') _WD_Capabilities_Capability('browserName', 'chrome') .... .... .... _WD_Capabilities_ToConsole(@ScriptLineNumber) Local $s_Desired_Capabilities = _WD_Capabilities_GetPretty() EndFunc1 point
-
That's the problem with pointers: whatever rock-solid vault you save it in, the "thing" the pointer points to (a block of memory) has to be kept alive until further use of the pointer, else anything bad can happen. I don't recall that AutoIt uses a garbage collector. I believe the allocated block is just returned to the system. If you allocate a much larger block, an exception almost always results because the system is more likey to require an allocation fitting the hole made by releasing the initial block. For $i = 1 To 5 Test() Next Func Test() Local $pStruct = DllStructGetPtr(CreateStruct()) ConsoleWrite($pStruct & @CRLF) Local $tStruct = DllStructCreate('wchar Test[1000000];', $pStruct) ConsoleWrite('Value: ' & $tStruct.Test & @CRLF & @CRLF) EndFunc Func CreateStruct() Local $tStruct = DllStructCreate('wchar Test[1000000];') ConsoleWrite(DllStructGetPtr($tStruct) & @CRLF) DllStructSetData($tStruct, 'Test', 'test') Return $tStruct EndFunc Yields an access violation at the second loop every time I ran it: 0x05F97020 0x05F97020 !>13:40:26 AutoIt3.exe ended.rc:-10737418191 point
-
DllStructs strange behavior
Andreik reacted to JockoDundee for a topic
IMHO, and without knowing AutoIt internal Implementation details, I think what’s happening is due to the $tStruct going out of scope - with its reference count=0, that’s why saving it works. The randomness may just be due to the timing of garbage collection or whatever memory cleanup AutoIt does on $tStruct. If it runs async, then anything is possible.1 point -
DllStructs strange behavior
JockoDundee reacted to spudw2k for a topic
I feel like the DLLStructCreate in Test() is stomping over the struct you create in the CreateStruct() function, but I can't explain what is happening. Can't you just use the struct as returned from CreateStruct()? For $i = 1 To 15 Test() Next Func Test() Local $tStruct = CreateStruct() ConsoleWrite('Value: ' & $tStruct.Test & @CRLF & @CRLF) EndFunc Func CreateStruct() Local $tStruct = DllStructCreate('char Test[4];') DllStructSetData($tStruct, 'Test', 'test') Return $tStruct EndFunc What is the bigger picture?1 point -
@jugador I was finally able to resolve the issue by passing an additional flag to _WinHttpOpenRequest when connecting to a secure site. 🎉😅1 point
-
How to make an au3-code-Test-Tool by using 'AutoIt3.exe' ?
Letraindusoir reacted to junkew for a topic
Did you read the note in the help file Note that either Call() or the called function can set the @error flag. If Call() sets the @error flag, the value will be 0xDEAD and @extended will also be set to 0xBEEF. See the example for a demonstration of testing for a function that was not found. I only see 3 solutions to do what you want but probably its not easy and leads to writing your own lexer/parser 1. Mix the call, assign, execute and eval functions call("_IENavigate",$oIE,"https://www.autoitscript.com/forum/") consolewrite("Execute @error = " & @error & @CRLF) I think the assign, execute and eval where not made to also call functions although I am not sure. As you can see this does not work (and as such your coding neither) execute('_IENavigate($oIE,"https://www.autoitscript.com/forum/"') consolewrite("Execute @error = " & @error & @CRLF) see example at bottom based on your code extended with consolewrite, msgbox as a base starting point 2. Make use of a function variable but will lead to similar things as in point 1 $f=_IENavigate $f($oIE,"https://www.autoitscript.com/forum/") 3. write out the textbox content to a modified .au3 file and execute that for point 2 this temp output could look like below (but probably will be more complicated) ''## put default includes here for $i=0 to 3 runline($i) if @error then .... next function runLine($lineNo) switch $lineNo case 0 _IENavigate($oIE,"https://www.autoitscript.com/forum/") case 1 _IEPropertyGet($oIE, "locationurl") case 2 Local $oKeyword=_IEGetObjById($oIE,"elSearchField") case 3 $oKeyword.value="excute" endswitch end function Example #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <Array.au3> Global $oIE,$oMyError, $idEdtEror,$Result $oIE = _IECreate() sleep(2000) ;call("_IENavigate",$oIE,"https://www.autoitscript.com/forum/") ;consolewrite("Execute @error = " & @error & @CRLF) ;consolewrite(isdeclared("$oIE")) ;consolewrite(isdeclared("oIE")) ;execute('_IENavigate($oIE,"https://www.autoitscript.com/forum/"') ;consolewrite("Execute @error = " & @error & @CRLF) ;call('consolewrite','"https://www.autoitscript.com/forum/"') ;consolewrite("Execute @error = " & @error & @CRLF) ;call('MsgBox', 0, "", "hello world") ;If @error = 0xDEAD And @extended = 0xBEEF Then consolewrite("Wrong function or parameters " & @CRLF) ;local $aArgs[4] =["CallArgArray", 0,"","hello world"] ;call('MsgBox',$aArgs) ;If @error = 0xDEAD And @extended = 0xBEEF Then consolewrite("Wrong function or parameters " & @CRLF) TestAu3Code() Func TestAu3Code() GUICreate("CodeTest") Local $idEdtCode = GUICtrlCreateEdit("", 10, 10, 380, 160, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) Local $idCommand = GUICtrlCreateButton("RunCode", 310, 180, 80, 25) $idEdtRetn = GUICtrlCreateEdit("", 10, 215, 380, 120, $ES_AUTOVSCROLL + $WS_VSCROLL) $idEdtEror = GUICtrlCreateEdit("", 10, 345, 380, 50, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState(@SW_SHOW) Local $code = 'consolewrite("Hello world")' & @CRLF $code &= 'msgbox(0,"","hello world")' & @CRLF $code &= '_IENavigate($oIE,"https://www.autoitscript.com/forum/")' & @CRLF $code &= '_IEPropertyGet($oIE, "locationurl") ' & @CRLF ;$code &= 'Local $oKeyword=_IEGetObjById($oIE,"elSearchField")' & @CRLF ;$code &= '$oKeyword.value="excute"' GUICtrlSetData($idEdtCode, $code) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCommand $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") Local $aCode = StringSplit(GUICtrlRead($idEdtCode), @CRLF, 1) local $myParams[1] ;_ArrayDisplay($aCode) For $i = 1 To $aCode[0] If StringLen(StringStripWS($aCode[$i], 8)) Then ;'$Result = Execute($aCode[$i]) $splitParts=StringSplit($aCode[$i],"(,)") $fName=$splitParts[1] if (stringinstr($aCode[$i],"=")>0) Then consolewrite("its an assignment, you have to do a little more " & @CRLF ) Else consolewrite($splitParts[0] & @CRLF ) _ArrayDisplay($splitParts) $parCount=$splitParts[0] - 2 redim $myParams[$parCount+1] $myParams[0] = "CallArgArray" ;Evaluate the parameter before we throw it into the call for $j=2 to $parCount+1 ;If not a string if stringleft(StringStripWS($splitParts[$j],$STR_STRIPLEADING + $STR_STRIPTRAILING),1)<>'"' Then if isnumber($splitParts[$j]) then consolewrite("Evaluating number " & $splitParts[$j] &@CRLF ) $myParams[$j-1]=int($splitParts[$j]) Else local $parName=stringreplace($splitParts[$j],"$","") consolewrite("Evaluating param " & $parName & isdeclared($parName) & @CRLF ) $myParams[$j-1]=eval($parName) endif Else consolewrite("Copying " & $splitParts[$j] & @CRLF ) $myParams[$j-1]=$splitParts[$j] EndIf next _ArrayDisplay($myParams) consolewrite("Calling " & $parCount & $fName & $myParams[0] & $myParams[1] & @CRLF ) call($fName, $myParams) If @error = 0xDEAD And @extended = 0xBEEF Then consolewrite("Wrong function or parameters " & @CRLF) EndIf If @error Then GUICtrlSetData($idEdtRetn, "Execute @error = " & @error & @CRLF, 1) GUICtrlSetData($idEdtRetn, "Result = " & $Result & @CRLF, 1) EndIf Next EndSwitch WEnd EndFunc ;==>TestAu3Code Func ErrFunc($oError) GUICtrlSetData($idEdtEror, "Catch a COM Error !" & @CRLF & _ "ErrCode: 0x" & Hex($oError.number, 8) & @CRLF & _ "ErrDesc: " & $oError.windescription & @CRLF & _ "ErrLine: " & $oError.scriptline & @CRLF, 1) EndFunc ;==>ErrFunc1 point -
... and ban evasions won't work either... Answer my PM or just stay away from our forums.1 point
-
AutoITROLLS (recommendation)
FrancescoDiMuro reacted to Jos for a topic
You have as of now a posting ban until I receive an proper answer to my PM and you can somehow post in a normal way in stead of this crap!. Jos1 point -
How to embed HTML into a GUI
danylarson reacted to Gianni for a topic
If you are only interested in "chromium", the above tip is the way to go (although sadly this topic is still in an "early stage"). If, on the other hand, you are interested in "I m looking to embed html with javascript code on a autoit Gui " then you might also be interested in this other topic, https://www.autoitscript.com/forum/topic/200338-browsercontrol-companion/, and probably for some time to come... Even if the "BrowserControl" is used by IE (but not only) and even if IE is no longer up to date and is in a dead end, this does not mean that the "BrowserControl" has to suffer the same fate. In fact, the "browser Control" is also used in other contexts, for example by the Windows Help (see here for a test about it: https://www.autoitscript.com/forum/topic/205843-non-control-buttons-and-mouse-clicks/?do=findComment&comment=1482182) and also by independent programs as it is supplied as a system component. It is also part, for example, of the WebBrowser .NET class "System.Windows.Controls" (https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.webbrowser?view= net- 5.0). ... Again, if it's okay with you to use the Browser Control (ObjCreate("Shell.Explorer.2") and not Chromium), here is just a nice example ready for your purpose ...1 point -
SAP UDF
MarkIT reacted to seangriffin for a topic
I would like to establish a SAP UDF post, considering the amount of discussion so far on how to automate SAP. I recently discovered how to access SAP's Scripting COM object through AutoIT, and began writing this UDF to support it. My time with SAP is limited to working hours so I'll post updates whenever I get the chance. REQUIREMENTS: AutoIt3 3.2 or higher, SAP GUI Release 6.40, SAP GUI Scripting interface is enabled You are already logged into SAP (ie. The "SAP Easy Access" window is displayed) To enable the SAP GUI Scripting interface: From the SAP GUI, select the "Customize Local Layout" button on the toolbar Select "Options". Select the "Scripting" tab. If the message "Scripting is installed!" is not displayed, then contact your SAP administrators to have SAP GUI Scripting installed. Select "Enable Scripting". Deselect "Notify when a script attaches to a running GUI". Deselect "Notify when a script opens a connection". LIST OF FUNCTIONS: EXAMPLES: _SAPSessAttach.au3_SAPSessCreate.au3_SAPVKeysSend.au3_SAPVKeysSendUntilWinExists.au3_SAPObjSelect.au3_SAPObjValueSet.au3_SAPObjValueGet.au3_SAPObjPropertySet.au3_SAPObjPropertyGet.au3_SAPWinExists.au3_SAPWinClose.au3 The following code is a simple example of using the UDF. Ensure you have met the requirements outlined in the REQUIREMENTS section above before commencing. #include <SAP.au3> _SAPSessAttach("SAP Easy Access") _SAPSessCreate("pa30") _SAPObjValueSet("usr/subSUBSCR_PERNR:SAPMP50A:0120/ctxtRP50G-PERSONID_EXT", "00000018") _SAPVKeysSend("Enter") $pers_no = _SAPObjValueGet("usr/subSUBSCR_PERNR:SAPMP50A:0120/ctxtRP50G-PERSONID_EXT") The first function is _SAPSessAttach. This establishes a connection to a SAP window. In the example, we connect to the first SAP window displayed after logging in to SAP - the SAP Easy Access window. From here, all other functions will operate within this SAP window / session. _SAPSessCreate then opens a new SAP session, and runs a transaction within it. In the example, this takes us to the Maintain HR Master Data screen (transaction pa30). _SAPObjValueSet sets the value of an object / control within the current SAP window. In the example, this sets the Personnel no. field to 00000018. To determine the ID of a SAP Object (ie. the Personnel no. field ID "usr/subSUBSCR_PERNR:SAPMP50A:0120/ctxtRP50G-PERSONID_EXT"), follow these manual steps in SAP: Select the "Customize Local Layout" button on the toolbar. Select "Script Development Tools". Select "Do a hit test on the window". Move your mouse to the object you want the ID of. Click "Copy Id" in the Scripting Wizard. Paste this ID into the function in your script. Remove all text upto and including "wnd[n]/". _SAPVKeysSend is then used to press the Enter key, and update the Maintain HR Master Data screen with the employee's details. The last line of the example gets the value of the Personnel no. field, using _SAPObjValueGet. DOWNLOAD: Latest Version - v0.4 (07/01/09) SAP.au3 SAP.au31 point -
Without seeing your script, I can only help you by showing you how you can use multiple timers by callbacks or WM_TIMER message. Maybe you can adapt this to your needs. #Include <Timers.au3> Global Const $WM_TIMER = 0x0113 Global $hTimer1 Global $hTimer2 Exit(Main()) Func Main() Local $iCount Local $hTimerGUI = GuiCreate("timer") ;separate callbacks $hTimer1= _Timer_SetTimer($hTimerGUI, 1000, "_Timer1_CallBack") $hTimer2= _Timer_SetTimer($hTimerGUI, 1500, "_Timer2_CallBack") While 1 sleep(10) $iCount += 1 If $iCount = 500 Then ExitLoop WEnd _Timer_KillAllTimers($hTimerGUI) ConsoleWrite(@LF) ;combined callbacks $hTimer1= _Timer_SetTimer($hTimerGUI, 1000, "_Timer3_CallBack") $hTimer2= _Timer_SetTimer($hTimerGUI, 1500, "_Timer3_CallBack") $iCount = 0 While 1 sleep(10) $iCount += 1 If $iCount = 500 Then ExitLoop WEnd _Timer_KillAllTimers($hTimerGUI) ConsoleWrite(@LF) ;combined callbacks $WM_TIMER GUIRegisterMsg($WM_TIMER,"_WM_TIMER_Message") $hTimer1= _Timer_SetTimer($hTimerGUI, 1000) $hTimer2= _Timer_SetTimer($hTimerGUI, 1500) $iCount = 0 While 1 sleep(10) $iCount += 1 If $iCount = 500 Then ExitLoop WEnd _Timer_KillAllTimers($hTimerGUI) GUIRegisterMsg($WM_TIMER,"") GUIDelete($hTimerGUI) Return 1 EndFunc ;separate callback for timer 1 Func _Timer1_Callback($hWnd, $Msg, $iIDTimer, $dwTime) ConsoleWrite("Timer1 executed."&@LF) EndFunc ;separate callback for timer 2 Func _Timer2_Callback($hWnd, $Msg, $iIDTimer, $dwTime) ConsoleWrite("Timer2 executed."&@LF) EndFunc ;combined callback ;check timer id Func _Timer3_Callback($hWnd, $Msg, $iIDTimer, $dwTime) Switch $iIDTimer Case $hTimer1 ConsoleWrite("[Timer1] executed."&@LF) Case $hTimer2 ConsoleWrite("[Timer2] executed."&@LF) EndSwitch EndFunc ;Combined callback with WM_TIMER message Func _WM_TIMER_Message($hWnd, $Msg, $iIDTimer, $dwTime) Switch $iIDTimer Case $hTimer1 ConsoleWrite("{Timer1} executed."&@LF) Case $hTimer2 ConsoleWrite("{Timer2} executed."&@LF) EndSwitch EndFunc1 point