Help With script. Topic is solved

Ask gaming related questions (AHK v1.1 and older)
drwill
Posts: 12
Joined: 05 May 2024, 12:38

Help With script.

Post by drwill » 05 May 2024, 12:43

Hello, im new !here!

:)

I need the pointer to be automatic moved to the window designed by the shortcript -

F1:: WinActivate, drw --> this must get the cursor wherever it is and point/select this window.

Pretty easy huh? Nocando.:/

Thanx in advance!


[Mod action: Moved topic to the v1 section since the short script shown is v1 code. The main section is for v2.]

User avatar
mikeyww
Posts: 27169
Joined: 09 Sep 2014, 18:38

Re: Help With script.

Post by mikeyww » 05 May 2024, 12:51

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33.11
winTitle := "ahk_exe Notepad.exe"

#If WinExist(winTitle)
F1::
CoordMode Mouse
WinActivate
WinGetPos x, y
MouseMove x, y
Return
#If
If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.

User avatar
boiler
Posts: 17184
Joined: 21 Dec 2014, 02:44

Re: Help With script.  Topic is solved

Post by boiler » 05 May 2024, 12:53

Or don’t change the CoordMode and just move to 0,0.

User avatar
mikeyww
Posts: 27169
Joined: 09 Sep 2014, 18:38

Re: Help With script.

Post by mikeyww » 05 May 2024, 12:57

Nice one!

Code: Select all

; Per boiler
#Requires AutoHotkey v1.1.33.11
winTitle := "ahk_exe Notepad.exe"

#If WinExist(winTitle)
F1::
WinActivate
MouseMove 0, 0
Return
#If

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 05 May 2024, 18:55

Just to rechapter... thats my script for selecting characters for a game, btw... i need it to be set automatically to the window on press, and click on it ( or pass the coordinates to click) but the windows are never the same size... thats the problem... would be nice if i coulf make all the other windows, with the exception of F1 Key, to select the window, and the press a button automatically, like the ` button, for example.

Code: Select all

F1:: WinActivate, Character1

F2:: WinActivate, Character2

F3:: WinActivate, Character3

F4:: WinActivate, Character4

F5:: WinActivate, Character5

F6:: WinActivate, Character6

F7:: WinActivate, Character7

F8:: WinActivate, Character8

DetectHiddenWindows, On
Script_Hwnd := WinExist("ahk_class AutoHotkey ahk_pid " DllCall("GetCurrentProcessId"))
DetectHiddenWindows, Off
DllCall("RegisterShellHookWindow", "uint", Script_Hwnd)
OnMessage(DllCall("RegisterWindowMessage", "str", "SHELLHOOK"), "ShellEvent")
ShellEvent(wParam, lParam) {
if (wParam = 0x8006) HSHELL_FLASH
{
WinGet,descobre,ProcessName, ahk_id %lParam%
if(descobre = "DofusMod.exe")
WinActivate, ahk_id %lParam%

}
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]

User avatar
mikeyww
Posts: 27169
Joined: 09 Sep 2014, 18:38

Re: Help With script.

Post by mikeyww » 05 May 2024, 19:07

Hmm. I have no idea what any of that means. What the script does:
I need the pointer to be automatic moved to the window designed by the shortcript -
F1:: WinActivate, drw
Just a tip for your latest script: unlabeled code following Return is unreachable and will never execute.

Enjoy!

User avatar
boiler
Posts: 17184
Joined: 21 Dec 2014, 02:44

Re: Help With script.

Post by boiler » 05 May 2024, 19:10

mikeyww wrote:
05 May 2024, 19:07
I have no idea what any of that means.
Was about to post this sentence almost exactly word-for-word.

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 05 May 2024, 20:05

Basic it select the current character window by pressing the shortcut. Nevertless, still need to do what i said, the script must press a character, can be any letter on keyboard. So it will select the current character windows and pass its turn on game - as you can see, all the F1,F2.... etc. will select the window on the respective character, but i need it plus select window, it must press a keyboard button, just do pass the turn on the game.

User avatar
boiler
Posts: 17184
Joined: 21 Dec 2014, 02:44

Re: Help With script.

Post by boiler » 05 May 2024, 20:57

Still not sure what you’re looking for, but maybe this is close.

Code: Select all

#Requires AutoHotkey v1.1.33.11

F1::
F2:
F3::
F4::
F5::
F6::
F7::
F8::
WinActivate, % "Character " RegExReplace("A_ThisHotkey", "\D")
MouseMove, 0, 0
Send, ``
return

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 06 May 2024, 19:24

@boiler & @mikeyww

Thanks for trying, its not what i need.

Let me try to explain, the code below, get the window name (character name ex. Willhood) and select the window, pop-in it up. Thats preety much it, just show, in the screen the window of the respective player, ok?
All I need is the code to plus select the window (done by the under function already), to press a letter on keyboard, like "~" or "`", so the player passa its turn on the game. Thats all!

