Jump to content

Attach to a window


Recommended Posts

Heya

Im a novice in autoit im afraid.

I have a working script , does what its suppose to except for the part where it no longer works if i alt tab out of the window where its suppose to run.

How do I attach a script to a window ?

1 silly example is all i need to get started.

Thanks.

Link to comment
Share on other sites

I dont understand what you are trying to do. Different things perform differently in different situations, so just saying 'it no longer works if I alt tab out of the window' will get you no-where; there could be any number of problems.

Please tell us what your script does, and post the code for it. Then, it will be easy for us to debug.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
Share on other sites

Apologies . Ill be more specific.

It reads pixels/text , checks with a database and types in whats needed on the screen as a response.

So when i alt tab , it reads pixels off the new screen and sends text to the current screen instead of the one its suppose to .

I guess i can run it under a virtual machine .i.e install everything on a virtual machine , run the script and then i can minimize it and it would still be running.

Even though this "short cut" works im willing to go to the trouble of "attaching" this script to specific window.

Meaning ... it would read pixels and stuff on that window and send replies to that window alone and not the current window i might have up....

Hope that made sense to you mate.

Link to comment
Share on other sites

Apologies . Ill be more specific.

It reads pixels/text , checks with a database and types in whats needed on the screen as a response.

So when i alt tab , it reads pixels off the new screen and sends text to the current screen instead of the one its suppose to .

I guess i can run it under a virtual machine .i.e install everything on a virtual machine , run the script and then i can minimize it and it would still be running.

Even though this "short cut" works im willing to go to the trouble of "attaching" this script to specific window.

Meaning ... it would read pixels and stuff on that window and send replies to that window alone and not the current window i might have up....

Hope that made sense to you mate.

When you say 'send' text to the current screen Im assuming you are using the Send() command.

This command simulates presses of the keyboard and is not what you want.

What you want is the 'ControlSend' command, which allows you to send text to a specific control, on a specific window.

If the control is an webpage, consider using the IE library instead for filling in forms.

You description sounds a bit like a game bot or a auto-poster. If this is correct, I suggest you read the forum rules and stop posting. If i am wrong, soldier on.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
Share on other sites

Thanks will look up controlsend then ... is there a control get pixel checksum too ? :=)

no idea. There is a get pixel function though.

The helpfile is your friend. Autoit boasts THE most extensive and easy to use helpfile out of all interpreted languages across the world IMHO.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Link to comment
Share on other sites

Trying to get this to work and its ... well .... odd

Heres a concrete example then . I opened a mspaint , color it all pink for example and run this

$handle = ControlGetHandle("Untitled - Paint", "", "")

$oi = PixelGetColor( 58,166 , $handle)

ClipPut ($oi)

Pretty straight forward right ?

then i run this

msgbox (1,"oi","oi") ;tab to the mspaint window in question

sleep(3000)

$oii = PixelGetColor( 58, 166)

clipput ($oii)

$oi doesnt equal $oii

What am i doing wrong ?

Link to comment
Share on other sites

Trying to get this to work and its ... well .... odd

Heres a concrete example then . I opened a mspaint , color it all pink for example and run this

$handle = ControlGetHandle("Untitled - Paint", "", "")

$oi = PixelGetColor( 58,166 , $handle)

ClipPut ($oi)

Pretty straight forward right ?

then i run this

msgbox (1,"oi","oi") ;tab to the mspaint window in question

sleep(3000)

$oii = PixelGetColor( 58, 166)

clipput ($oii)

$oi doesnt equal $oii

What am i doing wrong ?

Maybe it lost focus?

Did you try

WinActivate("Untitled ")

Edited by JoHanatCent
Link to comment
Share on other sites

Im a sad panda.

Thanks . You were right about the winactive. It solved the pixelget problem ... but now the screen flashes up whenever i do a pixelgetcolor.... Is there no work around this ? is there no way to get the pixel color without it pulling up the other screen ? its kinda annoying say when im watchin a movie and some other random screen pops up ...

Link to comment
Share on other sites

Im a sad panda.

Thanks . You were right about the winactive. It solved the pixelget problem ... but now the screen flashes up whenever i do a pixelgetcolor.... Is there no work around this ? is there no way to get the pixel color without it pulling up the other screen ? its kinda annoying say when im watchin a movie and some other random screen pops up ...

Did you try with:

Opt("PixelCoordMode",0)

Link to comment
Share on other sites

Opt("PixelCoordMode",0)

$handle = ControlGetHandle("Untitled - Paint", "", "")

WinActivate("Untitled - Paint")

;sleep(1000)

$lol = PixelGetColor( 58,166 , $handle)

Current code just in case im screwing something basic up.

And im afraid as soon as it hits the winactivate it brings the ms paint to the foreground which kinda kills the purpose of the extra programming.

Great job on the assists so far guys . Hope this is the last "bug" :huh2:

So what im lookin for here , to recap , is a way to get a pixelgetcolor without that window being brought to the foreground please.

Thanks

Link to comment
Share on other sites

"use m" ? sorry i didnt get that . yeah im sure vmware would work but theres no reason why it needs to bring the window to the foreground i mean ... theres got to be a way to get the pixel color without the need to swap window.

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