cxs Posted February 26, 2009 Posted February 26, 2009 Hi, I simply can't get this to run inside a Func. It runs fine if I remove the func test() and the endfunc and just run or compile it.. but not inside the function. I think I need some help on this one please. Func test() Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Program Manager","") If Not WinActive("Program Manager","") Then WinActivate("Program Manager","") WinWaitActive("Program Manager","") MouseClick("left",122,959,2) WinWait("earth","") If Not WinActive("earth","") Then WinActivate("earth","") WinWaitActive("earth","") MouseMove(666,573) MouseDown("left") MouseUp("left") WinWait("Flowers","") If Not WinActive("Flowers","") Then WinActivate("Flowers","") WinWaitActive("Flowers","") MouseMove(97,194) MouseDown("left") MouseUp("left") MouseMove(277,595) MouseDown("left") MouseUp("left") MouseMove(427,392) MouseDown("left") MouseUp("left") MouseMove(485,605) MouseDown("left") MouseUp("left") WinWait("Barbarossa","") If Not WinActive("Barbarossa","") Then WinActivate("Barbarossa","") WinWaitActive("Barbarossa","") MouseMove(514,397) MouseDown("right") MouseMove(515,396) MouseUp("right") EndFunc
Monamo Posted February 26, 2009 Posted February 26, 2009 Hi, I simply can't get this to run inside a Func. It runs fine if I remove the func test() and the endfunc and just run or compile it.. but not inside the function. I think I need some help on this one please. CODE Func test() Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Program Manager","") If Not WinActive("Program Manager","") Then WinActivate("Program Manager","") WinWaitActive("Program Manager","") MouseClick("left",122,959,2) WinWait("earth","") If Not WinActive("earth","") Then WinActivate("earth","") WinWaitActive("earth","") MouseMove(666,573) MouseDown("left") MouseUp("left") WinWait("Flowers","") If Not WinActive("Flowers","") Then WinActivate("Flowers","") WinWaitActive("Flowers","") MouseMove(97,194) MouseDown("left") MouseUp("left") MouseMove(277,595) MouseDown("left") MouseUp("left") MouseMove(427,392) MouseDown("left") MouseUp("left") MouseMove(485,605) MouseDown("left") MouseUp("left") WinWait("Barbarossa","") If Not WinActive("Barbarossa","") Then WinActivate("Barbarossa","") WinWaitActive("Barbarossa","") MouseMove(514,397) MouseDown("right") MouseMove(515,396) MouseUp("right") EndFunc When you put the opening and closing tags for your function, do you actually call the function in your code separately? That is... test() Func test() ; code block EndFunc - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
Skruge Posted February 26, 2009 Posted February 26, 2009 Welcome to the forums. Functions need to be called. Add this to the top of your script.test() [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]
cxs Posted February 26, 2009 Author Posted February 26, 2009 Hi, thanks for the fast replies.I have tried all I can think of. If I add test() to the top nothing happens.if I remove the "in bold"func test()code..endfuncand just leave the middle code part and compile, then it works flawlessly. but why not inside the func?
jvanegmond Posted February 26, 2009 Posted February 26, 2009 Since you need everything repeatedly explained over and over and over. expandcollapse popup; READ THE NEXT LINE!!!! test() ; <== PUT THIS HERE!!!!! ; READ THE PREVIOUS LINE!!!!! Func test() Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Program Manager","") If Not WinActive("Program Manager","") Then WinActivate("Program Manager","") WinWaitActive("Program Manager","") MouseClick("left",122,959,2) WinWait("earth","") If Not WinActive("earth","") Then WinActivate("earth","") WinWaitActive("earth","") MouseMove(666,573) MouseDown("left") MouseUp("left") WinWait("Flowers","") If Not WinActive("Flowers","") Then WinActivate("Flowers","") WinWaitActive("Flowers","") MouseMove(97,194) MouseDown("left") MouseUp("left") MouseMove(277,595) MouseDown("left") MouseUp("left") MouseMove(427,392) MouseDown("left") MouseUp("left") MouseMove(485,605) MouseDown("left") MouseUp("left") WinWait("Barbarossa","") If Not WinActive("Barbarossa","") Then WinActivate("Barbarossa","") WinWaitActive("Barbarossa","") MouseMove(514,397) MouseDown("right") MouseMove(515,396) MouseUp("right") EndFunc github.com/jvanegmond
cxs Posted February 26, 2009 Author Posted February 26, 2009 quote name='Manadar' date='Feb 26 2009, 10:31 PM' post='649779' Since you need everything repeatedly explained over and over and over. ; READ THE NEXT LINE!!!! test() ; <== PUT THIS HERE!!!!! ; READ THE PREVIOUS LINE!!!!! /quote I have tried that and it's not working. Kinda rude considering that your not helping !.
jvanegmond Posted February 26, 2009 Posted February 26, 2009 quote name='Manadar' date='Feb 26 2009, 10:31 PM' post='649779'Since you need everything repeatedly explained over and over and over.; READ THE NEXT LINE!!!!test() ; <== PUT THIS HERE!!!!!; READ THE PREVIOUS LINE!!!!!/quoteI have tried that and it's not working. Kinda rude considering that your not helping !.Very rude you are ignoring everyone's replies, not stating what you have tried and learned so far, and just make us repeat the same thing again.Beside that, you are asking for help and I possibly have solutions. I think I am entitled to be as rude as I see fit to be, as long as it gets the message across. github.com/jvanegmond
Moderators Melba23 Posted February 26, 2009 Moderators Posted February 26, 2009 cxs,Let me try and explain.You have your code inside Func....EndFunc statements. It will only therefore run if you call the function test(). What everyone is suggesting is that you add the function call to the top of your code so that you can get the code inside to run.Your first post:Func test() ... EndFuncNo way for Autoit to know that you want to run the code inside the function - it cannot read your mind, you have to tell it what to do!What the other posters are suggesting:test() Func test() ... EndFuncThis code starts by telling AutoIt to run the code in function test() and the code is therefore run!When you remove the Func...EndFunc statements AutoIt now sees the code as ready to run and so runs it. That is why it works when you remove those statements.I hope that is clear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
cxs Posted February 26, 2009 Author Posted February 26, 2009 Ok, I did post this:Hi, thanks for the fast replies.I have tried all I can think of. If I add test() to the top nothing happens.if I remove the "in bold"func test()code..endfuncand just leave the middle code part and compile, then it works flawlessly. but why not inside the func?I have tried calling the function withtest()Func test()code..EndfuncI have tried nesting it into antest()Func test()$aa=1If Not $aa=1 Then$aa=1elsethe above code I can't get to workEndifEndfuncI know I'm not an autoit genious thats why I'm asking for help, it looks to me like it should be able to be run from inside an Func. but the only way I can get my code to run is making a script like:code..and nothing else. I sismply can't understand whytest()Func test()code..Endfuncus not working.
qazwsx Posted February 26, 2009 Posted February 26, 2009 try running test() Func test () Consolewrite ("Works") Endfunc
cxs Posted February 26, 2009 Author Posted February 26, 2009 try running test() Func test () Consolewrite ("Works") Endfunc haha ... but it isn't. if I run it without the function the mouse starts moving around my screen and do stuff. If I add a function around it nothing happens. to me there should be no difference between the function or no function in this bit of code. I doubleclick the file with the function around it and exactly nothing happens. no mousemove, nothing. And I realy can't see why your making fun of me when I say it's not working. have any of you actually tested it???, because here on my side nothing happens... and this is the last bit of code I need before I have finished my program..
jvanegmond Posted February 26, 2009 Posted February 26, 2009 cxz, you're doing something else wrong. Your code works for everyone else, as far as I know. I don't see where it could go wrong. You are doing something else on the side of just encapsulating it in Func .. EndFunc and calling the function. Simplify your problem, test the problem again, try to find out what happened, then post back. github.com/jvanegmond
qazwsx Posted February 26, 2009 Posted February 26, 2009 I was being serious. Does that code work, if so we can begin to find the problem. Always start simple. Perhaps it has something to do with setting options inside of the function (not sure, no helpfile in front of me).
jvanegmond Posted February 26, 2009 Posted February 26, 2009 I was being serious. Does that code work, if so we can begin to find the problem. Always start simple. Perhaps it has something to do with setting options inside of the function (not sure, no helpfile in front of me).That's not it. A lot of people set options inside functions. It happens in UDFs as well. github.com/jvanegmond
muncherw Posted February 26, 2009 Posted February 26, 2009 I was being serious. Does that code workYes it does. I've tested it and I'm sure the other guys have as well. Works okay for me. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
cxs Posted February 26, 2009 Author Posted February 26, 2009 Yes it does. I've tested it and I'm sure the other guys have as well. Works okay for me.Well, thanks for all your help... Must be something related to my Vista 64bit then?, or perhaps some program or.. I don't know..Anyway, I'm closing this and finding another way to solve it. Appreciate it .. I'll continue learning autoit, it is a great program.
James Posted February 27, 2009 Posted February 27, 2009 There is nothing anyone else can do. If you really are 100% sure that this code won't run:TestMe() Func TestMe() MsgBox(0, "Hello?", "Can you see me?") ConsoleWrite("Can you see me?" & @CRLF) EndFuncThen supply the Trac with your PC details, including:Windows VersionService PacksLanguageProcessor (always useful)But this works for everyone, if it does not work then you have a serious problem. Try install AutoIt again. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
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