Code: Select all

F1:: WinActivate, Player1

F2:: WinActivate, Player2

DetectHiddenWindows, On
Script_Hwnd := WinExist("ahk_class AutoHotkey ahk_pid " DllCall("GetCurrentProcessId"))
DetectHiddenWindows, Off
DllCall("RegisterShellHookWindow", "uint", Script_Hwnd)
OnMessage(DllCall("RegisterWindowMessage", "str", "SHELLHOOK"), "ShellEvent")
ShellEvent(wParam, lParam) {
if (wParam = 0x8006) HSHELL_FLASH
{
WinGet,descobre,ProcessName, ahk_id %lParam%
if(descobre = "DofusMod.exe")
WinActivate, ahk_id %lParam%

}
}
@mikeyww
@boiler

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]

User avatar
boiler
Posts: 17184
Joined: 21 Dec 2014, 02:44

Re: Help With script.

Post by boiler » 06 May 2024, 22:42

The closest I can come to figuring out what you want is to have a separate hotkey for activating each character’s window. Are you wanting the script to automatically identify the various character windows and create a set of hotkesy for activating each of them?

I don’t know why you keep showing that code. The lines below the hotkeys would never execute. You may think that code is doing something to help the hotkeys activate the windows or identify the various windows, but the way you have shown it, it does nothing. What is that part of the code supposed to do? Where did you get it? It looks like if it were to execute, it would activate each of the program’s windows as soon as they’re created. I don’t know what that has to do with the hotkeys and why that would be needed.

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 06 May 2024, 23:18

boiler wrote:
06 May 2024, 22:42
The closest I can come to figuring out what you want is to have a separate hotkey for activating each character’s window. Are you wanting the script to automatically identify the various character windows and create a set of hotkesy for activating each of them?

I don’t know why you keep showing that code. The lines below the hotkeys would never execute. You may think that code is doing something to help the hotkeys activate the windows or identify the various windows, but the way you have shown it, it does nothing. What is that part of the code supposed to do? Where did you get it? It looks like if it were to execute, it would activate each of the program’s windows as soon as they’re created. I don’t know what that has to do with the hotkeys and why that would be needed.
--> Thats pretty much it. Well.. as you can see, F1 pop up the window of character1, F2 pop up the windows of character2 .. and so on... i just want that after i press the F1, F2 or FX button the script press a hotkey on keyboard, like ~ or ` (because its near F1, F2), quick to press. But with the ressalve, that one F1 must not pass the turn (must note have the hotkey associated to pass the turn on the game, just select the window, i will manually press to pass this character turn, because he will fight the monsters and kill all of then, if he cant kill and there are monsters left on the game, the other players will pass the turn automatically and will return to him (F1 - player 1).

User avatar
boiler
Posts: 17184
Joined: 21 Dec 2014, 02:44

Re: Help With script.

Post by boiler » 07 May 2024, 02:25

drwill wrote: and so on... i just want that after i press the F1, F2 or FX button the script press a hotkey on keyboard, like ~ or ` (because its near F1, F2), quick to press. But with the ressalve, that one F1 must not pass the turn (must note have the hotkey associated to pass the turn on the game, just select the window,
You say this as if we know what key is used to “pass the turn” or anything else. We don’t play the game. You choose what keys to send. If you want to send a keypress along with activating the window, then each hotkey just becomes a variant of these:

Code: Select all

F1::
WinActivate, Character 1 ahk_exe mygame.exe
Send, `` ; this requires two ` to escape the special character
return

F2::
WinActivate, Character 2 ahk_exe mygame.exe
Send, 2
return

Just replace mygame.exe with the actual process name for your game and Character 1 and Character 2 with the actual tiles of those windows. And I don’t know how to choose what keys to send with each. You would just choose those. How you send certain keys might require certain things to be done like ` above, or like sending the Tab key would be Send, {Tab}, as described in the Send documentation.

Don’t put any of that other code you had at the bottom of the scripts you posted.

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 07 May 2024, 08:43

Sorry im not an expert.

Code: Select all

F1::
WinActivate, Willhood ahk_exe DofusMod.exe
return

F2::
WinActivate,  Will-shot ahk_exe DofusMod.exe
Send, ``
return
>"C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe" /ErrorStdOut "D:\Will\Lohar-2024 - Copia.ahk"
D:\Will\Lohar-2024 - Copia.ahk (2) : ==> Function calls require a space or "(". Use comma only between parameters.
Specifically: WinActivate, Willhood ahk_exe DofusMod.exe
>Exit code: 2 Time: 0.08647

Didnt work.

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]

