Jump to content

120 different macros inside one script file


Recommended Posts

Hi all:

It is my first project with AutoIT. I am trying to adapt AutoIT to be used with an Enterpad overlay keyboard.

My goal is to make a script template containing 120 ready-to-customize macros linked to each of the 120 Enterpad keys.

If a user presses a key on the Enterpad, it will send the keystroke {F10} followed by 3 digits for the key number being pressed. So the keystroke will be {F10}001 if the user presses the first key on the Enterpad and {F10}120 if the last key is pressed.

So I wrote this simple script:

Global $Enterpad_key_number

HotKeySet("{F10}", "Enterpad")

While 1; Permanently loops
   Sleep(100)
Wend

Func Enterpad()
    $Enterpad_key_number = InputBox("Enterpad Key","", "", " M3")
    $Enterpad_key_number = "K" & $Enterpad_key_number
    Call($Enterpad_key_number)
EndFunc

Func K001()
    MsgBox(0,"test",$Enterpad_key_number)
EndFunc

Func K002()
    MsgBox(0,"test",$Enterpad_key_number)
EndFunc

;and so on for K003() to K120()

To capture the Enterpad key number, I used the InputBox() function. It works but this is not what I want. I just want to capture three consecutive characters from the keyboard without a dialog box. I evaluated the _IsPressed() function but its use in this context can lead to synchronization problems.

Does anybody have any suggestions on the best way to replace this InputBox() function?

Link to comment
Share on other sites

Hi all:

It is my first project with AutoIT. I am trying to adapt AutoIT to be used with an Enterpad overlay keyboard.

My goal is to make a script template containing 120 ready-to-customize macros linked to each of the 120 Enterpad keys.

If a user presses a key on the Enterpad, it will send the keystroke {F10} followed by 3 digits for the key number being pressed. So the keystroke will be {F10}001 if the user presses the first key on the Enterpad and {F10}120 if the last key is pressed.

So I wrote this simple script:

Global $Enterpad_key_number

HotKeySet("{F10}", "Enterpad")

While 1; Permanently loops
   Sleep(100)
Wend

Func Enterpad()
    $Enterpad_key_number = InputBox("Enterpad Key","", "", " M3")
    $Enterpad_key_number = "K" & $Enterpad_key_number
    Call($Enterpad_key_number)
EndFunc

Func K001()
    MsgBox(0,"test",$Enterpad_key_number)
EndFunc

Func K002()
    MsgBox(0,"test",$Enterpad_key_number)
EndFunc

;and so on for K003() to K120()

To capture the Enterpad key number, I used the InputBox() function. It works but this is not what I want. I just want to capture three consecutive characters from the keyboard without a dialog box. I evaluated the _IsPressed() function but its use in this context can lead to synchronization problems.

Does anybody have any suggestions on the best way to replace this InputBox() function?

Using the inputbox sounds reasonable to me if you only want numbers. Maybe an input would be better. It is useful if the user can see that the numbers have been typed correctly. You can set an input to accept only numbers with style $ES_NUMBER, and you could use notification $EN_CHANGE to detect when the input text has changed so that you can know when 3 digits have been entered.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

It is useful if the user can see that the numbers have been typed correctly.

Thanks martin. I should be more precise.

A user dont have to see or confirm that the numbers have been typed correctly as the number is automatically generated by the Enterpad keyboard. So, when a user presses a labeled key on the Enterpad, he or she wants the execution of the corresponding macro instantly without having to acknowledge the Enterpad key number with the dialog box.

It is like you want to launch the Google website with the first Enterpad key. The sequence will be:

  • You will press the key number 1 on the Enterpad
  • The Enterpad will send {F10}001 to the AutoIT script
  • AutoIT will have to execute the macro: run (http://www.google.com)
You certainly dont want to acknowledge between 2 and 3!
Link to comment
Share on other sites

I would use WS_EX_TOOLWindow, too:

$hWnd = GUICreate("invisible Enterpad", 50, 40,0,0,-1,128) ; 128 = WS_EX_TOOLWINDOW

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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