Jump to content

HotKeySet


 Share

Recommended Posts

im pretty new to autoit used some other programs like it in the past but it's been along time im having problems getting the HotKeySet command to work and i can't figure out what im doing wrong i tried setting up the script on just a continuous loop to make sure it would work and it did but when i introduce HotKeySet into the script nothing here is the script dont laugh at it's feebleness i just started ^.^

----------------------------------------------------------------------------------------------------------------------------------------------------------------

HotKeySet( "{q}" , "_runag" )
    
Func _runag()
        Send( "{T}" )
        Sleep( 100 )
        MouseMove( 306,150 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        MouseMove( 385, 454 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        Send( "{Backspace}" )
        Sleep( 100 )
        Send( "{5}" )
        Send( "{0}" )
        Send( "{0}" )
        Sleep( 100 )
        MouseMove( 534, 456 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 1000 )
        Send( "{T}" )
        Sleep( 100 )
        Send( "{E}" )
        Sleep( 100 )
        MouseMove( 744, 176 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        MouseMove( 740, 450 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        Send( "{Backspace}" )
        Sleep( 100 )
        Send( "{5}" )
        Send( "{0}" )
        Send( "{0}" )
        MouseMove( 963, 452 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 5000 )   
EndFunc

While 1
WEnd
Link to comment
Share on other sites

  • Moderators

stig90,

You have un-needed { } around the "key" parameter. :)

This works for me: :mellow:

HotKeySet("q", "_runag")

While 1
    Sleep(10)
WEnd

Func _runAg()
    ConsoleWrite("Hit" & @CRLF)
EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

new script still nothing

HotKeySet( "{q}" , "_runag" )
While 1
Sleep( 100 )
WEnd   
Func _runag()
        Send( "{T}" )
        Sleep( 100 )
        MouseMove( 306,150 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        MouseMove( 385, 454 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        Send( "{Backspace}" )
        Sleep( 100 )
        Send( "{5}" )
        Send( "{0}" )
        Send( "{0}" )
        Sleep( 100 )
        MouseMove( 534, 456 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 1000 )
        Send( "{T}" )
        Sleep( 100 )
        Send( "{E}" )
        Sleep( 100 )
        MouseMove( 744, 176 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        MouseMove( 740, 450 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        Send( "{Backspace}" )
        Sleep( 100 )
        Send( "{5}" )
        Send( "{0}" )
        Send( "{0}" )
        MouseMove( 963, 452 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 5000 )   
EndFunc

edited to be less huge and annoying since i forgot the [autoit] part on the coding

Edited by stig90
Link to comment
Share on other sites

  • Moderators

stig90,

Read my post above! :mellow:

M23

P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

HotKeySet( "q" , "_runag" )

While 1
Sleep( 100 )    
WEnd

Func _runag()
        Send( "{T}" )
        Sleep( 100 )
        MouseMove( 306,150 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        MouseMove( 385, 454 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        Send( "{Backspace}" )
        Sleep( 100 )
        Send( "{5}" )
        Send( "{0}" )
        Send( "{0}" )
        Sleep( 100 )
        MouseMove( 534, 456 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 1000 )
        Send( "{T}" )
        Sleep( 100 )
        Send( "{E}" )
        Sleep( 100 )
        MouseMove( 744, 176 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        MouseMove( 740, 450 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 100 )
        Send( "{Backspace}" )
        Sleep( 100 )
        Send( "{5}" )
        Send( "{0}" )
        Send( "{0}" )
        MouseMove( 963, 452 )
        Sleep( 100 )
        MouseClick( "Left" )
        Sleep( 5000 )   
EndFunc

still nothing

Link to comment
Share on other sites

  • Moderators

stig90,

If you run the exact script I posted - do you get the "Hit" in the SciTE console? That will show if the code works (and it does for me). :mellow:

What are you trying to automate with this script? Perhaps it is that app which is resisting the automation - not your script failing. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

stig90,

If pressing the "q" key with that script running does not fire the function then there is something wrong. Do you by chance have a previous instance of the script already running and so blocking the "q" key? :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

nope tbh i used autoit in the past along with some different programs like it and i vaguely remember hotkeyset working but since ive redownloaded autoit havn't been able to get it to work i can run the script once or set it on an infinite loop and it will work fine

Edited by stig90
Link to comment
Share on other sites

  • Moderators

stig90,

Please run this:

$iRet = HotKeySet("q", "fred")

If $iRet Then
    MsgBox(0, "HotKey", "has been SET")
Else
    MsgBox(0, "HotKey", "has NOT been SET")
EndIf

Func fred()
EndFunc

Perhaps you already have something blocking the "q" key from being set by AutoIt. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

stig90,

So try this: :mellow:

HotKeySet("q", "fred")

While 1
    Sleep(10)
WEnd

Func fred()
    MsgBox(0, "HotKey", "Pressed")
    Exit
EndFunc

Having fun? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

stig90,

i have alot to learn

So did we all at the beginning! :)

And do not get discouraged - you can get lots of help here if you show some effort. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 2 weeks later...

mm... hi! :)

I also encountered this problem.

for this code, the result is "has been set".

$iRet = HotKeySet("q", "fred")
 
If $iRet Then
    MsgBox(0, "HotKey", "has been SET")
Else
    MsgBox(0, "HotKey", "has NOT been SET")
EndIf
 
Func fred()
EndFunc

and for this

HotKeySet("q", "fred")
 
While 1
    Sleep(10)
WEnd
 
Func fred()
    MsgBox(0, "q", "Pressed")
    Exit
EndFunc

nothing

but keys like space or escape are read correctly

please help me :mellow:

Edited by fosder
Link to comment
Share on other sites

  • Moderators

fosder,

Your second snippet works perfectly for me. Are you saying that you do not get a MsgBox? :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...