automatischer Tastendruck Topic is solved
Moderator: jNizM
-
- Posts: 15
- Joined: 23 May 2020, 02:06
automatischer Tastendruck
Moin, wollte fragen ob es geht dass AHK ein bestimmtes Bild auf dem Bildschirm erkennt und dann eine bestimmte Taste drückt.
Last edited by BoBo on 04 Jul 2020, 01:45, edited 2 times in total.
Reason: Nach 'Spiele' verschoben.
Reason: Nach 'Spiele' verschoben.
-
- Posts: 15
- Joined: 23 May 2020, 02:06
Re: automatischer Tastendruck
Kannste me dabei helfen?
Re: automatischer Tastendruck
ein Beispiel
Code: Select all
;- example shows 4 pictures
;- 3th picture name is wrong so clicks picture-1+2 AND picture-4
;----------------------------------------------------------------------------
#Warn
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode,Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir, %A_ScriptDir% ; Ensures a consistent starting directory.
CoordMode,Pixel,Screen
CoordMode,Mouse,Screen
;-------------------------------------------------------------
i=0
ur1=https://autohotkey.com/boards/images/flags/russia.png
SplitPath,ur1, name1, dir1, ext, name_no_ext, drive
f1 =%a_scriptdir%\%name1%
ur2=https://autohotkey.com/boards/images/flags/germany.png
SplitPath,ur2, name2, dir2, ext, name_no_ext, drive
f2 =%a_scriptdir%\%name2%
ur3=https://autohotkey.com/boards/images/flags/china.png
SplitPath,ur3, name3, dir3, ext, name_no_ext, drive
f3 =%a_scriptdir%\%name3%
f3a:="" ;- wrong name so search next picture
ur4=https://autohotkey.com/boards/images/flags/france.png
SplitPath,ur4, name4, dir4, ext, name_no_ext, drive
f4 =%a_scriptdir%\%name4%
ifnotexist,%f1%
urldownloadtofile,%ur1%,%f1%
ifnotexist,%f2%
urldownloadtofile,%ur2%,%f2%
ifnotexist,%f3%
urldownloadtofile,%ur3%,%f3%
ifnotexist,%f4%
urldownloadtofile,%ur4%,%f4%
;---------------------------------------------------------------
Gui,add,picture, gA1 x10 y10 ,%f1%
Gui,add,picture, gA2 x90 y10 ,%f2%
Gui,add,picture, gA3 x170 y10 ,%f3%
Gui,add,picture, gA4 x250 y10 ,%f4%
gui,show, x100 y10 h70 w300 ,Use F2 to search Picture
return
guiclose:
exitapp
a1:
msgbox, 262208, ,Clicked Picture %name1%,2
return
a2:
msgbox, 262208, ,Clicked Picture %name2%,2
return
a3:
msgbox, 262208, ,Clicked Picture %name3%,2
return
a4:
msgbox, 262208, ,Clicked Picture %name4%,2
return
f2::
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f1%
picx=%name1%
gosub,errorx
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f2%
picx=%name2%
gosub,errorx
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f3a% ;- wrong name for TEST
picx=%name3%
gosub,errorx
ImageSearch,xf,yf,0,0,%a_screenwidth%,%a_screenheight%, *TransBlack %f4%
picx=%name4%
gosub,errorx
msgbox, 262208, ,FINISHED
return
errorx:
i++
if errorlevel=1
{
msgbox, 262208, ,Error`nTry with next picture in 3 seconds,3
return
}
else if errorlevel=2
{
msgbox, 262208, ,Picture %picx% not found`nNow continue in 3 seconds with next-picture,3
return
}
MouseMove,%xf%,%yf%,
ToolTip,Here is the picture %picx%
sleep,2500
tooltip
MouseClick,left,%xf%,%yf% ;- click on x-picture
return
;====================== END script =================================
-
- Posts: 15
- Joined: 23 May 2020, 02:06
Re: automatischer Tastendruck
Ist nice gemacht aber ich meine ob es geht dass wenn etwas bestimmtes vom Spiel angezeigt wird dass es dann die Tasten drückt.
Re: automatischer Tastendruck Topic is solved
Ein Beispiel, drückt die Taste Download von https://www.autohotkey.com/boards/
Code: Select all
; Example Download button from https://www.autohotkey.com/boards/
; run,https://www.autohotkey.com/boards/ <<< copy here the download button-picture
#Warn
#NoEnv
;CoordMode, pixel, screen
setworkingdir,%a_scriptdir%
picx=%a_ScriptDir%\download.bmp ;-- <<< this picture in a_scriptdir
!w::
;---------------------------------
loop,255
{
;tooltip,loop is running
variation = %a_index%
;imagesearch, outx, outy, 3324,337,3682,475, *%a_index% %picx%
;imagesearch, outx, outy, 1000,337,1100,475, *%a_index% %picx%
imagesearch, outx, outy,0,0,%a_screenwidth%,%a_screenheight%, *%a_index% %picx%
if Errorlevel=0
break
if ErrorLevel = 2
{
;msgbox, 262208, ,variation=%variation%`nCould not conduct the search,1
tooltip,Loop=%variation%`nerrorlevel=%errorlevel%`nCould not conduct the search
sleep,300
tooltip
continue
}
if ErrorLevel = 1
{
;msgbox, 262208, ,variation=%variation%`n The clip could not be found on the screen,1
tooltip,Loop=%variation%`nerrorlevel=%errorlevel%`nThe clip could not be found on the screen
sleep,300
tooltip
continue
}
}
if Errorlevel=0
{
tooltip
MouseMove,%outx%,%outy%,
ToolTip,Here is the picture %picx% ;- found
sleep,2500
tooltip
outx:=(outx+15)
outy:=(outy+15)
MouseClick,left ,%outx%,%outy% ;- click on x-picture
;MouseClick,right,%outx%,%outy% ;- see context
sleep,1000
msgbox, 262208, ,Picture=%picx%`nwhere found at =`n x=%outx% y=%outy%`nLoop=%variation%`nFINISHED ;- message picture found
}
return
;-----------
esc::exitapp
;==================================================
/*
1::
;CoordMode, pixel, screen;
;run,https://www.autohotkey.com/boards/ <<< copy here the download button
mousegetpos,x,y
msgbox,X=%x%`nY=%y%
return
*/