Jump to content

SkysLastChance

Active Members
  • Posts

    330
  • Joined

  • Last visited

Everything posted by SkysLastChance

  1. #include "wd_core.au3" #include "wd_helper.au3" ; Create profile directory if it doesn't exist Local $sUserDataDir = "C:\Script Prerequisites\ChromeDriverProfile" If Not FileExists($sUserDataDir) Then DirCreate($sUserDataDir) EndIf _WD_Option('Driver', 'chromedriver.exe') Local $iPort = _WD_GetFreePort(5555, 5600) _WD_Option('Port', $iPort) _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["user-data-dir=C:\\Script Prerequisites\\ChromeDriverProfile", "--profile-directory=Default", "--disable-extensions"], "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}' _WD_Startup() Local $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "google.com") _WD_LoadWait($sSession) I did this but your solution was better. @SOLVE-SMART Thank you!
  2. $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' Getting this error from the chromedriver: DevTools remote debugging requires a non-default data directory. Specify this using --user-data-dir. However, I have set the --user-data in the $sDesiredCapabilites. Can someone help and tell me what I am doing wrong? #include "wd_core.au3" #include "wd_helper.au3" _WD_Option('Driver', 'chromedriver.exe') Local $iPort = _WD_GetFreePort(5555, 5600) _WD_Option('Port', $iPort) _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' _WD_Startup() Local $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) _WD_Navigate($sSession, "google.com") _WD_LoadWait($sSession)
  3. Thank you for the help on this everyone. The truth is that all of these helped me out. Then I ran into more problems. My main problem ended up being that the task scheduler did not have access to the Folders/SQL tables that my script was trying to run. It is working as expected now.
  4. So I am having problems launching my script using task scheduler. I will admit I am new to task scheduler. I found a lot of topics on this same kind of thing, but most of them had to do with Send () and WinWaitActive() being the cause. I tested with a script just using: Msgbox(0,"","") It works fine if I have "Run only when user is logged on". If I try "Run whether user is logged on or not." It will not run. (tested while logged on also) It will not pop up the message box. I am unsure of how to debug this problem I am assuming it has to do with some permissions as I am on a company computer. Not sure where to look for errors though. Any help is appreciated.
  5. You may be running into a timing issue. 1001 is valid. I would also suggest using ControlSend and looking into that instead. Try This: $Path = 'C:\Program Files' ShellExecute('explorer.exe', $Path) If WinWaitActive($Path,"",10) Then ControlClick($Path, "", 1001, "left", 1) ControlSend($Path, "", 1001, 'C:\Windows' & "{ENTER}") Else Msgbox(0,"Error",$Path & " Is Not Active") EndIf
  6. Oh, I see. Do you have any antivirus installed? If so, you may want to disable it and try running your code again. That's where my head goes.
  7. A shot in the dark here. Have you tried adding: To the top of your script. #RequireAdmin Seeing the code you are trying to run may shed some more light on the problem as well.
  8. Send("{ASC 124}") https://www.ascii-code.com/124
  9. Our Anti-Virus did not like when I tried to run that .cmd file. 😆 However, I was able to get it to work using the .bat file.
  10. I know it is possible to start a compiled script on start up very easily using the start up folder. However, Is there a way I can start a script on start up that is not compiled? Getting my .exe files approved by IT is a pain. This is why I would like to avoid the compile if possible. My only idea is to create a .exe that launches other autoit scripts. that way I only have to get one .exe approved if that makes sense. I am hoping there might be a more eligant way.
  11. echo %temp% showed my problem it had a "2" folder it was trying to post into. I created the folder in the directory and Bingo.
  12. I am having a problem with one of the servers I am on. I can't seem to figure out the problem. It is working on 2 other identical servers. However, it will not work on my third. So something is difrent. I am just not sure what. ;WebDriver Func #include <wd_core.au3> #include <wd_helper.au3> #include <ConnView.au3> ;this is used to check port. useful for multiple connections on the same server. ;Hotkey to stop the scirpt HotKeySet(("{ESC}"), "Terminate") ;Used for Webdriver Functions Global $sDesiredCapabilities, $sSession, $_Port, $aHandles Global $iAltPort = 9515 Global $aTCPArray = _CV_GetExtendedTcpTable() ;Finds a avalible port if running on RDC (Remote Desktop Computer) This is needed if multiple users are running a script on the server at the same time. ;Starts at 9515 and +1 after SetupChrome($iAltPort) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Loop Starts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;What to do after chrome is open. Msgbox(0,"Yeah","Chrome is open") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func Terminate() _WD_DeleteSession($sSession) _WD_Shutdown() Exit EndFunc ;==>Terminate Func SetupChrome($iAltPort) ;Setup for chrome ports and chrome drive exe While 1 $_Port = _ArrayFindAll($aTCPArray, $iAltPort, 0, 0, 0, 0, 2) If @error Then ExitLoop Else $iAltPort = $iAltPort + 1 EndIf WEnd _WD_Option('Driver', 'chromedriver.exe') ; the .exe file name needs to be changed for each person _WD_Option('DriverParams', '--verbose --port=' & $iAltPort & ' --log-path="' & @ScriptDir & '\chrome.log"') _WD_Option('Port', $iAltPort) _WD_Option('DriverClose', False) _WD_Option('DriverDetect', False) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"], "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}' ;MsgBox($MB_OK, 'Message', 'Click OK to start Chrome Driver at local port: ' & $iAltPort) _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_LoadWait($sSession) ;;Which site to navigate to. _WD_Navigate($sSession, "google.com") _WD_LoadWait($sSession) EndFunc ;==>SetupChrome Chrome will not open. I have had this problem in the past, but it always seemed to be because I had the wrong version of chrome driver. However, I know I have the right version. Here is my output. >"C:\Users\BOTIE05\Desktop\New Verision of AutoIT\New Verision of AutoIT\SciTe\..\AutoIt3.exe" /ErrorStdOut "C:\Users\BOTIE05\Desktop\Chrome Template.au3" _WD_Option ==> Success [0] : Parameters: Option=Driver Value=chromedriver.exe _WD_Option ==> Success [0] : Parameters: Option=DriverParams Value=--verbose --port=9515 --log-path="C:\Users\BOTIE05\Desktop\chrome.log" _WD_Option ==> Success [0] : Parameters: Option=Port Value=9515 _WD_Option ==> Success [0] : Parameters: Option=DriverClose Value=False _WD_Option ==> Success [0] : Parameters: Option=DriverDetect Value=False _WD_IsLatestRelease ==> General Error [1] _WD_Startup: OS: WIN_2019 WIN32_NT 17763 _WD_Startup: AutoIt: 3.3.16.0 _WD_Startup: Webdriver UDF: 0.10.1 (Update status unknown [1]) _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WD_Startup: Driver: chromedriver.exe (32 Bit) _WD_Startup: Params: --verbose --port=9515 --log-path="C:\Users\BOTIE05\Desktop\chrome.log" _WD_Startup: Port: 9517 _WD_Startup: Command: "chromedriver.exe" --verbose --port=9515 --log-path="C:\Users\BOTIE05\Desktop\chrome.log" _WD_Startup ==> Success [0] __WD_Post ==> Webdriver Exception [10] : HTTP status = 500 _WD_CreateSession ==> Webdriver Exception [10] _WD_LoadWait ==> Invalid session ID [15] : Parameters: Delay=Default Timeout=Default Element=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=google.com _WD_LoadWait ==> Invalid session ID [15] : Parameters: Delay=Default Timeout=Default Element=Default Not really sure on how to read much of the chrome log. However, I did find this at the bottom. [1673039187.542][INFO]: [ec9653b0e61c705758686b9f1074c830] RESPONSE InitSession ERROR unknown error: cannot create temp dir for unpacking extensions [1673039187.542][DEBUG]: Log type 'driver' lost 2 entries on destruction [1673039187.542][DEBUG]: Log type 'browser' lost 0 entries on destruction I tried creating a folder inside my temp account and switching my environment variables. It diden't work though.
  13. This only happens when you are opening with autoit? If you manually open it will it stay up? You could try. #RequireAdmin ShellExecute("chrome.exe", "https://google.com --new-window --start-fullscreen")
  14. You are adding extra " ShellExecute("chrome.exe", "https://google.com --new-window --start-fullscreen") or Run("C:\Program Files\Google\Chrome\Application\chrome.exe") ?
  15. Sleep(10) ; don't remove this, or your RAM will blow up instantly Is this true?
  16. You need to strip out the code you don't need in the #include <ConnView.au3> You need to add. _WD_Option('DriverParams', '--verbose --port=' & $portEdge & ' --log-path="' & @ScriptDir & '\edge.log"') Are you sure you don't want to run? $sSession = _WD_CreateSession($sCapabilities) Thoese are the ones you are returning however, you are creating the session with $sDesiredCapabilities Couple other things that might help. Make sure you don't already have edge open befor you run the script. Rename the msedgedriver.exe for each user. I.E. (msedgedriver1.exe and msedgedriver2.exe)
  17. Hey fam, Is there a diffrent/better way I should be using to exlude temp files other then. $aData = _WinAPI_ReadDirectoryChanges($hDirectory, $FILE_NOTIFY_CHANGE_FILE_NAME, $pBuffer, 65536, False) $FileTempCheck = StringLeft($aData[1][0],2) ;Looks for the creation of a new file as long as it does not begin with ~$ will run. If $FileNew = 1 And $FileTempCheck <> "~$" Then ;My Script EndIf Thanks in advance.
  18. Probably not exactly what you need. However, this should get you on the right path at the very least. $Title = "AnyDesk" $ListAnyDesk = WinList($Title) For $i = 1 To $ListAnyDesk[0][0] $hwnd = $ListAnyDesk[$i][1] If $hwnd = WinActivate($Title) Then ControlClick($hwnd, "", "basic_button#91") EndIf Next
  19. Just to clerify this works? If WinActive("[REGEXPCLASS:ad_win#3]") Then MsgBox(0, "test", "Is Active.", 10) Can you show a screen shot of the control tab when the button is selected? (Au3info screen)
  20. Sorry, I have to go. I will check back tomorrow. Look into https://www.autoitscript.com/autoit3/docs/functions/WinGetHandle.htm
  21. If WinActive("AnyDesk") Then MsgBox(0, "test", "Is Active.", 10) ?
  22. @hahnhwang https://www.autoitscript.com/wiki/WebDriver#FAQ #7 You don't need an array in this case. However, Local $sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="mat-tab-label-0-0"]/div/span/app-number-viewerapp', 100, 5000) Local $sText = _WD_ElementAction($sSession, $sElement, 'property', 'innerText') MsgBox(0, "Total", $sText)
  23. Try this. WinActivate("[CLASS:ad_win#2]") If WinActive("[CLASS:ad_win#2]") Then MsgBox(0, "test", "Is Active.", 10) or If WinWaitActive("[CLASS:ad_win#2]") Then MsgBox(0, "test", "Is Active.", 10) If this doesn't work. Show a screen shot of Au3info screen.
×
×
  • Create New...