Jump to content

pete1234

Active Members
  • Posts

    51
  • Joined

  • Last visited

pete1234's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Have you looked at IniReadSection? It will store the results in an array which you can refer to without having to create variables for every key
  2. Thanks for the quick reply Affe. Unfortunately that won't work when you run IE in hidden mode since the Window will never exist and can't be activated. I need some way to return the URL that is generated via the button click to a variable and then pass that to INetGet, but I can't find any info about how to do this.
  3. I am working with a form in IE. There is a download button that, when clicked, generates a file to download. I am trying to automate this process and am having some problems. The code I have below is working and doing what I want. It clicks the button and saves the file to a location that I specify. ; the code before this is not relevant $sldDownloadBtn = _IEFormElementGetObjByName($sldDownloadForm, "Button1") _IEAction($sldDownloadBtn, "click") WinWaitActive("File Download - Security Warning") WinActivate("File Download - Security Warning") If @OSVersion = "Win_VISTA" Then ControlClick("File Download - Security Warning", "", "[CLASS:Button; INSTANCE:1]") If @OSVersion = "Win_XP" Then ControlClick("File Download - Security Warning", "", "[CLASS:Button; INSTANCE:2]") WinWaitActive("Save As") WinActivate("Save As") ControlSetText("Save As", "", "[CLASS:Edit; INSTANCE:1]", "c:\fakefile123.xls" ) If @OSVersion = "Win_VISTA" Then ControlClick("Save As", "", "[CLASS:Button; INSTANCE:1]") If @OSVersion = "Win_XP" Then ControlClick("Save As", "", "[CLASS:Button; INSTANCE:2]") $i = 1 ; Check to see if the file was downloaded While 1 If FileExists("C:\fakefile123.xls") Then ExitLoop Sleep(1000) $i = $i + 1 If $i > 240 Then MsgBox(0, "", "File not downloaded!") _IEQuit($oIE) Exit EndIf WEnd _IEQuit($oIE) msgbox(0, "", "Success") The problem is this works off window titles, and ultimately I need the program to run in the background. When I run the program with IE hidden the program stops at the call to WinWaitActive. Is there a way to find the URL that is generated after the button click? I could then use InetGet and avoid all this stuff with windows. Any thoughts?? FWIW this is the code attached to the button on the website <A href="javascript:document.forms[0].submit();"><input type="reset" value="Clear Form" name="reset">&nbsp;</A><A href="javascript:document.forms[0].submit();"></A><INPUT id="bBDFText" type="submit" value="Build Data File!" name="Button1"> Thanks so much for any insight
  4. This is more of a conceptual question. I have the following code: #Include <Array.au3> $BackupFiles = _ArrayCreate("C:\1.xls", "C:\2.xls", "C:\3.xls") $xlApp = ObjCreate("Excel.Application") If Not IsObj($xlApp) Then Exit With $xlApp .Visible = False .Workbooks.Open("C:\BackupMacros.xls") For $i = 0 to UBound($BackupFiles) - 1 .Run("AutoItBackup(" & chr(34) & $BackupFiles[$i] & chr(34) & ")") Next .Quit msgbox(0, "", "done") EndWith What I'm basically doing is running a macro on a bunch of different Excel files. This all works just as expected. The issue I've noticed is that if my array has only 2 elements, my code runs the macro on the first element twice. So if I change my array to only include 2 files instead of 3, and make no other changes, the macro I'm executing will run on the first file twice. If the array has 3 or more file this doesn't happen. Does anyone know what's going on? Thanks.
  5. Well I figured out how to run a macro from AutoIt: With $AccessApp. .OpenCurrentDatabase ($Database) ; Irrelevant $DummyVar = .Run("MyMacro") EndWith But this only works if MyMacro is defined as a public function in a module. It doesn't seem to work for subroutines or functions in a form. Any ideas?
  6. I'm trying to program a few tasks I normally do in Excel and Access into AutoIt, and while I've gotten the basics done, I'm struggling to port over some VBA code. For example, I have this code to essentially filter a report based on a date I enter into a text box: Const conDateFormat = "\#mm\/dd\/yyyy\#" strReport = "rptProgramSetup" strField = "ProgramEnd" ; Irrelevant code strWhere = strField & " Between " & Format(Me.txtStartDateMenu, conDateFormat) _ & " And " & Format(Me.txtEndDateMenu, conDateFormat) DoCmd.OpenReport strReport, acViewPreview, , strWhere I can get the report to open fine like so: $AccessApp = ObjCreate("Access.Application") ; Irrelevant code $AccessApp.DoCmd.OpenReport("rptProgramSetup").acViewPreview But it sends it directly to the printer rather than opening in Print Preview mode. I'm having similar issues with the other arguments of OpenReport. I was hoping someone could help me out with this, or perhaps point me in the direction of a useful developer's reference for doing this sort of stuff. Thanks a bunch.
  7. I'm writing a script to interact with a few forms in Access, and I was wondering if it was possible to replace my form name with a variable. Right now I have: $AccessApp = ObjCreate("Access.Application") $AccessApp.OpenCurrentDatabase ($Database); Variable declared earlier $AccessApp.Visible = True $AccessApp.DoCmd.OpenForm ("frmMainMenu") $AccessApp.Forms.frmMainMenu.txtStartDateDue.Value = @MON & "/" & @MDAY & "/" & StringRight(@YEAR, 2) Works great. But I was wondering if there was a way to replace Forms.frmMainMenu with something like Forms.$FormName. I obviously tried that and it didn't work, so I was just wondering if there was a way to do it that I'm not aware of. Thanks!
  8. You would need to use Func/EndFunc, and then instead of a Msgbox use Return
  9. I understand your point, but insults are not necessary. I clearly didn't clarify this as well as I should have, but I was under the impression that command line parameters that aren't static (like /help or something) needed to be tested with an If statement, hence the %1. When they pointed out it wouldn't be in my code, I took that in a more conceptual context...something along the lines of, you don't need to specify the command line, as running from the shell would run program.exe %1, and then my script would say if the command line is %1, and that's how the variable would be passed. You have to remember I'm a beginner. Anyways, for anyone else struggling with this concept, this works: For $n = 1 To $CmdLine[0] msgbox(0, "", $cmdline[$n]) Next Thanks again to everyone who has helped me.
  10. Um, I'm not ignoring them at all. I'm new to this sort of programming and am trying to follow their advice. And following all the posts in this thread, I thought I was going in the right direction with my loop except for the one error that ProgAndy pointed out. So now I'm trying to understand what I'm missing, and am thus asking for help.
  11. I'll second 7zip...you can include 7za.exe with your script as a standalone executable and use command line parameters for batch processing. You could read the files into an array, and then run a For loop to compress each file.
  12. Still doesn't work. I'm trying to get the MsgBox to display the path, but something is wrong with the If statement I believe. I have this: For $n = 1 To $CmdLine[0] If $CmdLine[$n] = "%1" Then msgbox(0, $CmdLine[$n], $CmdLine[$n + 1]) Else msgbox(0, "Test", "Doesn't work") ExitLoop EndIf Next The test MsgBox always pops up. I've also tried replacing "%1" with chr(34) & "%1" & chr(34) and it also doesn't work. Any ideas? Thanks for all the help guys.
  13. Thanks for the help guys. I've been able to run my program through the shell (the reg entry had to be in HKCR\Folder, not \Directory) but I can't figure out how to pass the %1 into my script. I was thinking I'd have to do something like this: For $n = 1 To $CmdLine[0] - 1 If $CmdLine[$n] = "%1" Then msgbox(0, "", $CmdLine[$n + 1]) ExitLoop EndIf Next Where my program would take the place of MsgBox...except this doesn't work at all. I'm sure it's something simple, but every variation of this I've tried doesn't work. Can someone point me in the right direction? Thanks again. And this is an export of the reg if something is wrong here, but everything with this part seems to be good Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Folder\shell\BatchPrint] [HKEY_CLASSES_ROOT\Folder\shell\BatchPrint\command] @="C:\\PrintTest.exe \"%1\""
  14. Yeah, I should have clarified, the reg entry approach is what I was referring to. I think I'm still a little confused about your idea though. If each time a user ran the program through the context menu, the entry in the registry would point to C:\Program.exe /Folder, correct? How would I then use a variable in the registry so the switch always reflects the folder the user the clicked on, as opposed to something static? Or maybe I'm taking the wrong approach here. Would the code say something like, Case $parameter = "/Folder" Then (do something to get the full path...I haven't the faintest idea how to do that)? Thanks. Edit: The above is a reply to Richard. PSaltyDS - Thanks for the suggestion. I will play around with it later tonight.
  15. I've got a script that uses FileSelectFolder to get a path name, and it then turns the list of files in that folder into an array and does a few different things to each file. It looks like this: $List = FileSelectFolder("Select Folder", @HomeDrive) $Array = _FileListToArray($List, "*.*", 1) _ArraySort($Array) For $i = 1 to $Array[0] Step 1 MsgBox(0, $1, $Array[$i]) Next I've replaced my actions with a MsgBox as they're irrelevant to my question. What I'd like to do is instead of using a dialog box, create a shell extension on all folders. Then a user would just have to right-click on the folder and click my shell extension to process the directory. But, I'm not sure how to grab that folder and pass it into my script as $List, thus replacing FileSelectFolder. Any ideas? Thanks a bunch.
×
×
  • Create New...