Jump to content

Send Command with a Variable


Recommended Posts

Hi All,

I am trying to write a script for a game I am playing. This game has a toolbar where if I type 1 to 9 I get skills activated on the main bar. If I type Shift-1 to Shift-9 I get skills activated on the 2nd toolbar (not the main toolbar).

My question is how to send a LSHIFT -3 (for example) using the Send command and variables from the settings on a user interface:

If GUICtrlRead($cbPotsUseShift) == 1 Then 
    $chPotsShift = "{LSHIFT}" ;use a LSHIFT to access the pots when they are on the 2nd toolbar
Else
    $chPotsShift = "" ;else access the pots on the main toolbar
EndIf

.
. ;do other stuff in here
.

If TimerDiff($tPot1) > GUICtrlRead($tbPotCD1) OR $bFirstPots Then ;see if it is time to reuse a pot
    $sCmd = $chPotsShift & GUICtrlRead($tbPotKey1) ;BAD STUFF HAPPENS HERE
    Send($sCmd)
    Sleep(500+Random(20,60)) ;Wait for the key to get sent
    $tPot1 = TimerInit() ;restart the timer
    Sleep(2000) ;delay while the game uses the pot
EndIf
Edited by mvriesen2004
Link to comment
Share on other sites

like

send("{LSHIFT}" & $Variable)
oÝ÷ Ûú®¢×¡¶¬yÚ'Ê«r¦z{mç(uë'^´k¢øyÛ!¢é]Âä½êâµÚ²z-"ÚâyÛayú%"^²Úk¢
Ú©Ý­©â·­Ø^rê좸§¶ºÚMÊ'²^Â)Ý£áz­¦ëb³Zkg¢Ú®¢Ðªê-êÞËayÊy«­¢+ØÀÌØí¡A½ÑÍM¡¥ÐôÅÕ½Ðíí1M!%QôÅÕ½Ðì(ÀÌØí¡
¡ÉÑÈôÅÕ½ÐíÅÕ½Ðì((ÀÌØíÍ
µôÀÌØí¡A½ÑÍM¡¥ÐµÀìÀÌØí¡
¡ÉÑÈí  MQU!AA9L!I)M¹ ÀÌØíÍ
µ¤)M±À ÔÀÀ­I¹½´ ÈÀ°ØÀ¤¤í]¥Ð½ÈÑ¡­äѼÐ͹Ð)M¹ ÅÕ½Ðíí1M!%QôÅÕ½ÐìµÀìÀÌØí¡
¡ÉÑȤ)M±À ÔÀÀ­I¹½´ ÈÀ°ØÀ¤¤í]¥Ð½ÈÑ¡­äѼÐ͹Ð

Anyone else have any ideas? What I am trying to do is allow the user to specify a keystroke from a GUI with checkboxes for Shift and Ctrl. Thus I can make various combinations of: Char, Shift-Char, Ctrl-Char, and Ctrl-Shift-Char based on the user's needs.

Link to comment
Share on other sites

Nope. This is a real nut buster. Here is the sample script I wrote using your suggestion:

run ("notepad.exe")
WinWaitActive("Untitled - Notepad")
If WinExists("Untitled - Notepad") Then
    Send("How are you?")
    Send(@CRLF)
    $chPotsShift = "LSHIFT"
    $chCharacter = "a"

    Send("{" & $chPotsShift & " down}")
    Send($chCharacter)
    Send("{" & $chPotsShift & " up}")
    Send(@CRLF)

    Send("{LSHIFT}a")
    Sleep(500+Random(20,60)) ;Wait for the key to get sentaa
    Send(@CRLF)
EndIf

I still get lower case 'a' 'a'.

Link to comment
Share on other sites

I got it. See below:

run ("notepad.exe")
WinWaitActive("Untitled - Notepad")
If WinExists("Untitled - Notepad") Then
    Send("How are you?")
    Send(@CRLF)
    $chPotsShift = "{LSHIFT}"
    $chCharacter = "a"

    Send($chPotsShift & "+" & $chCharacter)
    Send(@CRLF)

    Send("{LSHIFT}+a")
    Sleep(500+Random(20,60)) ;Wait for the key to get sentaa
    Send(@CRLF)
EndIf
Link to comment
Share on other sites

  • Developers

Yes. I know this is the hard coded approach. I was using a checkbox to to create alternative combinations of the shift, ctrl, and letter keys, so I need to dynamically create the Send string. I have what I need. Thanks!!!

Was only indicating that "{LSHIFT}" in Send("{LSHIFT}+a") doesn't do anything.

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

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