
onefish
Active Members-
Posts
53 -
Joined
-
Last visited
Everything posted by onefish
-
Scrape visible text from Javascript rendered webpage?
onefish replied to onefish's topic in AutoIt General Help and Support
Thanks Juvigy, I found a solution (outside autoit but it's working). -
Hi, I have been trolling through the forum and tried many of the suggested ways to scrape text from a webpage but I am yet to get a working solution. Is AutoIt capable of scraping text from a JavaScript rendered webpage? All text is fine, I can parse it out, just can't seem to get it. The visible text is in the DOM of course but the list is not in the HTML. I have tried various _IE and _INet statements but haven't found the key yet. Also I would really prefer if this is done in the background. Cheers!
-
I got it to work! Turned out to be very simple in the end. I was able to send the url through the command line after enclosing everything after the filename in "". This left a single " at the end of the string in the Filemaker parameter which I could strip out with substitute. Anyway in the end it works without all that using: ShellExecute ( "fmp://My/Really/Long/URL" ) I had been trying to execute the URL via an application previously. I feel really silly finding that the solution was so darn simple. Thanks for all your help guys
-
Jfish, I just ran the check and the object is created OK.
-
Database and script is on the same machine. The database actually initiates the AutoIt script with parameters. Then the AutoIt script does some things that the database can't do and the sends the info back using the fmp url (or at least that's what it's supposed to do). By universal I meant to the purpose of the database/AutoIt script solution
-
I have been reading a bit more and fmp: is registered as an internet protocol in the local machine. I'm thinking that winhttp may not be the right way to go as it appears to have errors if the request is not http but fmp. Does this sound right?
-
It's just pretty universal and doesn't require any additional setup on the database side.
-
Yep Filemaker Pro. The URL is good, that's not the problem. It does exactly what it's supposed to do when I send it via a browser. I'm just trying to work out how to send it without the browser.
-
Below is output using "http://fmp://...." which just seems wrong >"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Someone\Downloads\FMP_URL.au3" /UserParams +>22:01:00 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0 Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X86 Environment(Language:0409) +> SciTEDir => C:\Program Files\AutoIt3\SciTE UserDir => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files\AutoIt3 input:C:\Users\Someone\Downloads\FMP_URL.au3 +>22:01:00 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Someone\Downloads\FMP_URL.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop "C:\Users\Someone\Downloads\FMP_URL.au3" (7) : ==> The requested action with this object has failed.: $oHTTP.Send() $oHTTP^ ERROR ->22:01:07 AutoIt3.exe ended.rc:1 +>22:01:07 AutoIt3Wrapper Finished. >Exit code: 1 Time: 7.904 Below just using "fmp://...." see the error happens earlier in the script >"C:\Program Files\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Someone\Downloads\FMP_URL.au3" /UserParams +>22:09:22 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.3.6.0.0 Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X86 Environment(Language:0409) +> SciTEDir => C:\Program Files\AutoIt3\SciTE UserDir => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Someone\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files\AutoIt3 input:C:\Users\Someone\Downloads\FMP_URL.au3 +>22:09:22 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Someone\Downloads\FMP_URL.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop "C:\Users\Someone\Downloads\FMP_URL.au3" (5) : ==> The requested action with this object has failed.: $oHTTP.Open("GET","fmp://A/WHOLE/LOT/OF/STUFF/HERE", False) $oHTTP^ ERROR ->22:09:22 AutoIt3.exe ended.rc:1 +>22:09:22 AutoIt3Wrapper Finished. >Exit code: 1 Time: 1.15
-
Sorry again, I'm pretty green with AutoIt. the "^ERROR"/s that I posted is all that I see in the bottom section of ScitIE. Is there another way to see a better description of the error? It would be nice to know if Braggart's approach is the right way to send a URL from AutoIT,or if there's a better way.
-
Sorry Jos, I don't want to post the whole url as it contains username and password information. I am simply trying to send the URL from autoit instead of the browser address bar. I don't really know exactly what the browser is doing or how the url is handled by it but I know it works properly from there. The url is somehow directed to a locally hosted application on the same PC, no dns resolving or anything as I can disconnect from the internet and it still works. The URL itself contains data the tells the application to run a script with a parameter (native, non-autoit). The error I get when running the code from the link in my first post and pasted in my second post is: $oHTTP.Open("GET","fmp://M......." $oHTTP^ERROR If I change get request to be "http://fmp://M........" Then the error flag moves down the script to: $oHTTP.Send() $oHTTP^ERROR But I'm even not sure if this code is the right way to achieve what I need to achieve. I just thought I'd try it because I couldn't get run to send the url request.
-
Well the url is fmp: and about 100 charachters. the code I tried from the link in my first post was copy and paste but with my url instead of the one in the solution. $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "fmp://MyURL", False) $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode == 200 then $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists FileWrite($file, $oReceived) FileClose($file) EndIf Edit: the above code seems to error at the "." in $oHTTP.Open if that helps? I have tried: run("explorer.exe fmp://MyURL") and run("MyApp.exe fmp://MyURL") and a few others. The URL is good as it executes properly when I put it onto a browser address bar and hit enter. I just can't figure out how to mimic that from Autoit without the browser.
-
Please forgive my ignorance here, I'm sure I will call everything the wrong name. I need to send a url to a local file from an autoit script and can't seem the get it working. When I type the url into a browser address bar and hit enter it does exactly what it's supposed to do (i.e. change apps and execute an internal script with parameters passed in the url [not an autoit script]). But I don't want to use a browser to send the url, I want to do it silently from the autoit script. Most of the searches I did turned up requests to execute a url in the default browser, etc. I found THIS and THIS from Brugbart.com but I can't get it to work, not even with the copied and pasted solution at the end of his page. I tried using all sorts of stuff using run but never found one that worked. Seems like this should be easy but....................................help Cheers!
-
Noob question regarding functions and global variables
onefish replied to onefish's topic in AutoIt General Help and Support
Ahh, yes you are correct czardas, reassigning new data. -
Noob question regarding functions and global variables
onefish replied to onefish's topic in AutoIt General Help and Support
Thanks BrewManNH, I was just interpreting these statements from the best practice guide, perhaps I have misunderstood them: "Always declare your global variables in the global scope, not in the functions." "Declaring Global variables in a Function is never a good idea:" So, if I understand you right I can declare $g_sSomeLongString = "", before the script function and then re-declare $g_sSomeLongString="abcdefghijklmnopqrstuvwxyz" inside the function and the alphabet will be the value of the variable next time it is called up by another function (in the same script of course)? I don't need the variable before it's tested for errors anyway so there's technically no benefit to declaring it before the error checking function but I was thinking that there must be a reason why the tutorial said not declare global variables inside a function. -
I was reading BEST CODING PRACTICES earlier and realized that I had more or less broke most of them. I've just been rearranging this script I'm working on and trying to get a bit closer to "better coding practices" (best is a way off yet :-). I hadn't considered memory used by variables as much of a concern and instead structured my script in favor of lower CPU. I'm still trying to get a full understanding but from what I have read, local variables within a function are released from memory once the script moves outside the function, correct? That works for most of the error checking I need to do but there are 2x variables that require a bit to build (CPU wise) but they are needed to check for errors before actually using them in the script. I read in the Best Coding Practices that I shouldn't declare global variables from inside a function and I don't want to have to rebuild these couple variables again once the script moves passed error checking. What is the correct way to manage this? If I declare the global variable with value "" before the function start and then, inside the function, build the correct string and re-declare the global variable does the re-declared string value stick and become available for the next function? Thanks for your help!
-
Close Windows 10 Touch Keyboard
onefish replied to onefish's topic in AutoIt General Help and Support
careca, thanks for persisting. I had to divert my attention to other parts of this project for a while and have just found time to try your suggestion. The window info utility doesn't indicate any control ID for the 'X'/close control on the keyboard. I think I will give up on this nicety, it isn't critical after all. Just preferred behavior. -
G'day, as mentioned in my first post HERE, I am working on a script to use the Windows camera app in conjunction with a database on a couple of Win10 tablets. I have all the different components of the AutoIt script working now but I'm just not sure if there's a better way to do some things (I tend to find the complicated solutions first!). The AutoIt script monitors the camera apps save location for a new file before moving onto the next step and I was originally going to pass the save location to AutoIt from the database as a parameter. Then I kind of thought it might be better to have AutoIt fetch it from the system so I searched Google, the AutoIt forums, etc and I found lots of tutorials to change the default location through the Windows UI but nothing about how to fetch it from a script. I searched the registry too but couldn't find anything conclusive. All the research led me to understand that the Windows camera app uses libraries to determine the default save location. There isn't any setting to change it within the camera app itself, just the general PC settings for the library. I was playing around with the actual library file and found that it was just a simple xml document and that AutoIt can read it. So I wrote the below script which extracts the default save path from the CameraRoll.library-ms library and uses it to monitor the directory for a new file to be created (i.e. take a picture). I'm just not sure if there's a better, more reliable, way to find the default save location? Any advice is welcome. #include <Array.au3> $Path = @AppDataDir&"\Microsoft\Windows\Libraries\CameraRoll.library-ms" $StringPT = "(?:<url>)(.*)(?:</url>)" $url = StringRegExp(FileRead($Path),$StringPT,1)[0] $Count = DirGetSize($url,1)[1] $TimeOut = 20000 $Timer = 0 While $Count = DirGetSize($url,1)[1] Sleep(10) $Timer = $Timer + 10 If $Timer >= $TimeOut Then ExitLoop WEnd MsgBox(0,"","Old File Count: "&$Count&@CRLF&"New File Count: "&DirGetSize($url,1)[1],5) PS> If anyone actually runs this script then the file count may be incorrect. Mine is off by 1 (probably a hidden config file or something) but that isn't important for my purposes, just need to know when it changes.
-
VIOLA! I was definitely making this WAAAAAY more complicated than it needed to be. Thanks to a very good tip from sumtips the AutoIT run function does work when the modern app's URL protocol is used, and without having to find its AUMID. The below code opens the Windows 10 camera app. It also restores the camera window after it's been minimized. I couldn't get the maximize flag to work with modern apps once the window has been minimized, but using the run function again doesn't appear to start a second instance of the process (might need to check that a bit more though). run("explorer.exe microsoft.windows.camera:") I hope this mono-thread helps someone out there.
-
Perhaps I'm the only person that has need to open Windows modern apps using AutoIT? Or (quite possibly) I have just made this task into something bigger than it needs to be. Would any Win10 tablet PC owners (Surface Pro 3/4 or similar) out there be willing to run the below code and report back what their AUMID for the camera app is? If it's the same as mine then I've definitely made things too complicated and I'll just hard code it. I imagine at some point a function will be added to AutoIT to run modern apps as the old fashioned "Run" just doesn't do it anymore. ---------------------EDIT-------------------------- Code removed, better solution found in the next post.
-
I've been playing around with RegEnumKey and the below script returns the correct string in the $sSubKey variable. #include <Constants.au3> Local $sSubKey = "" Local $i = 1 Local $AUMIDPart = "Microsoft.WindowsCamera" While 1 $sSubKey = RegEnumKey("HKEY_CURRENT_USER\Software\Classes\ActivatableClasses\Package", $i) If @error Then MsgBox($MB_SYSTEMMODAL,"ERROR", "Subkey does not exist") Exit EndIf If StringRegExp($sSubKey, $AUMIDPart) = 1 Then ExitLoop $i = $i + 1 WEnd MsgBox($MB_SYSTEMMODAL,"Subkey "&$i,"""shell:AppsFolder\"&$sSubKey&"!App""") Is this the best way to go, or is there a better way than looping through the registry subkey?
-
I am compiling an AutoIT script which does several things, one of which is run and Windows camera app on a couple Win10 tablets. I can run the app using the following code: ShellExecute("explorer.exe", "shell:AppsFolder\Microsoft.WindowsCamera_8wekyb3d8bbwe!App") As mentioned, I have 2x tablets and strangely the AUMID for the camera app is the same for both of them but I'm not sure if it will always be that way (updates, etc). Hence, it just seems wrong to hard code the app AUMID into the script and I would much prefer to have the script fetch it each time it runs, therefore guaranteeing that the correct one is always used. I've tried Microsoft's advice HERE for the command line reg query and it returns the AUMID of the default browser. There is a registry key named AppsFolder\Microsoft.WindowsCamera_8wekyb3d8bbwe in the location outlined in the above link but there is no value set. Does anyone know the best way to reliably retrieve the AUMID of a specific app within an AutoIT script?
-
Close Windows 10 Touch Keyboard
onefish replied to onefish's topic in AutoIt General Help and Support
I think I may be running out of options here, argh! As the touch keyboard appears to run with elevated privileges, all my attempts to send messages to it to close fail unless I run as administrator, which creates a whole new set of issues. I thought that sending a mouse click to the close control coordinates of the keyboard would bypass all that but I can't get that to work either. I was able to work out that @DesktopWidth - 30 and @DesktopHeight - 316 is the center of the close control on both portrait and landscape modes as long as I don't un-dock the keyboard. But sending a mouseclick to that location moves the mouse cursor and appears to do a left click (small infinity symbol for fraction of a second) but it doesn't close the keyboard. I tried using Opt("MouseCoordMode",1) with ControlClick in that location too and still nothing. Should I admit defeat? -
Close Windows 10 Touch Keyboard
onefish replied to onefish's topic in AutoIt General Help and Support
I am liking the idea of sending a mouse click proposed by careca more and more as the requirement for elevated privileges to send the taskkill command is turning out to be problematic. As the AutoIT v3 Window utility is able to recognize the window and provide it's handle I am wondering if its possible to wingethandle by X and Y coordinates? 90 & 570 should ensure it's in the keyboard window mostly all the time. I'm hoping that having the correct handle would enable wingetpos to work better than it does by class. Or am I way off base? -
Close Windows 10 Touch Keyboard
onefish replied to onefish's topic in AutoIt General Help and Support
With winclose and the window name I can close all folder windows, Edge browser window, control panel window, I haven't tried any others but I'd suggest probably all of them. The darn keyboard is just different.