Sign in to follow this  
Followers 0
siriom

Attach to a window

14 posts in this topic

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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

The help is decent if you know what youre looking for.

It doesnt explain what a hwnd is or what a control id is though

Share this post


Link to post
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 ?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
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 ...

Share this post


Link to post
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)


Share this post


Link to post
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

Share this post


Link to post
Share on other sites

you cant get pixel color with out bringing window foreground.

For this you can use M such as Virtual Box or VMware


edited

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0