| View previous topic :: View next topic |
| Author |
Message |
m1m3r
Joined: 29 Apr 2006 Posts: 27 Location: Sweden
|
Posted: Wed Dec 26, 2007 8:54 am Post subject: Define position of a starting program or script? |
|
|
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 |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Wed Dec 26, 2007 9:00 am Post subject: |
|
|
a.ahk:
| Code: |
xpos_a = 100
ypos_a = 200
Run,b.exe %xpos_a% %ypos_a% |
b.ahk:
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 |
|
 |
m1m3r
Joined: 29 Apr 2006 Posts: 27 Location: Sweden
|
Posted: Wed Dec 26, 2007 9:15 am Post subject: |
|
|
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 |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1500
|
Posted: Wed Dec 26, 2007 8:33 pm Post subject: |
|
|
| 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 |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Wed Dec 26, 2007 8:43 pm Post subject: |
|
|
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 |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Wed Dec 26, 2007 9:05 pm Post subject: |
|
|
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 |
|
 |
m1m3r
Joined: 29 Apr 2006 Posts: 27 Location: Sweden
|
Posted: Wed Dec 26, 2007 9:10 pm Post subject: |
|
|
| 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 |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Thu Dec 27, 2007 2:45 am Post subject: |
|
|
| you missed the winwaitactive part,winwaitactive waits for your app to be active,then winmove moves it to the desired position. |
|
| Back to top |
|
 |
m1m3r
Joined: 29 Apr 2006 Posts: 27 Location: Sweden
|
Posted: Thu Dec 27, 2007 10:29 am Post subject: |
|
|
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 |
|
 |
dandy
Joined: 09 May 2007 Posts: 45
|
Posted: Thu Dec 27, 2007 10:33 am Post subject: |
|
|
have you tried:
| Code: |
run,myapp.exe,,hide
winwait,myapp.exe
winmove,myapp.exe |
|
|
| Back to top |
|
 |
|