how to send keys when start ahk file

Get help with using AutoHotkey and its commands and hotkeys
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

how to send keys when start ahk file

13 Oct 2017, 05:17

when i use command like this :
^s
click
return

this command not start automaticaly ,
and i should press ctrl + s key to start it

i tested this command to start automaticaly without press ( ctrl + s )

^s
run{click}
return

but i cannot get answer
User avatar
elModo7
Posts: 21
Joined: 01 Sep 2017, 02:38

Re: how to send keys when start ahk file

13 Oct 2017, 06:28

What is it that you want exactly? you want it to click just as you open the ahk file?
If so, you could do:

That way it runs just when you start it and then you can re-run with ctrl+s.
The "Sleep, 100" is just to give it some time, but can be removed.
And just in case you could add #persistent just at the beginning of the script to keep it from closing.
:beer:
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

Re: how to send keys when start ahk file

13 Oct 2017, 06:53

elModo7 wrote:What is it that you want exactly? you want it to click just as you open the ahk file?
If so, you could do:

That way it runs just when you start it and then you can re-run with ctrl+s.
The "Sleep, 100" is just to give it some time, but can be removed.
And just in case you could add #persistent just at the beginning of the script to keep it from closing.

cose should like this ?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
elModo7
Posts: 21
Joined: 01 Sep 2017, 02:38

Re: how to send keys when start ahk file

13 Oct 2017, 07:02

That's right, but it's not all that necessary, just my "raw code" should do the job too.
:beer:
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

Re: how to send keys when start ahk file

13 Oct 2017, 07:27

elModo7 wrote:That's right, but it's not all that necessary, just my "raw code" should do the job too.

thanks ahead
my last question is :
when i copy exmaple.ahk file in folder , this code cannot click on icon in Desktop
( my mean is : this click cannot go outside of folder window size )
when i use code like this
click

^s
click 10, 225, 2
return
-------------------------------------------
this code cannot go outside of folder window size
how can i resolve this problem ?
User avatar
elModo7
Posts: 21
Joined: 01 Sep 2017, 02:38

Re: how to send keys when start ahk file

13 Oct 2017, 07:32

Try this:

Change coordinates to your liking.
:beer:
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

Re: how to send keys when start ahk file

13 Oct 2017, 07:39

elModo7 wrote:Try this:

Change coordinates to your liking.

this code had behavior like previous code
---------------------------
Click

^s
MouseClick, left, 10, 225, 2
return
User avatar
elModo7
Posts: 21
Joined: 01 Sep 2017, 02:38

Re: how to send keys when start ahk file

13 Oct 2017, 07:44

AH! so you want to store your *.AHK file inside a folder, then have it go to the desktop and do click that folder/file right?
Then this is the complete code:

Code: [Select all] [Download] GeSHi © Codebox Plus

WinWait, , FolderView
IfWinNotActive, , FolderView, WinActivate, , FolderView
WinWaitActive, , FolderView
Send, {LWINDOWN}d{LWINUP}
MouseClick, left, 741, 375
Sleep, 100
:beer:
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

Re: how to send keys when start ahk file

13 Oct 2017, 07:56

elModo7 wrote:AH! so you want to store your *.AHK file inside a folder, then have it go to the desktop and do click that folder/file right?
Then this is the complete code:

Code: [Select all] [Download] GeSHi © Codebox Plus

WinWait, , FolderView
IfWinNotActive, , FolderView, WinActivate, , FolderView
WinWaitActive, , FolderView
Send, {LWINDOWN}d{LWINUP}
MouseClick, left, 741, 375
Sleep, 100

thank you
this problem resolved too ,
if i had opened website in browser ( like ie or mozilla or chrome ) and if i want to click on link within website in for example position 10 , 200
what can i do ?
( i tested this code and this code can click only within desktop and cannot click in everything else like browser )
User avatar
elModo7
Posts: 21
Joined: 01 Sep 2017, 02:38

Re: how to send keys when start ahk file

13 Oct 2017, 07:59

fun_9990 wrote:
elModo7 wrote:AH! so you want to store your *.AHK file inside a folder, then have it go to the desktop and do click that folder/file right?
Then this is the complete code:

