Jump to content
Sign in to follow this  
mvriesen2004

Send Command with a Variable

Recommended Posts

mvriesen2004

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

Share this post


Link to post
Share on other sites
mvriesen2004

Bump

Share this post


Link to post
Share on other sites
lopolop

like

send("{LSHIFT}" & $Variable)

Share this post


Link to post
Share on other sites
mvriesen2004

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.

Share this post


Link to post
Share on other sites
mvriesen2004

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

Share this post


Link to post
Share on other sites
mvriesen2004

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

Share this post


Link to post
Share on other sites
mvriesen2004

This is what you should use:

Send("+a")
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!!!

Share this post


Link to post
Share on other sites
Jos

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.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
mvriesen2004

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

Oh. Right. Thanks - i'm such a noob at this and the syntax is strange to a C++/Java programmer like myself. It seems more like VB.

Thanks!!!!!

Share this post


Link to post
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
Sign in to follow this  

×