The general idea is...
- When the hotkey is pressed, make sure I'm in the right program. If not, do nothing. This isn't working.
- Press the ALT key, press the down arrow 11 times, press the right arrow 2 times, press enter twice. This is the part that exports the current page as a PNG file. This is working.
- After export, press the ALT key, press the down arrow 13 times, press enter once. This will exit the program. This worked a few times, but eventually stopped working and I'm not sure why.
Code: Select all
^j::
; Make sure the Fritzing Window is active. If not, just exit so that
; we don't send these commands to whichever program happens to have
; focus.
; -----------
; NOT WORKING
; -----------
if !WinExist("ahk_exe Fritzing.exe") {
;wrong program is focused, return and do nothing
return
}
; Wait 1 second for the user to let go of the keys
Sleep, 1000
; Press ALT to activate the MENU BAR
send, {alt down}{alt up}
; Wait 100th of a second
Sleep, 10
; Press the DOWN ARROW 11 times to get to the EXPORT SUBMENU
Loop, 11 {
send, {Down}
}
; Press RIGHT twice to go to the IMAGE SUBMENU
send, {Right}
send, {Right}
; Press ENTER to select the first option, which is PNG
send, {enter}
; Wait a 10th of a second for the menu to come up
Sleep, 100
; Press ENTER to save the file using the default file name
send, {enter}
; Wait for the computer to save the file
Sleep, 350
; If the file does already exist, a warning window will pop up. If that
; warning window does NOT popup, then exit the program. If the warning
; window does popup, do nothing. The user will have to decide what to do.
; -----------
; NOT WORKING
; -----------
if !WinExist("ahk_class #32770") {
Sleep, 10
send, {alt down}{alt up}
Sleep, 10
Loop, 13 {
send, {Down}
}
send, {enter}
}
return