[Solved] Hotkey Script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sajjansinghania
Posts: 18
Joined: 23 Apr 2017 22:36

[Solved] Hotkey Script

#1 Post by sajjansinghania » 23 Apr 2017 22:42

I am an old person from Dos age.
I have Windows 8.1 & Firefox (latest) & IE11 (Latest).
I frequently log into a Card Game Bridge site http://www.bridgebase.com/client/client.php to play Bridge.
There is a communication window to interact with other players where I type some repetitive messages which are long. They are about 15 in total.
Below I write a few as examples :

Examples :
!H!HJoker Card's Team Match!H!H Welcome all.This is a tensionfree fun table. FAIR PLAY EXPECTED. Zero tolerance for rude behaviour. !H!HPLEASE!H!H ACCEPT CLAIMS & UNDOS for MISCLICKS. Ty

!H!HJoker Card's Team Match!H!H Please check kibitzers on your table. If your friends kibitzing please advise them to stay away from table to protect privacy and FAIR PLAY. If not, they will be ignored in future TMs Ty

!H!HJoker Card's Team Match!H!H !H!HJoker Card!H!H needs to increase # of Boards If you have experience as TD & wish to help kindly Search !H!HJoker Card!H!H on bottom right of your screen & contact !H!HJoker Card!H!H. Ty


I may mention here that !H in above is local conversion to the Heart sign.

Requirement :
Instead of typing out whole text every time I need it, I wish the experts suggest a Cmd oe Vbs script (with hotkey assigned) which helps me to reproduce my messages on this site.

Thank you in advance Sir.
Last edited by sajjansinghania on 14 May 2017 22:29, edited 2 times in total.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Hotkey Scriot

#2 Post by ShadowThief » 24 Apr 2017 15:42

Oh God, this entire site is made in Flash.

I was getting ready to write something in Javascript since batch doesn't really play nice with things outside of the command prompt, but there's really no way to interact with Flash programmatically.

Honestly, your best bet is to store the sentences you want in a regular text file and then copy and paste them into the textbox whenever you want to use them.

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Hotkey Scriot

#3 Post by penpen » 24 Apr 2017 18:08

