Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Sending multiple hotkeys



  • Please log in to reply
11 replies to this topic
tony787
  • Members
  • 7 posts
  • Last active: Sep 27 2014 02:03 AM
  • Joined: 25 Sep 2014

So heres what i have, i want to fill out a form with a bunch of hotkeys, what am i doing wrong?

The hot key shown in this example im trying to execute is +1 which is Shift and 1 key, ive tried several ways but its either not entering anything or sending the actual raw text +1 or just a number 1. Btw...... If i enter the +1 in a hotstring it works fine but i dont know how to call multiple hotstrings with 1 hotkey i dont even think its possible. Please someone help me, i cant figure this out. 

^+c::
Send +1
Send {Tab}
SendInput {Shift down}{1}{Shift up}
Send {Tab 2}
Send {o}
Send {Tab} 
Send {o}
Send {Tab}
Send {o}
Send {Tab 2}
SendInput {Raw}1234567890
Return


tony787
  • Members
  • 7 posts
  • Last active: Sep 27 2014 02:03 AM
  • Joined: 25 Sep 2014

anyone?



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

You can use the "gosub" command to call hotkeys within hotkeys.

Your example, modified, gives 2 "Hello".

Send, 1234567890 does not trigger the "+1" hotkey because of the #InputLevel directive.

^+c::
gosub, +1
Send {Tab}
gosub, +1
Send {Tab 2}
Send {o}
Send {Tab} 
Send {o}
Send {Tab}
Send {o}
Send {Tab 2}
Send 1234567890
Return

#InputLevel, 1
+1::Send, Hello


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


tony787
  • Members
  • 7 posts
  • Last active: Sep 27 2014 02:03 AM
  • Joined: 25 Sep 2014

@ OLDMAN Thanks for your reply, but its not working. Maybe i should explain further....

I need to call a hotkey which is triggered by +1 , this +1 hotkey is not created in autohotkey so i do not need to create and override the same hotkey which is whats going on in this script.



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

With 2 scripts in AutoHotkey, I can do it this way.

It's possible that you have to adjust the temporisation, if it works with your application.

; Script 1
#InputLevel, 1
^+c::
Send, +1{Sleep 5}
Send {Tab}
Send, {Shift down}1{Shift up}{Sleep 5}
Send {Tab 2}
Send {o}
Send {Tab} 
Send {o}
Send {Tab}
Send {o}
Send {Tab 2}
Send 1{Sleep 5}234567890
Return
; Script 2
+1::Send, Hello

Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


tony787
  • Members
  • 7 posts
  • Last active: Sep 27 2014 02:03 AM
  • Joined: 25 Sep 2014

Like i said i dont need to recreate a new hotkey for +1 so i dont see why i would need the 2nd script.

I did make progress though, by putting SendInput instead of Send its finally sending the hotkeys i want except they are not loading where i want them to, both +1 hotkeys are being pasted into the last form field where i call for the number 678. The first 2 fields where the hotkey text should be are empty... Any ideas?

^+c::
SendInput +1
Send {Tab}
SendInput +1
Send {Tab 2}
Send {o}
Send {Tab}
Send {o}
Send {Tab}
Send {o}
Send {Tab 2}
SendInput {Raw}678
Return


Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

Did you read my post ?

Because I was no telling you to use the 2nd script.


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


tony787
  • Members
  • 7 posts
  • Last active: Sep 27 2014 02:03 AM
  • Joined: 25 Sep 2014

I did read your post but im not sure what you want me to do? I tried adding the sleep commands but that didnt work.



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013
✓  Best Answer

The {Sleep} key doesn't sleep with the SendInput command. Well, it sleeps, but 0 ms.

It sleeps 10 ms with the Send command, if Send defaults to SendEvent.

{Sleep 5} = sleeps 50 ms.

 

If your application hotkeys react at the SendInput command, you probably can do this.

You may have to adjust the temporisation, in order to leave time to the application hotkey to trigger.

^+c::
SendInput, +1
Sleep 50
Send {Tab}
Send, +1
Sleep 50
Send {Tab 2}
Send {o}
Send {Tab} 
Send {o}
Send {Tab}
Send {o}
Send {Tab 2}
Send 1
Sleep 50
Send, 234567890
Return


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


tony787
  • Members
  • 7 posts
  • Last active: Sep 27 2014 02:03 AM
  • Joined: 25 Sep 2014

Thanks @OLDMAN adding the sleep commands on their own lines worked perfectly but now it seems i have an even bigger problem. When i hit the hotkey for it to start the script on a window it completely screws up the browser and window, the tab keys start going in reverse and the window completely scroll locks on me, even ctrl+c stops working and opens up the "view source" popup window... so i have to close the whole browser and open a new one. This is happening on both my browsers chrome, and firefox . I did some testing and i narrowed it down to the hotkeys causing the problem, but also it has something to do with a page with scroll because the same problem occurs in notepad when im pasting big amounts of text that involves scrolling down the notepad page. The script works perfectly fine in notepad when the hotkeys are assigned to small bits of text that dont make the window scroll. Is there some code im missing to make my script cooperate?

^+c::
Send ^+1 
Sleep 2000
Send {Tab}
Send +{F8}
Sleep 500
Send {Tab 2}
Send +{F9}
Sleep 500
Send {Tab}
Send +{F10}
Sleep 500
Send {Tab}
Send +{F11}
Sleep 500
Send {Tab 2}
SendInput {Raw}5623540716
Return



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

I've tested the hotkey on a French version of Firefox, on this post page and it works ok for me (with my test cases).

If I keep pressing on Ctrl+Shift during the whole hotkey process, the History panel opens (Ctrl+H).

 

As I don't know what, Ctrl+Shift+1, Shift+F8, Shift+F9, Shift+10 and Shift+F11, do in your application and what is the target Website, it'll be difficult to tell you what goes wrong.
 

You may have to investigate if it wouldn't be better to use IE and the COM interface.


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


tony787
  • Members
  • 7 posts
  • Last active: Sep 27 2014 02:03 AM
  • Joined: 25 Sep 2014

Thanks for being so helpful i finally fixed the problem by changing all send commands to SendInput and Shift F10 key to something else that key was causing me problems.