Jump to content
Sign in to follow this  
Lord Zion

Can anyone please help a clueless newbie ?

Recommended Posts

Lord Zion

Hello guys,

I just want to do a simple thing (simple for you not for me hehe) i will explain:

I just want to make a script that keeps running on the backgroung (maybe with icontray if possible) and everytime i press ctrl+space it types 4 3 2 1

Ive been trying to do this opening a notepad and writing the numbers there, but it only opens the notepad.exe and nothing happens when i press ctrl+space.

I could do it without the hotkey thing, it opens and types correctly, but i cant get it to work with it.

So far thats my noob script:

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

HotKeySet("{LCTRL}+{SPACE}", "keys")

Func keys()

Send("4")

Sleep(500)

Send("3")

Sleep(500)

Send("2")

Sleep(500)

Send("1")

EndFunc

I hope you guys can help me.

Thx a lot ! :P

Share this post


Link to post
Share on other sites
SpookMeister

HotKeySet("^{SPACE}", "keys")
HotKeySet("{ESC}","Terminate")

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")

While 1
    Sleep(500)
WEnd

Func keys()
    Send("4321")
EndFunc

Func Terminate()
    Exit
EndFunc


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
SpookMeister

Your main problem was that your script had ended long before you were pressing the CTRL-SPACE. The while loop keeps your script alive so it can sense the hotkey being pressed.


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
Lord Zion

THANK YOU VERY VERY MUCH MAN !!!!!!!!

AWESOME !!!!

Share this post


Link to post
Share on other sites
Josbe

Alternative:

$sTitle = "Untitled - Notepad"
Opt("SendKeyDelay", 500)
HotKeySet("^{SPACE}", "keys")

Run("notepad.exe")
WinWaitActive( $sTitle )

While WinExists( $sTitle )
   sleep(500)
; some stuff here

WEnd
Exit

Func keys()
    IF NOT WinActive( $sTitle ) Then Return
    Send("4321")
    
; With Opt("SendKeyDelay", 500), these lines aren't neccesary
;Sleep(500)
;Send("3")
;Sleep(500)
;Send("2")
;Sleep(500)
;Send("1")
EndFunc
Edited by Josbe

Share this post


Link to post
Share on other sites
Lord Zion

Thx a lot for you too Josbe, you guys are awesome !

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.