
MojoeB
Active Members-
Posts
27 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
MojoeB's Achievements

Seeker (1/7)
2
Reputation
-
Script not working in RDP Closed session
MojoeB replied to MRAJ's topic in AutoIt GUI Help and Support
The way you are using the WebDriver, your script requires a full user session. I would say that what you are describing is completely normal with a disconnected RDP session. One possible solution would be to run your script in headless mode - this should work without a graphical user session. If that's not enough, you could create a dedicated user for your programme and run it as a Windows service. This way, the script runs in the background and does not need to be actively monitored. Translated with DeepL.com (free version) -
#include <WinAPI.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> Local $pid = Run('notepad.exe') Sleep(1000) ; Wait for the window to load ; Find the main window handle of the started process Local $hWnd = WinGetHandle("[CLASS:Notepad]") If $hWnd = "" Then ConsoleWrite("Window not found." & @CRLF) Exit EndIf ; Display a selection menu Local $iChoice = MsgBox($MB_ICONQUESTION + $MB_TOPMOST + $MB_YESNOCANCEL, "Choose an Option", _ "Yes: Remove Minimize and Maximize buttons" & @CRLF & _ "No: Hide entire title bar" & @CRLF & _ "Cancel: Exit") Switch $iChoice Case $IDYES ; Remove Minimize and Maximize buttons Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) $iStyle = BitAND($iStyle, BitNOT($WS_MINIMIZEBOX + $WS_MAXIMIZEBOX)) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, _ BitOR($SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER, $SWP_FRAMECHANGED)) ConsoleWrite("Minimize and Maximize buttons have been removed." & @CRLF) Case $IDNO ; Hide entire title bar Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) $iStyle = BitAND($iStyle, BitNOT($WS_CAPTION)) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle) _WinAPI_SetWindowPos($hWnd, 0, 100, 100, 800, 600, _ BitOR($SWP_NOZORDER, $SWP_FRAMECHANGED)) ConsoleWrite("Title bar has been removed." & @CRLF) Case $IDCANCEL ; Exit without making changes ConsoleWrite("No changes made." & @CRLF) Exit EndSwitch
-
Highlight the content in the input box. (AutoIT)
MojoeB replied to 1stPK's topic in AutoIt GUI Help and Support
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> GUICreate("Demo Input Selection on Click", 300, 200) ; Create input fields $input1 = GUICtrlCreateInput("left click here", 50, 50, 200, 20) $input2 = GUICtrlCreateInput("left click here", 50, 100, 200, 20) ; Get handles for the input controls $hInput1 = GUICtrlGetHandle($input1) $hInput2 = GUICtrlGetHandle($input2) ; Register the WM_COMMAND message to handle control notifications GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState(@SW_SHOW) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; Function to handle WM_COMMAND messages Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $hCtrl = $lParam Switch $hCtrl Case $hInput1, $hInput2 Switch $nNotifyCode Case $EN_SETFOCUS ; Select all text in the inputbox1 _GUICtrlEdit_SetSel($hCtrl, 0, -1) Case $input2;$EN_KILLFOCUS ; Unselect text in the inputbox1 _GUICtrlEdit_SetSel($hCtrl, 0, -1) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc this? forget it i tested it there it worked and the 2nd time i tested it it didn't work anymore o.o -
1stPK reacted to a post in a topic: Highlight the content in the input box. (AutoIT)
-
Highlight the content in the input box. (AutoIT)
MojoeB replied to 1stPK's topic in AutoIt GUI Help and Support
Do you mean that all the text in the input field is selected (focused) when you click on it, so that it is highlighted in black/blue on your image? -
@BinaryBrother you need your own API key which you can get here 'API keys - OpenAI API', but only if you have entered payment information.
-
#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <WinHttp.au3> #include "JS.au3" Global $apiKey = "sk-*****" Func ChatGPT_Request($message) Local $url = "https://api.openai.com/v1/chat/completions" Local $headers = "Content-Type: application/json" & @CRLF & "Authorization: Bearer " & $apiKey Local $data = '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "' & $message & '"}]}' Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("POST", $url, False) $oHTTP.SetRequestHeader("Content-Type", "application/json") $oHTTP.SetRequestHeader("Authorization", "Bearer " & $apiKey) $oHTTP.Send($data) Local $response = $oHTTP.ResponseText ; Parse the JSON response Local $json = _JSON_Parse($response) If @error Then Return "Error: Failed to parse JSON response" EndIf ; Extract the message content Local $choices = _JSON_Get($json, "choices") If IsArray($choices) And UBound($choices) > 0 Then Local $messageObj = _JSON_Get($choices[0], "message") If IsMap($messageObj) Then Local $content = _JSON_Get($messageObj, "content") Return $content Else Return "Error: Message object not found" EndIf Else Return "Error: Choices array not found or empty" EndIf EndFunc ; Create GUI Global $hGUI = GUICreate("Chat with ChatGPT", 400, 320) Global $hInput = GUICtrlCreateInput("", 10, 260, 380, 20) Global $hOutput = GUICtrlCreateEdit("", 10, 10, 380, 240, $ES_READONLY) Global $hSend = GUICtrlCreateButton("Send", 160, 285, 80, 25) GUICtrlSetState($hOutput, $GUI_DISABLE) GUISetState(@SW_SHOW) ; Main loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hSend Local $userMessage = GUICtrlRead($hInput) GUICtrlSetData($hInput, "") GUICtrlSetData($hOutput, GUICtrlRead($hOutput) & @CRLF & "You: " & $userMessage) Local $response = ChatGPT_Request($userMessage) GUICtrlSetData($hOutput, GUICtrlRead($hOutput) & @CRLF & "ChatGPT: " & $response) EndSwitch WEnd (Json UDF I have this JS.au3(I named it myself)) : : autoit-json-udf/JSON.au3 at master · Sylvan86/autoit-json-udf · GitHub it works.
-
How can I get the entire code of a website page?
MojoeB replied to AndreyS's topic in AutoIt General Help and Support
to end the webdriver and session. _WD_DeleteSession($sSession) _WD_Shutdown($iWebDriver_PID,Default) - You get $iWebDriver_PID with $iWebDriver_PID = _WD_Startup() - $sSession with $sSession = _WD_CreateSession($sCapabilities) when I end Webdriver like this I also empty the variable $sCapabilities don't know if this is necessary probably not. Simply with - $sCapabilities = '' And then you just restart it -
How can I get the entire code of a website page?
MojoeB replied to AndreyS's topic in AutoIt General Help and Support
You can use the code to determine if the system has entered a sleep state. If the script detects that the system has indeed been in sleep mode, you can then proceed to terminate all processes related to WebDriver and restart them. This ensures that the functionality of WebDriver remains intact. -
How can I get the entire code of a website page?
MojoeB replied to AndreyS's topic in AutoIt General Help and Support
of course you have to adapt the code to your code. -
How can I get the entire code of a website page?
MojoeB replied to AndreyS's topic in AutoIt General Help and Support
Could you please check if AutoIt still works when the computer goes to sleep, unfortunately I can't do it at work. If so, could you test it with this code on WMI and then reply accordingly #include <MsgBoxConstants.au3> ; WMI-Objekt erstellen $objWMIService = ObjGet("winmgmts:\\.\root\cimv2") ; Überprüfen, ob das Objekt erstellt wurde If IsObj($objWMIService) Then ; WMI-Abfrage für Energieverwaltungsereignisse $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PowerManagementEvent") ; Prüfen, ob die Abfrage erfolgreich war If IsObj($colItems) Then $awakeFromSleep = False For $objItem In $colItems ; Überprüfen, ob das Ereignis das Aufwachen aus dem Ruhezustand ist If $objItem.EventType = 7 Then ; 7 entspricht dem Aufwachen aus dem Ruhezustand $awakeFromSleep = True ExitLoop EndIf Next If $awakeFromSleep Then MsgBox($MB_SYSTEMMODAL, "Status", "Der Computer ist kürzlich aus dem Ruhezustand erwacht.") Else MsgBox($MB_SYSTEMMODAL, "Status", "Keine Ereignisse zum Aufwachen aus dem Ruhezustand gefunden.") EndIf Else MsgBox($MB_SYSTEMMODAL, "Fehler", "Fehler bei der Ausführung der WMI-Abfrage.") EndIf Else MsgBox($MB_SYSTEMMODAL, "Fehler", "Fehler beim Erstellen des WMI-Objekts.") EndIf -
How can I get the entire code of a website page?
MojoeB replied to AndreyS's topic in AutoIt General Help and Support
Perhaps my experience report will be helpful: Antivirus software: Bitdefender. When updating the software or an autoscann, the connection in the script to the webdriver is lost (unfortunately I have this with some things, Outlook object is no longer found | IP connection that was established can no longer connect | or the script is simply stopped) although nothing can be seen in the Bitdefener log. Hibernation - I have not tried this at all as some of my scripts have to run 24/7. Logged into Windows, but on the lock screen, there are no problems. When trying to restart the same WebDriver with the same data, the connection to the script is lost or errors keep occurring. And now comes the funny part: If I just test the .au3 file without compiling it, then all of the above points do not apply to my tests! Except for the last point. Maybe you are also using Antivirus software that does something in the background after the PC wakes up that only harms your productivity. you can ignore the device messages in the webdriver console window if you are not using usb devices. This is displayed depending on how you have called up the webdriver. These messages can also be switched off somehow. -
How to change the chromepath for WebDriver
MojoeB replied to Jotos's topic in AutoIt General Help and Support
You also have the option to have the correct driver downloaded automatically. In your case, it would be something like this: _WD_UpdateDriver('chrome_legacy', @ScriptDir & '\Include', TRUE) -
VeeDub reacted to a post in a topic: Question about using _ImageSearch_Area
-
I apologize, I was testing in the wrong script window. :/^^ sry Now it works I have now placed If $headless Then _WD_CapabilitiesAdd('args', '--headless') EndIf directly above $sCapabilities = _WD_CapabilitiesGet() Return $sCapabilities tested it, and now headless works too. Thanks for the prompt! Danp2 I am using all the latest updates specifically for this project, everything is updated.
-
I even once copied over and adapted the demo start script because my own driver could not be operated. And to see if it runs for me. I have now added this, deleting my condition: If $headless Then _WD_CapabilitiesAdd('args', '--headless') EndIf It always shows me this as an error: _WD_CapabilitiesAdd ==> Browser or feature not supported [21] : Capability name are case sensitive ( check proper case in $_WD_KEYS__*** for "args"). $key = args $value1 = --headless $value2 =
-
Question about using _ImageSearch_Area
MojoeB replied to VeeDub's topic in AutoIt General Help and Support
_ImageSearch_Area($_ImagePath, $P_x1 = 0, $P_y1 = 0, $P_x2 = @DesktopWidth, $P_y2 = @DesktopHeight, $_Tolerance = 0, $_CenterPos = True) If you're not getting the expected results with your image search, it could be due to the images not being exactly the same as those on your desktop. This is where the Tolerance parameter comes into play. The Tolerance parameter in the _ImageSearch_Area function allows for some degree of inaccuracy in the image matching process. Essentially, a higher Tolerance value means the function can still find a match even if the image isn't a perfect match to the one you're looking for. This can be particularly useful if the image on the screen might change slightly in appearance due to factors like scaling, resolution differences, or minor color variations. For instance, if you set $_Tolerance to a value greater than 0 (like 10 or 20), the function will tolerate more differences between the searched image and the images on the screen. This could potentially solve the issue if the reason for not finding the image is due to minor discrepancies. In summary, if your image isn't being found because it's not 100% identical to the one on your desktop, adjusting the Tolerance value might help the _ImageSearch_Area function to find a close, if not exact, match. but that's just a guess.