AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Define position of a starting program or script?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
m1m3r



Joined: 29 Apr 2006
Posts: 27
Location: Sweden

PostPosted: Wed Dec 26, 2007 8:54 am    Post subject: Define position of a starting program or script? Reply with quote

From one script I want to run a second script, but the position of this GUI will be dynamically changed based on variables in script 1 - can this be done somehow?

Code:

Xpos = variable1
Ypos = variable2

Run, something.exe, Xpos, Ypos
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Wed Dec 26, 2007 9:00 am    Post subject: Reply with quote

a.ahk:
Code:

xpos_a = 100
ypos_a = 200
Run,b.exe %xpos_a% %ypos_a%

b.ahk:
Code:
MsgBox %0% %1% %2%

Compile both and start a.exe and watch b.exe tell how many parameters (%0% and the value of them %1% and %2%).
To assign to named variables:
Code:
xpos = %1%
ypos = %2%

_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
m1m3r



Joined: 29 Apr 2006
Posts: 27
Location: Sweden

PostPosted: Wed Dec 26, 2007 9:15 am    Post subject: Reply with quote

Thanks, but I accidentally left out some information in my first post - sometimes script 1 will launch other programs that are not compiled AHK scripts.

Since your solution passes xpos and ypos as variables to script 2 this can't be done to a third party application.
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1500

PostPosted: Wed Dec 26, 2007 8:33 pm    Post subject: Reply with quote

Code:
Run, %a_AHKPath% "%YourSecondScript% %param1% %Param2% ... "


That will pass parameters to YourSecondScript, and will be accessable in the that script by the built in variables %1% and %2% for params 1 and 2 respectively.

If any 3rd party apps accept parameters, you can have AHK pass them like:
Code:
run i_view32.exe /clippaste /convert=YourScreenShot.png

Which is an example for saving a screenshot with irfanview's kernel.
_________________
My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 604
Location: 127.0.0.1

PostPosted: Wed Dec 26, 2007 8:43 pm    Post subject: Reply with quote

External Apps might be repositioned using
Quote:

WinMove

--------------------------------------------------------------------------------

Changes the position and/or size of the specified window.

WinMove, X, Y
WinMove, WinTitle, WinText, X, Y [, Width, Height, ExcludeTitle, ExcludeText]


Autohotkeys Helpfile is your friend.

greets
derRaphael
_________________
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Wed Dec 26, 2007 9:05 pm    Post subject: Reply with quote

Using winmove:
Code:
Run,notepad.exe,,,pid
WinWaitActive,ahk_pid %pid%
WinMove,ahk_pid %pid%,,1,1,400,400

_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
m1m3r



Joined: 29 Apr 2006
Posts: 27
Location: Sweden

PostPosted: Wed Dec 26, 2007 9:10 pm    Post subject: Reply with quote

I have already tried using WinMove, but since the computer that the script will be running on is not extremely fast and some applications are rather large I had to experiment with different delays (to make sure the application was loaded) or else it did not work.
Back to top
View user's profile Send private message
dandy



Joined: 09 May 2007
Posts: 45

PostPosted: Thu Dec 27, 2007 2:45 am    Post subject: Reply with quote

you missed the winwaitactive part,winwaitactive waits for your app to be active,then winmove moves it to the desired position.
Back to top
View user's profile Send private message
m1m3r



Joined: 29 Apr 2006
Posts: 27
Location: Sweden

PostPosted: Thu Dec 27, 2007 10:29 am    Post subject: Reply with quote

Not really, winwaitactive gives the same result as delaying the script. What I want is the application to start on a given position, not to be moved there.

Perhaps there are settings in the registry that one could use - after all, Windows itself (sometimes) remember window positions.
Back to top
View user's profile Send private message
dandy



Joined: 09 May 2007
Posts: 45

PostPosted: Thu Dec 27, 2007 10:33 am    Post subject: Reply with quote

have you tried:

Code:

run,myapp.exe,,hide
winwait,myapp.exe
winmove,myapp.exe
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group