Jump to content

How to get hotkeys working with certain windows?


 Share

Recommended Posts

Hello,

I wanted to create a macro that would spamm the keys 7 and 8 on my keyboard until i press a new hotkey, as i have no programming experience i messed around with AutoIt and i have made this so far:

HotKeySet("o", "PauseProg") 
HotKeySet("p", "StartProg") 

While 1
    Sleep(100)  
    Wend

Func StartProg()  
    while 1
        Send("7") 
    Send("7") 
    Send("7") 
    Send("7") 
    Send("7") 
     Send("8") 

    WEnd
EndFunc


Func PauseProg()  
 While 1
    Sleep(100) 
Wend
EndFunc

It does what its suppose to do, i have 5 of those "Send("7")" because then it gives perfect timing, but the problem is that inside the window where it should send the keys when pressing the hotkey it will do nothing, i changed the application to windowed mode, put notepad next to the window, selected notepad, clicked the hotkey and then clicked on the application which was window moded, then it would work, same concept for pausing it. But it is annoying and takes away valuable seconds, is there any way to make it so the hotkeys would work when the application is foremost or do i need to learn some c++ or something?

Thanks!

Edited by jumper
Link to comment
Share on other sites

Maybe this example help you:

HotKeySet("{ESC}","Quit")
$GUI = GUICreate("My program",100,100)
GUISetState()

While 1
    Sleep(25)
WEnd

Func Quit()
    If WinActive("My program") Then
        Exit
    EndIf
EndFunc

When the words fail... music speaks.

Link to comment
Share on other sites

Maybe this example help you:

HotKeySet("{ESC}","Quit")
$GUI = GUICreate("My program",100,100)
GUISetState()

While 1
    Sleep(25)
WEnd

Func Quit()
    If WinActive("My program") Then
        Exit
    EndIf
EndFunc
It does not...

unless..

Would it be possible to make this "My program" window stay foremost 24/7 ...so it would be foremost at the same time while other windows get switched to foremost xD?

Link to comment
Share on other sites

Look in help file about WinExists,WinWaitActive and WinActivate.

I think your not following me at all, the application becomes foremost and blocks the hotkeys set by me, but if i use some other application, notepad for an example, i can start the script from there and then change manually to the application window where it will continue to send the keys it was sending a moment ago to notepad, but still hotkeys do not work.

Using the example you have given me makes the use of the script utterly pointless, just more code but no hotkeys working inside the application, it is not a workaround for the problem.

Link to comment
Share on other sites

Ok, it sounds like the game is blocking it to prevent in the game developer's mind of cheating. What you may want to look at is to see if the on-screen keyboard works. If it does, you may be able to get the hotsetkey to work on that.

No luck..

any other ideas?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...