AutoHotKey Going through Menus
Basically when you have to go through forms and dialogs you have to understand that there are times when you have to wait for the dialog to become available. I modified a recursive function on the ahk forums to a while loop. Personally I find recursion to be harder to follow then a simple loop even though they essentially do the same thing.
Notice that I put an extra wait inbetween the "Disk Image" dialog and the "Add Disk Image" dialog. It seemed that the code would sometimes try to execute on the top "Add Disk Image" dialog before it would actually close. I spent some time trying to find a way after I made this work on the command line. Going through menus seems fraught with issues, so I really wanted to change this.
I feel kind of irritated that in order to get it working in the command line I only had to do append a space and put the file name. Neko Project is the same way, only I do not know how to get it to go fullscreen from outside the command line
cmdx88x21 := executable . A_Space . """" . fd1 . """" A_Space . """" . "-fullscreen=on" . """"
Run(cmdx88x21, emuPath) ; Run is a function in HS lib.
;Old
LoadFDI(rompath, romName, romExtension, emuPath)
{
fd1 := romPath . "\" . romName . romExtension
Sleep, 1200
; Open the FileDialog to load FDD1;"Open Image" Shortcut
Send !d
Sleep, 1200
;Button3 is "Add" to open dialog to select a file
If WaitControl("Button3", 4000, "Disk Image")
ControlClick, Button3, Disk Image, , Left, 1
If WaitControl("Edit1", 4000, "Add Disk Image")
{
Control, EditPaste, %fd1%, Edit1, Add Disk Image
ControlClick, Button2, Add Disk Image
}
sleep, 1200
If WaitControl("Button1", 3000, "Disk Image")
{
ControlFocus ,Button1,Disk Image
Sleep 1000
ControlClick, Button1, Disk Image, , Left, 1
ControlClick, Button1, Disk Image, , Left, 1
ControlClick, OK, Disk Image, , Left, 1
}
}
WaitControl(controlName, timeout, winTitle)
{
while timeout > 0
{
ControlGet, isVisible, Visible, , %controlName%, %winTitle%
ControlGet, isEnabled, Visible, , %controlName%, %winTitle%
if(!isVisible)
{
Sleep, 100
timeout -= 100
}
else
return 1
}
return -1 ;not found
}
Comments
Post a Comment