You could insert scancodes to the actual frame (using an background KeyHandler), but i fear that requires c#, c++ or similar:
If i remember right, then JScript/VBS should not be able to create a Keyhandler.
Maybe it is possible in (pure) powershell (without c#) - but i don't know.

The best i can see using batch here is not much more than ShadowThief proposed, just create 15 files (similar to this):

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion
call ^
:text "| clip && rem "
@(
   echo(Hello
   echo(world!
) %~1 & pause
goto :eof

If you don't want the 'verbose' output, you could use:

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion
@(
   echo(Hello
   echo(world!
) | clip
goto :eof


penpen

sajjansinghania
Posts: 18
Joined: 23 Apr 2017 22:36

Re: Hotkey Scriot

#4 Post by sajjansinghania » 24 Apr 2017 19:18

@ShadowThief Sir. As I posted in my topic I am zero on computer systems. But I think Sir, I can assist you as follows :
1. Copy paste your program in a .vbs file.
2. If provided a JavaScript, I suggest some instructions be explained by you Sir, on how to run JavaScript.
I look forward to your guidance on this. Ty Sir.

@penpen Sir,
What you suggested Sir, does not help me but thank you for taking interest and suggest.

sajjansinghania
Posts: 18
Joined: 23 Apr 2017 22:36

Re: Hotkey Scriot

#5 Post by sajjansinghania » 12 May 2017 15:26

OK. All that I can understand is that there is no apparent solution in DOS.
Can some expert suggest a help forum handling Flash matters to create a simple code as per my need.
I shall be obliged for rest of my life Tx.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Hotkey Script

#6 Post by ShadowThief » 12 May 2017 15:41

I feel like if you could guarantee the position of the web browser on the monitor, you could throw together some powershell code that clicks in the text box and then types the message. I needed something like that once for a video game I was playing, but I could never figure out how to get the position of the cursor relative to the game window so I could only play in Windowed mode.

You're going to want to play around with the SetCursorPos parameters, because I can pretty much guarantee that you won't be clicking at 2150x900.

Code: Select all

# Using code from http://www.daveamenta.com/2013-08/use-powershell-to-automatically-click-a-point-on-the-screen-reapeatedly-auto-clicker/

[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null
$csharp_code = @"
    [DllImport("user32.dll")]
    public static extern bool SetCursorPos(int X, int Y);
    [DllImport("user32.dll")]
    public static extern bool GetCursorPos(out System.Drawing.Point pt);
   
    [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
    public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
   
    private const int MOUSEEVENTF_LEFTDOWN = 0x02;
    private const int MOUSEEVENTF_LEFTUP = 0x04;
    private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
    private const int MOUSEEVENTF_RIGHTUP = 0x10;
   
    public static void LeftClick(){
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
    }
   
    public static void RightClick(){
        mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
    }
"@
Add-Type -MemberDefinition $csharp_code -Namespace SpotClicker -Name Click -ReferencedAssemblies System.Drawing

$old_position_point = New-Object System.Drawing.Point
[SpotClicker.Click]::GetCursorPos([ref]$old_position_point) | Out-Null
[SpotClicker.Click]::SetCursorPos(2150,900) | Out-Null
[SpotClicker.Click]::LeftClick()
[spotClicker.Click]::SetCursorPos($old_position_point.X, $old_position_point.Y) | Out-Null

sajjansinghania
Posts: 18
Joined: 23 Apr 2017 22:36

Re: Hotkey Script

#7 Post by sajjansinghania » 12 May 2017 16:23

ShadowThief Sir,
I wrote at very outset that I have zero knowledge of commuter technology and am a below average user Sir. However, I am a easy learner and am prepared to do whatever you suggest Sir. Therefore, I expect you to explain how to handle the code above.

I frequently log into a Card Game Bridge site http://www.bridgebase.com/client/client.php to play Bridge.
There is a communication window to interact with other players where I type some repetitive messages which are long. They are about 15 in total.
Below I write a few as examples :
Examples :
!H!HJoker Card's Team Match!H!H Welcome all.This is a tensionfree fun table. FAIR PLAY EXPECTED. Zero tolerance for rude behaviour. !H!HPLEASE!H!H ACCEPT CLAIMS & UNDOS for MISCLICKS. Ty
!H!HJoker Card's Team Match!H!H Please check kibitzers on your table. If your friends kibitzing please advise them to stay away from table to protect privacy and FAIR PLAY. If not, they will be ignored in future TMs Ty
!H!HJoker Card's Team Match!H!H !H!HJoker Card!H!H needs to increase # of Boards If you have experience as TD & wish to help kindly Search !H!HJoker Card!H!H on bottom right of your screen & contact !H!HJoker Card!H!H. Ty
I may mention here that !H in above is local conversion to the Heart sign.
Requirement :
Instead of typing out whole text every time I need it, I wish the experts suggest a Cmd oe Vbs script (with hotkey assigned) which helps me to reproduce my messages on this site.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Hotkey Script

#8 Post by ShadowThief » 14 May 2017 19:51

Before I start writing something extravagant, are you aware that there is a Chat Manager in the chat box's Option menu where you can store multiple messages that you can send with a single click?

Image
Image
Image

sajjansinghania
Posts: 18
Joined: 23 Apr 2017 22:36

Re: Hotkey Script

#9 Post by sajjansinghania » 14 May 2017 22:28

ShadowThief Sir,
I knew from very beginning that dostips.com is a wonderful site for dummies like me, but could never realize I would find such a wonderful and most easy solution for my problem.
I have a feeling you did great homework before you came out with such easy solution finally. I must add, you not only helped me immensely Sir, but proved 1. You are best. 2. Dos still has relevance in this modern world. Experts in Dos still have worth.
Thanks tons once again Sir.

sajjansinghania
Posts: 18
Joined: 23 Apr 2017 22:36

Re: [Solved] Hotkey Script

#10 Post by sajjansinghania » 15 May 2017 10:11

Out of my extreme satisafaction, just want to add one.
I am doing as sugested which is 95% of my need but the best part is, before i got thit tip it was 0% now 95%. SHall try t tweak it slowly.
Cheers
:):)

Post Reply