Leaderboard
Popular Content
Showing content with the highest reputation on 01/29/2025 in all areas
-
It is a common belief that AdlibRegister will interrupt itself if the delay is too short for the function to complete. But it will not. It will simply pass to the next cycle. Here a simple example of it. HotKeySet("{ESC}", Terminate) AdlibRegister(Test, 1000) While Sleep(500) WEnd Func Test() For $i = 1 To 10 Sleep(300) Next ConsoleWrite(@SEC & @CRLF) EndFunc Func Terminate() Exit EndFunc Even if the delay is 1 sec and the function takes 3 secs, it does not interrupt itself. So there is not much need, IMO to unregister and reregister the function.3 points
-
Released v1.0.13 today! Added Command to remove Debug to Console and MsgBox lines added by the extension Commands to add and remove debug Trace lines Refined syntax check, with ability to set options through #AutoIt3Wrapper_AU3Check_Parameters Completions and Hovers for AutoIt3Wrapper Directives Changed Changes to autoit.includePaths setting now gets written to Windows Registry Fixed Go To Definition regression Output colors not showing due to other extensions (e.g., Github Copilot) Icons missing for some Const and Enum variables in the outline/Symbol search Detection of nested Regions outputCodePage setting not working Au3Check/Problems tab now works with includePaths setting Contributors @Danp2, @vanowm, @Sunev View and Rate on VSCode Marketplace Star, Submit Issues, and Contribute on GitHub2 points
-
Attach and Click Element using WebDriver UDF
SOLVE-SMART reacted to Danp2 for a topic
How was the browser originally launched? You won't be able to connect to it if it is the standard browser instance without the remote debugging enabled.1 point -
apt observation In this case, a safe way is to initialize it on every cycle. #include <File.au3> Global $aArray = ReadTestFile() AdlibRegister("_CheckIt", 1500) While 1 Sleep(50) WEnd Func ReadTestFile() Local $aArray, $sFile = @ScriptDir & "\test.ini" _FileReadToArray($sFile, $aArray) If Not IsArray($aArray) Then Exit MsgBox(4096, @ScriptName, "There was an error reading the file." & @LF & $sFile) Return $aArray EndFunc ;==>ReadTestFile Func _CheckIt() AdlibUnRegister("_CheckIt") For $i = 1 To $aArray[0] ConsoleWrite($i & ") " & $aArray[$i]) If ProcessExists($aArray[$i]) Then ConsoleWrite(" ProcessClose: " & ProcessClose($aArray[$i]) & @CRLF) EndIf ConsoleWrite("" & @CRLF) Next Sleep(500) AdlibRegister("_CheckIt", 1500) EndFunc ;==>_CheckIt1 point
-
you need to change the logic, i.e. you do the Array once at the beginning, and then in each AdlibRegister cycle you simply check it #include <File.au3> Global $aArray = ReadTestFile() AdlibRegister("_CheckIt", 1500) While 1 Sleep(50) WEnd Func ReadTestFile() Local $aArray, $sFile = @ScriptDir & "\test.ini" _FileReadToArray($sFile, $aArray) If Not IsArray($aArray) Then Exit MsgBox(4096, @ScriptName, "There was an error reading the file." & @LF & $sFile) Return $aArray EndFunc ;==>ReadTestFile Func _CheckIt() For $i = 1 To $aArray[0] ConsoleWrite($i & ") " & $aArray[$i]) If ProcessExists($aArray[$i]) Then ConsoleWrite(" ProcessClose: " & ProcessClose($aArray[$i]) & @CRLF) EndIf ConsoleWrite("" & @CRLF) Next EndFunc ;==>_CheckIt1 point
-
I'm sorry, but this code makes no sense. An .ini file typically has the following structure : [Sectionname1] 1..n Key=Value pairs [Sectionname2] 1..n Key=Value pairs and so on. If you read such a structure with FileReadToArray, you will not get valid file names. Of course you can save a list of file names (.exe's) with the extension .ini, but that would be confusing. Please post your Test.ini. AdlibRegister starts the Function Example every 1000 ms, the While Loop runs forever. So you get a huge number of ProcessClose attempts (from files that have not been started anywhere). Please describe what you actually want to achieve.1 point
-
Attach and Click Element using WebDriver UDF
SOLVE-SMART reacted to JugglingCoder for a topic
Hello SOLVE-SMART, thank you for taking a look. "refers to gaming related automation" This automation has nothing to do with a commercial game. I am trying to build "automation" so that I can click an AutoIt GUI on my tablet which in turn will click a place on a webpage which is shown on a projector screen. Please see attached image, it should explain a lot. The "game" is a simple self programmed Trivia type game which I use at events, etc. With old IE and "#include <IE.au3>" it was simple to click but things have changed and I need to learn/utilize the WebDriver UDF to get the click but am having difficulties. Basically I'm just trying to "attach" to a currently open widow (the trivia window) and then when clicking a button on the AutoIt GUI it clicks a div in the page that is shown on the projector.1 point -
Alright one last attempt : #include <GUIConstants.au3> #include <WinAPIGdi.au3> #include <ColorConstants.au3> Example() Func Example() Local $hGUI1 = GUICreate('Move region 1', 300, 300, 300, 200, -1, $WS_EX_CONTROLPARENT) GUISetBkColor($COLOR_RED) GUISetState() Local $hRgn1 = _WinAPI_CreateRectRgn(0, 0, 80, 80) _WinAPI_SetWindowRgn($hGUI1, $hRgn1) Local $hGUI2 = GUICreate('Move region 2', 300, 300, 420, 320, -1, $WS_EX_CONTROLPARENT) GUISetBkColor($COLOR_RED, $hGUI2) GUISetState(@SW_SHOW, $hGUI2) $hRgn2 = _WinAPI_CreateRectRgn(30, 30, 110, 110) _WinAPI_SetWindowRgn($hGUI2, $hRgn2) Sleep(2000) WinMove($hGUI1, "", 500, 500) _WinAPI_DeleteObject($hRgn1) _WinAPI_DeleteObject($hRgn2) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example You can also drag each square (button ?) independently...1 point
-
Something like that? #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <Timers.au3> $hGUI = GUICreate('Move region - is it possible.. ?', 600, 600) GUISetBkColor($COLOR_RED, $hGUI) GUISetState(@SW_SHOW, $hGUI) Global $x = 0, $y = 0, $iWidth = 80, $iHeight = 80 $hRgn1 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight) Global $x = 120, $y = 120, $iWidth = 80, $iHeight = 80 $hRgn2 = _WinAPI_CreateRectRgn($x, $y, $x + $iWidth, $y + $iHeight) $hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3]) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3) _WinAPI_SetWindowRgn($hGUI, $hCombinedRgn) ;help me ;how to move region? ;ex. _WinAPI_MoveRgn ... (set new iX iY) ;ex. _WinAPI_RgnSetPos ... (set new iX iY) ;any ideas? Global $i, $tPAINTSTRUCT _Timer_SetTimer($hGUI, 10, "UpdateRegion") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _Timer_KillAllTimers($hGUI) _WinAPI_DeleteObject($hRgn1) _WinAPI_DeleteObject($hRgn2) _WinAPI_DeleteObject($hCombinedRgn) ExitLoop EndSwitch WEnd Func UpdateRegion($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime _WinAPI_OffsetRgn($hRgn2, Sin($i) * 10, Cos($i) * 10) $i += 0.1 $hCombinedRgn = _WinAPI_CreateRectRgn(0, 0, WinGetPos($hGUI)[2], WinGetPos($hGUI)[3]) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn1, 1) _WinAPI_CombineRgn($hCombinedRgn, $hCombinedRgn, $hRgn2, 3) _WinAPI_SetWindowRgn($hGUI, $hCombinedRgn) _WinAPI_DeleteObject($hCombinedRgn) EndFunc1 point
-
Another beep song UPDATED!
Tony4219 reacted to colafrysen for a topic
Just thought i share some of my physics it seems you are use an array for storing the tones, but it is quite easy to calculate them the only thing you need is a base tone to start from, lets for example take A which is 440Hz. then the next note's Hz will be defined by this function. Y=440*12thRoot(2)^X which can be written as: Y=(440*2^(1/12)^X Where X is the number of notes from A(440) And Y= the Hz of that note. AutoIt Demo: Global $N For $X=0 to 12 step 1 Beep (_GetNote(440,$X),200) Next _Chord (440,True) Func _Chord ($Base,$Flag) dim $note[3] $note[0] = _GetNote($Base,$N) Switch $Flag Case True $note[1] = _GetNote($Base,4) Case False $note[1] = _GetNote($Base,3) EndSwitch $note[2] = _GetNote($Base,7) For $y=0 to 2 Beep ($note[$y],200) Next EndFunc Func _GetNote($StartHz,$N) Return $StartHz*2^(1/12)^$N EndFunc I don't know if you already knew this, but choose to use an array for simplicity or speed, but I thought; knowledge is meant to be shared1 point