AutoHotkey Community

It is currently May 27th, 2012, 4:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: April 7th, 2010, 3:44 am 
Offline

Joined: August 4th, 2009, 2:51 am
Posts: 20
Hey guys, i'm learning AHK slowly but surely.

I have a program i'm creating and was wondering if it's possible to have a image cycle between 3 different pictures, changing with every key press.

I'm not sure how the code would look but for example:

StartScript:
onkeypress (any) --> dir/image1.jpg
onkeypress (any) --> dir/image2.jpg
onkeypress (any) --> dir/image3.jpg
Goto, StartScript

I have no idea if this is even possible... but something more efficient might be to have any-key populate a image.jpg from a pre-defined variable with the 3 images listed somehow..


help ! <3


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 4:30 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
3 different pictures, changing with every key press.
Code:
File0= ;EnterFileNames
File1=
File2=
Loop
{
Input , Out, L1
Temp:="File" . Mod(A_Index,3)
SplashImage , % %Temp%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 4:36 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Here's a GUI option.
Code:
OnMessage(0x100,"WM_KeyDown")
Gui, Add, Pic, w100 h100 vPic, Shell32.dll
Gui, Show
return
GuiClose:
 ExitApp

WM_KeyDown() {
 static n=1
 n := n=3 ? 1:++n
 GuiControl,,Pic, *Icon%n% Shell32.dll
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 4:40 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
Looking back at your original post gave me an idea :)
Code:
Loop
{
SlashWait("File1.jpg")
SlashWait("File2.jpg")
SlashWait("File3.jpg")
}

SlashWait(File)
{
SplashImage, %File%
Input , Out, L1
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 4:54 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Related: WaitForAnyKey

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 5:22 am 
Offline

Joined: August 4th, 2009, 2:51 am
Posts: 20
And this is why AutoHotKey has the best community in the world :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 5:28 am 
Offline

Joined: August 4th, 2009, 2:51 am
Posts: 20
To clear up confusion, which out of the examples provided would be best for a image that's inside of a GUI?

The GUI example looks to be referencing .dll and changes the icon.

TIA


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 5:46 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
Code:
File1=a File.jpg
File2=another file.jpg
File3=more file.jpg

OnMessage(0x100,"WM_KeyDown")
Gui, Add, Pic, vPic, %File1%
Gui, Show
return
GuiClose:
 ExitApp

WM_KeyDown() {
 static n=1
 n := n=3 ? 1:++n
 Temp:="File" . n
 GuiControl,,Pic, % %Temp%
}
combine them :D

Quote:
The GUI example looks to be referencing .dll and changes the icon.
jaco0646 is using a Dll as a handy source of pictures. Not changing the icon of the script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 5:59 am 
Offline

Joined: August 4th, 2009, 2:51 am
Posts: 20
Yeah I might need to emphasize the "slowly" on learning :x

Here's what i've inserted into the gui

File1="C:\Documents and Settings\USERNAME\Desktop\cons1.gif"
File2="C:\Documents and Settings\USERNAME\Desktop\cons2.gif"
File3="C:\Documents and Settings\USERNAME\Desktop\cons3.gif"

OnMessage(0x100,"WM_KeyDown")
Gui, Add, Pic, x785 y306 w110 h150 , vPic, %File1%
Gui, Show
return
GuiClose:
ExitApp

WM_KeyDown() {
static n=1
n := n=3 ? 1:++n
}



However it doesn't display an image... not sure where it's failing but I assume it's due to vPic and %File1% what would I need to change exactly :x

Love always,

ThatguySky


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 6:02 am 
Offline

Joined: August 4th, 2009, 2:51 am
Posts: 20
Correction: Here is what i've inserted

Code:
File1="C:\Documents and Settings\sglass\Desktop\cons1.gif"
File2="C:\Documents and Settings\sglass\Desktop\cons2.gif"
File3="C:\Documents and Settings\sglass\Desktop\cons3.gif"

OnMessage(0x100,"WM_KeyDown")
Gui, Add, Pic, x785 y306 w110 h150 , vPic, %File1%
Gui, Show
return
GuiClose:
 ExitApp

WM_KeyDown() {
 static n=1
 n := n=3 ? 1:++n
 Temp:="File" . n
 GuiControl,,Pic, % %Temp%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 6:17 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
Code:
Gui, Add, Pic, x785 y306 w110 h150 , vPic, %File1%
Remove comma seperating the var name from other options.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 6:13 pm 
Offline

Joined: August 4th, 2009, 2:51 am
Posts: 20
Yeah for some reason that code (after correcting the comma) still doesn't display an image at all.. let alone change it when a key is pressed. :/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 8:43 pm 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
ThatGuySky wrote:
Yeah for some reason that code (after correcting the comma) still doesn't display an image at all.. let alone change it when a key is pressed. :/

Sorry was moble and could not test you also need to remove the "" from the file names.
Code:
File1=C:\Documents and Settings\sglass\Desktop\cons1.gif
File2=C:\Documents and Settings\sglass\Desktop\cons2.gif
File3=C:\Documents and Settings\sglass\Desktop\cons3.gif


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 8:53 pm 
Offline

Joined: August 4th, 2009, 2:51 am
Posts: 20
Yeah, this still isn't producing an image within the GUI, let alone change the image with each keypress...

I have a feeling we are missing something really simple.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2010, 9:04 pm 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
This works on my computer Image in the lower right corner
Code:
File1=C:\Documents and Settings\Owner\My Junk\_44599_1-ATT00000111.jpg
File2=C:\Documents and Settings\Owner\My Junk\_44599_2-ATT00001222.jpg
File3=C:\Documents and Settings\Owner\My Junk\_44599_3-ATT00002333.jpg

OnMessage(0x100,"WM_KeyDown")
Gui, Add, Pic, x785 y306 w110 h150 vPic, %File1%
Gui, Show
return
GuiClose:
 ExitApp

WM_KeyDown() {
 static n=1
 n := n=3 ? 1:++n
 Temp:="File" . n
 GuiControl,,Pic, % %Temp%
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot] and 75 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group