Jump to content

My Coding does NOTHING when I press the hotkey


Go to solution Solved by jchd,

Recommended Posts

HotKeySet('h', 'Hotkey1')

Func Hotkey1()
    ConsoleWrite('The Hotkey was pressed' & @CRLF)
EndFunc     ;==>Hotkey1

While 1
    Sleep(50)
WEnd

Func MC()
    Sleep(10)
    MouseClick("LEFT", 702. 953, 1, 1)
EndFunc

 

 

When I hit the Hotkey, it confirms that I pressed the Hotkey, but it does not Mouseclick.  I'm new to this.  What have I done wrong?  Thanks!

:D

Link to comment
Share on other sites

Where in your code do you call function MC?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

41 minutes ago, thatboy said:

but it does not Mouseclick.

Why should it? You don't ask for that.

BTW do you realize that discussing automating games is forbidden here?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

10 minutes ago, jchd said:

Why should it? You don't ask for that.

BTW do you realize that discussing automating games is forbidden here?

 

I'm not using it to play Video Games, but I appreciate your very helpful input, bud.

:D

Link to comment
Share on other sites

18 minutes ago, thatboy said:

Am I supposed to do "Func Mouseclick" Instead?

Did you try? If yes, does it work?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

1 minute ago, water said:

Did you try? If yes, does it work?

 

I actually took out the "Hotkeyset" line.

And I took out "Func"

 

My goal is for it to do it on its own on an infinite loop.  This is just a small fraction of the code.  I'm trying to run this script successfully, before I add anything else.  And I've yet to successfully run a script.

Now I Just have this:

 

#include <AutoItConstants.au3>

While 1
    Sleep(50)
WEnd

$mouse_Speed(10)
MouseClick("LEFT", 702. 953, 1, 1)

 

I Run this script and nothing happens. 

 

:D

Link to comment
Share on other sites

  • Developers

Read that source again and try to understand when you will encounter the MouseClick() function. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Grab your original script and update the name of the function that should be called when you press the hotkey.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Solution

If you insist on invoking function MC, then you need to invoke it by yourself, like in:

HotKeySet('h', Hotkey1) ; no quote needed since functions are first-class citizens

Func Hotkey1()
    ConsoleWrite('The Hotkey was pressed' & @CRLF)
    MC()                    ; invoke this holly function
EndFunc     ;==>Hotkey1

While 1
    Sleep(50)
WEnd

Func MC()
    Sleep(10)
    MouseClick("LEFT", 702, 953, 1, 1)      ; typo fixed
EndFunc

 

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

27 minutes ago, jchd said:

If you insist on invoking function MC, then you need to invoke it by yourself, like in:

HotKeySet('h', Hotkey1) ; no quote needed since functions are first-class citizens

Func Hotkey1()
    ConsoleWrite('The Hotkey was pressed' & @CRLF)
    MC()                    ; invoke this holly function
EndFunc     ;==>Hotkey1

While 1
    Sleep(50)
WEnd

Func MC()
    Sleep(10)
    MouseClick("LEFT", 702. 953, 1, 1)
EndFunc

 

Thanks a lot.  However, this code returns an error:

 

 HotKeySet('h', Hotkey1)

Func Hotkey1()
    ConsoleWrite('The Hotkey was pressed' & @CRLF)
    MC()
EndFunc     ;==>Hotkey1

While 1
    Sleep(50)
WEnd

Func MC()
    Sleep(10)
    MouseClick("LEFT", 702. 953, 1, 1)
EndFunc

 


Error:

The Hotkey was pressed

MouseClick("LEFT", 702. 953, 1, 1)
MouseClick("LEFT", ^ ERROR
>Exit code: 1

:D

Link to comment
Share on other sites

MouseClick("LEFT", 702. 953, 1, 1)

Just a small typo by @jchd (dot instead of comma).

@thatboy : You could have easily spotted this yourself if you took a look at the help or the error message in the console output ;).

Use

Func MC()
    Sleep(10)
    MouseClick("LEFT", 702, 953, 1, 1)
EndFunc

 

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

By the way: A hotkey to terminate the script would be beneficial :

HotKeySet('h', Hotkey1) ; no quote needed since functions are first-class citizens
HotKeySet("{ESC}", _Terminate)

Func Hotkey1()
    ConsoleWrite('The Hotkey was pressed' & @CRLF)
    MC()                    ; invoke this holly function
EndFunc     ;==>Hotkey1

While 1
    Sleep(50)
WEnd

Func MC()
    Sleep(10)
    MouseClick("LEFT", 702, 953, 1, 1)
EndFunc

Func _Terminate()
    MsgBox(BitOR(4096, 64), "Message :", "Script terminated" & @CRLF)
    Exit
EndFunc

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

18 minutes ago, Musashi said:

Just a small typo by @jchd (dot instead of comma)

Not mine: it comes verbatim from the OP, I was aware but was distracted before posting and forgot to fix it.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

59 minutes ago, jchd said:
1 hour ago, Musashi said:

Just a small typo by @jchd (dot instead of comma)

Not mine: it comes verbatim from the OP, I was aware but was distracted before posting and forgot to fix it.

True, I hope you accept my sincere apology ;).

@thatboy : Why did you mark your buggy script from your initial question as the Solution? You should mark the one from @jchd (he could still edit the typo though :)).

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

16 minutes ago, Musashi said:

True, I hope you accept my sincere apology ;).

@thatboy : Why did you mark your buggy script from your initial question as the Solution? You should mark the one from @jchd (he could still edit the typo though :)).

 

 

Was an accident.  My first time using this site.  How do I change it?

:D

Link to comment
Share on other sites

20 minutes ago, Musashi said:

(he could still edit the typo though :)).

Done.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

8 minutes ago, thatboy said:

mfs 

I had to google that one, and it didnt turn out good, google says either...

"M*therf*ckers" or "Middle Finger Salute", but maybe google is wrong. 😛

Edited by Werty

Some guy's script + some other guy's script = my script!

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