 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Night Guest
|
Posted: Sun Aug 12, 2007 7:11 pm Post subject: Send Command to Firefox |
|
|
Hi,
I want to send some commands to firefox.
He should do 499 times arrow left and then one time arrow up with a sleep of 1,5-2 sec.
Is it possible to send it always to firefox, even if he is not the active window?
Maybe also to say to which tab?
Or if not, how can I make it work the script gets paused when firefox is not the active window?
What I got so far is this:
| Code: | SetTimer, KeepRunning
Return
KeepRunning:
WinGet, szProcessName, ProcessName, A
If szProcessName = firefox.exe
Pause, off
Else
Pause, on
Return
~Pause::
Loop, 499
{
Break
Sleep 1900
SendInput {Left down}
Sleep 100
SendInput {Left up}
}
Sleep 1900
SendInput {Down down}
Sleep 100
SendInput {Down up}
Return |
But pause doesnt work.. hope for help, thx |
|
| Back to top |
|
 |
Rabiator
Joined: 17 Apr 2005 Posts: 264 Location: Sauerland
|
Posted: Sun Aug 12, 2007 10:21 pm Post subject: |
|
|
You should omit the Break in the loop.
__________________________________________
Created with BBCodeWriter 7.0 - the one and only  |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6349 Location: Pacific Northwest, US
|
Posted: Mon Aug 13, 2007 5:03 pm Post subject: |
|
|
Instead of using a loop, you can use SetKeyDelay, then send {left 499}{up}
Also, to sent to firefox when it is not active, use ControlSend, though you may have some trouble. Get it working against notepad first. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Night Guest
|
Posted: Mon Aug 13, 2007 5:23 pm Post subject: |
|
|
Could you modifiy my script and post it so it works?
Im not very good in this :/
Best would be:
FF active = 499 left
make another window active: script pause
FF active again = unpause.
I cant get the pause function to work.. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6349 Location: Pacific Northwest, US
|
Posted: Mon Aug 13, 2007 5:33 pm Post subject: |
|
|
you are currently using "Pause" in two ways. Do you want:
A)
script is disabled when firefox is not active (better to use #IfWinActive on the hotkey instead)
B)
script is sending keys to firefox, but you want to stop sending keys if you change programs, then resume (where it left off) when firefox is active again (better to use WinGet and extra loop inside your loop)
you are also using the Pause key as a hotkey to start it, and a Pause On and Off command, which are unrelated to all of the above. Maybe you just need to add the last (1) parameter to the pause command. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Night Guest
|
Posted: Mon Aug 13, 2007 5:50 pm Post subject: |
|
|
Option B) is what I want x)
I used the "pause" key because its one if the keys I normally dont need. Using the Roll key would also be possible. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6349 Location: Pacific Northwest, US
|
Posted: Mon Aug 13, 2007 5:55 pm Post subject: |
|
|
| Code: |
~Pause::
Loop, 499
{
WinGet, szProcessName, ProcessName, A
If (szProcessName != "firefox.exe")
Loop,
{
WinGet, szProcessName, ProcessName, A
If (szProcessName = "firefox.exe")
Break
}
Sleep 1900
SendInput {Left down}
Sleep 100
SendInput {Left up}
}
Sleep 1900
SendInput {Down down}
Sleep 100
SendInput {Down up}
Return
|
there are better ways of doing this. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Night Guest
|
Posted: Mon Aug 13, 2007 6:15 pm Post subject: |
|
|
What would be better?
I am here for learning x) |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|