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 

Send Command to Firefox

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





PostPosted: Sun Aug 12, 2007 7:11 pm    Post subject: Send Command to Firefox Reply with quote

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

PostPosted: Sun Aug 12, 2007 10:21 pm    Post subject: Reply with quote

You should omit the Break in the loop.

__________________________________________
Created with BBCodeWriter 7.0 - the one and only Very Happy
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6349
Location: Pacific Northwest, US

PostPosted: Mon Aug 13, 2007 5:03 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Night
Guest





PostPosted: Mon Aug 13, 2007 5:23 pm    Post subject: Reply with quote

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

PostPosted: Mon Aug 13, 2007 5:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Night
Guest





PostPosted: Mon Aug 13, 2007 5:50 pm    Post subject: Reply with quote

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

PostPosted: Mon Aug 13, 2007 5:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Night
Guest





PostPosted: Mon Aug 13, 2007 6:15 pm    Post subject: Reply with quote

What would be better?
I am here for learning x)
Back to top
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