gregster
Posts: 9080
Joined: 30 Sep 2013, 06:48

Re: Help With script.

Post by gregster » 07 May 2024, 08:51

You are obviously trying to run AHK v1 code with AHK v2. Either use v1 or change the syntax to v2.

btw, please use code tags when posting code:

ctags.png
ctags.png (14.18 KiB) Viewed 818 times

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 07 May 2024, 09:27

gregster wrote:
07 May 2024, 08:51
You are obviously trying to run AHK v1 code with AHK v2. Either use v1 or change the syntax to v2.

btw, please use code tags when posting code:


ctags.png
Hi im new in this programming language. sorry, have no idea of what you said, on how to do..

gregster
Posts: 9080
Joined: 30 Sep 2013, 06:48

Re: Help With script.

Post by gregster » 07 May 2024, 10:56

Since you always posted v1 code in your posts above, I would expect that you have AHK v1 already installed (apparently along with AHK v2, which is fine) and used it before.

The shown error message seems to indicate that now you tried to run the script from an editor like eg SciTE4AHK; so make sure to select AHK v1 to run the script (in SciTE, there is a version selector button, if I remember correctly).
Trying to run it outside of an editor, the v2 launcher would probably suggest to install v1, if not already available. Adding #Requires AutoHotkey v1.1 should avoid any ambiguity for the AHK launcher, if there should be any.

Regarding the usage of code tags, I have posted an image. Code tags will add one of those fancy and helpful codeboxes everyone else uses (so far, we have edited all your posts containing code (see above) and added them for you). If you have specific questions about steps 1 or 2 shown in the image (or additional ones), please feel free to ask.

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 08 May 2024, 08:42

@gregster
@boiler
@mikeyww

Hi guys, the code our friend boiler posted didnt work out for me, the F1 funtion its ok! But the F2 neither call the window of the program, like F1 does. And it should press the ` button too...

Code: Select all

F1::
WinActivate, Willhood ahk_exe DofusMod.exe
return

F2::
WinActivate,  Will-shot ahk_exe DofusMod.exe
Send, ``
return


User avatar
boiler
Posts: 17184
Joined: 21 Dec 2014, 02:44

Re: Help With script.

Post by boiler » 08 May 2024, 08:59

Are you sure the title of that window is exactly Will-shot with that exact capitalization and a regular hyphen in it? I would also put only one space after the comma and before that title. It's also possible there are hidden characters in the title. It's best to copy the title directly from Window Spy.

drwill
Posts: 12
Joined: 05 May 2024, 12:38

Re: Help With script.

Post by drwill » 08 May 2024, 17:17

@boiler

Im so sorry, thats the character name!! :) Will from Willian (my name), shoot from archer... name.

Post Reply

Return to “Gaming Help (v1)”