Hello,
I ask for your help with a problem in a script.
I have a script that allows you to type codes in a game but the problem is that it types codes from the numbers on the top of the keyboard and not from the numeric keypad. The game therefore does not detect pressing the number keys at the top of the keyboard. So my question is how do I get the script to use the numbers on the numeric keypad to type in the codes.
Thanks in advance.
script digit numeric keypad
Re: script digit numeric keypad
This is the code of the script :
[Mod edit: [code][/code] tags added.]
Code: Select all
+^R::Reload ; Reloads Script: Control + Shift + R
+^P::Pause ; (Un)Pauses Script: Control + Shift + P
Ins::Suspend ; Suspend Script: Insert
Esc::ExitApp ; Exit the Script: Escape
; Outputs a value to a log file
Log(value)
{
FileAppend,
(
%value%
), attempts.log
}
; Tries a pin code
Attempt(code)
{
; So the user knows what is being typed for them
ToolTip %code%
; Open up the pin code window
SendInput, e
; Wait for the window to 'load'
Sleep, 650
; Simulate key presses of typing in the code
SendRaw, %code%
; Log the code that was tried
Log(code)
; Wait for the window to close
Sleep, 600
return
}
; Ctrl + Shift + Left mouse button
+^LButton::
; Ask the user where they want to start from and now many codes to try, as well as if they want to try the common pin codes first
InputBox, start, The pin code to start at
InputBox, amount, The amout of pin codes to go through
MsgBox, 4, , Include common pin codes?
; Common pin codes
IfMsgBox, Yes
{
Log("================================= Common ============================================")
common := ["0000", "1111", "2222", "3333", "4444", "5555", "6666", "7777", "8888", "9999", "1010", "2020", "3030", "4040", "5050", "6060", "7070", "8080", "9090", "4321", "1000", "2000", "3000", "4000", "5000", "6000", "7000", "8000", "9000"]
For key, code in common
{
Attempt(code)
}
}
Log("================================= All ============================================")
while start <= amount
{
; Pad the number with zeros if we need to
code = % SubStr("0000" start, -3)
; Try the code
Attempt(code)
; Onto the next
start++
}
; Finished, clear the tooltip
ToolTip
Return
Re: script digit numeric keypad
Try this Attempt() function in place of the current one:
Notice that SendInput was used for the new version of the code. Do not use SendRaw.
Code: Select all
Attempt(code)
{
; Create Numpad version of the code
numpadCode := RegExReplace(code, "\d", "{Numpad$0}")
; So the user knows what is being typed for them
ToolTip %code%
; Open up the pin code window
SendInput, e
; Wait for the window to 'load'
Sleep, 650
; Simulate key presses of typing in the code
SendInput, %numpadCode%
; Log the code that was tried
Log(code)
; Wait for the window to close
Sleep, 600
return
}
Notice that SendInput was used for the new version of the code. Do not use SendRaw.
Re: script digit numeric keypad
Good evening,
Thank you for your reply. I tried your code by replacing "SendRaw% Code%" with "SendInput,% numpadcode%" but when I run the program with this modification I no longer have any code which is typed just "eeeeeee .." .
the new script :
[Mod edit: [code][/code] tags added.]
Thank you for your reply. I tried your code by replacing "SendRaw% Code%" with "SendInput,% numpadcode%" but when I run the program with this modification I no longer have any code which is typed just "eeeeeee .." .
the new script :
Code: Select all
+^R::Reload ; Reloads Script: Control + Shift + R
+^P::Pause ; (Un)Pauses Script: Control + Shift + P
Ins::Suspend ; Suspend Script: Insert
Esc::ExitApp ; Exit the Script: Escape
; Outputs a value to a log file
Log(value)
{
FileAppend,
(
%value%
), attempts.log
}
; Tries a pin code
Attempt(code)
{
; So the user knows what is being typed for them
ToolTip %code%
; Open up the pin code window
SendInput, e
; Wait for the window to 'load'
Sleep, 650
; Simulate key presses of typing in the code
SendInput, %numpadcode%
; Log the code that was tried
Log(code)
; Wait for the window to close
Sleep, 600
return
}
; Ctrl + Shift + Left mouse button
+^LButton::
; Ask the user where they want to start from and now many codes to try, as well as if they want to try the common pin codes first
InputBox, start, The pin code to start at
InputBox, amount, The amout of pin codes to go through
MsgBox, 4, , Include common pin codes?
; Common pin codes
IfMsgBox, Yes
{
Log("================================= Common ============================================")
common := ["0000", "1111", "2222", "3333", "4444", "5555", "6666", "7777", "8888", "9999", "1010", "2020", "3030", "4040", "5050", "6060", "7070", "8080", "9090", "4321", "1000", "2000", "3000", "4000", "5000", "6000", "7000", "8000", "9000"]
For key, code in common
{
Attempt(code)
}
}
Log("================================= All ============================================")
while start <= amount
{
; Pad the number with zeros if we need to
code = % SubStr("0000" start, -3)
; Try the code
Attempt(code)
; Onto the next
start++
}
; Finished, clear the tooltip
ToolTip
Return
Last edited by gregster on 25 Jul 2021, 16:11, edited 1 time in total.
Reason: Please use [code] tags. Thank you!
Reason: Please use [code] tags. Thank you!
Re: script digit numeric keypad
I didn’t say to only do that. I was just pointing out that you can’t change that back to SendRaw to make sure you understood that part. I said to replace the whole function with the one I posted. I assume you’ll be able to spot the other difference (hint: numpadCode doesn’t just magically get its value).