Jump to content

digiworks

Members
  • Posts

    18
  • Joined

  • Last visited

digiworks's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Look at _FileListToArray in the help file. You can retrieve an array of files/folders with the number being in $array[0]. (from the help file) #include <File.au3> #include <Array.au3> Local $FileList = _FileListToArray(@DesktopDir) If @error = 1 Then MsgBox(0, "", "No Folders Found.") Exit EndIf If @error = 4 Then MsgBox(0, "", "No Files Found.") Exit EndIf _ArrayDisplay($FileList, "$FileList") So in this example $FileList[0] is the number of files/folders on your desktop. Keep in mind it counts hidden files/folder as well. You can set the third argument of _FileListToArray to only return files or folders as well. Edit: formatting
  2. You don't specify the protocol/ip.. Have you tried the script I posted?
  3. #include <FTPEx.au3> Local $s_LocalFile = "d:documents and settingsE144667Meus documentosCOC_Painel_Report.txt" Local $s_RemoteFile = "COC_Painel_Report.txt" Local $server = '127.127....' Local $username = 'logn' Local $pass = 'pass' Local $Open = _FTP_Open('TelefonicaFTP') Local $Conn = _FTP_Connect($Open, $server, $username, $pass) _FTP_DirSetCurrent($Conn, "/COC/") _FTP_FilePut($Conn , $s_LocalFile, $s_RemoteFile , $FTP_TRANSFER_TYPE_BINARY , 0) Local $Ftpc = _FTP_Close($Open)
  4. That works perfectly! I had tried doing it earlier that way but without the Global so that must've been it! Thanks to everyone who contributed to this thread ^^
  5. I should've been more specific about that $result line.. it is actually calling a function which ends up changing @error but I didn't include that in my sample.. I'll post the entire thing because it is somewhat difficult to explain. #include <SQLite.au3> #include <array.au3> $text = "1234" While 1 $text = InputBox("Please Login", "Please enter your Badge Number and click OK.", "", "*") $result = CheckDB($text) If @error = 1 Then Exit ElseIf $result <> 0 Then _ArrayDisplay($result) ExitLoop ElseIf $result = 0 Then MsgBox(4096, "Error", "Invalid login") EndIf WEnd Func CheckDB($text) Local $hQuery, $aRow _SQLite_Startup() _SQLite_Open(@ScriptDir & "db.db") _SQLite_Query(-1, "SELECT * FROM Employees WHERE SSN='" & $text & "' OR BadgeNumber='" & $text & "'", $hQuery) _SQLite_FetchData($hQuery, $aRow) _SQLite_QueryFinalize($hQuery) If $aRow[0] = "" Then Return 0 Else Return $aRow EndIf EndFunc ;==>CheckDB So all of the SQL functions end up changing @error before it checks the input box @error.. to my understanding..
  6. I've stared at this for a good hour now and it has condensed to much smaller than it originally was.. I'm trying to validate an employee ID number to a SQL database in order to continue my script. I have the database stuff all finished, but I'm stuck with a stupid loop problem.. The following code is not my exact script by rather some chunks I cut out to demonstrate it. While 1 $text = InputBox("Please Login", "Please enter your Badge Number and click OK.", "", "*") $result = "1" ;in the full script this is the result of a SQL query (in an array) but for demonstration purposes it is 1 _Min(25, 10) If @error = 1 Then ; THIS is where my problem is. InputBox sets @error at 1 if cancel is pressed, but other functions are setting @error before this is checked resulting in it doing nothing. I changed @error with the simple math function above, breaking my cancel button.. Exit ElseIf $result <> 0 Then ;my SQL function returns the array of a query here. This would normally be _ArrayDisplay($result) but to demonstrate it I changed it to a MsgBox MsgBox(4096, "test", $result) ExitLoop ;exit the loop and continue with code after the While loop ElseIf $result = 0 Then ;the SQLite function I call returns 0 if there is no data in the query MsgBox(4096, "Error", "Invalid Data") EndIf WEnd I've stared at it too long now so if anyone has a suggestion to make my loop register the @error from the InputBox to fix the cancel button it would be greatly appreciated. Thanks!
  7. #include <IE.AU3> $flag = 0 ;AdlibRegister('_refresh', 50000) If Not WinExists("Yahoo! - Windows Internet Explorer") Then $o_object = _IECreate("http://www.yahoo.com") Else $o_object = _IEAttach("http://www.yahoo.com/", "URL") EndIf This will open the browser to Yahoo if it doesn't already exist, otherwise it will look for a browser window with the yahoo URL. Check your window title too because yours says Yahoo - Windows Internet Explorer and mine says Yahoo! - Windows Internet Explorer.
  8. You can get the reference with _IEAttach as well which will let you attach to an already existing browser.
  9. Maybe this is what you're looking for?? $bLoop = 1 While $bLoop = 1 $text = InputBox("Input Password", "Please enter the password and click OK", "", "*") If @error = 1 Then MsgBox(4096, "Error", "Incorrect Password") Else If $text <> "password" Then MsgBox(4096, "Error", "Incorrect Password") Else $bLoop = 0 EndIf EndIf WEnd script here..
  10. I looked at this function and it seems to be what I want, but I don't know anything about Javascript, so I don't know what to use for the $o_object variable. Do I have to use a form of GetObjBy and try to find the object or is it something that is already written into the code of the page? Below is the html code of the button itself. <a id="ctl00_Content_wizPerson_StepNavigationTemplateContainerID_btnStepSave" class="buttonB100" href="javascript:__doPostBack('ctl00$Content$wizPerson$StepNavigationTemplateContainerID$btnStepSave','')">Save</a> I guess what I need to know is where do you get $o_object from in a page that you didnt create with the script itself and then I could use _IEAction($o_object, "click"). I hope I'm explaining this in an understandable way. Thanks again for your help!
  11. This may be tough to explain as I have little knowledge of Javascript and how it is implemented on a web page, but here goes: At my workplace we use a web-based application to manage all employees and track their education records. I've attached a screenshot of the form used to create a new user. I am able to fill out the form fine, however I cannot click the 'Save' button. From the little I know about JS I can paste the code that is executed by the save button (javascript:__doPostBack('ctl00$Content$wizPerson$StepNavigationTemplateContainerID$btnStepSave','')) into the address bar and it will "push" the button, but I don't know how to do this in AutoIt. I've tried _IENavigate and looked at the _IEFormSubmit and _IEFormReset functions but it seemed you could only run functions on objects you created. Unfortunately I can't give access to the site as it's password protected. Any pointers would be great! Thank you for your time. Screenshot 03-06-2012 11.21.00.bmp
  12. The full version of Scite script editor can record mouse clicking.. Create a script and tools->AU3 Recorder. Keep in mind that clicking like MouseClick("left",369,597,1) is using xy coordinates on your screen, and if you have different screen resolutions, the buttons won't be in the same spot. Automating mouse clicking is fairly easy to write even without a recorder though, just look in helpfiles at MouseClick. Something you may also want to use in this process would be WinWaitActive, which pauses your script until the window you specify is active rather than guessing how long it will take the window appear and using Sleep. On a side note, I just used the script recorder, and it inserted this function: _WinWaitActivate I'm not sure if that's a Scite error or what not but I fixed it by changing it to WinWaitActive Hope this helps!
  13. Alternatively to doing what rodent1 suggested and checking if the window is active, you could use ControlSend instead of Send and it would work even if the window isn't active. There is also a possibility that the software itself is the problem.. What program are you trying to send to? Out of helpfiles: ControlSend ( "title", "text", controlID, "string" [, flag] )
  14. While 1 If WinExists("HO", "Close the program") Then WinClose("HO", "Close the program") EndIf sleep(100) WEnd
  15. Working! I don't know if this is really the best way of doing this, but I added this to it, and now it works With $OpenPresentation.WebOptions() .IncludeNavigation = 0 EndWith 0 meaning without a navigation bar and 1 meaning with a navigation bar Thank you both for your help! Here is the working script, for anyone who might find it useful in the future: #include <File.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> $GUI = GUICreate("PP to HTML Converter", 300, 65, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "quit") $convertbutton = GUICtrlCreateButton("Convert", 0, 30, 297) $browse = GUICtrlCreateButton("Browse...", 245, 4, -1, 22) GUICtrlSetOnEvent($browse, "browse") GUICtrlSetOnEvent($convertbutton, "convert") GUICtrlCreateLabel("File to Convert:", 1, 7) $file = GUICtrlCreateInput("", 80, 5, 160, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "") $aWin = WinGetPos($GUI) $slider = GUICtrlCreateSlider ( 1, 205, -1, 30) WinMove($GUI, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4) GUISetState(@SW_SHOW) Dim $szDrive, $szDir, $szFName, $szExt Global $file Func browse() $openpath = FileOpenDialog("Select a file", "C:", "PowerPoint Presentations (*.ppt)", 1 + 8) GUICtrlSetData($file, $openpath) EndFunc Func convert() $openpath = GUICtrlRead($file) _PathSplit($openpath, $szDrive, $szDir, $szFName, $szExt) $strippedname = StringStripWS($szFName, 8) DirCreate($szDrive & $szDir & $strippedname) $save = $szDrive & $szDir & $strippedname & "" & $strippedname Dim $AppPowerPoint Dim $OpenPresentation Const $ppSaveAsHTML = 12 $AppPowerPoint = ObjCreate("PowerPoint.Application") $AppPowerPoint.Visible = 1 $OpenPresentation = $AppPowerPoint.Presentations.Open(GUICtrlRead($file)) With $OpenPresentation.WebOptions() .IncludeNavigation = 0 EndWith $OpenPresentation.SaveAs ($save, $ppSaveAsHTML) $OpenPresentation.Close () $AppPowerPoint.Quit () cls() EndFunc Func cls() GUICtrlSetData($file, "") EndFunc Func quit() Exit EndFunc While 1 sleep(1000) WEnd Thanks again!
×
×
  • Create New...