Jump to content

Recommended Posts

Posted

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

Posted

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]

Posted

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]

Posted

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..

endfunc

and just leave the middle code part and compile, then it works flawlessly. but why not inside the func?

Posted

Since you need everything repeatedly explained over and over and over.

; 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
Posted

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 !.

Posted

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 !.

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.

  • Moderators
Posted

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()
...
EndFunc

No 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()
...
EndFunc

This 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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..

endfunc

and just leave the middle code part and compile, then it works flawlessly. but why not inside the func?

I have tried calling the function with

test()

Func test()

code..

Endfunc

I have tried nesting it into an

test()

Func test()

$aa=1

If Not $aa=1 Then

$aa=1

else

the above code I can't get to work

Endif

Endfunc

I 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 why

test()

Func test()

code..

Endfunc

us not working.

Posted

try running

test()
Func test ()
Consolewrite ("Works")
Endfunc

haha :P...

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..

Posted

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.

Posted

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).

Posted

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.
Posted

I was being serious. Does that code work

Yes 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]
Posted

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.

Posted

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)
EndFunc

Then supply the Trac with your PC details, including:

  • Windows Version
  • Service Packs
  • Language
  • Processor (always useful)
But this works for everyone, if it does not work then you have a serious problem. Try install AutoIt again.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...