Code: [Select all] [Download] GeSHi © Codebox Plus

WinWait, , FolderView
IfWinNotActive, , FolderView, WinActivate, , FolderView
WinWaitActive, , FolderView
Send, {LWINDOWN}d{LWINUP}
MouseClick, left, 741, 375
Sleep, 100

thank you
this problem resolved too ,
if i had opened website in browser ( like ie or mozilla or chrome ) and if i want to click on link within website in for example position 10 , 200
what can i do ?
( i tested this code and this code can click only within desktop and cannot click in everything else like browser )

Then you can use the initial one I gave you xD.
:beer:
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

Re: how to send keys when start ahk file

13 Oct 2017, 10:35

elModo7 wrote:...

elmodo7 , i am so sorry
this code is not working in browser
because cannot go outside of the folder window box
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

Re: how to send keys when start ahk file

13 Oct 2017, 18:16

i test it again
about use in browser
this command worked when it is in desktop but not work in folder
User avatar
elModo7
Posts: 21
Joined: 01 Sep 2017, 02:38

Re: how to send keys when start ahk file

17 Oct 2017, 10:09

fun_9990 wrote:i test it again
about use in browser
this command worked when it is in desktop but not work in folder

You asked about clicking outside of the folder(Desktop) if you wanted it to work in chrome.
Apparently Chrome has blank text for window tittle, what I'd do is use the Run function, go to the web you want in chrome, sleep
Lol my bad there you actually can, just use the same code with different window tittle, make it match yours:

Code: [Select all] [Download] GeSHi © Codebox Plus

WinWait, Wikipedia`, la enciclopedia libre - Google Chrome, Chrome Legacy Window
IfWinNotActive, Wikipedia`, la enciclopedia libre - Google Chrome, Chrome Legacy Window, WinActivate, Wikipedia`, la enciclopedia libre - Google Chrome, Chrome Legacy Window
WinWaitActive, Wikipedia`, la enciclopedia libre - Google Chrome, Chrome Legacy Window
MouseClick, left, 741, 375
Sleep, 100


That code, switches to your already opened chrome window, and clicks inside it.
If you want to go to that website without it being already open, just use

Code: [Select all] [Download] GeSHi © Codebox Plus

Run, http://yourweb.crap
At the beginning of the script.
:beer:
fun_9990
Posts: 14
Joined: 06 Oct 2017, 11:45

Re: how to send keys when start ahk file

21 Oct 2017, 09:36

elModo7 wrote:
fun_9990 wrote:i test it again
about use in browser
this command worked when it is in desktop but not work in folder

You asked about clicking outside of...


i think this code is not right
because when i open any website and try to click in sample position within it , this code has not any acitivity about open link
User avatar
elModo7
Posts: 21
Joined: 01 Sep 2017, 02:38

Re: how to send keys when start ahk file

26 Oct 2017, 05:04

I don't know exactly what you want to do, you first say something, then you want something slightly different xD.
Please explain it better.
:beer:
BoBo
Posts: 1423
Joined: 13 May 2014, 17:15

Re: how to send keys when start ahk file

26 Oct 2017, 05:15

when i use command like this :
^s
click
return

How's something like that won't throw an error? AFAIK that isn't a valid command!
Hellbent
Posts: 14
Joined: 23 Sep 2017, 13:34

Re: how to send keys when start ahk file

26 Oct 2017, 11:26

I Could be wrong here, but it looks like you are trying to make a hotkey to send a click, or w/e
It also looks like you want the coords for your clicks to be related to your screen and not just the active window.

Your script is auto executed and that is why when you have been running it (from the file explorer) it has been sending the clicks to the file explorer and not some other app.

First you might want to set the coordmode at the top of the script (you may or may not want to do this.)

Here is how you set your coords to be related to the screen



Next it looks like what you want to do is use ^s as a hotkey

Here is how you make that.

Code: [Select all] [Download] GeSHi © Codebox Plus

^s:: ;the two colons are needed to make it a hotkey
Click, x y
return


I hope this is what you were looking for.

Return to “Ask For Help”

Who is online

Users browsing this forum: Hellbent and 41 guests