LostZXC Posted August 28, 2008 Share Posted August 28, 2008 Dear Autoit Community, I am in the process of learning how to use autoit. I came across a UDF pair in the forums, "FileRegister.au3" and "FileUnregister". I copied them into my autoit\include: sub directory. When I attempted to use them no dice. Unknown function says scite. I then searched the forums for awhile and came across a note saying that I should add the heading "#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6" to the top of my script. Done, still no dice. Now scite says that I have variables that are used before being declared. This is progress though because I am now taken to the "FileRegister.au3" for the error notice. I have had this happen to me before when I did not include the "#include<some_UDF.au3>". I don't know what I am supposed to be doing, so it is very difficult to figure out what I am doing wrong... I am sure this issue has already been addressed, but I have been unable to find it as of yet. Would anyone be so kind as to point me toward a step by step set of instructions for creating and using a personal or rather, nonstandard UDF? Thank you for your time and trouble. The only thing I have to say for myself is that perhaps someday I will be proficient enough that I can answer questions for some other person. Link to comment Share on other sites More sharing options...
enaiman Posted August 28, 2008 Share Posted August 28, 2008 You will get better help if you post your script. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
LostZXC Posted August 29, 2008 Author Share Posted August 29, 2008 Never hurts to add info, so here it is. Sorry for not providing it int the first place. I am still getting the hang of things in these parts.RUN_KEYNOTE.au3 Link to comment Share on other sites More sharing options...
LostZXC Posted August 29, 2008 Author Share Posted August 29, 2008 Sorry, I thought that the script would be displayed, in the forum window. Here it is. I am trying to get a flash drive loaded with keynote, and an autoit exe that will open a keynote file. I Tried it without the registration... that is without having keynote installed on a machine, and it tilted because windows was unfamiliar with the file extension. All worked well 0n my machine where keynote is installed. I am sure I could make this work as is, but I want to learn how to do thing the right way. #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Include <Array.au3> #Include <FileRegister.au3> #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.13.7 (beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here local $target local $here local $drive Local $counter $drive=DriveGetDrive ( "all" ) for $counter = 1 to $drive[0] local $label =DriveGetLabel ( $drive[$counter] ) If $label = "Bernie's" Then local $target = $drive[$counter] & " "&$label local $here = $drive[$counter] ExitLoop EndIf Next _FileRegister ("knt", $here&"\KeyNote_Directory\keynote.exe", "Open with ProgramName", 1,"", "KeyNote file") ShellExecute($here&"\KeyNote_Directory\keynote.exe",$here&"\My KeyNote files\bernie's notes.knt") Link to comment Share on other sites More sharing options...
enaiman Posted August 29, 2008 Share Posted August 29, 2008 What I can see so far: You declare "local" variables in global scope and that's not a good practice at all - use Dim or Global. You will declare variables as "local" inside functions - not on the main script. Advice - declare only variables on top of your script (Dim or Global) - the following lines, get rid of "local" thing (local $label =DriveGetLabel ( $drive[$counter] ) )and try again. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
LostZXC Posted September 22, 2008 Author Share Posted September 22, 2008 __________________________________Resolution____________________________________sorry, but I thought I had already posted the result. After trying a few things we (mostly enaiman) determined that the udf name I was trying to call was not the same as the one listed. I thought that you had to prefix the name of a function you called upon with an underscore... Not So. What I had was this: Notice the little red fellow right before ' FileRegister("knt..... ' , that was my problem.#Include <FileRegister.au3>_FileRegister ("knt", $here&"\KeyNote_Directory\keynote.exe", "Open with ProgramName", 1,"", "KeyNote file") I told autoit to include FileRegister.au3. That means that I could then call upon the functions that are written in FileRegister.au3. However I called upon a bogus function, because I changed the name by putting the underscore in front. After removing the underscore all better, as far as making things work right. Alas I was still not able to make keynote behave. At length I locked the keyboard and mouse then pulled up a run box, and used it to activate the file I wanted. If anyone comes across a better way, or sees something I did wrong please let me know. I appreciate the opportunity to learn when I have made a mistake. Below is the final code that I used.#Include <Array.au3>#cs ----------------------------------------------------------------------------AutoIt Version: 3.2.13.7 (beta)Author: LostZXCScript Function: open a keynote file on a flashdriveTemplate AutoIt script.#ce ----------------------------------------------------------------------------; Script Start - Add your code below hereglobal $target global $here global $driveglobal $counterglobal $labelglobal $here1$drive=DriveGetDrive ( "all" )for $counter = 1 to $drive[0]$label =DriveGetLabel ( $drive[$counter] )If $label = "Bernie's" Then$target = $drive[$counter] & " "&$label$here = $drive[$counter]ExitLoopEndIfNext$here1 = StringStripWS($here,3)If $here1 = "" Then MsgBox(0,"Uh Oh !!!","I could not find the drive labeled [bernie's]. If you have renamed it please change it back") ExitEndIfSend("{Lwindown}r{LwinUp}")Do sleep(100)Until WinActive("Run") = 1If WinActive("Run") = 1 Then Send( $here & '\KeyNote_Directory\keynote.exe "' & $here & "\My KeyNote files\bernie'" & 's notes.knt"{enter}')EndIf Exit Link to comment Share on other sites More sharing options...
martin Posted September 22, 2008 Share Posted September 22, 2008 (edited) If you have #include <udffile.au3> then scite will look in the include file for product or Beta depending on how you ask it to run or compile. (There is a way to set a list of folders to search but I've forgotten, someone is bound to say.) If =you want to have the udf in the script dir then #include "udffile.au3" or if you simply want to have it some other folder then #include "c:\scripts\autoit\folder3\udffile.au3" Edited September 22, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now