Jump to content

ControlSend with Shift/Alt/Ctrl


Recommended Posts

Hey, all. I'm coming from AHK, which had issues with key modifiers and ControlSend. If CS was used in a loop and you tried to use ctrl/shift or alt while the command was fired, the keys weren't registered. Essentially, if the loop was very fast, none of those keys would work at all.

Before I try and learn this scripting language, I was wondering if AutoIt has this issue and, if so, has any workarounds.

Thanks :]

Link to comment
Share on other sites

I don't think so. But give it a try. A loop with ControlSend command will take you 3 seconds to write.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Heh. Yeah, if you already know the language :P

EDIT: I'm getting the same 'stuck keys' bug that I've been reading about, but can't seem to get the 'flag = 1' option to work. I don't think that's my issue, but it's worth a try.

But, I can't seem to get it to work on in inactive Chrome window. Firefox works okay- which is acceptable, but Chrome would be ideal. Plus, it's strange thatit works on the very unspecific FF window that doesn't even appear to have any control values on the window info utility:

ControlSend("FARK", "", "", "{DOWN}")

...But doesn't work on a very specific Chrome window:

ControlSend("FARK", "", "[ID:294967424; CLASS:Chrome_RenderWidgetHostHWND; INSTANCE:1]", "{DOWN}")

Or, maybe I'm just doing something wrong :P

Anywho, maybe I should make a new thread? Seems weird. Here's my script, if you want to take a look:

AutoItSetOption("WinTitleMatchMode", 2)

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")

While 1
    ControlSend("FARK", "", "[ID:294967424; CLASS:Chrome_RenderWidgetHostHWND; INSTANCE:1]", "{DOWN}")
    Sleep(1000)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
    WEnd
EndFunc
Edited by jiggy
Link to comment
Share on other sites

You need to find some way of getting the programs handle and assigning it to a variable.

Local $hWnd = WinWait(@ProgramFilesDir & "\Google\Chrome\Application\chrome.exe", "", 10)

So long as you launch the program from within your script and you dont close the program then the handle for that window will stay the same.

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

If I want to automate a window but still use my computer for other things then I just make a virtual machine and run chrome in the virtual machine and my script that continues to send "{DOWN}" from within the virtual machine. It doesn't affect the operation of my main OS and it runs forever. Is this just an example or can I ask why you want to continue to press down every 1 second?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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