Jump to content

Couple newbie questions


Recommended Posts

Okay, keep in mind I'm a newb, and I don't really have any scripting or programming background. With that out of the way...

I'm starting to experiment with building a GUI. What I want to do is create a function that will take a variable and search Google with it. I know how I could manually do it, but I want to do it the fastest way, or "right" way. What would be the best way to do this. Here's what I have so far:

func googlesearch()

run("C:\Program Files\Mozilla Firefox\firefox.exe")

WinActivate("Mozilla Firefox")

WinWaitActive("Mozilla Firefox")

sleep(100)

send(guictrlread($input_1)) <------- this is my variable

send("{enter}")

Exit

EndFunc

now I know there's a far better way to do this... I just don't know how. How can I directly search google w/o manually running my web browser, sending the variable, then sending {enter}?

Also... is there a command that pauses the script until a webpage has loaded?

Link to comment
Share on other sites

$yourvar = ( inputbox.. blabla.....)

func googlesearch()
    run("C:\Program Files\Mozilla Firefox\firefox.exe
[url=http://www.google.nl/search?biw=1024&hl=nl&q=]http://www.google.nl/search?biw=1024&hl=nl&q=[/url] & $yourvar & &btnG=Google+zoeken&meta=")
EndFunc

lol, really dont know if something like this works... try it out.. didnt test tbh

Edited by MarkMarkMark
Link to comment
Share on other sites

$string = "AutoIt Scripting Language"

$sString = StringReplace($string, " ", "+")

run(@Comspec & '/c start www.google.com/search?q=" & $sString, "", @SW_HIDE)

that should do it for you

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

$string = "AutoIt Scripting Language"

$sString = StringReplace($string, " ", "+")

run(@Comspec & '/c start www.google.com/search?q=" & $sString, "", @SW_HIDE)

that should do it for you

<{POST_SNAPBACK}>

I couldn't get it to work -- the debugger said "Unable to execute the external program.:

run(@Comspec & "/c start www.google.com/search?q=" & $sString, "", @SW_HIDE)"

btw: what does the "@Comspec" and /c do?

Link to comment
Share on other sites

It's starts the default command line interpreter (either cmd.exe or command.com) and runs the command entered. Once finished executing, the '/c' closes the command line.

Start ... opens the file/hyperlink in the default associated program.

start myfile.doc

That should open the Word Document in MS Word (if installed), and if the file exists.

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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